feat: Allow serialising and deserialising OmemoSessionManager

This commit is contained in:
2022-08-06 12:24:26 +02:00
parent 3b8ccfaccf
commit 859f25d867
4 changed files with 144 additions and 38 deletions

View File

@@ -293,4 +293,23 @@ class OmemoDoubleRatchet {
return decrypt(mk, ciphertext, concat([sessionAd, header.writeToBuffer()]), sessionAd);
}
@visibleForTesting
Future<bool> equals(OmemoDoubleRatchet other) async {
// ignore: invalid_use_of_visible_for_testing_member
final dhrMatch = dhr == null ? other.dhr == null : await dhr!.equals(other.dhr!);
final ckrMatch = ckr == null ? other.ckr == null : listsEqual(ckr!, other.ckr!);
final cksMatch = cks == null ? other.cks == null : listsEqual(cks!, other.cks!);
// ignore: invalid_use_of_visible_for_testing_member
return await dhs.equals(other.dhs) &&
dhrMatch &&
listsEqual(rk, other.rk) &&
cksMatch &&
ckrMatch &&
ns == other.ns &&
nr == other.nr &&
pn == other.pn &&
listsEqual(sessionAd, other.sessionAd);
}
}