[gnome-keysign: 10/15] gpgmeh: create exceptions for issued during signature import
- From: Tobias Mueller <tobiasmue src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-keysign: 10/15] gpgmeh: create exceptions for issued during signature import
- Date: Fri, 8 Apr 2022 14:10:32 +0000 (UTC)
commit c362bcabfc458144d178e97d8fb30d4f1e63eeae
Author: Tobias Mueller <muelli cryptobitch de>
Date: Fri Apr 8 14:36:50 2022 +0200
gpgmeh: create exceptions for issued during signature import
This allows for the UI to provide rich feedback about the case at hand.
For example, the UI can choose to ignore when a signature has already
been imported, i.e. NoNewSignatures. Or fail very loudly when a
revocation has been imported.
keysign/gpgmeh.py | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/keysign/gpgmeh.py b/keysign/gpgmeh.py
index 61279aa..25f2b00 100755
--- a/keysign/gpgmeh.py
+++ b/keysign/gpgmeh.py
@@ -550,6 +550,13 @@ def sign_keydata_and_encrypt(keydata, error_cb=None, homedir=None):
yield (UID.from_gpgme(uid), ciphertext, uid_data)
+class NoNewSignatures(GPGMEError):
+ pass
+class NewRevocations(GPGMEError):
+ pass
+class NewSubkey(GPGMEError):
+ pass
+
def decrypt_signature(encrypted_sig, homedir=None):
"""
Takes an encrypted signture, tries to decrypt it, and returns the
@@ -569,9 +576,12 @@ def decrypt_signature(encrypted_sig, homedir=None):
log.warning("Trying to import a new key instead of a signature!")
raise GPGMEError
- if result.new_signatures == 0 or result.new_revocations != 0 or result.new_sub_keys != 0:
- log.warning("The signature that we were importing is not as we expected!")
- raise GPGMEError
+ if result.new_signatures == 0:
+ raise NoNewSignatures()
+ if result.new_revocations != 0:
+ raise NewRevocations()
+ if result.new_sub_keys != 0:
+ raise NewSubkey()
return decrypted_sig
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]