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
File diff suppressed because one or more lines are too long
+35 -28
View File
@@ -1,31 +1,31 @@
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.0/lib/collection.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.0/lib/src/algorithms.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.0/lib/src/boollist.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.0/lib/src/canonicalized_map.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.0/lib/src/combined_wrappers/combined_iterable.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.0/lib/src/combined_wrappers/combined_iterator.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.0/lib/src/combined_wrappers/combined_list.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.0/lib/src/combined_wrappers/combined_map.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.0/lib/src/comparators.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.0/lib/src/empty_unmodifiable_set.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.0/lib/src/equality.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.0/lib/src/equality_map.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.0/lib/src/equality_set.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.0/lib/src/functions.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.0/lib/src/iterable_extensions.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.0/lib/src/iterable_zip.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.0/lib/src/list_extensions.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.0/lib/src/priority_queue.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.0/lib/src/queue_list.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.0/lib/src/union_set.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.0/lib/src/union_set_controller.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.0/lib/src/unmodifiable_wrappers.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.0/lib/src/utils.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.0/lib/src/wrappers.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/flutter_webrtc-0.9.27/lib/src/web/rtc_transform_stream.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/js-0.6.5/lib/js.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/meta-1.8.0/lib/meta.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/meta-1.8.0/lib/meta_meta.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.1/lib/collection.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.1/lib/src/algorithms.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.1/lib/src/boollist.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.1/lib/src/canonicalized_map.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.1/lib/src/combined_wrappers/combined_iterable.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.1/lib/src/combined_wrappers/combined_iterator.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.1/lib/src/combined_wrappers/combined_list.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.1/lib/src/combined_wrappers/combined_map.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.1/lib/src/comparators.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.1/lib/src/empty_unmodifiable_set.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.1/lib/src/equality.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.1/lib/src/equality_map.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.1/lib/src/equality_set.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.1/lib/src/functions.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.1/lib/src/iterable_extensions.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.1/lib/src/iterable_zip.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.1/lib/src/list_extensions.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.1/lib/src/priority_queue.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.1/lib/src/queue_list.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.1/lib/src/union_set.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.1/lib/src/union_set_controller.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.1/lib/src/unmodifiable_wrappers.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.1/lib/src/utils.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/collection-1.17.1/lib/src/wrappers.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/flutter_webrtc-0.9.34/lib/src/web/rtc_transform_stream.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/js-0.6.7/lib/js.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/meta-1.9.1/lib/meta.dart
file:///Users/weiweiduan/.pub-cache/hosted/pub.dev/meta-1.9.1/lib/meta_meta.dart
file:///Users/weiweiduan/Desktop/projects/livekit/client-sdk-flutter/.dart_tool/package_config.json
file:///Users/weiweiduan/Desktop/projects/livekit/client-sdk-flutter/web/crypto.dart
file:///Users/weiweiduan/Desktop/projects/livekit/client-sdk-flutter/web/e2ee.cryptor.dart
@@ -47,6 +47,7 @@ org-dartlang-sdk:///lib/_http/websocket.dart
org-dartlang-sdk:///lib/_http/websocket_impl.dart
org-dartlang-sdk:///lib/_internal/js_runtime/lib/annotations.dart
org-dartlang-sdk:///lib/_internal/js_runtime/lib/async_patch.dart
org-dartlang-sdk:///lib/_internal/js_runtime/lib/bigint_patch.dart
org-dartlang-sdk:///lib/_internal/js_runtime/lib/collection_patch.dart
org-dartlang-sdk:///lib/_internal/js_runtime/lib/constant_map.dart
org-dartlang-sdk:///lib/_internal/js_runtime/lib/convert_patch.dart
@@ -59,6 +60,7 @@ org-dartlang-sdk:///lib/_internal/js_runtime/lib/interceptors.dart
org-dartlang-sdk:///lib/_internal/js_runtime/lib/internal_patch.dart
org-dartlang-sdk:///lib/_internal/js_runtime/lib/io_patch.dart
org-dartlang-sdk:///lib/_internal/js_runtime/lib/isolate_patch.dart
org-dartlang-sdk:///lib/_internal/js_runtime/lib/js_allow_interop_patch.dart
org-dartlang-sdk:///lib/_internal/js_runtime/lib/js_array.dart
org-dartlang-sdk:///lib/_internal/js_runtime/lib/js_helper.dart
org-dartlang-sdk:///lib/_internal/js_runtime/lib/js_names.dart
@@ -71,12 +73,15 @@ org-dartlang-sdk:///lib/_internal/js_runtime/lib/linked_hash_map.dart
org-dartlang-sdk:///lib/_internal/js_runtime/lib/math_patch.dart
org-dartlang-sdk:///lib/_internal/js_runtime/lib/native_helper.dart
org-dartlang-sdk:///lib/_internal/js_runtime/lib/native_typed_data.dart
org-dartlang-sdk:///lib/_internal/js_runtime/lib/records.dart
org-dartlang-sdk:///lib/_internal/js_runtime/lib/regexp_helper.dart
org-dartlang-sdk:///lib/_internal/js_runtime/lib/string_helper.dart
org-dartlang-sdk:///lib/_internal/js_runtime/lib/synced/async_await_error_codes.dart
org-dartlang-sdk:///lib/_internal/js_runtime/lib/synced/embedded_names.dart
org-dartlang-sdk:///lib/_internal/js_runtime/lib/synced/load_library_priority.dart
org-dartlang-sdk:///lib/_internal/js_runtime/lib/typed_data_patch.dart
org-dartlang-sdk:///lib/_internal/js_shared/lib/js_interop_patch.dart
org-dartlang-sdk:///lib/_internal/js_shared/lib/js_types.dart
org-dartlang-sdk:///lib/_internal/js_shared/lib/js_util_patch.dart
org-dartlang-sdk:///lib/_internal/js_shared/lib/rti.dart
org-dartlang-sdk:///lib/_internal/js_shared/lib/synced/embedded_names.dart
@@ -86,6 +91,7 @@ org-dartlang-sdk:///lib/async/async_error.dart
org-dartlang-sdk:///lib/async/broadcast_stream_controller.dart
org-dartlang-sdk:///lib/async/deferred_load.dart
org-dartlang-sdk:///lib/async/future.dart
org-dartlang-sdk:///lib/async/future_extensions.dart
org-dartlang-sdk:///lib/async/future_impl.dart
org-dartlang-sdk:///lib/async/schedule_microtask.dart
org-dartlang-sdk:///lib/async/stream.dart
@@ -220,6 +226,7 @@ org-dartlang-sdk:///lib/js/_js.dart
org-dartlang-sdk:///lib/js/_js_annotations.dart
org-dartlang-sdk:///lib/js/_js_client.dart
org-dartlang-sdk:///lib/js/js.dart
org-dartlang-sdk:///lib/js_interop/js_interop.dart
org-dartlang-sdk:///lib/js_util/js_util.dart
org-dartlang-sdk:///lib/math/math.dart
org-dartlang-sdk:///lib/math/point.dart
File diff suppressed because one or more lines are too long
+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;
}
}
}