diff options
Diffstat (limited to 'src/mailman_pgp/pgp/inline.py')
| -rw-r--r-- | src/mailman_pgp/pgp/inline.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/mailman_pgp/pgp/inline.py b/src/mailman_pgp/pgp/inline.py index d87b3da..a8e8004 100644 --- a/src/mailman_pgp/pgp/inline.py +++ b/src/mailman_pgp/pgp/inline.py @@ -17,7 +17,7 @@ """Strict inline PGP message wrapper.""" -from pgpy import PGPMessage +from pgpy import PGPKey, PGPMessage from pgpy.types import Armorable from public import public @@ -70,6 +70,26 @@ class InlineWrapper: # XXX: This mistakes non-cleartext signature as encrypted. return self._is_inline() and self._has_armor('MESSAGE') + def has_keys(self): + """ + Whether the message contains public or private keys. + + :return: If the message contains keys. + :rtype: bool + """ + return self._is_inline() and (self._has_armor('PUBLIC KEY BLOCK') or + self._has_armor('PRIVATE KEY BLOCK')) + + def keys(self): + """ + Get the collection of keys in this message. + + :return: A collection of keys. + """ + # TODO: potentially return all things returned from from_blob? + key, _ = PGPKey.from_blob(self._as_string()) + yield key + def verify(self, key): """ Verify the signature of this message with key. |
