From fa2b97fb2e6e75af8bfc0bc3620b1a37179bdedc Mon Sep 17 00:00:00 2001 From: J08nY Date: Wed, 2 Aug 2017 00:15:21 +0200 Subject: Fix .attach_keys and .attach_revocs in Wrappers. --- src/mailman_pgp/pgp/inline.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/mailman_pgp/pgp/inline.py') diff --git a/src/mailman_pgp/pgp/inline.py b/src/mailman_pgp/pgp/inline.py index cf92ffc..49f0a6e 100644 --- a/src/mailman_pgp/pgp/inline.py +++ b/src/mailman_pgp/pgp/inline.py @@ -18,11 +18,13 @@ """Strict inline PGP message wrapper.""" import copy from email.iterators import walk +from email.mime.text import MIMEText from pgpy import PGPMessage from pgpy.constants import SymmetricKeyAlgorithm from public import public +from mailman_pgp.utils.email import make_multipart from mailman_pgp.utils.pgp import key_from_blob, revoc_from_blob @@ -211,6 +213,21 @@ class InlineWrapper: continue yield revoc + def attach_revocs(self, *key_revocations): + """ + Attach a key revocation signature to the message. + + :param key_revocations: A key revocation signature to attach. + :type key_revocations: pgpy.PGPSignature + :return: The message with the signature attached. + :rtype: mailman.email.message.Message + """ + out = make_multipart(self.msg) + for key_revocation in key_revocations: + revoc_part = MIMEText(str(key_revocation)) + out.attach(revoc_part) + return out + def verify(self, key): """ Verify the signatures of this message with key. -- cgit v1.2.3-70-g09d2