Skip to content

Commit 40722c4

Browse files
committed
Add decryption/encryption dedicated APIs
1 parent 45066af commit 40722c4

File tree

1 file changed

+42
-10
lines changed

1 file changed

+42
-10
lines changed

index.bs

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,17 @@ dictionary SFrameTransformOptions {
237237
typedef [EnforceRange] unsigned long long SmallCryptoKeyID;
238238
typedef (SmallCryptoKeyID or bigint) CryptoKeyID;
239239

240-
interface mixin SFrameKeyManagement {
240+
interface mixin SFrameEncrypterManagement {
241241
Promise<undefined> setEncryptionKey(CryptoKey key, optional CryptoKeyID keyID);
242242
attribute EventHandler onerror;
243243
};
244244

245+
interface mixin SFrameDecrypterManagement {
246+
Promise<undefined> addDecryptionKey(CryptoKey key, CryptoKeyID keyID);
247+
Promise<undefined> removeDecryptionKey(CryptoKeyID keyID);
248+
attribute EventHandler onerror;
249+
};
250+
245251
[Exposed=Window]
246252
interface SFrameTransform : EventTarget {
247253
constructor(optional SFrameTransformOptions options = {});
@@ -253,14 +259,14 @@ interface SFrameEncrypterStream : EventTarget {
253259
constructor(optional SFrameTransformOptions options = {});
254260
};
255261
SFrameEncrypterStream includes GenericTransformStream;
256-
SFrameEncrypterStream includes SFrameKeyManagement;
262+
SFrameEncrypterStream includes SFrameEncrypterManagement;
257263

258264
[Exposed=(Window,DedicatedWorker)]
259265
interface SFrameDecrypterStream : EventTarget {
260266
constructor(optional SFrameTransformOptions options = {});
261267
};
262268
SFrameDecrypterStream includes GenericTransformStream;
263-
SFrameDecrypterStream includes SFrameKeyManagement;
269+
SFrameDecrypterStream includes SFrameDecrypterManagement;
264270

265271
enum SFrameTransformErrorEventType {
266272
"authentication",
@@ -335,14 +341,40 @@ The <dfn>SFrame transform algorithm</dfn>, given |this| and |frame|, runs these
335341
1. [=ReadableStream/Enqueue=] |frame| in |this|.`[[transform]]`.
336342

337343
## Methods ## {#sframe-transform-methods}
338-
The <dfn method for="SFrameTransform">setEncryptionKey(|key|, |keyID|)</dfn> method steps are:
344+
The <dfn method for="SFrameEncrypterKeyManager">setEncryptionKey(|key|, |keyID|)</dfn> method steps are:
345+
1. Let |promise| be [=a new promise=].
346+
1. If |keyId| is <code>undefined</code>, run the following steps:
347+
1. Let |currentKeyId| be |this|.`[[currentKeyId]]` if not undefined or 0 otherwise.
348+
1. If |currentKeyId| is greater or equal to 2<sup>64</sup>-1, [=reject=] |promise| with a {{RangeError}} exception and abort these steps.
349+
1. Set |keyId| to |currentKeyId| incremented by 1.
350+
1. If |keyID| is a {{bigint}} which cannot be represented as a integer between 0 and 2<sup>64</sup>-1 inclusive, [=reject=] |promise| with a {{RangeError}} exception and abort these steps.
351+
1. Set |this|.`[[currentKeyId]]` to |keyId|.
352+
1. [=In parallel=], run the following steps:
353+
1. Set |key| and |keyID| as key material to use for the SFrame transform encryption algorithm, as defined by [[RFC9605]].
354+
1. If setting the key material fails, [=queue a task=] to [=reject=] |promise| with an {{InvalidModificationError}} exception and abort these steps.
355+
1. [=Queue a task=] to [=resolve=] |promise| with undefined.
356+
1. Return |promise|.
357+
358+
The <dfn method for="SFrameDecrypterKeyManager">addEncryptionKey(|key|, |keyID|)</dfn> method steps are:
339359
1. Let |promise| be [=a new promise=].
340-
2. If |keyID| is a {{bigint}} which cannot be represented as a integer between 0 and 2<sup>64</sup>-1 inclusive, [=reject=] |promise| with a {{RangeError}} exception.
341-
3. Otherwise, [=in parallel=], run the following steps:
342-
1. Set |key| with its optional |keyID| as key material to use for the SFrame transform algorithm, as defined by [[RFC9605]].
343-
2. If setting the key material fails, [=reject=] |promise| with an {{InvalidModificationError}} exception and abort these steps.
344-
3. [=Resolve=] |promise| with undefined.
345-
4. Return |promise|.
360+
1. If |keyID| is a {{bigint}} which cannot be represented as a integer between 0 and 2<sup>64</sup>-1 inclusive, [=reject=] |promise| with a {{RangeError}} exception, and abort these steps..
361+
1. [=In parallel=], run the following steps:
362+
1. Let |keyStore| be the key store used for the SFrame transform algorithm, as defined by [[RFC9605]].
363+
1. Set an entry to |keyStore| with |keyId| as key and |keyValue| as value. This overrides any existing entry to |keyId|.
364+
1. If setting the key material fails, [=queue a task=] to [=reject=] |promise| with an {{InvalidModificationError}} exception and abort these steps.
365+
1. [=Resolve=] |promise| with undefined.
366+
1. Return |promise|.
367+
368+
// FIXME: Should SFrameTransform receiver be made aware of the current key in use, so that it would call removeEncryptionKey appropriately.
369+
// Or should we add an option to let the UA remove the key automatically on new KeyID?
370+
The <dfn method for="SFrameDecrypterKeyManager">removeEncryptionKey(|key|, |keyID|)</dfn> method steps are:
371+
1. Let |promise| be [=a new promise=].
372+
1. If |keyID| is a {{bigint}} which cannot be represented as a integer between 0 and 2<sup>64</sup>-1 inclusive, [=reject=] |promise| with a {{RangeError}} exception, and abort these steps.
373+
1. [=In parallel=], run the following steps:
374+
1. Let |keyStore| be the key store used for the SFrame transform algorithm, as defined by [[RFC9605]].
375+
1. Remove the entry of |keyStore| at |keyId| if it exits.
376+
1. [=Resolve=] |promise| with undefined.
377+
1. Return |promise|.
346378

347379

348380
# RTCRtpScriptTransform # {#scriptTransform}

0 commit comments

Comments
 (0)