aboutsummaryrefslogtreecommitdiff
path: root/src/mailman_pgp/pgp/mime.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailman_pgp/pgp/mime.py')
-rw-r--r--src/mailman_pgp/pgp/mime.py27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/mailman_pgp/pgp/mime.py b/src/mailman_pgp/pgp/mime.py
index 3421167..3a20ce3 100644
--- a/src/mailman_pgp/pgp/mime.py
+++ b/src/mailman_pgp/pgp/mime.py
@@ -20,6 +20,7 @@ from email.iterators import walk
from email.utils import collapse_rfc2231_value
from pgpy import PGPKey, PGPMessage, PGPSignature
+from pgpy.constants import SymmetricKeyAlgorithm
from public import public
@@ -84,6 +85,12 @@ class MIMEWrapper:
content_subtype == 'encrypted' and
protocol_param == MIMEWrapper._encrypted_subtype)
+ def is_keys(self):
+ for part in walk(self.msg):
+ if part.get_content_type() != MIMEWrapper._keys_subtype:
+ return False
+ return True
+
def has_keys(self):
"""
Whether the message contains keys as per RFC3156 section 7.
@@ -119,9 +126,15 @@ class MIMEWrapper:
clear_text = self.msg.get_payload(0).as_string()
sig_text = self.msg.get_payload(1).get_payload()
signature = PGPSignature.from_blob(sig_text)
- return key.verify(clear_text, signature)
+ yield key.verify(clear_text, signature)
- def sign(self):
+ def sign(self, key):
+ """
+
+ :param key:
+ :type key: pgpy.PGPKey
+ :return:
+ """
pass
def decrypt(self, key):
@@ -137,5 +150,13 @@ class MIMEWrapper:
msg = PGPMessage.from_blob(msg_text)
return key.decrypt(msg)
- def encrypt(self):
+ def encrypt(self, *keys, cipher=SymmetricKeyAlgorithm.AES256):
+ """
+
+ :param keys:
+ :type keys: pgpy.PGPKey
+ :param cipher:
+ :type cipher: SymmetricKeyAlgorithm
+ :return:
+ """
pass