Przeglądaj źródła

e2ee: make it easier to change the AES key length

as suggested during the community call recently
dev1
Philipp Hancke 5 lat temu
rodzic
commit
966f75af73
1 zmienionych plików z 9 dodań i 5 usunięć
  1. 9
    5
      modules/e2ee/Worker.js

+ 9
- 5
modules/e2ee/Worker.js Wyświetl plik

11
     // packet. See https://developer.mozilla.org/en-US/docs/Web/API/AesGcmParams
11
     // packet. See https://developer.mozilla.org/en-US/docs/Web/API/AesGcmParams
12
     const ivLength = 12;
12
     const ivLength = 12;
13
 
13
 
14
+    // We use a 128 bit key for AES GCM.
15
+    const keyGenParameters = {
16
+        name: 'AES-GCM',
17
+        length: 128
18
+    };
19
+
14
     // We copy the first bytes of the VP8 payload unencrypted.
20
     // We copy the first bytes of the VP8 payload unencrypted.
15
     // For keyframes this is 10 bytes, for non-keyframes (delta) 3. See
21
     // For keyframes this is 10 bytes, for non-keyframes (delta) 3. See
16
     //   https://tools.ietf.org/html/rfc6386#section-9.1
22
     //   https://tools.ietf.org/html/rfc6386#section-9.1
39
     let keyBytes;
45
     let keyBytes;
40
 
46
 
41
     /**
47
     /**
42
-     * Derives a AES-GCM key with 128 bits from the input using PBKDF2
48
+     * Derives a AES-GCM key from the input using PBKDF2
49
+     * The key length can be configured above and should be either 128 or 256 bits.
43
      * @param {Uint8Array} keyBytes - Value to derive key from
50
      * @param {Uint8Array} keyBytes - Value to derive key from
44
      * @param {Uint8Array} salt - Salt used in key derivation
51
      * @param {Uint8Array} salt - Salt used in key derivation
45
      */
52
      */
54
             salt,
61
             salt,
55
             iterations: 100000,
62
             iterations: 100000,
56
             hash: 'SHA-256'
63
             hash: 'SHA-256'
57
-        }, material, {
58
-            name: 'AES-GCM',
59
-            length: 128
60
-        }, false, [ 'encrypt', 'decrypt' ]);
64
+        }, material, keyGenParameters, false, [ 'encrypt', 'decrypt' ]);
61
     }
65
     }
62
 
66
 
63
 
67
 

Ładowanie…
Anuluj
Zapisz