summaryrefslogtreecommitdiff
path: root/alot/crypto.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2017-08-24 11:14:59 -0700
committerRuben Pollan <meskio@sindominio.net>2017-09-25 12:34:50 +0200
commit0db403fc22fb43dcfa5919dd2aedf223a2b81dcb (patch)
treee7e537477577801bc1b8e6c5d3556d266020cda2 /alot/crypto.py
parent24ebb8bf44691ada1232b4308ae90518817fece8 (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.
Diffstat (limited to 'alot/crypto.py')
-rw-r--r--alot/crypto.py3
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]