diff options
author | Ruben Pollan <meskio@sindominio.net> | 2017-10-31 10:36:35 +0100 |
---|---|---|
committer | Ruben Pollan <meskio@sindominio.net> | 2017-12-03 20:43:38 +0100 |
commit | f6c71494f0ada864e80ee74c60ec09939a14f44b (patch) | |
tree | 89f89a5549ad462ff5ee3fc2ed6cda8c0c367109 /src/leap/bitmask/keymanager | |
parent | d13fb37acd01dc1e4d62631e0e131a937a001f33 (diff) |
[refactor] remove rengenerate key
We are not planning to regenerate keys (for now), only to extend the
expiration date.
Diffstat (limited to 'src/leap/bitmask/keymanager')
-rw-r--r-- | src/leap/bitmask/keymanager/__init__.py | 14 | ||||
-rw-r--r-- | src/leap/bitmask/keymanager/keys.py | 5 | ||||
-rw-r--r-- | src/leap/bitmask/keymanager/openpgp.py | 42 |
3 files changed, 4 insertions, 57 deletions
diff --git a/src/leap/bitmask/keymanager/__init__.py b/src/leap/bitmask/keymanager/__init__.py index 2fa80c7c..c1095877 100644 --- a/src/leap/bitmask/keymanager/__init__.py +++ b/src/leap/bitmask/keymanager/__init__.py @@ -361,20 +361,6 @@ class KeyManager(object): d.addCallback(signal_finished) return d - @defer.inlineCallbacks - def regenerate_key(self): - """ - Regenerate a key bound to the user's address. - - :return: A Deferred which fires with the generated EncryptionKey. - :rtype: Deferred - """ - - self.log.info('Regenerating key for %s.' % self._address) - - new_key = yield self._openpgp.regenerate_key(self._address) - defer.returnValue(new_key) - # # Setters/getters # diff --git a/src/leap/bitmask/keymanager/keys.py b/src/leap/bitmask/keymanager/keys.py index 6c0c64ff..0f68c06b 100644 --- a/src/leap/bitmask/keymanager/keys.py +++ b/src/leap/bitmask/keymanager/keys.py @@ -191,7 +191,7 @@ class OpenPGPKey(object): return False - def merge(self, newkey, key_renewal=False): + def merge(self, newkey): if newkey.fingerprint != self.fingerprint: self.log.critical( "Can't put a key whith the same key_id and different " @@ -223,8 +223,7 @@ class OpenPGPKey(object): if newkey.last_audited_at > self.last_audited_at: self.validation = newkey.last_audited_at self.encr_used = newkey.encr_used or self.encr_used - if not key_renewal: - self.sign_used = newkey.sign_used or self.sign_used + self.sign_used = newkey.sign_used or self.sign_used self.refreshed_at = datetime.now() def get_json(self): diff --git a/src/leap/bitmask/keymanager/openpgp.py b/src/leap/bitmask/keymanager/openpgp.py index aea82156..ef77e30c 100644 --- a/src/leap/bitmask/keymanager/openpgp.py +++ b/src/leap/bitmask/keymanager/openpgp.py @@ -161,44 +161,6 @@ class OpenPGPScheme(object): # # Keys management # - @defer.inlineCallbacks - def regenerate_key(self, address): - """ - Deactivate Current keypair, - Generate a new OpenPGP keypair bound to C{address}, - and sign the new key with the old key. - - :param address: The address bound to the key. - :type address: str - - :return: A Deferred which fires with the new key bound to address. - :rtype: Deferred - """ - leap_assert(is_address(address), 'Not an user address: %s' % address) - current_sec_key = yield self.get_key(address, private=True) - current_pub_key = yield self.get_key(address, private=False) - with TempGPGWrapper([current_sec_key], self._gpgbinary) as gpg: - if current_sec_key.is_expired(): - temporary_extension_period = '1' # extend for 1 extra day - gpg.expire(current_sec_key.fingerprint, - expiration_time=temporary_extension_period) - yield self.unactivate_key(address) # only one priv key allowed - yield self.delete_key(current_pub_key) - new_key = yield self.gen_key(address) - gpg.import_keys(new_key.key_data) - key_signing = yield from_thread(gpg.sign_key, new_key.fingerprint) - if key_signing.status == 'ok': - fetched_keys = gpg.list_keys(secret=False) - fetched_key = filter(lambda k: k['fingerprint'] == - new_key.fingerprint, fetched_keys)[0] - key_data = gpg.export_keys(new_key.fingerprint, secret=False) - renewed_key = self._build_key_from_gpg( - fetched_key, - key_data, - new_key.address) - yield self.put_key(renewed_key) - defer.returnValue(new_key) - def gen_key(self, address): """ Generate an OpenPGP keypair bound to C{address}. @@ -411,7 +373,7 @@ class OpenPGPScheme(object): d.addCallback(put_key, openpgp_privkey) return d - def put_key(self, key, key_renewal=False): + def put_key(self, key): """ Put C{key} in local storage. @@ -431,7 +393,7 @@ class OpenPGPScheme(object): active_content = activedoc.content oldkey = build_key_from_dict(keydoc.content, active_content) - key.merge(oldkey, key_renewal) + key.merge(oldkey) keydoc.set_json(key.get_json()) d = self._soledad.put_doc(keydoc) d.addCallback(put_active, activedoc) |