diff options
| author | J08nY | 2017-07-11 20:57:29 +0200 |
|---|---|---|
| committer | J08nY | 2017-07-11 20:57:29 +0200 |
| commit | 77b63eaae46697b24fe4cc604a36b869619b4638 (patch) | |
| tree | b91c61103b588f822313abb0716bae76f168ca44 /src/mailman_pgp/pgp/mime.py | |
| parent | 97abc15b2e92fcf9109997043e4297f16d0bf5c7 (diff) | |
| download | mailman-pgp-77b63eaae46697b24fe4cc604a36b869619b4638.tar.gz mailman-pgp-77b63eaae46697b24fe4cc604a36b869619b4638.tar.zst mailman-pgp-77b63eaae46697b24fe4cc604a36b869619b4638.zip | |
Diffstat (limited to 'src/mailman_pgp/pgp/mime.py')
| -rw-r--r-- | src/mailman_pgp/pgp/mime.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/mailman_pgp/pgp/mime.py b/src/mailman_pgp/pgp/mime.py index 1ecbe76..975b8bd 100644 --- a/src/mailman_pgp/pgp/mime.py +++ b/src/mailman_pgp/pgp/mime.py @@ -87,7 +87,7 @@ class MIMEWrapper: return self.is_signed() def get_signed(self): - yield self.msg.get_payload(0).as_string(0) + yield self.msg.get_payload(0).as_string() def is_encrypted(self): """ @@ -145,6 +145,26 @@ class MIMEWrapper: key, _ = PGPKey.from_blob(part.get_payload()) yield key + def attach_key(self, key): + """ + + :param key: + :type key: pgpy.PGPKey + :return: + """ + filename = '0x' + key.fingerprint.keyid + '.asc' + key_part = MIMEApplication(_data=str(key), + _subtype=MIMEWrapper._keys_subtype, + _encoder=encode_7or8bit, + name=filename) + key_part.add_header('Content-Description', + 'OpenPGP key') + key_part.add_header('Content-Disposition', 'attachment', + filename=filename) + out = copy.deepcopy(self.msg) + out.attach(key_part) + return out + def verify(self, key): """ Verify the signature of this message with key. |
