@@ -8,19 +8,25 @@ import 'crypto.dart' as crypto;
8
8
import 'e2ee.logger.dart' ;
9
9
import 'e2ee.utils.dart' ;
10
10
11
+ const KEYRING_SIZE = 16 ;
12
+
11
13
class KeyOptions {
12
14
KeyOptions ({
13
15
required this .sharedKey,
14
16
required this .ratchetSalt,
15
17
required this .ratchetWindowSize,
16
18
this .uncryptedMagicBytes,
17
19
this .failureTolerance = - 1 ,
20
+ this .keyRingSze = KEYRING_SIZE ,
21
+ this .discardFrameWhenCryptorNotReady = false ,
18
22
});
19
23
bool sharedKey;
20
24
Uint8List ratchetSalt;
21
25
int ratchetWindowSize = 0 ;
22
26
int failureTolerance;
23
27
Uint8List ? uncryptedMagicBytes;
28
+ int keyRingSze;
29
+ bool discardFrameWhenCryptorNotReady;
24
30
25
31
@override
26
32
String toString () {
@@ -77,8 +83,6 @@ class KeyProvider {
77
83
}
78
84
}
79
85
80
- const KEYRING_SIZE = 16 ;
81
-
82
86
class KeySet {
83
87
KeySet (this .material, this .encryptionKey);
84
88
web.CryptoKey material;
@@ -90,10 +94,15 @@ class ParticipantKeyHandler {
90
94
required this .worker,
91
95
required this .keyOptions,
92
96
required this .participantIdentity,
93
- });
97
+ }) {
98
+ if (keyOptions.keyRingSze <= 0 || keyOptions.keyRingSze > 255 ) {
99
+ throw Exception ('Invalid key ring size' );
100
+ }
101
+ cryptoKeyRing = List .filled (keyOptions.keyRingSze, null );
102
+ }
94
103
int currentKeyIndex = 0 ;
95
104
96
- List <KeySet ?> cryptoKeyRing = List . filled ( KEYRING_SIZE , null ) ;
105
+ late List <KeySet ?> cryptoKeyRing;
97
106
98
107
bool _hasValidKey = false ;
99
108
0 commit comments