From cbff516a2542a9d48704774bbd2477e5a1587d6e Mon Sep 17 00:00:00 2001 From: drebs Date: Mon, 11 Mar 2013 16:54:58 -0300 Subject: Refactor and organize bootstrap sequence. --- src/leap/soledad/util.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/leap/soledad/util.py') diff --git a/src/leap/soledad/util.py b/src/leap/soledad/util.py index c64d4c5f..b8ee4cf3 100644 --- a/src/leap/soledad/util.py +++ b/src/leap/soledad/util.py @@ -70,20 +70,27 @@ class GPGWrapper(gnupg.GPG): return key raise LookupError("GnuPG public key for email %s not found!" % email) - def find_key_by_subkey(self, subkey): - for key in self.list_keys(): + def find_key_by_subkey(self, subkey, secret=False): + for key in self.list_keys(secret=secret): for sub in key['subkeys']: if sub[0] == subkey: return key raise LookupError( "GnuPG public key for subkey %s not found!" % subkey) - def find_key_by_keyid(self, keyid): - for key in self.list_keys(): + def find_key_by_keyid(self, keyid, secret=False): + for key in self.list_keys(secret=secret): if keyid == key['keyid']: return key raise LookupError( - "GnuPG public key for subkey %s not found!" % subkey) + "GnuPG public key for keyid %s not found!" % keyid) + + def find_key_by_fingerprint(self, fingerprint, secret=False): + for key in self.list_keys(secret=secret): + if fingerprint == key['fingerprint']: + return key + raise LookupError( + "GnuPG public key for fingerprint %s not found!" % fingerprint) def encrypt(self, data, recipient, sign=None, always_trust=True, passphrase=None, symmetric=False): -- cgit v1.2.3