diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2017-08-24 11:14:59 -0700 |
---|---|---|
committer | Ruben Pollan <meskio@sindominio.net> | 2017-09-25 12:34:50 +0200 |
commit | 0db403fc22fb43dcfa5919dd2aedf223a2b81dcb (patch) | |
tree | e7e537477577801bc1b8e6c5d3556d266020cda2 | |
parent | 24ebb8bf44691ada1232b4308ae90518817fece8 (diff) |
crypto: Don't allow passing empty keys
This will result in wrong behavior, gpg will prompt for a password
rather than using keys to encrypt.
-rw-r--r-- | alot/crypto.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/alot/crypto.py b/alot/crypto.py index 6e3e8fa6..5ed3a909 100644 --- a/alot/crypto.py +++ b/alot/crypto.py @@ -157,7 +157,7 @@ def detached_signature_for(plaintext_str, keys): return sign_result.signatures, sigblob -def encrypt(plaintext_str, keys=None): +def encrypt(plaintext_str, keys): """Encrypt data and return the encrypted form. :param str plaintext_str: the mail to encrypt @@ -166,6 +166,7 @@ def encrypt(plaintext_str, keys=None): :returns: encrypted mail :rtype: str """ + assert keys, 'Must provide at least one key to encrypt with' ctx = gpg.core.Context(armor=True) out = ctx.encrypt(plaintext_str, recipients=keys, sign=False, always_trust=True)[0] |