From 276c82849f61bd13b0fb2b38a028d58d87e830ed Mon Sep 17 00:00:00 2001 From: J08nY Date: Fri, 21 Jul 2017 18:39:21 +0200 Subject: Add more functionality to REST interface for lists. --- src/mailman_pgp/utils/pgp.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/mailman_pgp/utils/pgp.py') 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 . """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 -- cgit v1.2.3-70-g09d2