core (memory): Modernize methods signature/docstrings of encrypt_value and decrypt_value:

- Use `client` instead of `profile`
- Add `decrypt_value_by_profile` which is notably useful on client startup, when the
  encrypted password needs to be retrieved, and the `SatXMPPEntity` instance is not yet
  created.
- Add type hints/update docstrings

rel 477
This commit is contained in:
Goffi 2026-06-06 11:23:51 +02:00
commit ed462a661b

View file

@ -248,7 +248,7 @@ class Account(potr.context.Account):
if self.privkey is None:
raise exceptions.InternalError(_("Save is called but privkey is None !"))
priv_key = hexlify(self.privkey.serializePrivateKey())
encrypted_priv_key = self.host.memory.encrypt_value(priv_key, self.client.profile)
encrypted_priv_key = self.host.memory.encrypt_value(self.client, priv_key)
self.client._otr_data[PRIVATE_KEY] = encrypted_priv_key
def load_trusts(self):
@ -373,7 +373,7 @@ class OTR(object):
yield client._otr_data.load()
encrypted_priv_key = client._otr_data.get(PRIVATE_KEY, None)
if encrypted_priv_key is not None:
priv_key = self.host.memory.decrypt_value(encrypted_priv_key, client.profile)
priv_key = self.host.memory.decrypt_value(client, encrypted_priv_key)
ctxMng.account.privkey = potr.crypt.PK.parsePrivateKey(
unhexlify(priv_key.encode("utf-8"))
)[0]