aboutsummaryrefslogtreecommitdiff
path: root/src/mailman_pgp/pgp/inline.py
diff options
context:
space:
mode:
authorJ08nY2017-06-22 20:03:26 +0200
committerJ08nY2017-06-22 20:03:26 +0200
commit263577d4826630e6871b35c73fe3dd114ee70e22 (patch)
tree20613916e85536d16fe803a6e73a6126a7866bcb /src/mailman_pgp/pgp/inline.py
parent90529b7058362d2a43625f95bcd3afc8b9733203 (diff)
downloadmailman-pgp-263577d4826630e6871b35c73fe3dd114ee70e22.tar.gz
mailman-pgp-263577d4826630e6871b35c73fe3dd114ee70e22.tar.zst
mailman-pgp-263577d4826630e6871b35c73fe3dd114ee70e22.zip
Diffstat (limited to 'src/mailman_pgp/pgp/inline.py')
-rw-r--r--src/mailman_pgp/pgp/inline.py22
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.