From 06c72c0af35395e714b2fb23ff4fbb9bfb8d87f3 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Thu, 18 Jun 2009 11:15:03 -0600 Subject: [PATCH] Bug #8351: Fix PGP passphrase verification --- framework/Crypt/lib/Horde/Crypt/Pgp.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/framework/Crypt/lib/Horde/Crypt/Pgp.php b/framework/Crypt/lib/Horde/Crypt/Pgp.php index 111b03b50..74c94e4a0 100644 --- a/framework/Crypt/lib/Horde/Crypt/Pgp.php +++ b/framework/Crypt/lib/Horde/Crypt/Pgp.php @@ -635,12 +635,19 @@ class Horde_Crypt_Pgp extends Horde_Crypt * * @return boolean Returns true on valid passphrase, false on invalid * passphrase. + * @throws Horde_Exception */ public function verifyPassphrase($public_key, $private_key, $passphrase) { + /* Get e-mail address of public key. */ + $key_info = $this->pgpPacketInformation($public_key); + if (!isset($key_info['signature']['id1']['email'])) { + throw new Horde_Exception(_("Could not determine the recipient's e-mail address."), 'horde.error'); + } + /* Encrypt a test message. */ try { - $this->encrypt('Test', array('type' => 'message', 'pubkey' => $public_key)); + $result = $this->encrypt('Test', array('type' => 'message', 'pubkey' => $public_key, 'recips' => array($key_info['signature']['id1']['email'] => $public_key))); } catch (Horde_Exception $e) { return false; } @@ -1081,6 +1088,7 @@ class Horde_Crypt_Pgp extends Horde_Crypt '--batch', '--always-trust' ); + if (empty($params['symmetric'])) { /* Store public key in temporary keyring. */ $keyring = $this->_putInKeyring(array_values($params['recips'])); -- 2.11.0