@@ -8,19 +8,25 @@ import 'crypto.dart' as crypto;
88import 'e2ee.logger.dart' ;
99import 'e2ee.utils.dart' ;
1010
11+ const KEYRING_SIZE = 16 ;
12+
1113class KeyOptions {
1214 KeyOptions ({
1315 required this .sharedKey,
1416 required this .ratchetSalt,
1517 required this .ratchetWindowSize,
1618 this .uncryptedMagicBytes,
1719 this .failureTolerance = - 1 ,
20+ this .keyRingSze = KEYRING_SIZE ,
21+ this .discardFrameWhenCryptorNotReady = false ,
1822 });
1923 bool sharedKey;
2024 Uint8List ratchetSalt;
2125 int ratchetWindowSize = 0 ;
2226 int failureTolerance;
2327 Uint8List ? uncryptedMagicBytes;
28+ int keyRingSze;
29+ bool discardFrameWhenCryptorNotReady;
2430
2531 @override
2632 String toString () {
@@ -77,8 +83,6 @@ class KeyProvider {
7783 }
7884}
7985
80- const KEYRING_SIZE = 16 ;
81-
8286class KeySet {
8387 KeySet (this .material, this .encryptionKey);
8488 web.CryptoKey material;
@@ -90,10 +94,15 @@ class ParticipantKeyHandler {
9094 required this .worker,
9195 required this .keyOptions,
9296 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+ }
94103 int currentKeyIndex = 0 ;
95104
96- List <KeySet ?> cryptoKeyRing = List . filled ( KEYRING_SIZE , null ) ;
105+ late List <KeySet ?> cryptoKeyRing;
97106
98107 bool _hasValidKey = false ;
99108
0 commit comments