Title: [273393] branches/safari-611-branch
Revision
273393
Author
repst...@apple.com
Date
2021-02-24 09:10:20 -0800 (Wed, 24 Feb 2021)

Log Message

Cherry-pick r273158. rdar://problem/74623451

    Allow to use BigInt as key identifier
    https://bugs.webkit.org/show_bug.cgi?id=222165

    Reviewed by Darin Adler.

    Source/WebCore:

    Allow to pass a BigInt as key id so as to use all of SFrame key ID 8 bytes.
    A RangeError is thrown if BigInt is more than 64 bits.

    Update the implementation to use a Vector instead of a map to keep the keys.
    This allows to also use 0 and 2^64-1 values that HashMap reserves for its personal use.

    Covered by updated test.

    * Modules/mediastream/RTCRtpSFrameTransform.idl:
    * Modules/mediastream/RTCRtpSFrameTransformer.cpp:
    (WebCore::RTCRtpSFrameTransformer::setEncryptionKey):
    (WebCore::RTCRtpSFrameTransformer::updateEncryptionKey):
    (WebCore::RTCRtpSFrameTransformer::decryptFrame):
    * Modules/mediastream/RTCRtpSFrameTransformer.h:
    * Sources.txt:
    * WebCore.xcodeproj/project.pbxproj:
    * bindings/js/JSRTCRtpSFrameTransformCustom.cpp: Added.
    (WebCore::JSRTCRtpSFrameTransform::setEncryptionKey):

    LayoutTests:

    * webrtc/sframe-keys-expected.txt:
    * webrtc/sframe-keys.html:

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@273158 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Added Paths

Diff

Modified: branches/safari-611-branch/LayoutTests/ChangeLog (273392 => 273393)


--- branches/safari-611-branch/LayoutTests/ChangeLog	2021-02-24 17:10:16 UTC (rev 273392)
+++ branches/safari-611-branch/LayoutTests/ChangeLog	2021-02-24 17:10:20 UTC (rev 273393)
@@ -1,5 +1,53 @@
 2021-02-23  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r273158. rdar://problem/74623451
+
+    Allow to use BigInt as key identifier
+    https://bugs.webkit.org/show_bug.cgi?id=222165
+    
+    Reviewed by Darin Adler.
+    
+    Source/WebCore:
+    
+    Allow to pass a BigInt as key id so as to use all of SFrame key ID 8 bytes.
+    A RangeError is thrown if BigInt is more than 64 bits.
+    
+    Update the implementation to use a Vector instead of a map to keep the keys.
+    This allows to also use 0 and 2^64-1 values that HashMap reserves for its personal use.
+    
+    Covered by updated test.
+    
+    * Modules/mediastream/RTCRtpSFrameTransform.idl:
+    * Modules/mediastream/RTCRtpSFrameTransformer.cpp:
+    (WebCore::RTCRtpSFrameTransformer::setEncryptionKey):
+    (WebCore::RTCRtpSFrameTransformer::updateEncryptionKey):
+    (WebCore::RTCRtpSFrameTransformer::decryptFrame):
+    * Modules/mediastream/RTCRtpSFrameTransformer.h:
+    * Sources.txt:
+    * WebCore.xcodeproj/project.pbxproj:
+    * bindings/js/JSRTCRtpSFrameTransformCustom.cpp: Added.
+    (WebCore::JSRTCRtpSFrameTransform::setEncryptionKey):
+    
+    LayoutTests:
+    
+    * webrtc/sframe-keys-expected.txt:
+    * webrtc/sframe-keys.html:
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@273158 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-02-19  Youenn Fablet  <you...@apple.com>
+
+            Allow to use BigInt as key identifier
+            https://bugs.webkit.org/show_bug.cgi?id=222165
+
+            Reviewed by Darin Adler.
+
+            * webrtc/sframe-keys-expected.txt:
+            * webrtc/sframe-keys.html:
+
+2021-02-23  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r273129. rdar://problem/74623422
 
     Scrolling on https://www.apple.com/ipad-air/ can jitter on certain sections

Modified: branches/safari-611-branch/LayoutTests/webrtc/sframe-keys-expected.txt (273392 => 273393)


--- branches/safari-611-branch/LayoutTests/webrtc/sframe-keys-expected.txt	2021-02-24 17:10:16 UTC (rev 273392)
+++ branches/safari-611-branch/LayoutTests/webrtc/sframe-keys-expected.txt	2021-02-24 17:10:20 UTC (rev 273393)
@@ -1,6 +1,8 @@
 
 
+PASS Passing various key IDs
 PASS Audio exchange with SFrame setup
 PASS Add a new encryption key
 PASS Add a new encryption key with key id
+PASS Add a new encryption key with BigInt key id
 

Modified: branches/safari-611-branch/LayoutTests/webrtc/sframe-keys.html (273392 => 273393)


--- branches/safari-611-branch/LayoutTests/webrtc/sframe-keys.html	2021-02-24 17:10:16 UTC (rev 273392)
+++ branches/safari-611-branch/LayoutTests/webrtc/sframe-keys.html	2021-02-24 17:10:20 UTC (rev 273393)
@@ -10,12 +10,29 @@
         <script src =""
         <script>
 let sender, receiver;
-let key1, key2, key3;
+let key1, key2, key3, key4;
 
 promise_test(async (test) => {
+    const key = await crypto.subtle.importKey("raw", new Uint8Array([143, 77, 43, 10, 72, 19, 37, 67, 236, 219, 24, 93, 26, 165, 91, 178]), "HKDF", false, ["deriveBits", "deriveKey"]);
+    const transform = new SFrameTransform;
+
+    await transform.setEncryptionKey(key);
+    await transform.setEncryptionKey(key, 1);
+
+    await transform.setEncryptionKey(key, BigInt('18446744073709551613'));
+    await transform.setEncryptionKey(key, BigInt('18446744073709551614'));
+    await transform.setEncryptionKey(key, BigInt('18446744073709551615'));
+    await transform.setEncryptionKey(key, BigInt('18446744073709551616')).then(assert_unreached, (e) => {
+        assert_true(e instanceof RangeError);
+        assert_equals(e.message, "Not a 64 bits integer");
+    });
+}, "Passing various key IDs");
+
+promise_test(async (test) => {
     key1 = await crypto.subtle.importKey("raw", new Uint8Array([143, 77, 43, 10, 72, 19, 37, 67, 236, 219, 24, 93, 26, 165, 91, 178]), "HKDF", false, ["deriveBits", "deriveKey"]);
     key2 = await crypto.subtle.importKey("raw", new Uint8Array([144, 77, 43, 10, 72, 19, 37, 67, 236, 219, 24, 93, 26, 165, 91, 178]), "HKDF", false, ["deriveBits", "deriveKey"]);
     key3 = await crypto.subtle.importKey("raw", new Uint8Array([145, 77, 43, 10, 72, 19, 37, 67, 236, 219, 24, 93, 26, 165, 91, 178]), "HKDF", false, ["deriveBits", "deriveKey"]);
+    key4 = await crypto.subtle.importKey("raw", new Uint8Array([146, 77, 43, 10, 72, 19, 37, 67, 236, 219, 24, 93, 26, 165, 91, 178]), "HKDF", false, ["deriveBits", "deriveKey"]);
 
     const localStream = await navigator.mediaDevices.getUserMedia({audio: true});
     const stream = await new Promise((resolve, reject) => {
@@ -30,6 +47,7 @@
                 transform.setEncryptionKey(key1);
                 transform.setEncryptionKey(key2);
                 transform.setEncryptionKey(key3, 1000);
+                transform.setEncryptionKey(key4, BigInt('18446744073709551615'));
                 receiver = trackEvent.receiver;
                 receiver.transform = transform;
                 resolve(trackEvent.streams[0]);
@@ -78,6 +96,16 @@
    assert_true(await waitForReceiverKeyId(receiver, 1000), "key id 2");
    assert_true(await waitForCounterIncrease(receiver), "counter increase 2");
 }, "Add a new encryption key with key id");
+
+promise_test(async (test) => {
+   sender.transform.setEncryptionKey(key4, BigInt('18446744073709551613'));
+
+   if (!window.internals)
+       return;
+
+   assert_true(await waitForReceiverKeyId(receiver, 1000), "key id 3");
+   assert_true(await waitForCounterIncrease(receiver), "counter increase 3");
+}, "Add a new encryption key with BigInt key id");
         </script>
     </body>
 </html>

Modified: branches/safari-611-branch/Source/WebCore/ChangeLog (273392 => 273393)


--- branches/safari-611-branch/Source/WebCore/ChangeLog	2021-02-24 17:10:16 UTC (rev 273392)
+++ branches/safari-611-branch/Source/WebCore/ChangeLog	2021-02-24 17:10:20 UTC (rev 273393)
@@ -1,5 +1,69 @@
 2021-02-23  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r273158. rdar://problem/74623451
+
+    Allow to use BigInt as key identifier
+    https://bugs.webkit.org/show_bug.cgi?id=222165
+    
+    Reviewed by Darin Adler.
+    
+    Source/WebCore:
+    
+    Allow to pass a BigInt as key id so as to use all of SFrame key ID 8 bytes.
+    A RangeError is thrown if BigInt is more than 64 bits.
+    
+    Update the implementation to use a Vector instead of a map to keep the keys.
+    This allows to also use 0 and 2^64-1 values that HashMap reserves for its personal use.
+    
+    Covered by updated test.
+    
+    * Modules/mediastream/RTCRtpSFrameTransform.idl:
+    * Modules/mediastream/RTCRtpSFrameTransformer.cpp:
+    (WebCore::RTCRtpSFrameTransformer::setEncryptionKey):
+    (WebCore::RTCRtpSFrameTransformer::updateEncryptionKey):
+    (WebCore::RTCRtpSFrameTransformer::decryptFrame):
+    * Modules/mediastream/RTCRtpSFrameTransformer.h:
+    * Sources.txt:
+    * WebCore.xcodeproj/project.pbxproj:
+    * bindings/js/JSRTCRtpSFrameTransformCustom.cpp: Added.
+    (WebCore::JSRTCRtpSFrameTransform::setEncryptionKey):
+    
+    LayoutTests:
+    
+    * webrtc/sframe-keys-expected.txt:
+    * webrtc/sframe-keys.html:
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@273158 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-02-19  Youenn Fablet  <you...@apple.com>
+
+            Allow to use BigInt as key identifier
+            https://bugs.webkit.org/show_bug.cgi?id=222165
+
+            Reviewed by Darin Adler.
+
+            Allow to pass a BigInt as key id so as to use all of SFrame key ID 8 bytes.
+            A RangeError is thrown if BigInt is more than 64 bits.
+
+            Update the implementation to use a Vector instead of a map to keep the keys.
+            This allows to also use 0 and 2^64-1 values that HashMap reserves for its personal use.
+
+            Covered by updated test.
+
+            * Modules/mediastream/RTCRtpSFrameTransform.idl:
+            * Modules/mediastream/RTCRtpSFrameTransformer.cpp:
+            (WebCore::RTCRtpSFrameTransformer::setEncryptionKey):
+            (WebCore::RTCRtpSFrameTransformer::updateEncryptionKey):
+            (WebCore::RTCRtpSFrameTransformer::decryptFrame):
+            * Modules/mediastream/RTCRtpSFrameTransformer.h:
+            * Sources.txt:
+            * WebCore.xcodeproj/project.pbxproj:
+            * bindings/js/JSRTCRtpSFrameTransformCustom.cpp: Added.
+            (WebCore::JSRTCRtpSFrameTransform::setEncryptionKey):
+
+2021-02-23  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r273129. rdar://problem/74623422
 
     Scrolling on https://www.apple.com/ipad-air/ can jitter on certain sections

Modified: branches/safari-611-branch/Source/WebCore/Modules/mediastream/RTCRtpSFrameTransform.idl (273392 => 273393)


--- branches/safari-611-branch/Source/WebCore/Modules/mediastream/RTCRtpSFrameTransform.idl	2021-02-24 17:10:16 UTC (rev 273392)
+++ branches/safari-611-branch/Source/WebCore/Modules/mediastream/RTCRtpSFrameTransform.idl	2021-02-24 17:10:20 UTC (rev 273393)
@@ -50,7 +50,7 @@
 ] interface RTCRtpSFrameTransform {
     [CallWith=ScriptExecutionContext] constructor(optional RTCRtpSFrameTransformOptions options);
 
-    Promise<undefined> setEncryptionKey(CryptoKey key, optional unsigned long long keyID);
+    [Custom] Promise<undefined> setEncryptionKey(CryptoKey key, optional any keyID);
     // FIXME: Add support for missing methods.
     // Promise<undefined> ratchetEncryptionKey();
     // Promise<undefined> setSigningKey(CryptoKey key);

Modified: branches/safari-611-branch/Source/WebCore/Modules/mediastream/RTCRtpSFrameTransformer.cpp (273392 => 273393)


--- branches/safari-611-branch/Source/WebCore/Modules/mediastream/RTCRtpSFrameTransformer.cpp	2021-02-24 17:10:16 UTC (rev 273392)
+++ branches/safari-611-branch/Source/WebCore/Modules/mediastream/RTCRtpSFrameTransformer.cpp	2021-02-24 17:10:20 UTC (rev 273393)
@@ -149,9 +149,6 @@
 
 ExceptionOr<void> RTCRtpSFrameTransformer::setEncryptionKey(const Vector<uint8_t>& rawKey, Optional<uint64_t> keyId)
 {
-    if (keyId && *keyId == std::numeric_limits<uint64_t>::max())
-        return Exception { TypeError, "Key ID is too big" };
-
     auto locker = holdLock(m_keyLock);
     return updateEncryptionKey(rawKey, keyId, ShouldUpdateKeys::Yes);
 }
@@ -158,8 +155,6 @@
 
 ExceptionOr<void> RTCRtpSFrameTransformer::updateEncryptionKey(const Vector<uint8_t>& rawKey, Optional<uint64_t> keyId, ShouldUpdateKeys shouldUpdateKeys)
 {
-    ASSERT(!keyId || *keyId != std::numeric_limits<uint64_t>::max());
-
     ASSERT(m_keyLock.isLocked());
 
     auto saltKeyResult = computeSaltKey(rawKey);
@@ -176,12 +171,16 @@
     if (encryptionKeyResult.hasException())
         return encryptionKeyResult.releaseException();
 
-    if (!keyId)
-        keyId = m_keys.size();
+    if (shouldUpdateKeys == ShouldUpdateKeys::No)
+        m_keyId = *keyId;
+    else {
+        // FIXME: In case keyId is not set, it might be best to use the first non used ID.
+        if (!keyId)
+            keyId = m_keys.size();
 
-    m_keyId = *keyId;
-    if (shouldUpdateKeys == ShouldUpdateKeys::Yes)
-        m_keys.set(*keyId + 1, rawKey);
+        m_keyId = *keyId;
+        m_keys.append({ m_keyId, rawKey });
+    }
 
     m_saltKey = saltKeyResult.releaseReturnValue();
     m_authenticationKey = authenticationKeyResult.releaseReturnValue();
@@ -230,13 +229,10 @@
     m_counter = header->counter;
 
     if (header->keyId != m_keyId) {
-        if (header->keyId == std::numeric_limits<uint64_t>::max())
+        auto position = m_keys.findMatching([keyId = header->keyId](auto& item) { return item.keyId == keyId; });
+        if (position == notFound)
             return Exception { DataError, "Key ID is unknown" };
-
-        auto iterator = m_keys.find(header->keyId + 1);
-        if (iterator == m_keys.end())
-            return Exception { DataError, "Key ID is unknown" };
-        auto result = updateEncryptionKey(iterator->value, header->keyId, ShouldUpdateKeys::No);
+        auto result = updateEncryptionKey(m_keys[position].keyData, header->keyId, ShouldUpdateKeys::No);
         if (result.hasException())
             return result.releaseException();
     }

Modified: branches/safari-611-branch/Source/WebCore/Modules/mediastream/RTCRtpSFrameTransformer.h (273392 => 273393)


--- branches/safari-611-branch/Source/WebCore/Modules/mediastream/RTCRtpSFrameTransformer.h	2021-02-24 17:10:16 UTC (rev 273392)
+++ branches/safari-611-branch/Source/WebCore/Modules/mediastream/RTCRtpSFrameTransformer.h	2021-02-24 17:10:20 UTC (rev 273393)
@@ -80,8 +80,13 @@
     Vector<uint8_t> m_authenticationKey;
     Vector<uint8_t> m_encryptionKey;
     Vector<uint8_t> m_saltKey;
-    HashMap<uint64_t, Vector<uint8_t>> m_keys;
 
+    struct IdentifiedKey {
+        uint64_t keyId { 0 };
+        Vector<uint8_t> keyData;
+    };
+    Vector<IdentifiedKey> m_keys;
+
     bool m_isEncrypting { false };
     uint64_t m_authenticationSize { 10 };
     uint64_t m_keyId { 0 };

Modified: branches/safari-611-branch/Source/WebCore/Sources.txt (273392 => 273393)


--- branches/safari-611-branch/Source/WebCore/Sources.txt	2021-02-24 17:10:16 UTC (rev 273392)
+++ branches/safari-611-branch/Source/WebCore/Sources.txt	2021-02-24 17:10:20 UTC (rev 273393)
@@ -593,6 +593,7 @@
 bindings/js/JSPluginElementFunctions.cpp
 bindings/js/JSPopStateEventCustom.cpp
 bindings/js/JSPromiseRejectionEventCustom.cpp
+bindings/js/JSRTCRtpSFrameTransformCustom.cpp
 bindings/js/JSReadableStreamSourceCustom.cpp
 bindings/js/JSRemoteDOMWindowBase.cpp
 bindings/js/JSRemoteDOMWindowCustom.cpp

Modified: branches/safari-611-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj (273392 => 273393)


--- branches/safari-611-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2021-02-24 17:10:16 UTC (rev 273392)
+++ branches/safari-611-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2021-02-24 17:10:20 UTC (rev 273393)
@@ -7756,6 +7756,7 @@
 		4170A2E91D8C0CC000318452 /* JSDOMWrapper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMWrapper.cpp; sourceTree = "<group>"; };
 		417253A81354BBBC00360F2A /* MediaControlTextTrackContainerElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaControlTextTrackContainerElement.cpp; sourceTree = "<group>"; };
 		417253A91354BBBC00360F2A /* MediaControlTextTrackContainerElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaControlTextTrackContainerElement.h; sourceTree = "<group>"; };
+		41733D7D25DFBFC500A136E5 /* JSRTCRtpSFrameTransformCustom.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSRTCRtpSFrameTransformCustom.cpp; sourceTree = "<group>"; };
 		4174E91E2535DCD600FE4202 /* MediaStreamTrackAudioSourceProviderCocoa.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MediaStreamTrackAudioSourceProviderCocoa.h; sourceTree = "<group>"; };
 		4174E9202535DCDD00FE4202 /* MediaStreamTrackAudioSourceProviderCocoa.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MediaStreamTrackAudioSourceProviderCocoa.cpp; sourceTree = "<group>"; };
 		417612AB1E3A993B00C3D81D /* LibWebRTCMediaEndpoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LibWebRTCMediaEndpoint.cpp; path = libwebrtc/LibWebRTCMediaEndpoint.cpp; sourceTree = "<group>"; };
@@ -27093,6 +27094,7 @@
 				BC5823F40C0A98DF0053F1B5 /* JSHTMLElementCustom.cpp */,
 				BCE1C43F0D9830F4003B02F2 /* JSLocationCustom.cpp */,
 				4B6B5CBE216434FB00603817 /* JSPaintWorkletGlobalScopeCustom.cpp */,
+				41733D7D25DFBFC500A136E5 /* JSRTCRtpSFrameTransformCustom.cpp */,
 				418C395D1C8F0AAB0051C8A3 /* JSReadableStreamSourceCustom.cpp */,
 				46BCBBBE2085005B00710638 /* JSRemoteDOMWindowCustom.cpp */,
 				7A3EBEAA21BF054C000D043D /* JSSVGViewSpecCustom.cpp */,

Added: branches/safari-611-branch/Source/WebCore/bindings/js/JSRTCRtpSFrameTransformCustom.cpp (0 => 273393)


--- branches/safari-611-branch/Source/WebCore/bindings/js/JSRTCRtpSFrameTransformCustom.cpp	                        (rev 0)
+++ branches/safari-611-branch/Source/WebCore/bindings/js/JSRTCRtpSFrameTransformCustom.cpp	2021-02-24 17:10:20 UTC (rev 273393)
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "JSRTCRtpSFrameTransform.h"
+
+#if ENABLE(WEB_RTC)
+
+#include "JSCryptoKey.h"
+#include "JSDOMPromiseDeferred.h"
+#include <_javascript_Core/JSBigInt.h>
+
+namespace WebCore {
+using namespace JSC;
+
+JSValue JSRTCRtpSFrameTransform::setEncryptionKey(JSGlobalObject& lexicalGlobalObject, CallFrame& callFrame, Ref<DeferredPromise>&& promise)
+{
+    auto& vm = getVM(&lexicalGlobalObject);
+    auto throwScope = DECLARE_THROW_SCOPE(vm);
+
+    if (UNLIKELY(callFrame.argumentCount() < 1)) {
+        throwVMError(&lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(&lexicalGlobalObject));
+        return jsUndefined();
+    }
+
+    EnsureStillAliveScope argument0 = callFrame.uncheckedArgument(0);
+    auto key = convert<IDLInterface<CryptoKey>>(lexicalGlobalObject, argument0.value(), [](auto& lexicalGlobalObject, auto& scope) {
+        throwArgumentTypeError(lexicalGlobalObject, scope, 0, "key", "SFrameTransform", "setEncryptionKey", "CryptoKey");
+    });
+    RETURN_IF_EXCEPTION(throwScope, jsUndefined());
+
+    EnsureStillAliveScope argument1 = callFrame.argument(1);
+    Optional<uint64_t> keyID;
+    if (!argument1.value().isUndefined()) {
+        if (argument1.value().isBigInt()) {
+            if (argument1.value().asHeapBigInt()->length() > 1) {
+                throwException(&lexicalGlobalObject, throwScope, createDOMException(&lexicalGlobalObject, RangeError, "Not a 64 bits integer"_s));
+                return jsUndefined();
+            }
+            keyID = JSBigInt::toBigUInt64(argument1.value());
+        } else
+            keyID = Optional<Converter<IDLUnsignedLongLong>::ReturnType>(convert<IDLUnsignedLongLong>(lexicalGlobalObject, argument1.value()));
+    }
+    RETURN_IF_EXCEPTION(throwScope, jsUndefined());
+    throwScope.release();
+
+    wrapped().setEncryptionKey(*key, keyID, WTFMove(promise));
+    return jsUndefined();
+}
+
+}
+
+#endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to