diff options
Diffstat (limited to 'src/mailman_pgp/pgp/inline.py')
| -rw-r--r-- | src/mailman_pgp/pgp/inline.py | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/mailman_pgp/pgp/inline.py b/src/mailman_pgp/pgp/inline.py index 372204a..5c23777 100644 --- a/src/mailman_pgp/pgp/inline.py +++ b/src/mailman_pgp/pgp/inline.py @@ -221,19 +221,21 @@ class InlineWrapper: self._decrypt(part, key) return out - def _encrypt(self, pmsg, *keys, cipher): + def _encrypt(self, pmsg, *keys, cipher, **kwargs): emsg = copy.copy(pmsg) if len(keys) == 1: - emsg = keys[0].encrypt(emsg, cipher=cipher) + emsg = keys[0].encrypt(emsg, cipher=cipher, **kwargs) else: session_key = cipher.gen_key() for key in keys: emsg = key.encrypt(emsg, cipher=cipher, - session_key=session_key) + session_key=session_key, + **kwargs) del session_key return emsg - def encrypt(self, *keys, cipher=SymmetricKeyAlgorithm.AES256): + def encrypt(self, *keys, cipher=SymmetricKeyAlgorithm.AES256, + **kwargs): """ Encrypt the message with key/s, using cipher. @@ -251,12 +253,13 @@ class InlineWrapper: if not part.is_multipart(): payload = str(part.get_payload()) pmsg = PGPMessage.new(payload) - emsg = self._encrypt(pmsg, *keys, cipher=cipher) + emsg = self._encrypt(pmsg, *keys, cipher=cipher, **kwargs) part.set_payload(str(emsg)) return out def sign_encrypt(self, key, *keys, hash=None, - cipher=SymmetricKeyAlgorithm.AES256): + cipher=SymmetricKeyAlgorithm.AES256, + **kwargs): """ Sign and encrypt the message, in one go. @@ -280,12 +283,14 @@ class InlineWrapper: payload = str(part.get_payload()) pmsg = PGPMessage.new(payload) smsg = self._sign(pmsg, key, hash=hash) - emsg = self._encrypt(smsg, *keys, cipher=cipher) + emsg = self._encrypt(smsg, *keys, cipher=cipher, **kwargs) part.set_payload(str(emsg)) return out def sign_then_encrypt(self, key, *keys, hash=None, - cipher=SymmetricKeyAlgorithm.AES256): + cipher=SymmetricKeyAlgorithm.AES256, + **kwargs): # TODO: sign into cleartext here and then encrypt? I mean that's weird # but thats what sing *then* encrypt means for inline pgp. - return self.sign_encrypt(key, *keys, hash=hash, cipher=cipher) + return self.sign_encrypt(key, *keys, hash=hash, cipher=cipher, + **kwargs) |
