|
|
@@ -207,6 +207,7 @@ export class Context {
|
|
207
|
207
|
async _decryptFrame(
|
|
208
|
208
|
encodedFrame,
|
|
209
|
209
|
keyIndex,
|
|
|
210
|
+ initialKey = undefined,
|
|
210
|
211
|
ratchetCount = 0) {
|
|
211
|
212
|
|
|
212
|
213
|
const { encryptionKey } = this._cryptoKeyRing[keyIndex];
|
|
|
@@ -260,9 +261,18 @@ export class Context {
|
|
260
|
261
|
return await this._decryptFrame(
|
|
261
|
262
|
encodedFrame,
|
|
262
|
263
|
keyIndex,
|
|
|
264
|
+ initialKey ?? this._cryptoKeyRing[this._currentKeyIndex],
|
|
263
|
265
|
ratchetCount + 1);
|
|
264
|
266
|
}
|
|
265
|
267
|
|
|
|
268
|
+ /*
|
|
|
269
|
+ Since the key it is first send and only afterwards actually used for encrypting, there were
|
|
|
270
|
+ situations when the decrypting failed due to the fact that the received frame was not encrypted
|
|
|
271
|
+ yet and ratcheting, of course, did not solve the problem. So if we fail RATCHET_WINDOW_SIZE times,
|
|
|
272
|
+ we come back to the initial key.
|
|
|
273
|
+ */
|
|
|
274
|
+ this._setKeys(initialKey);
|
|
|
275
|
+
|
|
266
|
276
|
// TODO: notify the application about error status.
|
|
267
|
277
|
}
|
|
268
|
278
|
|