aboutsummaryrefslogtreecommitdiff
path: root/src/mailman_pgp/pgp/mime.py
diff options
context:
space:
mode:
authorJ08nY2017-07-28 15:25:57 +0200
committerJ08nY2017-07-28 15:26:35 +0200
commit84b94dfcc84c9f9e1a69734a3005637daee77cb3 (patch)
treee84aa441880b9fad4d9fc8d672cda9fcd3b331f3 /src/mailman_pgp/pgp/mime.py
parentf48c5d7f60e73593f347b346cdf5caedf0c05628 (diff)
downloadmailman-pgp-84b94dfcc84c9f9e1a69734a3005637daee77cb3.tar.gz
mailman-pgp-84b94dfcc84c9f9e1a69734a3005637daee77cb3.tar.zst
mailman-pgp-84b94dfcc84c9f9e1a69734a3005637daee77cb3.zip
Diffstat (limited to 'src/mailman_pgp/pgp/mime.py')
-rw-r--r--src/mailman_pgp/pgp/mime.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/mailman_pgp/pgp/mime.py b/src/mailman_pgp/pgp/mime.py
index 33ec93e..a1303c9 100644
--- a/src/mailman_pgp/pgp/mime.py
+++ b/src/mailman_pgp/pgp/mime.py
@@ -24,11 +24,12 @@ from email.mime.application import MIMEApplication
from email.utils import collapse_rfc2231_value
from mailman.email.message import Message, MultipartDigestMessage
-from pgpy import PGPDetachedSignature, PGPKey, PGPMessage
+from pgpy import PGPDetachedSignature, PGPMessage
from pgpy.constants import HashAlgorithm, SymmetricKeyAlgorithm
from public import public
from mailman_pgp.utils.email import copy_headers
+from mailman_pgp.utils.pgp import key_from_blob
@public
@@ -179,7 +180,10 @@ class MIMEWrapper:
for part in walk(self.msg):
if (not part.is_multipart() # noqa
and part.get_content_type() == MIMEWrapper._keys_type):
- key, _ = PGPKey.from_blob(part.get_payload())
+ try:
+ key = key_from_blob(part.get_payload())
+ except:
+ continue
yield key
def attach_key(self, key):
@@ -215,7 +219,11 @@ class MIMEWrapper:
"""
clear_text = next(iter(self.get_signed()))
signature = next(iter(self.get_signature()))
- yield key.verify(clear_text, signature)
+ try:
+ verification = key.verify(clear_text, signature)
+ except:
+ return
+ yield verification
def _micalg(self, hash_algo):
algs = {
@@ -281,6 +289,7 @@ class MIMEWrapper:
:rtype: mailman.email.message.Message
"""
pmsg = next(iter(self.get_encrypted()))
+ # TODO: exception safe this.
decrypted = key.decrypt(pmsg)
dmsg = decrypted.message