|
@@ -5,8 +5,9 @@ import { deriveKeys, importKey, ratchet } from './crypto-utils';
|
5
|
5
|
import { isArrayEqual } from './utils';
|
6
|
6
|
|
7
|
7
|
// We use a ringbuffer of keys so we can change them and still decode packets that were
|
8
|
|
-// encrypted with an old key.
|
9
|
|
-const keyRingSize = 3;
|
|
8
|
+// encrypted with an old key. We use a size of 16 which corresponds to the four bits
|
|
9
|
+// in the frame trailer.
|
|
10
|
+const keyRingSize = 16;
|
10
|
11
|
|
11
|
12
|
// We copy the first bytes of the VP8 payload unencrypted.
|
12
|
13
|
// For keyframes this is 10 bytes, for non-keyframes (delta) 3. See
|
|
@@ -129,7 +130,7 @@ export class Context {
|
129
|
130
|
// but we put it at the end.
|
130
|
131
|
// 0 1 2 3 4 5 6 7
|
131
|
132
|
// ---------+---------------------------------+-+-+-+-+-+-+-+-+
|
132
|
|
- // payload | CTR... (length=LEN) |S|LEN |0| KID |
|
|
133
|
+ // payload | CTR... (length=LEN) |S|LEN |KID |
|
133
|
134
|
// ---------+---------------------------------+-+-+-+-+-+-+-+-+
|
134
|
135
|
const counter = new Uint8Array(16);
|
135
|
136
|
const counterView = new DataView(counter.buffer);
|
|
@@ -210,7 +211,7 @@ export class Context {
|
210
|
211
|
*/
|
211
|
212
|
async decodeFunction(encodedFrame, controller) {
|
212
|
213
|
const data = new Uint8Array(encodedFrame.data);
|
213
|
|
- const keyIndex = data[encodedFrame.data.byteLength - 1] & 0x7;
|
|
214
|
+ const keyIndex = data[encodedFrame.data.byteLength - 1] & 0xf; // lower four bits.
|
214
|
215
|
|
215
|
216
|
if (this._cryptoKeyRing[keyIndex]) {
|
216
|
217
|
const counterLength = 1 + ((data[encodedFrame.data.byteLength - 1] >> 4) & 0x7);
|