Browse Source

e2ee: remove encodedFrameType workaround (#1099)

no longer required as of Chrome 84.0.4108.0 and has been merged into M83 as well.
master
Philipp Hancke 5 years ago
parent
commit
c3fd3431a6
No account linked to committer's email address
1 changed files with 8 additions and 11 deletions
  1. 8
    11
      modules/e2ee/E2EEContext.js

+ 8
- 11
modules/e2ee/E2EEContext.js View File

@@ -304,32 +304,29 @@ export default class E2EEcontext {
304 304
         const keyIndex = data[encodedFrame.data.byteLength - 1];
305 305
 
306 306
         if (this._cryptoKeyRing[keyIndex]) {
307
-            // TODO: use encodedFrame.type again, see https://bugs.chromium.org/p/chromium/issues/detail?id=1068468
308
-            const encodedFrameType = encodedFrame.type
309
-                ? (data[0] & 0x1) === 0 ? 'key' : 'delta' // eslint-disable-line no-bitwise
310
-                : undefined;
311 307
             const iv = new Uint8Array(encodedFrame.data, encodedFrame.data.byteLength - ivLength - 1, ivLength);
312
-            const cipherTextStart = unencryptedBytes[encodedFrameType];
313
-            const cipherTextLength = encodedFrame.data.byteLength - (unencryptedBytes[encodedFrameType] + ivLength + 1);
308
+            const cipherTextStart = unencryptedBytes[encodedFrame.type];
309
+            const cipherTextLength = encodedFrame.data.byteLength - (unencryptedBytes[encodedFrame.type]
310
+                + ivLength + 1);
314 311
 
315 312
             return crypto.subtle.decrypt({
316 313
                 name: 'AES-GCM',
317 314
                 iv,
318
-                additionalData: new Uint8Array(encodedFrame.data, 0, unencryptedBytes[encodedFrameType])
315
+                additionalData: new Uint8Array(encodedFrame.data, 0, unencryptedBytes[encodedFrame.type])
319 316
             }, this._cryptoKeyRing[keyIndex], new Uint8Array(encodedFrame.data, cipherTextStart, cipherTextLength))
320 317
             .then(plainText => {
321
-                const newData = new ArrayBuffer(unencryptedBytes[encodedFrameType] + plainText.byteLength);
318
+                const newData = new ArrayBuffer(unencryptedBytes[encodedFrame.type] + plainText.byteLength);
322 319
                 const newUint8 = new Uint8Array(newData);
323 320
 
324
-                newUint8.set(new Uint8Array(encodedFrame.data, 0, unencryptedBytes[encodedFrameType]));
325
-                newUint8.set(new Uint8Array(plainText), unencryptedBytes[encodedFrameType]);
321
+                newUint8.set(new Uint8Array(encodedFrame.data, 0, unencryptedBytes[encodedFrame.type]));
322
+                newUint8.set(new Uint8Array(plainText), unencryptedBytes[encodedFrame.type]);
326 323
 
327 324
                 encodedFrame.data = newData;
328 325
 
329 326
                 return controller.enqueue(encodedFrame);
330 327
             }, e => {
331 328
                 logger.error(e);
332
-                if (encodedFrameType === undefined) { // audio, replace with silence.
329
+                if (encodedFrame.type === undefined) { // audio, replace with silence.
333 330
                     const newData = new ArrayBuffer(3);
334 331
                     const newUint8 = new Uint8Array(newData);
335 332
 

Loading…
Cancel
Save