Przeglądaj źródła

fix(e2ee) fix key index after ratchetting

- After ratchet do not set it as new key for current index. Set it to correct position in crypto ring.
dev1
Ahmet Sarı 4 lat temu
rodzic
commit
16aaa125dd
No account linked to committer's email address
1 zmienionych plików z 8 dodań i 3 usunięć
  1. 8
    3
      modules/e2ee/Context.js

+ 8
- 3
modules/e2ee/Context.js Wyświetl plik

96
      * Sets a set of keys and resets the sendCount.
96
      * Sets a set of keys and resets the sendCount.
97
      * decryption.
97
      * decryption.
98
      * @param {Object} keys set of keys.
98
      * @param {Object} keys set of keys.
99
+     * @param {Number} keyIndex optional
99
      * @private
100
      * @private
100
      */
101
      */
101
-    _setKeys(keys) {
102
-        this._cryptoKeyRing[this._currentKeyIndex] = keys;
102
+    _setKeys(keys, keyIndex = -1) {
103
+        if (keyIndex >= 0) {
104
+            this._cryptoKeyRing[keyIndex] = keys;
105
+        } else {
106
+            this._cryptoKeyRing[this._currentKeyIndex] = keys;
107
+        }
103
         this._sendCount = BigInt(0); // eslint-disable-line new-cap
108
         this._sendCount = BigInt(0); // eslint-disable-line new-cap
104
     }
109
     }
105
 
110
 
322
                         new Uint8Array(calculatedTag.slice(0, DIGEST_LENGTH[encodedFrame.type])))) {
327
                         new Uint8Array(calculatedTag.slice(0, DIGEST_LENGTH[encodedFrame.type])))) {
323
                     validAuthTag = true;
328
                     validAuthTag = true;
324
                     if (distance > 0) {
329
                     if (distance > 0) {
325
-                        this._setKeys(newKeys);
330
+                        this._setKeys(newKeys, keyIndex);
326
                     }
331
                     }
327
                     break;
332
                     break;
328
                 }
333
                 }

Ładowanie…
Anuluj
Zapisz