From dea149b6f5175a8082c81f32ee34ce4e4d878e0e Mon Sep 17 00:00:00 2001 From: drebs Date: Mon, 25 Nov 2013 11:20:55 -0200 Subject: Fix error returns on openpgp backend. Also fix: - some docstrings. - variabled referenced without previous assignement. --- src/leap/keymanager/__init__.py | 3 +++ src/leap/keymanager/openpgp.py | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src/leap/keymanager') diff --git a/src/leap/keymanager/__init__.py b/src/leap/keymanager/__init__.py index dbc54891..6cfbf710 100644 --- a/src/leap/keymanager/__init__.py +++ b/src/leap/keymanager/__init__.py @@ -425,6 +425,9 @@ class KeyManager(object): :type data: str :param privkey: The key used to decrypt. :type privkey: OpenPGPKey + :param passphrase: The passphrase for the secret key used for + decryption. + :type passphrase: str :param verify: The key used to verify a signature. :type verify: OpenPGPKey diff --git a/src/leap/keymanager/openpgp.py b/src/leap/keymanager/openpgp.py index cb46371c..5781d67b 100644 --- a/src/leap/keymanager/openpgp.py +++ b/src/leap/keymanager/openpgp.py @@ -341,6 +341,7 @@ class OpenPGPScheme(EncryptionScheme): leap_assert(match is not None, 'No user address in key data.') address = match.group(1) + openpgp_privkey = None if privkey is not None: match = re.match(mail_regex, privkey['uids'].pop()) leap_assert(match is not None, 'No user address in key data.') @@ -374,6 +375,7 @@ class OpenPGPScheme(EncryptionScheme): """ leap_assert_type(key_data, (str, unicode)) + openpgp_privkey = None try: openpgp_pubkey, openpgp_privkey = self.parse_ascii_key(key_data) except (errors.KeyAddressMismatch, errors.KeyFingerprintMismatch) as e: @@ -524,6 +526,9 @@ class OpenPGPScheme(EncryptionScheme): :type data: str :param privkey: The key used to decrypt. :type privkey: OpenPGPKey + :param passphrase: The passphrase for the secret key used for + decryption. + :type passphrase: str :param verify: The key used to verify a signature. :type verify: OpenPGPKey @@ -549,7 +554,7 @@ class OpenPGPScheme(EncryptionScheme): verify.fingerprint != result.pubkey_fingerprint: raise errors.InvalidSignature( 'Failed to verify signature with key %s: %s' % - (verify.key_id, stderr)) + (verify.key_id, result.stderr)) # XXX: this is the encoding used by gpg module # https://github.com/isislovecruft/python-gnupg/\ @@ -612,7 +617,7 @@ class OpenPGPScheme(EncryptionScheme): if result.fingerprint is None: raise errors.SignFailed( 'Failed to sign with key %s: %s' % - (privkey['keyid'], stderr)) + (privkey['keyid'], result.stderr)) leap_assert( result.fingerprint == kfprint, 'Signature and private key fingerprints mismatch: ' -- cgit v1.2.3