plugin otr: priv_key is better than getPrivKey here, as it should not be None + fixed private key encryption/decryption

This commit is contained in:
Goffi 2014-08-25 21:32:29 +02:00
commit 20ea92ce1c

View file

@ -130,7 +130,9 @@ class Account(potr.context.Account):
def savePrivkey(self):
log.debug(u"savePrivkey")
priv_key = self.getPrivkey().serializePrivateKey()
if self.privkey is None:
raise exceptions.InternalError(_("Save is called but privkey is None !"))
priv_key = self.privkey.serializePrivateKey().encode('hex')
d = self.host.memory.encryptValue(priv_key, self.client.profile)
def save_encrypted_key(encrypted_priv_key):
self.client.otr_data[PRIVATE_KEY] = encrypted_priv_key
@ -193,7 +195,7 @@ class OTR(object):
encrypted_priv_key = client.otr_data.get(PRIVATE_KEY, None)
if encrypted_priv_key is not None:
priv_key = yield self.host.memory.decryptValue(encrypted_priv_key, profile)
client.otr_priv_key = potr.crypt.PK.parsePrivateKey(priv_key)[0]
client.otr_priv_key = potr.crypt.PK.parsePrivateKey(priv_key.decode('hex'))[0]
else:
client.otr_priv_key = None