feat: Add a basic OMEMO session manager

This commit is contained in:
2022-08-04 12:50:19 +02:00
parent 713ea8e1b1
commit 27b1931629
5 changed files with 154 additions and 0 deletions

View File

@@ -1,3 +1,5 @@
import 'dart:math';
/// Flattens [inputs] and concatenates the elements.
List<int> concat(List<List<int>> inputs) {
final tmp = List<int>.empty(growable: true);
@@ -20,3 +22,15 @@ bool listsEqual(List<int> a, List<int> b) {
return true;
}
/// Use Dart's cryptographically secure random number generator at Random.secure()
/// to generate [length] random numbers between 0 and 256 exclusive.
List<int> generateRandomBytes(int length) {
final bytes = List<int>.empty(growable: true);
final r = Random.secure();
for (var i = 0; i < length; i++) {
bytes.add(r.nextInt(256));
}
return bytes;
}