Diff
Modified: trunk/LayoutTests/ChangeLog (209165 => 209166)
--- trunk/LayoutTests/ChangeLog 2016-12-01 01:03:02 UTC (rev 209165)
+++ trunk/LayoutTests/ChangeLog 2016-12-01 01:11:11 UTC (rev 209166)
@@ -1,3 +1,14 @@
+2016-11-30 Jiewen Tan <[email protected]>
+
+ SubtleCrypto::deriveKey always return NOT_SUPPORTED_ERR for now
+ https://bugs.webkit.org/show_bug.cgi?id=164744
+ <rdar://problem/29258083>
+
+ Reviewed by Darin Adler.
+
+ * crypto/subtle/deriveKey-malformed-parameters-expected.txt: Added.
+ * crypto/subtle/deriveKey-malformed-parameters.html: Added.
+
2016-11-26 Jiewen Tan <[email protected]>
Update SubtleCrypto::digest to match the latest spec
Added: trunk/LayoutTests/crypto/subtle/deriveKey-malformed-parameters-expected.txt (0 => 209166)
--- trunk/LayoutTests/crypto/subtle/deriveKey-malformed-parameters-expected.txt (rev 0)
+++ trunk/LayoutTests/crypto/subtle/deriveKey-malformed-parameters-expected.txt 2016-12-01 01:11:11 UTC (rev 209166)
@@ -0,0 +1,15 @@
+Test deriveKey operation with malformed parameters
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS crypto.subtle.deriveKey() rejected promise with TypeError: Not enough arguments.
+PASS crypto.subtle.deriveKey(1) rejected promise with TypeError: Not enough arguments.
+PASS crypto.subtle.deriveKey(1, 2) rejected promise with TypeError: Not enough arguments.
+PASS crypto.subtle.deriveKey(1, 2, 3) rejected promise with TypeError: Not enough arguments.
+PASS crypto.subtle.deriveKey(1, 2, 3, 4) rejected promise with TypeError: Not enough arguments.
+PASS crypto.subtle.deriveKey("ECDH", 2, 3, 4, 5) rejected promise with NotSupportedError (DOM Exception 9): The operation is not supported..
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/crypto/subtle/deriveKey-malformed-parameters.html (0 => 209166)
--- trunk/LayoutTests/crypto/subtle/deriveKey-malformed-parameters.html (rev 0)
+++ trunk/LayoutTests/crypto/subtle/deriveKey-malformed-parameters.html 2016-12-01 01:11:11 UTC (rev 209166)
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test deriveKey operation with malformed parameters");
+
+// Not enough arguments.
+shouldReject('crypto.subtle.deriveKey()');
+shouldReject('crypto.subtle.deriveKey(1)');
+shouldReject('crypto.subtle.deriveKey(1, 2)');
+shouldReject('crypto.subtle.deriveKey(1, 2, 3)');
+shouldReject('crypto.subtle.deriveKey(1, 2, 3, 4)');
+// Not support.
+shouldReject('crypto.subtle.deriveKey("ECDH", 2, 3, 4, 5)');
+</script>
+
+<script src=""
+</body>
+</html>
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (209165 => 209166)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2016-12-01 01:03:02 UTC (rev 209165)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2016-12-01 01:11:11 UTC (rev 209166)
@@ -1,3 +1,13 @@
+2016-11-30 Jiewen Tan <[email protected]>
+
+ SubtleCrypto::deriveKey always return NOT_SUPPORTED_ERR for now
+ https://bugs.webkit.org/show_bug.cgi?id=164744
+ <rdar://problem/29258083>
+
+ Reviewed by Darin Adler.
+
+ * WebCryptoAPI/idlharness-expected.txt:
+
2016-11-26 Jiewen Tan <[email protected]>
Update SubtleCrypto::digest to match the latest spec
Modified: trunk/LayoutTests/imported/w3c/WebCryptoAPI/idlharness-expected.txt (209165 => 209166)
--- trunk/LayoutTests/imported/w3c/WebCryptoAPI/idlharness-expected.txt 2016-12-01 01:03:02 UTC (rev 209165)
+++ trunk/LayoutTests/imported/w3c/WebCryptoAPI/idlharness-expected.txt 2016-12-01 01:11:11 UTC (rev 209166)
@@ -55,8 +55,8 @@
PASS SubtleCrypto interface: calling digest(AlgorithmIdentifier,BufferSource) on crypto.subtle with too few arguments must throw TypeError
PASS SubtleCrypto interface: crypto.subtle must inherit property "generateKey" with the proper type (5)
PASS SubtleCrypto interface: calling generateKey(AlgorithmIdentifier,boolean,[object Object]) on crypto.subtle with too few arguments must throw TypeError
-FAIL SubtleCrypto interface: crypto.subtle must inherit property "deriveKey" with the proper type (6) assert_inherits: property "deriveKey" not found in prototype chain
-FAIL SubtleCrypto interface: calling deriveKey(AlgorithmIdentifier,CryptoKey,AlgorithmIdentifier,boolean,[object Object]) on crypto.subtle with too few arguments must throw TypeError assert_inherits: property "deriveKey" not found in prototype chain
+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 "importKey" with the proper type (8)
Modified: trunk/Source/WebCore/ChangeLog (209165 => 209166)
--- trunk/Source/WebCore/ChangeLog 2016-12-01 01:03:02 UTC (rev 209165)
+++ trunk/Source/WebCore/ChangeLog 2016-12-01 01:11:11 UTC (rev 209166)
@@ -1,3 +1,22 @@
+2016-11-30 Jiewen Tan <[email protected]>
+
+ SubtleCrypto::deriveKey always return NOT_SUPPORTED_ERR for now
+ https://bugs.webkit.org/show_bug.cgi?id=164744
+ <rdar://problem/29258083>
+
+ Reviewed by Darin Adler.
+
+ Since we don't support any cryptography algorithms that has deriveKey operations,
+ SubtleCrypto::deriveKey will always return NOT_SUPPORTED_ERR for now.
+
+ Test: crypto/subtle/deriveKey-malformed-parameters.html
+
+ * bindings/js/JSSubtleCryptoCustom.cpp:
+ (WebCore::normalizeCryptoAlgorithmParameters):
+ (WebCore::jsSubtleCryptoFunctionDeriveKeyPromise):
+ (WebCore::JSSubtleCrypto::deriveKey):
+ * crypto/SubtleCrypto.idl:
+
2016-11-26 Jiewen Tan <[email protected]>
Update SubtleCrypto::digest to match the latest spec
Modified: trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp (209165 => 209166)
--- trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp 2016-12-01 01:03:02 UTC (rev 209165)
+++ trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp 2016-12-01 01:11:11 UTC (rev 209166)
@@ -58,6 +58,7 @@
Sign,
Verify,
Digest,
+ DeriveKey,
GenerateKey,
ImportKey,
WrapKey,
@@ -147,6 +148,9 @@
return nullptr;
}
break;
+ case Operations::DeriveKey:
+ setDOMException(&state, NOT_SUPPORTED_ERR);
+ return nullptr;
case Operations::GenerateKey:
switch (*identifier) {
case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5: {
@@ -677,6 +681,23 @@
algorithm->digest(WTFMove(data), WTFMove(callback), WTFMove(exceptionCallback), *scriptExecutionContextFromExecState(&state), subtle->wrapped().workQueue());
}
+static void jsSubtleCryptoFunctionDeriveKeyPromise(ExecState& state, Ref<DeferredPromise>&& promise)
+{
+ VM& vm = state.vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ if (UNLIKELY(state.argumentCount() < 5)) {
+ promise->reject<JSValue>(createNotEnoughArgumentsError(&state));
+ return;
+ }
+
+ auto params = normalizeCryptoAlgorithmParameters(state, state.uncheckedArgument(0), Operations::DeriveKey);
+ RETURN_IF_EXCEPTION(scope, void());
+
+ // We should always return a NOT_SUPPORTED_ERR since we currently don't support any algorithms that has deriveKey operation.
+ ASSERT_NOT_REACHED();
+}
+
static void jsSubtleCryptoFunctionGenerateKeyPromise(ExecState& state, Ref<DeferredPromise>&& promise)
{
VM& vm = state.vm();
@@ -947,6 +968,11 @@
return callPromiseFunction<jsSubtleCryptoFunctionDigestPromise, PromiseExecutionScope::WindowOrWorker>(state);
}
+JSValue JSSubtleCrypto::deriveKey(ExecState& state)
+{
+ return callPromiseFunction<jsSubtleCryptoFunctionDeriveKeyPromise, PromiseExecutionScope::WindowOrWorker>(state);
+}
+
JSValue JSSubtleCrypto::generateKey(ExecState& state)
{
return callPromiseFunction<jsSubtleCryptoFunctionGenerateKeyPromise, PromiseExecutionScope::WindowOrWorker>(state);
Modified: trunk/Source/WebCore/crypto/SubtleCrypto.idl (209165 => 209166)
--- trunk/Source/WebCore/crypto/SubtleCrypto.idl 2016-12-01 01:03:02 UTC (rev 209165)
+++ trunk/Source/WebCore/crypto/SubtleCrypto.idl 2016-12-01 01:11:11 UTC (rev 209166)
@@ -36,6 +36,7 @@
[Custom] Promise<any> sign(AlgorithmIdentifier algorithm, CryptoKey key, BufferSource data);
[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);
// 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);