diff options
author | Michał Górny <mgorny@gentoo.org> | 2023-01-22 10:02:07 +0100 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2023-01-22 10:02:07 +0100 |
commit | faa264c5b8c81df7480dde39950baba5c7ce802b (patch) | |
tree | e082dc3d24df26a96e5b0d72bdac6a685a45a7fa | |
parent | 1c16808d1c1826808d9ac705ee531bcf8b8c6be9 (diff) | |
download | gemato-faa264c5b8c81df7480dde39950baba5c7ce802b.tar.gz |
openpgp: Pass OpenPGPSignatureData to OpenPGPVerificationFailure
Signed-off-by: Michał Górny <mgorny@gentoo.org>
-rw-r--r-- | gemato/exceptions.py | 6 | ||||
-rw-r--r-- | gemato/openpgp.py | 12 |
2 files changed, 10 insertions, 8 deletions
diff --git a/gemato/exceptions.py b/gemato/exceptions.py index cf9208e..8492df9 100644 --- a/gemato/exceptions.py +++ b/gemato/exceptions.py @@ -120,8 +120,6 @@ class OpenPGPRuntimeError(GematoException): Base exception class for OpenPGP runtime errors. """ - __slots__ = ['output'] - def __init__(self, output): super().__init__(output) self.output = output @@ -159,6 +157,10 @@ class OpenPGPVerificationFailure(OpenPGPRuntimeError): An exception raised when OpenPGP verification fails. """ + def __init__(self, output, sig_data=None): + super().__init__(output) + self.sig_data = sig_data + def __str__(self): return f'OpenPGP verification failed:\n{self.output}' diff --git a/gemato/openpgp.py b/gemato/openpgp.py index 50166c4..8c1db59 100644 --- a/gemato/openpgp.py +++ b/gemato/openpgp.py @@ -239,23 +239,23 @@ class SystemGPGEnvironment: OpenPGPSignatureStatus.NO_PUBLIC_KEY, OpenPGPSignatureStatus.ERROR): raise OpenPGPVerificationFailure( - err.decode("utf8", errors="backslashreplace")) + err.decode("utf8", errors="backslashreplace"), sig) elif sig.sig_status == OpenPGPSignatureStatus.EXPIRED_KEY: raise OpenPGPExpiredKeyFailure( - err.decode('utf8', errors='backslashreplace')) + err.decode('utf8', errors='backslashreplace'), sig) elif sig.sig_status == OpenPGPSignatureStatus.REVOKED_KEY: raise OpenPGPRevokedKeyFailure( - err.decode('utf8', errors='backslashreplace')) + err.decode('utf8', errors='backslashreplace'), sig) else: raise OpenPGPUnknownSigFailure( - err.decode('utf8', errors='backslashreplace')) + err.decode('utf8', errors='backslashreplace'), sig) if not sig.valid_sig: raise OpenPGPUnknownSigFailure( - err.decode('utf8', errors='backslashreplace')) + err.decode('utf8', errors='backslashreplace'), sig) if not sig.trusted_sig: raise OpenPGPUntrustedSigFailure( - err.decode('utf8', errors='backslashreplace')) + err.decode('utf8', errors='backslashreplace'), sig) return sig_list |