Mercurial > libervia-backend
diff sat/plugins/plugin_sec_otr.py @ 3160:330a5f1d9eea
core (memory/crypto): replaced `PyCrypto` by `cryptography`:
`PyCrypto` is unmaintained for years but was used in SàT for password hashing. This patch
fixes that by replacing `PyCrypto` by the reference `cryptography` module which is well
maintained.
The behaviour stays the same (except that previously async `hash`, `encrypt` and `decrypt`
methods are now synchronous, as they are quick and using a deferToThread may actually be
more resource intensive than using blocking methods).
It is planed to improve `memory.crypto` by using more up-to-date cryptography/hashing
algorithms in the future.
PyCrypto is no more a dependency of SàT
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 09 Feb 2020 23:50:26 +0100 |
parents | 559a625a236b |
children | dcebc585c29f |
line wrap: on
line diff
--- a/sat/plugins/plugin_sec_otr.py Sun Feb 09 23:50:21 2020 +0100 +++ b/sat/plugins/plugin_sec_otr.py Sun Feb 09 23:50:26 2020 +0100 @@ -248,12 +248,8 @@ if self.privkey is None: raise exceptions.InternalError(_("Save is called but privkey is None !")) priv_key = hexlify(self.privkey.serializePrivateKey()) - 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 - - d.addCallback(save_encrypted_key) + encrypted_priv_key = self.host.memory.encryptValue(priv_key, self.client.profile) + self.client._otr_data[PRIVATE_KEY] = encrypted_priv_key def loadTrusts(self): trust_data = self.client._otr_data.get("trust", {}) @@ -377,7 +373,7 @@ yield client._otr_data.load() encrypted_priv_key = client._otr_data.get(PRIVATE_KEY, None) if encrypted_priv_key is not None: - priv_key = yield self.host.memory.decryptValue( + priv_key = self.host.memory.decryptValue( encrypted_priv_key, client.profile ) ctxMng.account.privkey = potr.crypt.PK.parsePrivateKey(