From 0db403fc22fb43dcfa5919dd2aedf223a2b81dcb Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Thu, 24 Aug 2017 11:14:59 -0700 Subject: 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. --- alot/crypto.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'alot/crypto.py') 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] -- cgit v1.2.3