aboutsummaryrefslogtreecommitdiff
path: root/src/mailman_pgp/pgp/wrapper.py
diff options
context:
space:
mode:
authorJ08nY2017-06-22 19:12:04 +0200
committerJ08nY2017-06-22 19:12:04 +0200
commit5014e7a75f02f8c707847122ff43b37064247a43 (patch)
tree19bda52a1507fa7fe09e051ccee0129aace62d85 /src/mailman_pgp/pgp/wrapper.py
parent429234b8db28ed6aadf21a3ccfce7eaf7065be71 (diff)
downloadmailman-pgp-5014e7a75f02f8c707847122ff43b37064247a43.tar.gz
mailman-pgp-5014e7a75f02f8c707847122ff43b37064247a43.tar.zst
mailman-pgp-5014e7a75f02f8c707847122ff43b37064247a43.zip
Diffstat (limited to 'src/mailman_pgp/pgp/wrapper.py')
-rw-r--r--src/mailman_pgp/pgp/wrapper.py34
1 files changed, 28 insertions, 6 deletions
diff --git a/src/mailman_pgp/pgp/wrapper.py b/src/mailman_pgp/pgp/wrapper.py
index 5d8bf41..9a004c4 100644
--- a/src/mailman_pgp/pgp/wrapper.py
+++ b/src/mailman_pgp/pgp/wrapper.py
@@ -14,10 +14,8 @@
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
-""""""
-from email.message import Message
+"""A combined PGP/MIME + inline PGP wrapper."""
-from pgpy import PGPKey
from public import public
from mailman_pgp.pgp.inline import InlineWrapper
@@ -26,7 +24,15 @@ from mailman_pgp.pgp.mime import MIMEWrapper
@public
class PGPWrapper():
- def __init__(self, msg: Message):
+ """A combined PGP/MIME + inline PGP wrapper."""
+
+ def __init__(self, msg):
+ """
+ Wrap the given message.
+
+ :param msg: The message to wrap.
+ :type msg: mailman.email.message.Message
+ """
self.msg = msg
self.mime = MIMEWrapper(msg)
self.inline = InlineWrapper(msg)
@@ -40,7 +46,15 @@ class PGPWrapper():
def is_signed(self):
return self.is_mime_signed() or self.is_inline_signed()
- def verify(self, key: PGPKey):
+ def verify(self, key):
+ """
+ Verify the signature of this message with key.
+
+ :param key: The key to verify with.
+ :type key: pgpy.PGPKey
+ :return: The verified signature.
+ :rtype: pgpy.types.SignatureVerification
+ """
if self.is_mime_signed():
return self.mime.verify(key)
else:
@@ -55,7 +69,15 @@ class PGPWrapper():
def is_encrypted(self):
return self.is_mime_encrypted() or self.is_inline_encrypted()
- def decrypt(self, key: PGPKey):
+ def decrypt(self, key):
+ """
+ Decrypt this message with key.
+
+ :param key: The key to decrypt with.
+ :type key: pgpy.PGPKey
+ :return: The decrypted message.
+ :rtype: PGPMessage
+ """
if self.is_mime_encrypted():
return self.mime.decrypt(key)
else: