fix: Skip decryption when ratchet exceeded. (#318)

This commit is contained in:
CloudWebRTC
2023-07-13 22:02:06 +08:00
committed by GitHub
parent 4a39b03327
commit 49f22057f4
4 changed files with 936 additions and 580 deletions
+4 -2
View File
@@ -161,7 +161,7 @@ class FrameCryptor {
CryptorError lastError = CryptorError.kNew;
final DedicatedWorkerGlobalScope worker;
int currentKeyIndex = 0;
bool hasValidKey = false;
Completer? _ratchetCompleter;
List<KeySet?> cryptoKeyRing = List.filled(KEYRING_SIZE, null);
@@ -243,6 +243,7 @@ class FrameCryptor {
keyOptions.ratchetSalt,
);
await setKeySetFromMaterial(keySet, keyIndex);
hasValidKey = true;
}
Future<void> setKeySetFromMaterial(KeySet keySet, int keyIndex) async {
@@ -530,7 +531,7 @@ class FrameCryptor {
var initialKeySet = getKeySet(keyIndex);
initialKeyIndex = keyIndex;
if (initialKeySet == null) {
if (initialKeySet == null || !hasValidKey) {
if (lastError != CryptorError.kMissingKey) {
lastError = CryptorError.kMissingKey;
postMessage({
@@ -641,6 +642,7 @@ class FrameCryptor {
if (initialKeySet != null) {
await setKeySetFromMaterial(initialKeySet, initialKeyIndex);
}
hasValidKey = false;
}
}
}