fix: Fix ratchets going out of sync

This commit is contained in:
2023-06-15 01:26:49 +02:00
parent c483585d0b
commit 87a985fee0
4 changed files with 154 additions and 22 deletions

View File

@@ -200,6 +200,7 @@ class OmemoDoubleRatchet {
);
rk = List.from(newRk1);
ckr = List.from(newRk1);
dhs = await OmemoKeyPair.generateNewPair(KeyPairType.x25519);
final newRk2 = await kdfRk(
rk,
@@ -226,6 +227,7 @@ class OmemoDoubleRatchet {
final newCkr = await kdfCk(ckr!, kdfCkNextChainKey);
final mk = await kdfCk(ckr!, kdfCkNextMessageKey);
ckr = newCkr;
mkSkipped[SkippedKey(dhr!, nr)] = mk;
nr++;
}
@@ -309,6 +311,7 @@ class OmemoDoubleRatchet {
final ck = await kdfCk(ckr!, kdfCkNextChainKey);
final mk = await kdfCk(ckr!, kdfCkNextMessageKey);
ckr = ck;
nr++;
return _decrypt(message, header.ciphertext, mk);
}