diff options
| author | J08nY | 2017-08-21 17:20:29 +0200 |
|---|---|---|
| committer | J08nY | 2017-08-21 17:20:29 +0200 |
| commit | c74e96f813542d94592bf80c24afdec5d6988b2a (patch) | |
| tree | e4d8374afd9fcd985a12de636771a9e4203ab96d /src/mailman_pgp/pgp/mime.py | |
| parent | 54ad58f448f23cd26bbfad6abcfe5e4ca9b686ee (diff) | |
| download | mailman-pgp-c74e96f813542d94592bf80c24afdec5d6988b2a.tar.gz mailman-pgp-c74e96f813542d94592bf80c24afdec5d6988b2a.tar.zst mailman-pgp-c74e96f813542d94592bf80c24afdec5d6988b2a.zip | |
Diffstat (limited to 'src/mailman_pgp/pgp/mime.py')
| -rw-r--r-- | src/mailman_pgp/pgp/mime.py | 14 |
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) |
