mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 03:59:21 +03:00
Drop support for PEAR Crypt_GPG as it is lacking features we want in #89
This commit is contained in:
parent
998a1c6cc8
commit
f26c35c411
1 changed files with 1 additions and 130 deletions
|
|
@ -9,14 +9,11 @@ class GnuPG
|
|||
// Instance of gnupg pecl extension
|
||||
$GnuPG,
|
||||
// Instance of \SnappyMail\PGP\GPG
|
||||
$GPG,
|
||||
// Instance of PEAR Crypt_GPG
|
||||
$Crypt_GPG;
|
||||
$GPG;
|
||||
|
||||
public static function isSupported() : bool
|
||||
{
|
||||
return \class_exists('gnupg')
|
||||
|| \stream_resolve_include_path('Crypt/GPG.php')
|
||||
|| \SnappyMail\PGP\GPG::isSupported();
|
||||
}
|
||||
|
||||
|
|
@ -43,20 +40,6 @@ class GnuPG
|
|||
} else if (\SnappyMail\PGP\GPG::isSupported()) {
|
||||
$self = new self;
|
||||
$self->GPG = new \SnappyMail\PGP\GPG($homedir);
|
||||
} else {
|
||||
/**
|
||||
* $binary = trim(`which gpg`) ?: trim(`which gpg2`);
|
||||
* \is_executable($binary)
|
||||
*/
|
||||
include_once 'Crypt/GPG.php';
|
||||
if (\class_exists('Crypt_GPG')) {
|
||||
$self = new self;
|
||||
$self->Crypt_GPG = new \Crypt_GPG([
|
||||
// 'debug' => true,
|
||||
// 'binary' => $binary,
|
||||
'homedir' => $homedir
|
||||
]);
|
||||
}
|
||||
}
|
||||
if ($self) {
|
||||
$self->homedir = $homedir;
|
||||
|
|
@ -76,10 +59,6 @@ class GnuPG
|
|||
if ($this->GPG) {
|
||||
return $this->GPG->adddecryptkey($fingerprint, $passphrase);
|
||||
}
|
||||
if ($this->Crypt_GPG) {
|
||||
$this->Crypt_GPG->addDecryptKey($fingerprint, $passphrase);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -94,10 +73,6 @@ class GnuPG
|
|||
if ($this->GPG) {
|
||||
return $this->GPG->addencryptkey($fingerprint);
|
||||
}
|
||||
if ($this->Crypt_GPG) {
|
||||
$this->Crypt_GPG->addEncryptKey($fingerprint);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -112,10 +87,6 @@ class GnuPG
|
|||
if ($this->GPG) {
|
||||
return $this->GPG->addsignkey($fingerprint, $passphrase);
|
||||
}
|
||||
if ($this->Crypt_GPG) {
|
||||
$this->Crypt_GPG->addSignKey($fingerprint, $passphrase);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -130,10 +101,6 @@ class GnuPG
|
|||
if ($this->GPG) {
|
||||
return $this->GPG->cleardecryptkeys();
|
||||
}
|
||||
if ($this->Crypt_GPG) {
|
||||
$this->Crypt_GPG->clearDecryptKeys();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -148,10 +115,6 @@ class GnuPG
|
|||
if ($this->GPG) {
|
||||
return $this->GPG->clearencryptkeys();
|
||||
}
|
||||
if ($this->Crypt_GPG) {
|
||||
$this->Crypt_GPG->clearEncryptKeys();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -166,10 +129,6 @@ class GnuPG
|
|||
if ($this->GPG) {
|
||||
return $this->GPG->clearsignkeys();
|
||||
}
|
||||
if ($this->Crypt_GPG) {
|
||||
$this->Crypt_GPG->clearSignKeys();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -184,9 +143,6 @@ class GnuPG
|
|||
if ($this->GPG) {
|
||||
return $this->GPG->decrypt($text);
|
||||
}
|
||||
if ($this->Crypt_GPG) {
|
||||
return $this->Crypt_GPG->decrypt($encryptedData);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -201,9 +157,6 @@ class GnuPG
|
|||
if ($this->GPG) {
|
||||
return $this->GPG->decryptFile($filename);
|
||||
}
|
||||
if ($this->Crypt_GPG) {
|
||||
return $this->Crypt_GPG->decryptFile($filename, $decryptedFile = null);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -218,9 +171,6 @@ class GnuPG
|
|||
if ($this->GPG) {
|
||||
return $this->GPG->decryptverify($text, $plaintext);
|
||||
}
|
||||
if ($this->Crypt_GPG) {
|
||||
return $this->Crypt_GPG->decryptAndVerify($text, $ignoreVerifyErrors = false);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -235,9 +185,6 @@ class GnuPG
|
|||
if ($this->GPG) {
|
||||
return $this->GPG->decryptverifyFile($filename, $plaintext);
|
||||
}
|
||||
if ($this->Crypt_GPG) {
|
||||
return $this->Crypt_GPG->decryptAndVerifyFile($filename, $decryptedFile = null, $ignoreVerifyErrors = false);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -252,9 +199,6 @@ class GnuPG
|
|||
if ($this->GPG) {
|
||||
return $this->GPG->encrypt($plaintext);
|
||||
}
|
||||
if ($this->Crypt_GPG) {
|
||||
return $this->Crypt_GPG->encrypt($plaintext);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -269,9 +213,6 @@ class GnuPG
|
|||
if ($this->GPG) {
|
||||
return $this->GPG->encryptFile($filename);
|
||||
}
|
||||
if ($this->Crypt_GPG) {
|
||||
return $this->Crypt_GPG->encryptFile($filename, $encryptedFile = null);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -286,9 +227,6 @@ class GnuPG
|
|||
if ($this->GPG) {
|
||||
return $this->GPG->encryptsign($plaintext);
|
||||
}
|
||||
if ($this->Crypt_GPG) {
|
||||
return $this->Crypt_GPG->encryptAndSign($plaintext);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -303,9 +241,6 @@ class GnuPG
|
|||
if ($this->GPG) {
|
||||
return $this->GPG->encryptsignFile($filename);
|
||||
}
|
||||
if ($this->Crypt_GPG) {
|
||||
return $this->Crypt_GPG->encryptAndSignFile($filename, $signedFile = null);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -320,11 +255,6 @@ class GnuPG
|
|||
if ($this->GPG) {
|
||||
return $this->GPG->export($fingerprint);
|
||||
}
|
||||
if ($this->Crypt_GPG) {
|
||||
$this->Crypt_GPG->exportPrivateKey($fingerprint, $armor = true);
|
||||
$this->Crypt_GPG->exportPublicKey($fingerprint, $armor = true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -339,14 +269,6 @@ class GnuPG
|
|||
if ($this->GPG) {
|
||||
return $this->GPG->getengineinfo();
|
||||
}
|
||||
if ($this->Crypt_GPG) {
|
||||
return [
|
||||
'protocol' => null,
|
||||
'file_name' => null, // $this->Crypt_GPG->binary
|
||||
'home_dir' => $this->homedir,
|
||||
'version' => $this->Crypt_GPG->getVersion()
|
||||
];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -361,9 +283,6 @@ class GnuPG
|
|||
if ($this->GPG) {
|
||||
return $this->GPG->geterror();
|
||||
}
|
||||
if ($this->Crypt_GPG) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -378,9 +297,6 @@ class GnuPG
|
|||
if ($this->GPG) {
|
||||
return $this->GPG->geterrorinfo();
|
||||
}
|
||||
if ($this->Crypt_GPG) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -395,9 +311,6 @@ class GnuPG
|
|||
if ($this->GPG) {
|
||||
return $this->GPG->getprotocol();
|
||||
}
|
||||
if ($this->Crypt_GPG) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -426,9 +339,6 @@ class GnuPG
|
|||
if ($this->GPG) {
|
||||
return $this->GPG->import($keydata);
|
||||
}
|
||||
if ($this->Crypt_GPG) {
|
||||
return $this->Crypt_GPG->importKey($keydata);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -443,9 +353,6 @@ class GnuPG
|
|||
if ($this->GPG) {
|
||||
return $this->GPG->importFile($filename);
|
||||
}
|
||||
if ($this->Crypt_GPG) {
|
||||
return $this->Crypt_GPG->importKeyFile($filename);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -516,8 +423,6 @@ class GnuPG
|
|||
}
|
||||
}
|
||||
}
|
||||
else if ($this->Crypt_GPG) {
|
||||
}
|
||||
return $keys;
|
||||
}
|
||||
|
||||
|
|
@ -533,10 +438,6 @@ class GnuPG
|
|||
if ($this->GPG) {
|
||||
return $this->GPG->setarmor($armor ? 1 : 0);
|
||||
}
|
||||
if ($this->Crypt_GPG) {
|
||||
//$armor ? \Crypt_GPG::ARMOR_ASCII : \Crypt_GPG::ARMOR_
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -553,8 +454,6 @@ class GnuPG
|
|||
if ($this->GPG) {
|
||||
$this->GPG->seterrormode($errormode);
|
||||
}
|
||||
if ($this->Crypt_GPG) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -570,9 +469,6 @@ class GnuPG
|
|||
if ($this->GPG) {
|
||||
return $this->GPG->setsignmode($signmode);
|
||||
}
|
||||
if ($this->Crypt_GPG) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -587,9 +483,6 @@ class GnuPG
|
|||
if ($this->GPG) {
|
||||
return $this->GPG->sign($plaintext);
|
||||
}
|
||||
if ($this->Crypt_GPG) {
|
||||
return $this->Crypt_GPG->sign($data, $mode = self::SIGN_MODE_NORMAL);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -604,9 +497,6 @@ class GnuPG
|
|||
if ($this->GPG) {
|
||||
return $this->GPG->signFile($filename);
|
||||
}
|
||||
if ($this->Crypt_GPG) {
|
||||
return $this->Crypt_GPG->signFile($filename, $signedFile = null, $mode = self::SIGN_MODE_NORMAL);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -621,9 +511,6 @@ class GnuPG
|
|||
if ($this->GPG) {
|
||||
return $this->GPG->verify($signed_text, $signature, $plaintext);
|
||||
}
|
||||
if ($this->Crypt_GPG) {
|
||||
return $this->Crypt_GPG->verify($signed_text, $signature);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -638,9 +525,6 @@ class GnuPG
|
|||
if ($this->GPG) {
|
||||
return $this->GPG->verifyFile($filename, $signature, $plaintext);
|
||||
}
|
||||
if ($this->Crypt_GPG) {
|
||||
return $this->Crypt_GPG->verifyFile($filename, $signature);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -657,17 +541,4 @@ class GnuPG
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
$this->Crypt_GPG->deletePublicKey($keyId);
|
||||
$this->Crypt_GPG->deletePrivateKey($keyId);
|
||||
$this->Crypt_GPG->getKeys($keyId = '');
|
||||
$this->Crypt_GPG->getFingerprint($keyId, $format = self::FORMAT_NONE);
|
||||
$this->Crypt_GPG->getLastSignatureInfo();
|
||||
$this->Crypt_GPG->addPassphrase($key, $passphrase);
|
||||
$this->Crypt_GPG->clearPassphrases();
|
||||
$this->Crypt_GPG->hasEncryptKeys();
|
||||
$this->Crypt_GPG->hasSignKeys();
|
||||
$this->Crypt_GPG->getWarnings();
|
||||
*/
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue