feat: Track the old Signed Prekey after rotation
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:math';
|
||||
import 'package:cryptography/cryptography.dart';
|
||||
import 'package:omemo_dart/src/keys.dart';
|
||||
|
||||
/// Flattens [inputs] and concatenates the elements.
|
||||
List<int> concat(List<List<int>> inputs) {
|
||||
@@ -39,3 +42,34 @@ List<int> generateRandomBytes(int length) {
|
||||
int generateRandom32BitNumber() {
|
||||
return Random.secure().nextInt(4294967295 /*pow(2, 32) - 1*/);
|
||||
}
|
||||
|
||||
OmemoPublicKey? decodeKeyIfNotNull(Map<String, dynamic> map, String key, KeyPairType type) {
|
||||
if (map[key] == null) return null;
|
||||
|
||||
return OmemoPublicKey.fromBytes(
|
||||
base64.decode(map[key]! as String),
|
||||
type,
|
||||
);
|
||||
}
|
||||
|
||||
List<int>? base64DecodeIfNotNull(Map<String, dynamic> map, String key) {
|
||||
if (map[key] == null) return null;
|
||||
|
||||
return base64.decode(map[key]! as String);
|
||||
}
|
||||
|
||||
String? base64EncodeIfNotNull(List<int>? bytes) {
|
||||
if (bytes == null) return null;
|
||||
|
||||
return base64.encode(bytes);
|
||||
}
|
||||
|
||||
OmemoKeyPair? decodeKeyPairIfNotNull(String? pk, String? sk, KeyPairType type) {
|
||||
if (pk == null || sk == null) return null;
|
||||
|
||||
return OmemoKeyPair.fromBytes(
|
||||
base64.decode(pk),
|
||||
base64.decode(sk),
|
||||
type,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user