Title: [219805] releases/WebKitGTK/webkit-2.16
Revision
219805
Author
[email protected]
Date
2017-07-24 02:54:44 -0700 (Mon, 24 Jul 2017)

Log Message

Merge r216992 - Replace CryptoOperationData with BufferSource for WebKitSubtleCrypto
https://bugs.webkit.org/show_bug.cgi?id=172146
<rdar://problem/32122256>

Reviewed by Brent Fulgham.

Source/WebCore:

In this patch, we replaces CryptoOperationData with BufferSource for WebKitSubtleCrypto in
the custom binding codes.

Test: crypto/webkitSubtle/import-export-raw-key-leak.html

* bindings/js/JSWebKitSubtleCryptoCustom.cpp:
(WebCore::JSWebKitSubtleCrypto::encrypt):
(WebCore::JSWebKitSubtleCrypto::decrypt):
(WebCore::JSWebKitSubtleCrypto::sign):
(WebCore::JSWebKitSubtleCrypto::verify):
(WebCore::JSWebKitSubtleCrypto::digest):
(WebCore::JSWebKitSubtleCrypto::importKey):
(WebCore::JSWebKitSubtleCrypto::unwrapKey):
* crypto/WebKitSubtleCrypto.idl:

LayoutTests:

* crypto/webkitSubtle/argument-conversion-expected.txt:
* crypto/webkitSubtle/import-export-raw-key-leak-expected.txt: Added.
* crypto/webkitSubtle/import-export-raw-key-leak.html: Added.

Modified Paths

Added Paths

Diff

Modified: releases/WebKitGTK/webkit-2.16/LayoutTests/ChangeLog (219804 => 219805)


--- releases/WebKitGTK/webkit-2.16/LayoutTests/ChangeLog	2017-07-24 09:51:05 UTC (rev 219804)
+++ releases/WebKitGTK/webkit-2.16/LayoutTests/ChangeLog	2017-07-24 09:54:44 UTC (rev 219805)
@@ -1,3 +1,15 @@
+2017-05-15  Jiewen Tan  <[email protected]>
+
+        Replace CryptoOperationData with BufferSource for WebKitSubtleCrypto
+        https://bugs.webkit.org/show_bug.cgi?id=172146
+        <rdar://problem/32122256>
+
+        Reviewed by Brent Fulgham.
+
+        * crypto/webkitSubtle/argument-conversion-expected.txt:
+        * crypto/webkitSubtle/import-export-raw-key-leak-expected.txt: Added.
+        * crypto/webkitSubtle/import-export-raw-key-leak.html: Added.
+
 2017-05-11  Zalan Bujtas  <[email protected]>
 
         AX: Defer text changes until after the tree is clean if needed.

Modified: releases/WebKitGTK/webkit-2.16/LayoutTests/crypto/webkitSubtle/argument-conversion-expected.txt (219804 => 219805)


--- releases/WebKitGTK/webkit-2.16/LayoutTests/crypto/webkitSubtle/argument-conversion-expected.txt	2017-07-24 09:51:05 UTC (rev 219804)
+++ releases/WebKitGTK/webkit-2.16/LayoutTests/crypto/webkitSubtle/argument-conversion-expected.txt	2017-07-24 09:54:44 UTC (rev 219805)
@@ -16,10 +16,10 @@
 
 Passing invalid data to digest()
 PASS crypto.webkitSubtle.digest({name: 'sha-1'}) threw exception TypeError: Not enough arguments.
-PASS crypto.webkitSubtle.digest({name: 'sha-1'}, null) threw exception TypeError: Only ArrayBuffer and ArrayBufferView objects can be passed as CryptoOperationData.
-PASS crypto.webkitSubtle.digest({name: 'sha-1'}, 10) threw exception TypeError: Only ArrayBuffer and ArrayBufferView objects can be passed as CryptoOperationData.
-PASS crypto.webkitSubtle.digest({name: 'sha-1'}, [10]) threw exception TypeError: Only ArrayBuffer and ArrayBufferView objects can be passed as CryptoOperationData.
-PASS crypto.webkitSubtle.digest({name: 'sha-1'}, [new Uint8Array([0])]) threw exception TypeError: Only ArrayBuffer and ArrayBufferView objects can be passed as CryptoOperationData.
+PASS crypto.webkitSubtle.digest({name: 'sha-1'}, null) threw exception TypeError: Type error.
+PASS crypto.webkitSubtle.digest({name: 'sha-1'}, 10) threw exception TypeError: Type error.
+PASS crypto.webkitSubtle.digest({name: 'sha-1'}, [10]) threw exception TypeError: Type error.
+PASS crypto.webkitSubtle.digest({name: 'sha-1'}, [new Uint8Array([0])]) threw exception TypeError: Type error.
 
 Passing invalid algorithmIdentifiers to digest()
 PASS crypto.webkitSubtle.digest({ toString:function() { return 'sha-1' } }, data) threw exception NotSupportedError (DOM Exception 9): The operation is not supported..

Added: releases/WebKitGTK/webkit-2.16/LayoutTests/crypto/webkitSubtle/import-export-raw-key-leak-expected.txt (0 => 219805)


--- releases/WebKitGTK/webkit-2.16/LayoutTests/crypto/webkitSubtle/import-export-raw-key-leak-expected.txt	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.16/LayoutTests/crypto/webkitSubtle/import-export-raw-key-leak-expected.txt	2017-07-24 09:54:44 UTC (rev 219805)
@@ -0,0 +1,8 @@
+CONSOLE MESSAGE: line 44: WebKitSubtleCrypto is deprecated. Please use SubtleCrypto instead.
+Sending Worker Message
+Worker Terminated
+PASS exportedKey.byteLength is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: releases/WebKitGTK/webkit-2.16/LayoutTests/crypto/webkitSubtle/import-export-raw-key-leak.html (0 => 219805)


--- releases/WebKitGTK/webkit-2.16/LayoutTests/crypto/webkitSubtle/import-export-raw-key-leak.html	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.16/LayoutTests/crypto/webkitSubtle/import-export-raw-key-leak.html	2017-07-24 09:54:44 UTC (rev 219805)
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src=""
+    <script type="text/_javascript_">
+    jsTestIsAsync = true;
+
+    var keySize = 0x100;
+    var blob = new Blob([""], {type : 'application/_javascript_'});
+    var worker = new Worker(URL.createObjectURL(blob));
+
+    function run()
+    {
+        if (window.testRunner)
+            testRunner.dumpAsText();
+
+        function arrayBufferNeuter(ab)
+        {
+            /* Neuter the ArrayBuffer */
+            debug("Sending Worker Message");
+            worker.postMessage(ab, [ab]);
+            worker.terminate();
+            debug("Worker Terminated");
+        }
+
+        var a = new ArrayBuffer(keySize);
+        var b = { };
+        b.__defineGetter__('name', function(){
+            arrayBufferNeuter(a);
+            return "AES-CBC";
+        });
+        var result = window.crypto.webkitSubtle.importKey("raw", a, b, true);
+        result.then(function(key) {
+            window.crypto.webkitSubtle.exportKey("raw", key).then(function(result) {
+                exportedKey = result;
+                shouldBeZero("exportedKey.byteLength");
+                finishJSTest();
+            });
+        });
+    }
+    </script>
+    <script src=""
+</head>
+<body _onload_="run()"></body>
+</html>

Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/ChangeLog (219804 => 219805)


--- releases/WebKitGTK/webkit-2.16/Source/WebCore/ChangeLog	2017-07-24 09:51:05 UTC (rev 219804)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/ChangeLog	2017-07-24 09:54:44 UTC (rev 219805)
@@ -1,3 +1,26 @@
+2017-05-15  Jiewen Tan  <[email protected]>
+
+        Replace CryptoOperationData with BufferSource for WebKitSubtleCrypto
+        https://bugs.webkit.org/show_bug.cgi?id=172146
+        <rdar://problem/32122256>
+
+        Reviewed by Brent Fulgham.
+
+        In this patch, we replaces CryptoOperationData with BufferSource for WebKitSubtleCrypto in
+        the custom binding codes.
+
+        Test: crypto/webkitSubtle/import-export-raw-key-leak.html
+
+        * bindings/js/JSWebKitSubtleCryptoCustom.cpp:
+        (WebCore::JSWebKitSubtleCrypto::encrypt):
+        (WebCore::JSWebKitSubtleCrypto::decrypt):
+        (WebCore::JSWebKitSubtleCrypto::sign):
+        (WebCore::JSWebKitSubtleCrypto::verify):
+        (WebCore::JSWebKitSubtleCrypto::digest):
+        (WebCore::JSWebKitSubtleCrypto::importKey):
+        (WebCore::JSWebKitSubtleCrypto::unwrapKey):
+        * crypto/WebKitSubtleCrypto.idl:
+
 2017-05-13  Zalan Bujtas  <[email protected]>
 
         AccessibilityRenderObject::textUnderElement needs to assert on unclean tree.

Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/bindings/js/JSWebKitSubtleCryptoCustom.cpp (219804 => 219805)


--- releases/WebKitGTK/webkit-2.16/Source/WebCore/bindings/js/JSWebKitSubtleCryptoCustom.cpp	2017-07-24 09:51:05 UTC (rev 219804)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/bindings/js/JSWebKitSubtleCryptoCustom.cpp	2017-07-24 09:54:44 UTC (rev 219805)
@@ -28,6 +28,7 @@
 
 #if ENABLE(SUBTLE_CRYPTO)
 
+#include "BufferSource.h"
 #include "CryptoAlgorithm.h"
 #include "CryptoAlgorithmParametersDeprecated.h"
 #include "CryptoAlgorithmRegistry.h"
@@ -39,7 +40,6 @@
 #include "JSCryptoKey.h"
 #include "JSCryptoKeyPair.h"
 #include "JSCryptoKeySerializationJWK.h"
-#include "JSCryptoOperationData.h"
 #include "JSDOMPromise.h"
 #include "ScriptState.h"
 #include <runtime/Error.h>
@@ -148,7 +148,7 @@
         return jsUndefined();
     }
 
-    auto data = "" scope, state.uncheckedArgument(2));
+    auto data = "" state.uncheckedArgument(2)));
     RETURN_IF_EXCEPTION(scope, { });
 
     RefPtr<DeferredPromise> wrapper = createDeferredPromise(state, domWindow());
@@ -160,7 +160,7 @@
         wrapper->reject(); // FIXME: This should reject with an Exception.
     };
 
-    auto result = algorithm->encrypt(*parameters, *key, data, WTFMove(successCallback), WTFMove(failureCallback));
+    auto result = algorithm->encrypt(*parameters, *key, { data.data(), data.length() }, WTFMove(successCallback), WTFMove(failureCallback));
     if (result.hasException()) {
         propagateException(state, scope, result.releaseException());
         return { };
@@ -193,7 +193,7 @@
         return jsUndefined();
     }
 
-    auto data = "" scope, state.uncheckedArgument(2));
+    auto data = "" state.uncheckedArgument(2)));
     RETURN_IF_EXCEPTION(scope, { });
 
     RefPtr<DeferredPromise> wrapper = createDeferredPromise(state, domWindow());
@@ -205,7 +205,7 @@
         wrapper->reject(); // FIXME: This should reject with an Exception.
     };
 
-    auto result = algorithm->decrypt(*parameters, *key, data, WTFMove(successCallback), WTFMove(failureCallback));
+    auto result = algorithm->decrypt(*parameters, *key, { data.data(), data.length() }, WTFMove(successCallback), WTFMove(failureCallback));
     if (result.hasException()) {
         propagateException(state, scope, result.releaseException());
         return { };
@@ -238,7 +238,7 @@
         return jsUndefined();
     }
 
-    auto data = "" scope, state.uncheckedArgument(2));
+    auto data = "" state.uncheckedArgument(2)));
     RETURN_IF_EXCEPTION(scope, { });
 
     RefPtr<DeferredPromise> wrapper = createDeferredPromise(state, domWindow());
@@ -250,7 +250,7 @@
         wrapper->reject(); // FIXME: This should reject with an Exception.
     };
 
-    auto result = algorithm->sign(*parameters, *key, data, WTFMove(successCallback), WTFMove(failureCallback));
+    auto result = algorithm->sign(*parameters, *key, { data.data(), data.length() }, WTFMove(successCallback), WTFMove(failureCallback));
     if (result.hasException()) {
         propagateException(state, scope, result.releaseException());
         return { };
@@ -283,10 +283,10 @@
         return jsUndefined();
     }
 
-    auto signature = cryptoOperationDataFromJSValue(state, scope, state.uncheckedArgument(2));
+    auto signature = BufferSource(convert<IDLBufferSource>(state, state.uncheckedArgument(2)));
     RETURN_IF_EXCEPTION(scope, { });
 
-    auto data = "" scope, state.uncheckedArgument(3));
+    auto data = "" state.uncheckedArgument(3)));
     RETURN_IF_EXCEPTION(scope, { });
 
     RefPtr<DeferredPromise> wrapper = createDeferredPromise(state, domWindow());
@@ -298,7 +298,7 @@
         wrapper->reject(); // FIXME: This should reject with an Exception.
     };
 
-    auto result = algorithm->verify(*parameters, *key, signature, data, WTFMove(successCallback), WTFMove(failureCallback));
+    auto result = algorithm->verify(*parameters, *key, { signature.data(), signature.length() }, { data.data(), data.length() }, WTFMove(successCallback), WTFMove(failureCallback));
     if (result.hasException()) {
         propagateException(state, scope, result.releaseException());
         return { };
@@ -321,7 +321,7 @@
     auto parameters = JSCryptoAlgorithmDictionary::createParametersForDigest(state, scope, algorithm->identifier(), state.uncheckedArgument(0));
     RETURN_IF_EXCEPTION(scope, { });
 
-    auto data = "" scope, state.uncheckedArgument(1));
+    auto data = "" state.uncheckedArgument(1)));
     RETURN_IF_EXCEPTION(scope, { });
 
     RefPtr<DeferredPromise> wrapper = createDeferredPromise(state, domWindow());
@@ -333,7 +333,7 @@
         wrapper->reject(); // FIXME: This should reject with an Exception.
     };
 
-    auto result = algorithm->digest(*parameters, data, WTFMove(successCallback), WTFMove(failureCallback));
+    auto result = algorithm->digest(*parameters, { data.data(), data.length() }, WTFMove(successCallback), WTFMove(failureCallback));
     if (result.hasException()) {
         propagateException(state, scope, result.releaseException());
         return { };
@@ -456,7 +456,7 @@
     auto keyFormat = cryptoKeyFormatFromJSValue(state, scope, state.uncheckedArgument(0));
     RETURN_IF_EXCEPTION(scope, { });
 
-    auto data = "" scope, state.uncheckedArgument(1));
+    auto data = "" state.uncheckedArgument(1)));
     RETURN_IF_EXCEPTION(scope, { });
 
     RefPtr<CryptoAlgorithm> algorithm;
@@ -487,7 +487,7 @@
         wrapper->reject(); // FIXME: This should reject with an Exception.
     };
 
-    WebCore::importKey(state, keyFormat, data, WTFMove(algorithm), WTFMove(parameters), extractable, keyUsages, WTFMove(successCallback), WTFMove(failureCallback));
+    WebCore::importKey(state, keyFormat, { data.data(), data.length() }, WTFMove(algorithm), WTFMove(parameters), extractable, keyUsages, WTFMove(successCallback), WTFMove(failureCallback));
     RETURN_IF_EXCEPTION(scope, JSValue());
 
     return promise;
@@ -625,7 +625,7 @@
     auto keyFormat = cryptoKeyFormatFromJSValue(state, scope, state.uncheckedArgument(0));
     RETURN_IF_EXCEPTION(scope, { });
 
-    auto wrappedKeyData = cryptoOperationDataFromJSValue(state, scope, state.uncheckedArgument(1));
+    auto wrappedKeyData = BufferSource(convert<IDLBufferSource>(state, state.uncheckedArgument(1)));
     RETURN_IF_EXCEPTION(scope, { });
 
     RefPtr<CryptoKey> unwrappingKey = JSCryptoKey::toWrapped(vm, state.uncheckedArgument(2));
@@ -691,7 +691,7 @@
         wrapper->reject(); // FIXME: This should reject with an Exception.
     };
 
-    auto result = unwrapAlgorithm->decryptForUnwrapKey(*unwrapAlgorithmParameters, *unwrappingKey, wrappedKeyData, WTFMove(decryptSuccessCallback), WTFMove(decryptFailureCallback));
+    auto result = unwrapAlgorithm->decryptForUnwrapKey(*unwrapAlgorithmParameters, *unwrappingKey, { wrappedKeyData.data(), wrappedKeyData.length() }, WTFMove(decryptSuccessCallback), WTFMove(decryptFailureCallback));
     if (result.hasException()) {
         propagateException(state, scope, result.releaseException());
         return { };

Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/crypto/WebKitSubtleCrypto.idl (219804 => 219805)


--- releases/WebKitGTK/webkit-2.16/Source/WebCore/crypto/WebKitSubtleCrypto.idl	2017-07-24 09:51:05 UTC (rev 219804)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/crypto/WebKitSubtleCrypto.idl	2017-07-24 09:54:44 UTC (rev 219805)
@@ -28,14 +28,14 @@
     GenerateIsReachable=ImplDocument,
     NoInterfaceObject,
 ] interface WebKitSubtleCrypto {
-    [Custom] Promise<ArrayBuffer> encrypt(AlgorithmIdentifier algorithm, Key key, sequence<CryptoOperationData> data);
-    [Custom] Promise<ArrayBuffer> decrypt(AlgorithmIdentifier algorithm, Key key, sequence<CryptoOperationData> data);
-    [Custom] Promise<ArrayBuffer> sign(AlgorithmIdentifier algorithm, Key key, sequence<CryptoOperationData> data);
-    [Custom] Promise<boolean> verify(AlgorithmIdentifier algorithm, Key key, CryptoOperationData signature, sequence<CryptoOperationData> data);
-    [Custom] Promise<ArrayBuffer> digest(AlgorithmIdentifier algorithm, sequence<CryptoOperationData> data);
+    [Custom] Promise<ArrayBuffer> encrypt(AlgorithmIdentifier algorithm, Key key, sequence<BufferSource> data);
+    [Custom] Promise<ArrayBuffer> decrypt(AlgorithmIdentifier algorithm, Key key, sequence<BufferSource> data);
+    [Custom] Promise<ArrayBuffer> sign(AlgorithmIdentifier algorithm, Key key, sequence<BufferSource> data);
+    [Custom] Promise<boolean> verify(AlgorithmIdentifier algorithm, Key key, BufferSource signature, sequence<BufferSource> data);
+    [Custom] Promise<ArrayBuffer> digest(AlgorithmIdentifier algorithm, sequence<BufferSource> data);
     [Custom] Promise<(CryptoKey or CryptoKeyPair)> generateKey(AlgorithmIdentifier algorithm, optional boolean extractable, optional sequence<KeyUsage> keyUsages);
-    [Custom] Promise<CryptoKey> importKey(KeyFormat format, CryptoOperationData keyData, AlgorithmIdentifier? algorithm, optional boolean extractable, optional sequence<KeyUsage> keyUsages);
+    [Custom] Promise<CryptoKey> importKey(KeyFormat format, BufferSource keyData, AlgorithmIdentifier? algorithm, optional boolean extractable, optional sequence<KeyUsage> keyUsages);
     [Custom] Promise<ArrayBuffer> exportKey(KeyFormat format, Key key);
     [Custom] Promise<ArrayBuffer> wrapKey(KeyFormat format, Key key, Key wrappingKey, AlgorithmIdentifier wrapAlgorithm);
-    [Custom] Promise<CryptoKey> unwrapKey(KeyFormat format, CryptoOperationData wrappedKey, Key unwrappingKey, AlgorithmIdentifier unwrapAlgorithm, AlgorithmIdentifier? unwrappedKeyAlgorithm, optional boolean extractable, optional sequence<KeyUsage> keyUsages);
+    [Custom] Promise<CryptoKey> unwrapKey(KeyFormat format, BufferSource wrappedKey, Key unwrappingKey, AlgorithmIdentifier unwrapAlgorithm, AlgorithmIdentifier? unwrappedKeyAlgorithm, optional boolean extractable, optional sequence<KeyUsage> keyUsages);
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to