Mercurial > libervia-backend
diff src/plugins/plugin_sec_otr.py @ 1137:768f1f1ef12c
plugin otr: priv_key is better than getPrivKey here, as it should not be None + fixed private key encryption/decryption
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 25 Aug 2014 21:32:29 +0200 |
parents | ea2bbdf5b541 |
children | 7fcafc3206b1 |
line wrap: on
line diff
--- a/src/plugins/plugin_sec_otr.py Mon Aug 25 21:32:23 2014 +0200 +++ b/src/plugins/plugin_sec_otr.py Mon Aug 25 21:32:29 2014 +0200 @@ -130,7 +130,9 @@ 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 @@ 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