summaryrefslogtreecommitdiff
path: root/alot/crypto.py
diff options
context:
space:
mode:
authorLucas Hoffmann <l-m-h@web.de>2016-03-11 12:37:37 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2016-03-11 11:52:38 +0000
commitbda3aa99c797d609c185642fb767272e9bf884c1 (patch)
tree3a67d7540d0b05056080f4c6ad8b595216b6d37c /alot/crypto.py
parentaf047f128951545af135c56d8f87ef0a924fc0ab (diff)
Add and update several docstrings.
Diffstat (limited to 'alot/crypto.py')
-rw-r--r--alot/crypto.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/alot/crypto.py b/alot/crypto.py
index d5931618..5565b890 100644
--- a/alot/crypto.py
+++ b/alot/crypto.py
@@ -219,10 +219,12 @@ def hash_key(key):
"""
Returns a hash of the given key. This is a workaround for
https://bugs.launchpad.net/pygpgme/+bug/1089865
- and can be removed if the missing feature is added to pygpgme
+ and can be removed if the missing feature is added to pygpgme.
:param key: the key we want a hash of
- :rtype: a has of the key as string
+ :type key: gpgme.Key
+ :returns: a hash of the key
+ :rtype: str
"""
hash_str = ""
for tmp_key in key.subkeys:
@@ -231,6 +233,17 @@ def hash_key(key):
def validate_key(key, sign=False, encrypt=False):
+ """Assert that a key is valide and optionally that it can be used for
+ signing or encrypting. Raise GPGProblem otherwise.
+
+ :param key: the GPG key to check
+ :type key: gpgme.Key
+ :param sign: whether the key should be able to sign
+ :type sign: bool
+ :param encrypt: whether the key should be able to encrypt
+ :type encrypt: bool
+
+ """
if key.revoked:
raise GPGProblem("The key \"" + key.uids[0].uid + "\" is revoked.",
code=GPGCode.KEY_REVOKED)