diff options
author | drebs <drebs@leap.se> | 2013-03-11 16:54:58 -0300 |
---|---|---|
committer | drebs <drebs@leap.se> | 2013-03-11 17:43:19 -0300 |
commit | cbff516a2542a9d48704774bbd2477e5a1587d6e (patch) | |
tree | cb5c14c82c2519a6d88de60e9c937532c71132e8 /src/leap/soledad/util.py | |
parent | ab1e1c8862b70d47c7e5f10267639ef71b3bc536 (diff) |
Refactor and organize bootstrap sequence.
Diffstat (limited to 'src/leap/soledad/util.py')
-rw-r--r-- | src/leap/soledad/util.py | 17 |
1 files changed, 12 insertions, 5 deletions
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): |