aboutsummaryrefslogtreecommitdiff
path: root/src/mailman_pgp/pgp/mime.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailman_pgp/pgp/mime.py')
-rw-r--r--src/mailman_pgp/pgp/mime.py14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/mailman_pgp/pgp/mime.py b/src/mailman_pgp/pgp/mime.py
index 878fe59..eeeed95 100644
--- a/src/mailman_pgp/pgp/mime.py
+++ b/src/mailman_pgp/pgp/mime.py
@@ -24,7 +24,7 @@ from email.mime.application import MIMEApplication
from email.utils import collapse_rfc2231_value
from mailman.email.message import Message, MultipartDigestMessage
-from pgpy import PGPDetachedSignature, PGPMessage
+from pgpy import PGPMessage, PGPSignature
from pgpy.constants import HashAlgorithm, SymmetricKeyAlgorithm
from public import public
@@ -99,10 +99,10 @@ class MIMEWrapper:
"""
:return:
- :rtype: typing.Generator[pgpy.PGPDetachedSignature]
+ :rtype: typing.Generator[pgpy.PGPSignature]
"""
try:
- sig = PGPDetachedSignature.from_blob(
+ sig = PGPSignature.from_blob(
self.msg.get_payload(1).get_payload())
except:
return
@@ -319,19 +319,17 @@ class MIMEWrapper:
copy_headers(msg, out)
return out
- def sign(self, key, hash=None):
+ def sign(self, key, **kwargs):
"""
Sign a message with key.
:param key: The key to sign with.
:type key: pgpy.PGPKey
- :param hash:
- :type hash: pgpy.constants.HashAlgorithm
:return: The signed message.
:rtype: mailman.email.message.Message
"""
payload = next(iter(self.get_payload()))
- signature = key.sign(payload, hash=hash)
+ signature = key.sign(payload, **kwargs)
return self._wrap_signed(self.msg, signature)
def decrypt(self, key):
@@ -470,7 +468,7 @@ class MIMEWrapper:
if len(keys) == 0:
raise ValueError('At least one key necessary.')
- out = self.sign(key, hash)
+ out = self.sign(key, hash=hash)
out_wrapped = MIMEWrapper(out)
pmsg = PGPMessage.new(next(out_wrapped.get_payload()))
pmsg = self._encrypt(pmsg, *keys, cipher=cipher, **kwargs)