From 3491d459ac0ce9bf7f0ed076d3a2b8c2d73b0ff0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sm=C3=A1ri=20McCarthy?= Date: Mon, 19 Jan 2015 16:38:49 +0000 Subject: [PATCH] Revokation handled correctly --- mailpile/crypto/gpgi.py | 3 ++- mailpile/plugins/crypto_utils.py | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/mailpile/crypto/gpgi.py b/mailpile/crypto/gpgi.py index 0cdefece2..76db56804 100644 --- a/mailpile/crypto/gpgi.py +++ b/mailpile/crypto/gpgi.py @@ -194,6 +194,7 @@ def parse_pubkey(self, line): "authenticate": "A" in line["capabilities"], } line["disabled"] = "D" in line["capabilities"] + line["revoked"] = "r" in line["validity"] line["private_key"] = False line["subkeys"] = [] line["uids"] = [] @@ -604,7 +605,7 @@ def list_secret_keys(self): public_keys = self.parse_keylist(retvals[1]["stdout"]) for fprint, info in public_keys.iteritems(): if fprint in secret_keys: - for k in ("disabled", ): # FIXME: Copy more? + for k in ("disabled", "revoked"): # FIXME: Copy more? secret_keys[fprint][k] = info[k] return secret_keys diff --git a/mailpile/plugins/crypto_utils.py b/mailpile/plugins/crypto_utils.py index 5699694f6..3d12fd738 100644 --- a/mailpile/plugins/crypto_utils.py +++ b/mailpile/plugins/crypto_utils.py @@ -263,6 +263,8 @@ class GPGCheckKeys(Search): HTTP_CALLABLE = ('GET', ) COMMAND_CACHE_TTL = 0 + MIN_KEYSIZE = 2048 + class CommandResult(Command.CommandResult): def __init__(self, *args, **kwargs): Command.CommandResult.__init__(self, *args, **kwargs) @@ -316,10 +318,10 @@ def command(self): is_serious = False elif (not info['capabilities_map'].get('encrypt') or not info['capabilities_map'].get('sign')): - rev = info.get('revocation_date') - if rev and rev <= today: - k_info['description'] = _('%s: Bad: key was revoked' + if info.get("revoked"): + k_info['description'] = _('%s: --- Revoked.' ) % fprint + is_serious = False elif exp and exp <= today: k_info['description'] = _('%s: Bad: expired on %s' ) % (fprint, @@ -330,7 +332,7 @@ def command(self): elif exp and exp <= fortnight: k_info['description'] = _('%s: Bad: expires on %s' ) % (fprint, info['expiration_date']) - elif k_info['keysize'] < 2048: + elif k_info['keysize'] < self.MIN_KEYSIZE: k_info['description'] = _('%s: Bad: too small (%d bits)' ) % (fprint, k_info['keysize']) else: