[feat] update usage only if needed
authorRuben Pollan <meskio@sindominio.net>
Thu, 21 Jan 2016 17:48:23 +0000 (18:48 +0100)
committerRuben Pollan <meskio@sindominio.net>
Thu, 25 Feb 2016 17:35:25 +0000 (11:35 -0600)
During encryption we where updating 'enc_used' in the key without
checking if it was already set.

src/leap/keymanager/__init__.py

index 99ee163..9e3b6ee 100644 (file)
@@ -579,8 +579,9 @@ class KeyManager(object):
             encrypted = yield _keys.encrypt(
                 data, pubkey, passphrase, sign=signkey,
                 cipher_algo=cipher_algo)
-            pubkey.encr_used = True
-            yield _keys.put_key(pubkey)
+            if not pubkey.encr_used:
+                pubkey.encr_used = True
+                yield _keys.put_key(pubkey)
             defer.returnValue(encrypted)
 
         dpub = self.get_key(address, ktype, private=False,