Title: [209191] trunk
Revision
209191
Author
jiewen_...@apple.com
Date
2016-12-01 11:42:30 -0800 (Thu, 01 Dec 2016)

Log Message

SubtleCrypto::deriveBits always return NOT_SUPPORTED_ERR for now
https://bugs.webkit.org/show_bug.cgi?id=164745
<rdar://problem/29258118>

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

* WebCryptoAPI/idlharness-expected.txt:

Source/WebCore:

Since we don't support any cryptography algorithms that has deriveBits operations,
SubtleCrypto::deriveBits will always return NOT_SUPPORTED_ERR for now.

Test: crypto/subtle/deriveBits-malformed-parameters.html

* bindings/js/JSSubtleCryptoCustom.cpp:
(WebCore::normalizeCryptoAlgorithmParameters):
(WebCore::jsSubtleCryptoFunctionDeriveBitsPromise):
(WebCore::JSSubtleCrypto::deriveBits):
* crypto/SubtleCrypto.idl:

LayoutTests:

* crypto/subtle/deriveBits-malformed-parameters-expected.txt: Added.
* crypto/subtle/deriveBits-malformed-parameters.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (209190 => 209191)


--- trunk/LayoutTests/ChangeLog	2016-12-01 19:33:47 UTC (rev 209190)
+++ trunk/LayoutTests/ChangeLog	2016-12-01 19:42:30 UTC (rev 209191)
@@ -1,3 +1,14 @@
+2016-12-01  Jiewen Tan  <jiewen_...@apple.com>
+
+        SubtleCrypto::deriveBits always return NOT_SUPPORTED_ERR for now
+        https://bugs.webkit.org/show_bug.cgi?id=164745
+        <rdar://problem/29258118>
+
+        Reviewed by Darin Adler.
+
+        * crypto/subtle/deriveBits-malformed-parameters-expected.txt: Added.
+        * crypto/subtle/deriveBits-malformed-parameters.html: Added.
+
 2016-12-01  Ryan Haddad  <ryanhad...@apple.com>
 
         Marking media/modern-media-controls/tracks-panel/tracks-panel-select-track-with-keyboard.html as failing on mac-wk1.

Added: trunk/LayoutTests/crypto/subtle/deriveBits-malformed-parameters-expected.txt (0 => 209191)


--- trunk/LayoutTests/crypto/subtle/deriveBits-malformed-parameters-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/crypto/subtle/deriveBits-malformed-parameters-expected.txt	2016-12-01 19:42:30 UTC (rev 209191)
@@ -0,0 +1,13 @@
+Test deriveBits operation with malformed parameters
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS crypto.subtle.deriveBits() rejected promise  with TypeError: Not enough arguments.
+PASS crypto.subtle.deriveBits(1) rejected promise  with TypeError: Not enough arguments.
+PASS crypto.subtle.deriveBits(1, 2) rejected promise  with TypeError: Not enough arguments.
+PASS crypto.subtle.deriveBits("ECDH", 2, 3) rejected promise  with NotSupportedError (DOM Exception 9): The operation is not supported..
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/crypto/subtle/deriveBits-malformed-parameters.html (0 => 209191)


--- trunk/LayoutTests/crypto/subtle/deriveBits-malformed-parameters.html	                        (rev 0)
+++ trunk/LayoutTests/crypto/subtle/deriveBits-malformed-parameters.html	2016-12-01 19:42:30 UTC (rev 209191)
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test deriveBits operation with malformed parameters");
+
+// Not enough arguments.
+shouldReject('crypto.subtle.deriveBits()');
+shouldReject('crypto.subtle.deriveBits(1)');
+shouldReject('crypto.subtle.deriveBits(1, 2)');
+// Not support.
+shouldReject('crypto.subtle.deriveBits("ECDH", 2, 3)');
+</script>
+
+<script src=""
+</body>
+</html>

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (209190 => 209191)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2016-12-01 19:33:47 UTC (rev 209190)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2016-12-01 19:42:30 UTC (rev 209191)
@@ -1,3 +1,13 @@
+2016-12-01  Jiewen Tan  <jiewen_...@apple.com>
+
+        SubtleCrypto::deriveBits always return NOT_SUPPORTED_ERR for now
+        https://bugs.webkit.org/show_bug.cgi?id=164745
+        <rdar://problem/29258118>
+
+        Reviewed by Darin Adler.
+
+        * WebCryptoAPI/idlharness-expected.txt:
+
 2016-11-30  Sam Weinig  <s...@webkit.org>
 
         [WebIDL] Remove custom bindings for File and Blob constructors

Modified: trunk/LayoutTests/imported/w3c/WebCryptoAPI/idlharness-expected.txt (209190 => 209191)


--- trunk/LayoutTests/imported/w3c/WebCryptoAPI/idlharness-expected.txt	2016-12-01 19:33:47 UTC (rev 209190)
+++ trunk/LayoutTests/imported/w3c/WebCryptoAPI/idlharness-expected.txt	2016-12-01 19:42:30 UTC (rev 209191)
@@ -57,8 +57,8 @@
 PASS SubtleCrypto interface: calling generateKey(AlgorithmIdentifier,boolean,[object Object]) on crypto.subtle with too few arguments must throw TypeError 
 PASS SubtleCrypto interface: crypto.subtle must inherit property "deriveKey" with the proper type (6) 
 PASS SubtleCrypto interface: calling deriveKey(AlgorithmIdentifier,CryptoKey,AlgorithmIdentifier,boolean,[object Object]) on crypto.subtle with too few arguments must throw TypeError 
-FAIL SubtleCrypto interface: crypto.subtle must inherit property "deriveBits" with the proper type (7) assert_inherits: property "deriveBits" not found in prototype chain
-FAIL SubtleCrypto interface: calling deriveBits(AlgorithmIdentifier,CryptoKey,unsigned long) on crypto.subtle with too few arguments must throw TypeError assert_inherits: property "deriveBits" not found in prototype chain
+PASS SubtleCrypto interface: crypto.subtle must inherit property "deriveBits" with the proper type (7) 
+PASS SubtleCrypto interface: calling deriveBits(AlgorithmIdentifier,CryptoKey,unsigned long) on crypto.subtle with too few arguments must throw TypeError 
 PASS SubtleCrypto interface: crypto.subtle must inherit property "importKey" with the proper type (8) 
 PASS SubtleCrypto interface: calling importKey(KeyFormat,[object Object],[object Object],AlgorithmIdentifier,boolean,[object Object]) on crypto.subtle with too few arguments must throw TypeError 
 PASS SubtleCrypto interface: crypto.subtle must inherit property "exportKey" with the proper type (9) 

Modified: trunk/Source/WebCore/ChangeLog (209190 => 209191)


--- trunk/Source/WebCore/ChangeLog	2016-12-01 19:33:47 UTC (rev 209190)
+++ trunk/Source/WebCore/ChangeLog	2016-12-01 19:42:30 UTC (rev 209191)
@@ -1,3 +1,22 @@
+2016-12-01  Jiewen Tan  <jiewen_...@apple.com>
+
+        SubtleCrypto::deriveBits always return NOT_SUPPORTED_ERR for now
+        https://bugs.webkit.org/show_bug.cgi?id=164745
+        <rdar://problem/29258118>
+
+        Reviewed by Darin Adler.
+
+        Since we don't support any cryptography algorithms that has deriveBits operations,
+        SubtleCrypto::deriveBits will always return NOT_SUPPORTED_ERR for now.
+
+        Test: crypto/subtle/deriveBits-malformed-parameters.html
+
+        * bindings/js/JSSubtleCryptoCustom.cpp:
+        (WebCore::normalizeCryptoAlgorithmParameters):
+        (WebCore::jsSubtleCryptoFunctionDeriveBitsPromise):
+        (WebCore::JSSubtleCrypto::deriveBits):
+        * crypto/SubtleCrypto.idl:
+
 2016-12-01  Eric Carlson  <eric.carl...@apple.com>
 
         [MediaStream][Mac] Video presets sometimes don't work

Modified: trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp (209190 => 209191)


--- trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp	2016-12-01 19:33:47 UTC (rev 209190)
+++ trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp	2016-12-01 19:42:30 UTC (rev 209191)
@@ -59,6 +59,7 @@
     Verify,
     Digest,
     DeriveKey,
+    DeriveBits,
     GenerateKey,
     ImportKey,
     WrapKey,
@@ -149,6 +150,7 @@
             }
             break;
         case Operations::DeriveKey:
+        case Operations::DeriveBits:
             setDOMException(&state, NOT_SUPPORTED_ERR);
             return nullptr;
         case Operations::GenerateKey:
@@ -698,6 +700,23 @@
     ASSERT_NOT_REACHED();
 }
 
+static void jsSubtleCryptoFunctionDeriveBitsPromise(ExecState& state, Ref<DeferredPromise>&& promise)
+{
+    VM& vm = state.vm();
+    auto scope = DECLARE_THROW_SCOPE(vm);
+
+    if (UNLIKELY(state.argumentCount() < 3)) {
+        promise->reject<JSValue>(createNotEnoughArgumentsError(&state));
+        return;
+    }
+
+    auto params = normalizeCryptoAlgorithmParameters(state, state.uncheckedArgument(0), Operations::DeriveBits);
+    RETURN_IF_EXCEPTION(scope, void());
+
+    // We should always return a NOT_SUPPORTED_ERR since we currently don't support any algorithms that has deriveBits operation.
+    ASSERT_NOT_REACHED();
+}
+
 static void jsSubtleCryptoFunctionGenerateKeyPromise(ExecState& state, Ref<DeferredPromise>&& promise)
 {
     VM& vm = state.vm();
@@ -973,6 +992,11 @@
     return callPromiseFunction<jsSubtleCryptoFunctionDeriveKeyPromise, PromiseExecutionScope::WindowOrWorker>(state);
 }
 
+JSValue JSSubtleCrypto::deriveBits(ExecState& state)
+{
+    return callPromiseFunction<jsSubtleCryptoFunctionDeriveBitsPromise, PromiseExecutionScope::WindowOrWorker>(state);
+}
+
 JSValue JSSubtleCrypto::generateKey(ExecState& state)
 {
     return callPromiseFunction<jsSubtleCryptoFunctionGenerateKeyPromise, PromiseExecutionScope::WindowOrWorker>(state);

Modified: trunk/Source/WebCore/crypto/SubtleCrypto.idl (209190 => 209191)


--- trunk/Source/WebCore/crypto/SubtleCrypto.idl	2016-12-01 19:33:47 UTC (rev 209190)
+++ trunk/Source/WebCore/crypto/SubtleCrypto.idl	2016-12-01 19:42:30 UTC (rev 209191)
@@ -37,6 +37,7 @@
     [Custom] Promise<any> verify(AlgorithmIdentifier algorithm, CryptoKey key, BufferSource signature, BufferSource data);
     [Custom] Promise<any> digest(AlgorithmIdentifier algorithm, BufferSource data);
     [Custom] Promise<any> deriveKey(AlgorithmIdentifier algorithm, CryptoKey baseKey, AlgorithmIdentifier derivedKeyType, boolean extractable, sequence<KeyUsage> keyUsages);
+    [Custom] Promise<ArrayBuffer> deriveBits(AlgorithmIdentifier algorithm, CryptoKey baseKey, unsigned long length);
     // FIXME: Should this return a Promise<(CryptoKey or CryptoKeyPair)>?
     [Custom] Promise<any> generateKey(AlgorithmIdentifier algorithm, boolean extractable, sequence<CryptoKeyUsage> keyUsages);
     [Custom] Promise<CryptoKey> importKey(KeyFormat format, (BufferSource or JsonWebKey) keyData, AlgorithmIdentifier algorithm, boolen extractable, sequence<CryptoKeyUsage> keyUsages);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to