summaryrefslogtreecommitdiff
path: root/src/mailman_pgp/utils/pgp.py
diff options
context:
space:
mode:
authorJ08nY2017-07-21 18:39:21 +0200
committerJ08nY2017-07-21 18:39:21 +0200
commit276c82849f61bd13b0fb2b38a028d58d87e830ed (patch)
tree1e5b3a0ae5ee6ef2244cc1794db252f00f3ddf19 /src/mailman_pgp/utils/pgp.py
parent389eb09b8af9d1482cb140e52b53e13d97ce78ae (diff)
downloadmailman-pgp-276c82849f61bd13b0fb2b38a028d58d87e830ed.tar.gz
mailman-pgp-276c82849f61bd13b0fb2b38a028d58d87e830ed.tar.zst
mailman-pgp-276c82849f61bd13b0fb2b38a028d58d87e830ed.zip
Diffstat (limited to 'src/mailman_pgp/utils/pgp.py')
-rw-r--r--src/mailman_pgp/utils/pgp.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/mailman_pgp/utils/pgp.py b/src/mailman_pgp/utils/pgp.py
index 7b2f958..0e1e75c 100644
--- a/src/mailman_pgp/utils/pgp.py
+++ b/src/mailman_pgp/utils/pgp.py
@@ -16,6 +16,7 @@
# this program. If not, see <http://www.gnu.org/licenses/>.
"""Miscellaneous PGP utilities."""
+from pgpy import PGPKey
from public import public
@@ -47,3 +48,31 @@ def hashes(verifications):
hasher = sigsubj.signature.hash_algorithm.hasher
hasher.update(data)
yield hasher.digest()
+
+
+@public
+def key_from_blob(blob):
+ """
+
+ :param blob:
+ :return:
+ """
+ keys = PGPKey.from_blob(blob)
+ if isinstance(keys, tuple):
+ return keys[0]
+ else:
+ return keys
+
+
+@public
+def key_from_file(file):
+ """
+
+ :param file:
+ :return:
+ """
+ keys = PGPKey.from_file(file)
+ if isinstance(keys, tuple):
+ return keys[0]
+ else:
+ return keys