aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJ08nY2017-06-21 00:14:09 +0200
committerJ08nY2017-06-21 00:14:09 +0200
commit1c76a2e1b22298d7664f4a9f04f73b084113b92d (patch)
tree9bab52328b6155c0c2e2083dadb8f5c8b2c0157d /src
parent907b4d1d974d419e4d289a0101b7e5b05f6d1918 (diff)
downloadmailman-pgp-1c76a2e1b22298d7664f4a9f04f73b084113b92d.tar.gz
mailman-pgp-1c76a2e1b22298d7664f4a9f04f73b084113b92d.tar.zst
mailman-pgp-1c76a2e1b22298d7664f4a9f04f73b084113b92d.zip
Diffstat (limited to 'src')
-rw-r--r--src/mailman_pgp/pgp/mime.py29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/mailman_pgp/pgp/mime.py b/src/mailman_pgp/pgp/mime.py
index d593525..a2742f1 100644
--- a/src/mailman_pgp/pgp/mime.py
+++ b/src/mailman_pgp/pgp/mime.py
@@ -19,7 +19,7 @@
from email.message import Message
from email.utils import collapse_rfc2231_value
-from pgpy import PGPKey, PGPSignature
+from pgpy import PGPKey, PGPMessage, PGPSignature
class PGPMIMEWrapper:
@@ -46,9 +46,10 @@ class PGPMIMEWrapper:
protocol_param = collapse_rfc2231_value(self.msg.get_param('protocol'))
content_subtype = self.msg.get_content_subtype()
- return second_type == PGPMIMEWrapper._signed_subtype and \
- content_subtype == 'signed' and \
- protocol_param == PGPMIMEWrapper._signed_subtype
+ return \
+ second_type == PGPMIMEWrapper._signed_subtype and \
+ content_subtype == 'signed' and \
+ protocol_param == PGPMIMEWrapper._signed_subtype
def is_encrypted(self):
"""
@@ -63,11 +64,12 @@ class PGPMIMEWrapper:
content_subtype = self.msg.get_content_subtype()
protocol_param = collapse_rfc2231_value(self.msg.get_param('protocol'))
- return 'Version: 1' in first_part and \
- first_type == PGPMIMEWrapper._encrypted_subtype and \
- second_type == 'application/octet-stream' and \
- content_subtype == 'encrypted' and \
- protocol_param == PGPMIMEWrapper._encrypted_subtype
+ return \
+ 'Version: 1' in first_part and \
+ first_type == PGPMIMEWrapper._encrypted_subtype and \
+ second_type == 'application/octet-stream' and \
+ content_subtype == 'encrypted' and \
+ protocol_param == PGPMIMEWrapper._encrypted_subtype
def verify(self, key: PGPKey):
"""
@@ -81,4 +83,11 @@ class PGPMIMEWrapper:
return key.verify(clear_text, signature)
def decrypt(self, key: PGPKey):
- pass
+ """
+
+ :param key:
+ :return:
+ """
+ msg_text = self.msg.get_payload(1).get_payload()
+ msg = PGPMessage.from_blob(msg_text)
+ return key.decrypt(msg)