Skip to content

Commit 7cde254

Browse files
committed
Add SFrameEncrypterStream, SFrameDecrypterStream & drop role
1 parent e879889 commit 7cde254

File tree

1 file changed

+48
-25
lines changed

1 file changed

+48
-25
lines changed

index.bs

Lines changed: 48 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -216,15 +216,10 @@ Similarly, if a web application sets the transform synchronously at creation of
216216
# SFrameTransform # {#sframe}
217217

218218
<p>
219-
The API presented in this section allows applications to process SFrame data using specific cipher suites defined in [[RFC9605]].
219+
The APIs presented in this section allow applications to process SFrame data using specific cipher suites defined in [[RFC9605]].
220220
</p>
221221

222222
<xmp class="idl">
223-
enum SFrameTransformRole {
224-
"encrypt",
225-
"decrypt"
226-
};
227-
228223
// List of supported cipher suites, as defined in [[RFC9605]] section 4.5.
229224
enum SFrameCipherSuite {
230225
"AES_128_CTR_HMAC_SHA256_80",
@@ -235,20 +230,36 @@ enum SFrameCipherSuite {
235230
};
236231

237232
dictionary SFrameTransformOptions {
238-
SFrameTransformRole role = "encrypt";
239233
required SFrameCipherSuite cipherSuite;
240234
};
241235

242236
typedef [EnforceRange] unsigned long long SmallCryptoKeyID;
243237
typedef (SmallCryptoKeyID or bigint) CryptoKeyID;
244238

245-
[Exposed=(Window,DedicatedWorker)]
246-
interface SFrameTransform : EventTarget {
247-
constructor(optional SFrameTransformOptions options = {});
239+
interface mixin SFrameKeyManagement {
248240
Promise<undefined> setEncryptionKey(CryptoKey key, optional CryptoKeyID keyID);
249241
attribute EventHandler onerror;
250242
};
251-
SFrameTransform includes GenericTransformStream;
243+
244+
[Exposed=Window]
245+
interface SFrameTransform : EventTarget {
246+
constructor(optional SFrameTransformOptions options = {});
247+
};
248+
SFrameTransform includes SFrameKeyManagement;
249+
250+
[Exposed=(Window,DedicatedWorker)]
251+
interface SFrameEncrypterStream : EventTarget {
252+
constructor(optional SFrameTransformOptions options = {});
253+
};
254+
SFrameEncrypterStream includes GenericTransformStream;
255+
SFrameEncrypterStream includes SFrameKeyManagement;
256+
257+
[Exposed=(Window,DedicatedWorker)]
258+
interface SFrameDecrypterStream : EventTarget {
259+
constructor(optional SFrameTransformOptions options = {});
260+
};
261+
SFrameDecrypterStream includes GenericTransformStream;
262+
SFrameDecrypterStream includes SFrameKeyManagement;
252263

253264
enum SFrameTransformErrorEventType {
254265
"authentication",
@@ -273,42 +284,54 @@ dictionary SFrameTransformErrorEventInit : EventInit {
273284
</xmp>
274285

275286
The <dfn constructor for="SFrameTransform" lt="SFrameTransform(options)"><code>new SFrameTransform(<var>options</var>)</code></dfn> constructor steps are:
276-
1. Let |transformAlgorithm| be an algorithm which takes a |frame| as input and runs the <a href="#sframe-transform-algorithm">SFrame transform algorithm</a> with |this| and |frame|.
287+
1. Let |options| be the method's first argument.
288+
1. Run the [=SFrame initialization algorithm=] with |this| and |options|.
289+
290+
The <dfn constructor for="SFrameEncrypterStream" lt="SFrameEncrypterStream(options)"><code>new SFrameEncrypterStream(<var>options</var>)</code></dfn> constructor steps are:
291+
1. Let |options| be the method's first argument.
292+
1. Run the [=SFrame initialization algorithm=] with |this| and |options|.
293+
1. Set |this|.`[[role]]` to 'encrypt'.
294+
295+
The <dfn constructor for="SFrameDecrypterStream" lt="SFrameDecrypterStream(options)"><code>new SFrameDecrypterStream(<var>options</var>)</code></dfn> constructor steps are:
296+
1. Let |options| be the method's first argument.
297+
1. Run the [=SFrame initialization algorithm=] with |this| and |options|.
298+
1. Set |this|.`[[role]]` to 'decrypt'.
299+
300+
## Algorithms ## {#sframe-algorithms}
301+
302+
The <dfn>SFrame initialization algorithm</dfn>, given |this| and |options|, runs these steps:
303+
1. Let |transformAlgorithm| be an algorithm which takes a |frame| as input and runs the [=SFrame transform algorithm=] with |this| and |frame|.
277304
1. Set |this|.`[[transform]]` to a new {{TransformStream}}.
278305
1. <a dfn for="ReadableStream">Set up</a> [=this=].`[[transform]]` with [=TransformStream/set up/transformAlgorithm=] set to |transformAlgorithm|.
279-
1. Let |options| be the method's first argument.
280-
1. Set |this|.`[[role]]` to |options|["{{SFrameTransformOptions/role}}"].
281306
1. Set |this|.`[[cipherSuite]]` to |options|["{{SFrameTransformOptions/cipherSuite}}"].
282307
1. Set |this|.`[[readable]]` to |this|.`[[transform]]`.`[[readable]]`.
283308
1. Set |this|.`[[writable]]` to |this|.`[[transform]]`.`[[writable]]`.
284309

285-
## Algorithm ## {#sframe-transform-algorithm}
286-
287-
The SFrame transform algorithm, given |sframe| as a SFrameTransform object and |frame|, runs these steps:
288-
1. Let |role| be |sframe|.`[[role]]`.
289-
1. If |frame|.`[[owner]]` is a {{RTCRtpSender}}, set |role| to 'encrypt'.
290-
1. If |frame|.`[[owner]]` is a {{RTCRtpReceiver}}, set |role| to 'decrypt'.
310+
The <dfn>SFrame transform algorithm</dfn>, given |this| and |frame|, runs these steps:
311+
1. Let |role| be |this|.`[[role]]`.
312+
1. If |this|.`[[owner]]` is an {{RTCRtpSender}}, set |role| to 'encrypt'.
313+
1. If |this|.`[[owner]]` is an {{RTCRtpReceiver}}, set |role| to 'decrypt'.
291314
1. Let |data| be undefined.
292315
1. If |frame| is a {{BufferSource}}, set |data| to |frame|.
293316
1. If |frame| is a {{RTCEncodedAudioFrame}}, set |data| to |frame|.{{RTCEncodedAudioFrame/data}}
294317
1. If |frame| is a {{RTCEncodedVideoFrame}}, set |data| to |frame|.{{RTCEncodedVideoFrame/data}}
295318
1. If |data| is undefined, abort these steps.
296-
1. Let |buffer| be the result of running the SFrame algorithm with |data|, |sframe|.`[[cipherSuite]]`, and |role| as parameters. This algorithm is defined by [[RFC9605]] and returns an {{ArrayBuffer}}.
319+
1. Let |buffer| be the result of running the SFrame algorithm with |data|, |this|.`[[cipherSuite]]`, and |role| as parameters. This algorithm is defined by [[RFC9605]] and returns an {{ArrayBuffer}}.
297320
1. If the SFrame algorithm exits abruptly with an error, [=queue a task=] to run the following sub steps:
298-
1. If the processing fails on decryption side due to |data| not following the SFrame format, [=fire an event=] named {{SFrameTransform/onerror|error}} at |sframe|,
321+
1. If the processing fails on decryption side due to |data| not following the SFrame format, [=fire an event=] named {{SFrameTransform/onerror|error}} at |this|,
299322
using the {{SFrameTransformErrorEvent}} interface with its {{SFrameTransformErrorEvent/errorType}} attribute set to {{SFrameTransformErrorEventType/syntax}}
300323
and its {{SFrameTransformErrorEvent/frame}} attribute set to |frame|.
301-
1. If the processing fails on decryption side due to the key identifier parsed in |data| being unknown, [=fire an event=] named {{SFrameTransform/onerror|error}} at |sframe|,
324+
1. If the processing fails on decryption side due to the key identifier parsed in |data| being unknown, [=fire an event=] named {{SFrameTransform/onerror|error}} at |this|,
302325
using the {{SFrameTransformErrorEvent}} interface with its {{SFrameTransformErrorEvent/errorType}} attribute set to {{SFrameTransformErrorEventType/keyID}},
303326
its {{SFrameTransformErrorEvent/frame}} attribute set to |frame| and its {{SFrameTransformErrorEvent/keyID}} attribute set to the keyID value parsed in the SFrame header.
304-
1. If the processing fails on decryption side due to validation of the authentication tag, [=fire an event=] named {{SFrameTransform/onerror|error}} at |sframe|,
327+
1. If the processing fails on decryption side due to validation of the authentication tag, [=fire an event=] named {{SFrameTransform/onerror|error}} at |this|,
305328
using the {{SFrameTransformErrorEvent}} interface with its {{SFrameTransformErrorEvent/errorType}} attribute set to {{SFrameTransformErrorEventType/authentication}}
306329
and its {{SFrameTransformErrorEvent/frame}} attribute set to |frame|.
307330
1. Abort these steps.
308331
1. If |frame| is a {{BufferSource}}, set |frame| to |buffer|.
309332
1. If |frame| is a {{RTCEncodedAudioFrame}}, set |frame|.{{RTCEncodedAudioFrame/data}} to |buffer|.
310333
1. If |frame| is a {{RTCEncodedVideoFrame}}, set |frame|.{{RTCEncodedVideoFrame/data}} to |buffer|.
311-
1. [=ReadableStream/Enqueue=] |frame| in |sframe|.`[[transform]]`.
334+
1. [=ReadableStream/Enqueue=] |frame| in |this|.`[[transform]]`.
312335

313336
## Methods ## {#sframe-transform-methods}
314337
The <dfn method for="SFrameTransform">setEncryptionKey(|key|, |keyID|)</dfn> method steps are:

0 commit comments

Comments
 (0)