Title: [203696] trunk
Revision
203696
Author
jiewen_...@apple.com
Date
2016-07-25 13:35:16 -0700 (Mon, 25 Jul 2016)

Log Message

Rename SubtleCrypto to WebKitSubtleCrypto
https://bugs.webkit.org/show_bug.cgi?id=160067
<rdar://problem/27483617>

Reviewed by Brent Fulgham.

Source/WebCore:

Tests: crypto/webkitSubtle/gc-2.html
       crypto/webkitSubtle/gc-3.html
       crypto/webkitSubtle/gc.html

Rename Class SubtleCrypto to WebKitSubtleCrypto, and Crypto.subtle to Crypto.webkitSubtle in order
to let the new implementation to reuse the name SubtleCrypto. This renaming should match what our
current JSBindings use, and therefore should not introduce any change of behavoir.

* CMakeLists.txt:
Revise project files for for new file names.
* DerivedSources.cpp:
* DerivedSources.make:
* PlatformEfl.cmake:
* PlatformGTK.cmake:
* PlatformMac.cmake:
* WebCore.xcodeproj/project.pbxproj:
Revise project files for for new file names.
* bindings/js/JSWebKitSubtleCryptoCustom.cpp: Renamed from Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp.
* crypto/WebKitSubtleCrypto.cpp: Renamed from Source/WebCore/crypto/SubtleCrypto.cpp.
* crypto/WebKitSubtleCrypto.h: Renamed from Source/WebCore/crypto/SubtleCrypto.h.
* crypto/WebKitSubtleCrypto.idl: Renamed from Source/WebCore/crypto/SubtleCrypto.idl.
* page/Crypto.cpp:
(WebCore::Crypto::webkitSubtle):
(WebCore::Crypto::subtle): Deleted.
* page/Crypto.h:
* page/Crypto.idl:

LayoutTests:

Move tests involving crypto.webkitSubtle from crypto/subtle to crypto/webkitSubtle.

* crypto/webkitSubtle/gc-2-expected.txt: Renamed from LayoutTests/crypto/subtle/gc-2-expected.txt.
* crypto/webkitSubtle/gc-2.html: Renamed from LayoutTests/crypto/subtle/gc-2.html.
* crypto/webkitSubtle/gc-3-expected.txt: Renamed from LayoutTests/crypto/subtle/gc-3-expected.txt.
* crypto/webkitSubtle/gc-3.html: Renamed from LayoutTests/crypto/subtle/gc-3.html.
* crypto/webkitSubtle/gc-expected.txt: Renamed from LayoutTests/crypto/subtle/gc-expected.txt.
* crypto/webkitSubtle/gc.html: Renamed from LayoutTests/crypto/subtle/gc.html.
* platform/efl/TestExpectations:
* platform/gtk/TestExpectations:
* platform/ios-simulator-wk1/TestExpectations:
* platform/win/TestExpectations:

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (203695 => 203696)


--- trunk/LayoutTests/ChangeLog	2016-07-25 19:57:47 UTC (rev 203695)
+++ trunk/LayoutTests/ChangeLog	2016-07-25 20:35:16 UTC (rev 203696)
@@ -1,3 +1,24 @@
+2016-07-25  Jiewen Tan  <jiewen_...@apple.com>
+
+        Rename SubtleCrypto to WebKitSubtleCrypto
+        https://bugs.webkit.org/show_bug.cgi?id=160067
+        <rdar://problem/27483617>
+
+        Reviewed by Brent Fulgham.
+
+        Move tests involving crypto.webkitSubtle from crypto/subtle to crypto/webkitSubtle.
+
+        * crypto/webkitSubtle/gc-2-expected.txt: Renamed from LayoutTests/crypto/subtle/gc-2-expected.txt.
+        * crypto/webkitSubtle/gc-2.html: Renamed from LayoutTests/crypto/subtle/gc-2.html.
+        * crypto/webkitSubtle/gc-3-expected.txt: Renamed from LayoutTests/crypto/subtle/gc-3-expected.txt.
+        * crypto/webkitSubtle/gc-3.html: Renamed from LayoutTests/crypto/subtle/gc-3.html.
+        * crypto/webkitSubtle/gc-expected.txt: Renamed from LayoutTests/crypto/subtle/gc-expected.txt.
+        * crypto/webkitSubtle/gc.html: Renamed from LayoutTests/crypto/subtle/gc.html.
+        * platform/efl/TestExpectations:
+        * platform/gtk/TestExpectations:
+        * platform/ios-simulator-wk1/TestExpectations:
+        * platform/win/TestExpectations:
+
 2016-07-25  Brady Eidson  <beid...@apple.com>
 
         Allow LocalStorage by default for file URLs.

Deleted: trunk/LayoutTests/crypto/subtle/gc-2-expected.txt (203695 => 203696)


--- trunk/LayoutTests/crypto/subtle/gc-2-expected.txt	2016-07-25 19:57:47 UTC (rev 203695)
+++ trunk/LayoutTests/crypto/subtle/gc-2-expected.txt	2016-07-25 20:35:16 UTC (rev 203696)
@@ -1,12 +0,0 @@
-Test that window.crypto.subtle wrapper preserves custom properties.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-PASS [object Crypto] is defined.
-PASS [object WebKitSubtleCrypto] is defined.
-PASS anotherWindowCrypto.webkitSubtle.foo is "bar"
-PASS successfullyParsed is true
-
-TEST COMPLETE
-

Deleted: trunk/LayoutTests/crypto/subtle/gc-2.html (203695 => 203696)


--- trunk/LayoutTests/crypto/subtle/gc-2.html	2016-07-25 19:57:47 UTC (rev 203695)
+++ trunk/LayoutTests/crypto/subtle/gc-2.html	2016-07-25 20:35:16 UTC (rev 203696)
@@ -1,46 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<meta charset="utf-8">
-<script src=""
-</head>
-<body>
-<script>
-
-description("Test that window.crypto.subtle wrapper preserves custom properties.");
-jsTestIsAsync = true;
-
-var anotherWindowCrypto;
-
-function startTest()
-{
-    anotherWindowCrypto = frames[0].crypto;
-    shouldBeDefined(anotherWindowCrypto);
-    shouldBeDefined(anotherWindowCrypto.webkitSubtle);
-
-    anotherWindowCrypto.webkitSubtle.foo = "bar";
-    document.body.removeChild(document.getElementsByTagName("iframe")[0]);
-    gc();
-    setTimeout(continueTest, 10);
-}
-
-function continueTest()
-{
-    gc();
-    setTimeout(finishTest, 10);
-}
-
-function finishTest()
-{
-    gc();
-    shouldBe('anotherWindowCrypto.webkitSubtle.foo', '"bar"');
-    finishJSTest();
-}
-
-window._onload_ = startTest;
-
-</script>
-<iframe src=""
-<script src=""
-</body>
-</html>

Deleted: trunk/LayoutTests/crypto/subtle/gc-3-expected.txt (203695 => 203696)


--- trunk/LayoutTests/crypto/subtle/gc-3-expected.txt	2016-07-25 19:57:47 UTC (rev 203695)
+++ trunk/LayoutTests/crypto/subtle/gc-3-expected.txt	2016-07-25 20:35:16 UTC (rev 203696)
@@ -1,11 +0,0 @@
-Test that window.crypto wrapper protects all dependencies, so it can always be used to create crypto.subtle.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-PASS [object Crypto] is defined.
-PASS [object WebKitSubtleCrypto] is defined.
-PASS successfullyParsed is true
-
-TEST COMPLETE
-

Deleted: trunk/LayoutTests/crypto/subtle/gc-3.html (203695 => 203696)


--- trunk/LayoutTests/crypto/subtle/gc-3.html	2016-07-25 19:57:47 UTC (rev 203695)
+++ trunk/LayoutTests/crypto/subtle/gc-3.html	2016-07-25 20:35:16 UTC (rev 203696)
@@ -1,43 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<meta charset="utf-8">
-<script src=""
-</head>
-<body>
-<script>
-
-description("Test that window.crypto wrapper protects all dependencies, so it can always be used to create crypto.subtle.");
-jsTestIsAsync = true;
-
-var anotherWindowCrypto;
-
-function startTest()
-{
-    anotherWindowCrypto = frames[0].crypto;
-    shouldBeDefined(anotherWindowCrypto);
-    document.body.removeChild(document.getElementsByTagName("iframe")[0]);
-    gc();
-    setTimeout(continueTest, 10);
-}
-
-function continueTest()
-{
-    gc();
-    setTimeout(finishTest, 10);
-}
-
-function finishTest()
-{
-    gc();
-    shouldBeDefined(anotherWindowCrypto.webkitSubtle);
-    finishJSTest();
-}
-
-window._onload_ = startTest;
-
-</script>
-<iframe src=""
-<script src=""
-</body>
-</html>

Deleted: trunk/LayoutTests/crypto/subtle/gc-expected.txt (203695 => 203696)


--- trunk/LayoutTests/crypto/subtle/gc-expected.txt	2016-07-25 19:57:47 UTC (rev 203695)
+++ trunk/LayoutTests/crypto/subtle/gc-expected.txt	2016-07-25 20:35:16 UTC (rev 203696)
@@ -1,10 +0,0 @@
-Test that window.crypto.subtle wrapper preserves custom properties.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-PASS window.crypto.webkitSubtle.foo is "bar"
-PASS successfullyParsed is true
-
-TEST COMPLETE
-

Deleted: trunk/LayoutTests/crypto/subtle/gc.html (203695 => 203696)


--- trunk/LayoutTests/crypto/subtle/gc.html	2016-07-25 19:57:47 UTC (rev 203695)
+++ trunk/LayoutTests/crypto/subtle/gc.html	2016-07-25 20:35:16 UTC (rev 203696)
@@ -1,38 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<meta charset="utf-8">
-<script src=""
-</head>
-<body>
-<script>
-
-description("Test that window.crypto.subtle wrapper preserves custom properties.");
-jsTestIsAsync = true;
-
-function startTest()
-{
-    window.crypto.webkitSubtle.foo = "bar";
-    gc();
-    setTimeout(continueTest, 10);
-}
-
-function continueTest()
-{
-    gc();
-    setTimeout(finishTest, 10);
-}
-
-function finishTest()
-{
-    gc();
-    shouldBe('window.crypto.webkitSubtle.foo', '"bar"');
-    finishJSTest();
-}
-
-window._onload_ = startTest;
-
-</script>
-<script src=""
-</body>
-</html>

Copied: trunk/LayoutTests/crypto/webkitSubtle/gc-2-expected.txt (from rev 203695, trunk/LayoutTests/crypto/subtle/gc-2-expected.txt) (0 => 203696)


--- trunk/LayoutTests/crypto/webkitSubtle/gc-2-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/crypto/webkitSubtle/gc-2-expected.txt	2016-07-25 20:35:16 UTC (rev 203696)
@@ -0,0 +1,12 @@
+Test that window.crypto.webkitSubtle wrapper preserves custom properties.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS [object Crypto] is defined.
+PASS [object WebKitSubtleCrypto] is defined.
+PASS anotherWindowCrypto.webkitSubtle.foo is "bar"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Copied: trunk/LayoutTests/crypto/webkitSubtle/gc-2.html (from rev 203695, trunk/LayoutTests/crypto/subtle/gc-2.html) (0 => 203696)


--- trunk/LayoutTests/crypto/webkitSubtle/gc-2.html	                        (rev 0)
+++ trunk/LayoutTests/crypto/webkitSubtle/gc-2.html	2016-07-25 20:35:16 UTC (rev 203696)
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src=""
+</head>
+<body>
+<script>
+
+description("Test that window.crypto.webkitSubtle wrapper preserves custom properties.");
+jsTestIsAsync = true;
+
+var anotherWindowCrypto;
+
+function startTest()
+{
+    anotherWindowCrypto = frames[0].crypto;
+    shouldBeDefined(anotherWindowCrypto);
+    shouldBeDefined(anotherWindowCrypto.webkitSubtle);
+
+    anotherWindowCrypto.webkitSubtle.foo = "bar";
+    document.body.removeChild(document.getElementsByTagName("iframe")[0]);
+    gc();
+    setTimeout(continueTest, 10);
+}
+
+function continueTest()
+{
+    gc();
+    setTimeout(finishTest, 10);
+}
+
+function finishTest()
+{
+    gc();
+    shouldBe('anotherWindowCrypto.webkitSubtle.foo', '"bar"');
+    finishJSTest();
+}
+
+window._onload_ = startTest;
+
+</script>
+<iframe src=""
+<script src=""
+</body>
+</html>

Copied: trunk/LayoutTests/crypto/webkitSubtle/gc-3-expected.txt (from rev 203695, trunk/LayoutTests/crypto/subtle/gc-3-expected.txt) (0 => 203696)


--- trunk/LayoutTests/crypto/webkitSubtle/gc-3-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/crypto/webkitSubtle/gc-3-expected.txt	2016-07-25 20:35:16 UTC (rev 203696)
@@ -0,0 +1,11 @@
+Test that window.crypto wrapper protects all dependencies, so it can always be used to create crypto.webkitSubtle.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS [object Crypto] is defined.
+PASS [object WebKitSubtleCrypto] is defined.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Copied: trunk/LayoutTests/crypto/webkitSubtle/gc-3.html (from rev 203695, trunk/LayoutTests/crypto/subtle/gc-3.html) (0 => 203696)


--- trunk/LayoutTests/crypto/webkitSubtle/gc-3.html	                        (rev 0)
+++ trunk/LayoutTests/crypto/webkitSubtle/gc-3.html	2016-07-25 20:35:16 UTC (rev 203696)
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src=""
+</head>
+<body>
+<script>
+
+description("Test that window.crypto wrapper protects all dependencies, so it can always be used to create crypto.webkitSubtle.");
+jsTestIsAsync = true;
+
+var anotherWindowCrypto;
+
+function startTest()
+{
+    anotherWindowCrypto = frames[0].crypto;
+    shouldBeDefined(anotherWindowCrypto);
+    document.body.removeChild(document.getElementsByTagName("iframe")[0]);
+    gc();
+    setTimeout(continueTest, 10);
+}
+
+function continueTest()
+{
+    gc();
+    setTimeout(finishTest, 10);
+}
+
+function finishTest()
+{
+    gc();
+    shouldBeDefined(anotherWindowCrypto.webkitSubtle);
+    finishJSTest();
+}
+
+window._onload_ = startTest;
+
+</script>
+<iframe src=""
+<script src=""
+</body>
+</html>

Copied: trunk/LayoutTests/crypto/webkitSubtle/gc-expected.txt (from rev 203695, trunk/LayoutTests/crypto/subtle/gc-expected.txt) (0 => 203696)


--- trunk/LayoutTests/crypto/webkitSubtle/gc-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/crypto/webkitSubtle/gc-expected.txt	2016-07-25 20:35:16 UTC (rev 203696)
@@ -0,0 +1,10 @@
+Test that window.crypto.webkitSubtle wrapper preserves custom properties.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.crypto.webkitSubtle.foo is "bar"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Copied: trunk/LayoutTests/crypto/webkitSubtle/gc.html (from rev 203695, trunk/LayoutTests/crypto/subtle/gc.html) (0 => 203696)


--- trunk/LayoutTests/crypto/webkitSubtle/gc.html	                        (rev 0)
+++ trunk/LayoutTests/crypto/webkitSubtle/gc.html	2016-07-25 20:35:16 UTC (rev 203696)
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src=""
+</head>
+<body>
+<script>
+
+description("Test that window.crypto.webkitSubtle wrapper preserves custom properties.");
+jsTestIsAsync = true;
+
+function startTest()
+{
+    window.crypto.webkitSubtle.foo = "bar";
+    gc();
+    setTimeout(continueTest, 10);
+}
+
+function continueTest()
+{
+    gc();
+    setTimeout(finishTest, 10);
+}
+
+function finishTest()
+{
+    gc();
+    shouldBe('window.crypto.webkitSubtle.foo', '"bar"');
+    finishJSTest();
+}
+
+window._onload_ = startTest;
+
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/LayoutTests/platform/efl/TestExpectations (203695 => 203696)


--- trunk/LayoutTests/platform/efl/TestExpectations	2016-07-25 19:57:47 UTC (rev 203695)
+++ trunk/LayoutTests/platform/efl/TestExpectations	2016-07-25 20:35:16 UTC (rev 203696)
@@ -1823,6 +1823,7 @@
 # crypto.subtle is not yet enabled, but digest algorithms are already implemented
 # and their tests are whitelisted
 webkit.org/b/133122 crypto/subtle [ Skip ]
+webkit.org/b/133122 crypto/webkitSubtle [ Skip ]
 webkit.org/b/133319 crypto/subtle/sha-1.html [ Pass ]
 webkit.org/b/133319 crypto/subtle/sha-224.html [ Pass ]
 webkit.org/b/133319 crypto/subtle/sha-256.html [ Pass ]

Modified: trunk/LayoutTests/platform/gtk/TestExpectations (203695 => 203696)


--- trunk/LayoutTests/platform/gtk/TestExpectations	2016-07-25 19:57:47 UTC (rev 203695)
+++ trunk/LayoutTests/platform/gtk/TestExpectations	2016-07-25 20:35:16 UTC (rev 203696)
@@ -409,6 +409,7 @@
 # crypto.subtle is not yet enabled, but digest algorithms are already implemented
 # and their tests are whitelisted
 webkit.org/b/133122 crypto/subtle [ Skip ]
+webkit.org/b/133122 crypto/webkitSubtle [ Skip ]
 webkit.org/b/133319 crypto/subtle/sha-1.html [ Pass ]
 webkit.org/b/133319 crypto/subtle/sha-224.html [ Pass ]
 webkit.org/b/133319 crypto/subtle/sha-256.html [ Pass ]

Modified: trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations (203695 => 203696)


--- trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations	2016-07-25 19:57:47 UTC (rev 203695)
+++ trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations	2016-07-25 20:35:16 UTC (rev 203696)
@@ -1005,7 +1005,9 @@
 storage/indexeddb
 imported/w3c/IndexedDB-private-browsing
 imported/w3c/web-platform-tests/IndexedDB
+crypto/subtle/rsa-indexeddb-non-exportable-private.html
 crypto/subtle/rsa-indexeddb-non-exportable.html
+crypto/subtle/rsa-indexeddb-private.html
 crypto/subtle/rsa-indexeddb.html
 fast/history/page-cache-indexed-closed-db.html
 fast/history/page-cache-indexed-opened-db.html

Modified: trunk/LayoutTests/platform/win/TestExpectations (203695 => 203696)


--- trunk/LayoutTests/platform/win/TestExpectations	2016-07-25 19:57:47 UTC (rev 203695)
+++ trunk/LayoutTests/platform/win/TestExpectations	2016-07-25 20:35:16 UTC (rev 203696)
@@ -259,6 +259,9 @@
 http/tests/security/cross-origin-worker-indexeddb-allowed.html [ Skip ]
 http/tests/security/cross-origin-worker-indexeddb.html [ Skip ]
 http/tests/security/no-indexeddb-from-sandbox.html [ Skip ]
+crypto/subtle/rsa-indexeddb-non-exportable-private.html [ Skip ]
+crypto/subtle/rsa-indexeddb-non-exportable.html [ Skip ]
+crypto/subtle/rsa-indexeddb-private.html [ Skip ]
 crypto/subtle/rsa-indexeddb.html [ Skip ]
 fast/history/page-cache-indexed-closed-db.html [ Skip ]
 fast/history/page-cache-indexed-opened-db.html [ Skip ]
@@ -593,6 +596,7 @@
 webkit.org/b/116559 storage/websql/ [ Skip ]
 
 # TODO crypto.subtle is not yet enabled
+crypto/webkitSubtle/ [ Skip ]
 crypto/subtle/ [ Skip ]
 
 # TODO Missing WebSpeech implementation

Modified: trunk/Source/WebCore/CMakeLists.txt (203695 => 203696)


--- trunk/Source/WebCore/CMakeLists.txt	2016-07-25 19:57:47 UTC (rev 203695)
+++ trunk/Source/WebCore/CMakeLists.txt	2016-07-25 20:35:16 UTC (rev 203696)
@@ -315,7 +315,7 @@
 
     crypto/CryptoKey.idl
     crypto/CryptoKeyPair.idl
-    crypto/SubtleCrypto.idl
+    crypto/WebKitSubtleCrypto.idl
 
     css/CSSCharsetRule.idl
     css/CSSFontFaceLoadEvent.idl
@@ -1210,7 +1210,6 @@
     bindings/js/JSStorageCustom.cpp
     bindings/js/JSStyleSheetCustom.cpp
     bindings/js/JSStyleSheetListCustom.cpp
-    bindings/js/JSSubtleCryptoCustom.cpp
     bindings/js/JSTextCustom.cpp
     bindings/js/JSTextTrackCueCustom.cpp
     bindings/js/JSTextTrackCustom.cpp
@@ -1224,6 +1223,7 @@
     bindings/js/JSWebGLRenderingContextBaseCustom.cpp
     bindings/js/JSWebGLRenderingContextCustom.cpp
     bindings/js/JSWebKitPointCustom.cpp
+    bindings/js/JSWebKitSubtleCryptoCustom.cpp
     bindings/js/JSWorkerCustom.cpp
     bindings/js/JSWorkerGlobalScopeBase.cpp
     bindings/js/JSWorkerGlobalScopeCustom.cpp

Modified: trunk/Source/WebCore/ChangeLog (203695 => 203696)


--- trunk/Source/WebCore/ChangeLog	2016-07-25 19:57:47 UTC (rev 203695)
+++ trunk/Source/WebCore/ChangeLog	2016-07-25 20:35:16 UTC (rev 203696)
@@ -1,3 +1,38 @@
+2016-07-25  Jiewen Tan  <jiewen_...@apple.com>
+
+        Rename SubtleCrypto to WebKitSubtleCrypto
+        https://bugs.webkit.org/show_bug.cgi?id=160067
+        <rdar://problem/27483617>
+
+        Reviewed by Brent Fulgham.
+
+        Tests: crypto/webkitSubtle/gc-2.html
+               crypto/webkitSubtle/gc-3.html
+               crypto/webkitSubtle/gc.html
+
+        Rename Class SubtleCrypto to WebKitSubtleCrypto, and Crypto.subtle to Crypto.webkitSubtle in order
+        to let the new implementation to reuse the name SubtleCrypto. This renaming should match what our
+        current JSBindings use, and therefore should not introduce any change of behavoir.
+
+        * CMakeLists.txt:
+        Revise project files for for new file names.
+        * DerivedSources.cpp:
+        * DerivedSources.make:
+        * PlatformEfl.cmake:
+        * PlatformGTK.cmake:
+        * PlatformMac.cmake:
+        * WebCore.xcodeproj/project.pbxproj:
+        Revise project files for for new file names.
+        * bindings/js/JSWebKitSubtleCryptoCustom.cpp: Renamed from Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp.
+        * crypto/WebKitSubtleCrypto.cpp: Renamed from Source/WebCore/crypto/SubtleCrypto.cpp.
+        * crypto/WebKitSubtleCrypto.h: Renamed from Source/WebCore/crypto/SubtleCrypto.h.
+        * crypto/WebKitSubtleCrypto.idl: Renamed from Source/WebCore/crypto/SubtleCrypto.idl.
+        * page/Crypto.cpp:
+        (WebCore::Crypto::webkitSubtle):
+        (WebCore::Crypto::subtle): Deleted.
+        * page/Crypto.h:
+        * page/Crypto.idl:
+
 2016-07-25  Brady Eidson  <beid...@apple.com>
 
         Allow LocalStorage by default for file URLs.

Modified: trunk/Source/WebCore/DerivedSources.cpp (203695 => 203696)


--- trunk/Source/WebCore/DerivedSources.cpp	2016-07-25 19:57:47 UTC (rev 203695)
+++ trunk/Source/WebCore/DerivedSources.cpp	2016-07-25 20:35:16 UTC (rev 203696)
@@ -427,7 +427,6 @@
 #include "JSSpeechSynthesisEvent.cpp"
 #include "JSSpeechSynthesisUtterance.cpp"
 #include "JSSpeechSynthesisVoice.cpp"
-#include "JSSubtleCrypto.cpp"
 #include "JSSQLError.cpp"
 #include "JSSQLException.cpp"
 #include "JSSQLResultSet.cpp"
@@ -646,6 +645,7 @@
 #include "JSWebKitNamespace.cpp"
 #include "JSWebKitPlaybackTargetAvailabilityEvent.cpp"
 #include "JSWebKitPoint.cpp"
+#include "JSWebKitSubtleCrypto.cpp"
 #include "JSWebKitTransitionEvent.cpp"
 #include "JSWebSocket.cpp"
 #include "JSWheelEvent.cpp"

Modified: trunk/Source/WebCore/DerivedSources.make (203695 => 203696)


--- trunk/Source/WebCore/DerivedSources.make	2016-07-25 19:57:47 UTC (rev 203695)
+++ trunk/Source/WebCore/DerivedSources.make	2016-07-25 20:35:16 UTC (rev 203696)
@@ -235,7 +235,7 @@
     $(WebCore)/animation/DocumentTimeline.idl \
     $(WebCore)/crypto/CryptoKey.idl \
     $(WebCore)/crypto/CryptoKeyPair.idl \
-    $(WebCore)/crypto/SubtleCrypto.idl \
+    $(WebCore)/crypto/WebKitSubtleCrypto.idl \
     $(WebCore)/css/CSSCharsetRule.idl \
     $(WebCore)/css/CSSFontFaceLoadEvent.idl \
     $(WebCore)/css/CSSFontFaceRule.idl \

Modified: trunk/Source/WebCore/PlatformEfl.cmake (203695 => 203696)


--- trunk/Source/WebCore/PlatformEfl.cmake	2016-07-25 19:57:47 UTC (rev 203695)
+++ trunk/Source/WebCore/PlatformEfl.cmake	2016-07-25 20:35:16 UTC (rev 203696)
@@ -403,7 +403,7 @@
         crypto/CryptoAlgorithmRegistry.cpp
         crypto/CryptoKey.cpp
         crypto/CryptoKeyPair.cpp
-        crypto/SubtleCrypto.cpp
+        crypto/WebKitSubtleCrypto.cpp
 
         crypto/algorithms/CryptoAlgorithmAES_CBC.cpp
         crypto/algorithms/CryptoAlgorithmAES_KW.cpp

Modified: trunk/Source/WebCore/PlatformGTK.cmake (203695 => 203696)


--- trunk/Source/WebCore/PlatformGTK.cmake	2016-07-25 19:57:47 UTC (rev 203695)
+++ trunk/Source/WebCore/PlatformGTK.cmake	2016-07-25 20:35:16 UTC (rev 203696)
@@ -797,7 +797,7 @@
         crypto/CryptoAlgorithmRegistry.cpp
         crypto/CryptoKey.cpp
         crypto/CryptoKeyPair.cpp
-        crypto/SubtleCrypto.cpp
+        crypto/WebKitSubtleCrypto.cpp
 
         crypto/algorithms/CryptoAlgorithmAES_CBC.cpp
         crypto/algorithms/CryptoAlgorithmAES_KW.cpp

Modified: trunk/Source/WebCore/PlatformMac.cmake (203695 => 203696)


--- trunk/Source/WebCore/PlatformMac.cmake	2016-07-25 19:57:47 UTC (rev 203695)
+++ trunk/Source/WebCore/PlatformMac.cmake	2016-07-25 20:35:16 UTC (rev 203696)
@@ -196,7 +196,7 @@
     crypto/CryptoAlgorithmRegistry.cpp
     crypto/CryptoKey.cpp
     crypto/CryptoKeyPair.cpp
-    crypto/SubtleCrypto.cpp
+    crypto/WebKitSubtleCrypto.cpp
 
     crypto/algorithms/CryptoAlgorithmAES_CBC.cpp
     crypto/algorithms/CryptoAlgorithmAES_KW.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (203695 => 203696)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-07-25 19:57:47 UTC (rev 203695)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-07-25 20:35:16 UTC (rev 203696)
@@ -2337,6 +2337,11 @@
 		550A0BCA085F6039007353D6 /* QualifiedName.h in Headers */ = {isa = PBXBuildFile; fileRef = 550A0BC8085F6039007353D6 /* QualifiedName.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		555B87EC1CAAF0AB00349425 /* ImageDecoderCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 555B87EA1CAAF0AB00349425 /* ImageDecoderCG.cpp */; };
 		555B87ED1CAAF0AB00349425 /* ImageDecoderCG.h in Headers */ = {isa = PBXBuildFile; fileRef = 555B87EB1CAAF0AB00349425 /* ImageDecoderCG.h */; };
+		5709E8CD1D413D47003244AC /* WebKitSubtleCrypto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5709E8CA1D413CE3003244AC /* WebKitSubtleCrypto.cpp */; };
+		5709E8CE1D413D5B003244AC /* JSWebKitSubtleCryptoCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FF8F661807460800132674 /* JSWebKitSubtleCryptoCustom.cpp */; };
+		5709E8CF1D413D9A003244AC /* WebKitSubtleCrypto.h in Headers */ = {isa = PBXBuildFile; fileRef = 5709E8CB1D413CE3003244AC /* WebKitSubtleCrypto.h */; };
+		570A99DA1D417408004EC630 /* JSWebKitSubtleCrypto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FF8F62180745D800132674 /* JSWebKitSubtleCrypto.cpp */; };
+		570A99DB1D41A2F3004EC630 /* JSWebKitSubtleCrypto.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FF8F63180745D800132674 /* JSWebKitSubtleCrypto.h */; };
 		572A7F211C6E5719009C6149 /* SimulatedClick.h in Headers */ = {isa = PBXBuildFile; fileRef = 572A7F201C6E5719009C6149 /* SimulatedClick.h */; };
 		572A7F231C6E5A66009C6149 /* SimulatedClick.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 572A7F221C6E5A66009C6149 /* SimulatedClick.cpp */; };
 		57EF5E601D20C83900171E60 /* TextCodecReplacement.h in Headers */ = {isa = PBXBuildFile; fileRef = 57EF5E5F1D20C83900171E60 /* TextCodecReplacement.h */; };
@@ -6637,11 +6642,6 @@
 		E1FE137E184D270200892F13 /* CryptoAlgorithmAES_KWMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FE137C184D270200892F13 /* CryptoAlgorithmAES_KWMac.cpp */; };
 		E1FF57A30F01255B00891EBB /* ThreadGlobalData.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FF57A20F01255B00891EBB /* ThreadGlobalData.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		E1FF57A60F01256B00891EBB /* ThreadGlobalData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FF57A50F01256B00891EBB /* ThreadGlobalData.cpp */; };
-		E1FF8F5F1807442100132674 /* SubtleCrypto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FF8F5D1807442100132674 /* SubtleCrypto.cpp */; };
-		E1FF8F601807442100132674 /* SubtleCrypto.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FF8F5E1807442100132674 /* SubtleCrypto.h */; };
-		E1FF8F64180745D800132674 /* JSSubtleCrypto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FF8F62180745D800132674 /* JSSubtleCrypto.cpp */; };
-		E1FF8F65180745D800132674 /* JSSubtleCrypto.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FF8F63180745D800132674 /* JSSubtleCrypto.h */; };
-		E1FF8F681807460800132674 /* JSSubtleCryptoCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FF8F661807460800132674 /* JSSubtleCryptoCustom.cpp */; };
 		E1FF8F6C180DB5BE00132674 /* CryptoAlgorithmRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FF8F6A180DB5BE00132674 /* CryptoAlgorithmRegistry.cpp */; };
 		E1FF8F6D180DB5BE00132674 /* CryptoAlgorithmRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FF8F6B180DB5BE00132674 /* CryptoAlgorithmRegistry.h */; };
 		E38838981BAD145F00D62EE3 /* JSModuleLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38838941BAD145F00D62EE3 /* JSModuleLoader.cpp */; };
@@ -10016,6 +10016,9 @@
 		555B87EA1CAAF0AB00349425 /* ImageDecoderCG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageDecoderCG.cpp; sourceTree = "<group>"; };
 		555B87EB1CAAF0AB00349425 /* ImageDecoderCG.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageDecoderCG.h; sourceTree = "<group>"; };
 		55D408F71A7C631800C78450 /* SVGImageClients.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGImageClients.h; sourceTree = "<group>"; };
+		5709E8CA1D413CE3003244AC /* WebKitSubtleCrypto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebKitSubtleCrypto.cpp; sourceTree = "<group>"; };
+		5709E8CB1D413CE3003244AC /* WebKitSubtleCrypto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitSubtleCrypto.h; sourceTree = "<group>"; };
+		5709E8CC1D413CE3003244AC /* WebKitSubtleCrypto.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebKitSubtleCrypto.idl; sourceTree = "<group>"; };
 		572A7F201C6E5719009C6149 /* SimulatedClick.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimulatedClick.h; sourceTree = "<group>"; };
 		572A7F221C6E5A66009C6149 /* SimulatedClick.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimulatedClick.cpp; sourceTree = "<group>"; };
 		57EF5E5F1D20C83900171E60 /* TextCodecReplacement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextCodecReplacement.h; sourceTree = "<group>"; };
@@ -13410,8 +13413,8 @@
 		B57CB52C182A3EED0079A647 /* InlineElementBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InlineElementBox.cpp; sourceTree = "<group>"; };
 		B595FF461824CEE300FF51CD /* RenderIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderIterator.h; sourceTree = "<group>"; };
 		B59CA59AF170D8FAA5B8C9AD /* MathMLScriptsElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MathMLScriptsElement.cpp; sourceTree = "<group>"; };
+		B59CA59AF170D8FAA5B8CABE /* MathMLPaddedElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MathMLPaddedElement.cpp; sourceTree = "<group>"; };
 		B59CA849D41E6F65D81197AB /* MathMLScriptsElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MathMLScriptsElement.h; sourceTree = "<group>"; };
-		B59CA59AF170D8FAA5B8CABE /* MathMLPaddedElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MathMLPaddedElement.cpp; sourceTree = "<group>"; };
 		B59CA849D41E6F65D81198BC /* MathMLPaddedElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MathMLPaddedElement.h; sourceTree = "<group>"; };
 		B59DD697119029E5007E9684 /* JSDatabaseCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDatabaseCallback.h; sourceTree = "<group>"; };
 		B59DD698119029E5007E9684 /* JSDatabaseCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDatabaseCallback.cpp; sourceTree = "<group>"; };
@@ -14784,12 +14787,9 @@
 		E1FE137C184D270200892F13 /* CryptoAlgorithmAES_KWMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoAlgorithmAES_KWMac.cpp; sourceTree = "<group>"; };
 		E1FF57A20F01255B00891EBB /* ThreadGlobalData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadGlobalData.h; sourceTree = "<group>"; };
 		E1FF57A50F01256B00891EBB /* ThreadGlobalData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadGlobalData.cpp; sourceTree = "<group>"; };
-		E1FF8F5C1807364B00132674 /* SubtleCrypto.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = SubtleCrypto.idl; sourceTree = "<group>"; };
-		E1FF8F5D1807442100132674 /* SubtleCrypto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SubtleCrypto.cpp; sourceTree = "<group>"; };
-		E1FF8F5E1807442100132674 /* SubtleCrypto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SubtleCrypto.h; sourceTree = "<group>"; };
-		E1FF8F62180745D800132674 /* JSSubtleCrypto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSubtleCrypto.cpp; sourceTree = "<group>"; };
-		E1FF8F63180745D800132674 /* JSSubtleCrypto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSSubtleCrypto.h; sourceTree = "<group>"; };
-		E1FF8F661807460800132674 /* JSSubtleCryptoCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSubtleCryptoCustom.cpp; sourceTree = "<group>"; };
+		E1FF8F62180745D800132674 /* JSWebKitSubtleCrypto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebKitSubtleCrypto.cpp; sourceTree = "<group>"; };
+		E1FF8F63180745D800132674 /* JSWebKitSubtleCrypto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebKitSubtleCrypto.h; sourceTree = "<group>"; };
+		E1FF8F661807460800132674 /* JSWebKitSubtleCryptoCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebKitSubtleCryptoCustom.cpp; sourceTree = "<group>"; };
 		E1FF8F6A180DB5BE00132674 /* CryptoAlgorithmRegistry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoAlgorithmRegistry.cpp; sourceTree = "<group>"; };
 		E1FF8F6B180DB5BE00132674 /* CryptoAlgorithmRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmRegistry.h; sourceTree = "<group>"; };
 		E38838941BAD145F00D62EE3 /* JSModuleLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSModuleLoader.cpp; sourceTree = "<group>"; };
@@ -22769,7 +22769,6 @@
 				BC98A27C0C0C9950004BEBF7 /* JSStyleSheetCustom.cpp */,
 				AD726FEC16D9F4B9003A4E6D /* JSStyleSheetCustom.h */,
 				A84EBD770CB8C89200079609 /* JSStyleSheetListCustom.cpp */,
-				E1FF8F661807460800132674 /* JSSubtleCryptoCustom.cpp */,
 				08E4FE450E2BD41400F4CAE0 /* JSSVGLengthCustom.cpp */,
 				B2C96D8C0B3AF2B7005E80EC /* JSSVGPathSegCustom.cpp */,
 				07E117061489EBEB00EC5ACE /* JSTextTrackCueCustom.cpp */,
@@ -22785,6 +22784,7 @@
 				D3F3D3591A69A3B00059FC2B /* JSWebGL2RenderingContextCustom.cpp */,
 				D3F3D35A1A69A3B00059FC2B /* JSWebGLRenderingContextBaseCustom.cpp */,
 				49EED14C1051971A00099FAB /* JSWebGLRenderingContextCustom.cpp */,
+				E1FF8F661807460800132674 /* JSWebKitSubtleCryptoCustom.cpp */,
 				BC275B7811C5D1C300C9206C /* JSWebKitPointCustom.cpp */,
 				E1CA5CBB0E8CDCAF00E8EF90 /* JSWorkerCustom.cpp */,
 				E18258AB0EF3CD7000933242 /* JSWorkerGlobalScopeCustom.cpp */,
@@ -23794,9 +23794,9 @@
 				E19727151820549E00592D51 /* CryptoKeyType.h */,
 				E172AF6F180F289500FBADB9 /* CryptoKeyUsage.h */,
 				E18DF33418AAF12C00773E59 /* SerializedCryptoKeyWrap.h */,
-				E1FF8F5D1807442100132674 /* SubtleCrypto.cpp */,
-				E1FF8F5E1807442100132674 /* SubtleCrypto.h */,
-				E1FF8F5C1807364B00132674 /* SubtleCrypto.idl */,
+				5709E8CA1D413CE3003244AC /* WebKitSubtleCrypto.cpp */,
+				5709E8CB1D413CE3003244AC /* WebKitSubtleCrypto.h */,
+				5709E8CC1D413CE3003244AC /* WebKitSubtleCrypto.idl */,
 			);
 			path = crypto;
 			sourceTree = "<group>";
@@ -23808,8 +23808,8 @@
 				E157A8DF1817331C009F821D /* JSCryptoKey.h */,
 				E1F80B8B183172B5007885C3 /* JSCryptoKeyPair.cpp */,
 				E1F80B8C183172B5007885C3 /* JSCryptoKeyPair.h */,
-				E1FF8F62180745D800132674 /* JSSubtleCrypto.cpp */,
-				E1FF8F63180745D800132674 /* JSSubtleCrypto.h */,
+				E1FF8F62180745D800132674 /* JSWebKitSubtleCrypto.cpp */,
+				E1FF8F63180745D800132674 /* JSWebKitSubtleCrypto.h */,
 			);
 			name = Crypto;
 			sourceTree = "<group>";
@@ -26581,6 +26581,8 @@
 				A871D4560A127CBC00B12A68 /* HTMLPlugInElement.h in Headers */,
 				4415292E0E1AE8A000C4A2D0 /* HTMLPlugInImageElement.h in Headers */,
 				A8EA7CB00A192B9C00A8EF5F /* HTMLPreElement.h in Headers */,
+				570A99DB1D41A2F3004EC630 /* JSWebKitSubtleCrypto.h in Headers */,
+				5709E8CF1D413D9A003244AC /* WebKitSubtleCrypto.h in Headers */,
 				977B3873122883E900B81FF8 /* HTMLPreloadScanner.h in Headers */,
 				A43BF5991149290A00C643CA /* HTMLProgressElement.h in Headers */,
 				A8CFF7A30A156978000A4234 /* HTMLQuoteElement.h in Headers */,
@@ -27147,7 +27149,6 @@
 				BCE0139B0C0BEF180043860A /* JSStyleSheet.h in Headers */,
 				AD726FEE16DA11BC003A4E6D /* JSStyleSheetCustom.h in Headers */,
 				A84EBD830CB8C97700079609 /* JSStyleSheetList.h in Headers */,
-				E1FF8F65180745D800132674 /* JSSubtleCrypto.h in Headers */,
 				B20111080AB7740500DB0E68 /* JSSVGAElement.h in Headers */,
 				24D9129213CA951E00D21915 /* JSSVGAltGlyphDefElement.h in Headers */,
 				6515EC920D9723FF0063D49A /* JSSVGAltGlyphElement.h in Headers */,
@@ -28377,7 +28378,6 @@
 				1AE96A931D1A0DDD00B86768 /* JSApplePayShippingMethodSelectedEvent.h in Headers */,
 				1A8F6B020DB53006001DB794 /* SubstituteResource.h in Headers */,
 				1AE96A8B1D1A0DDD00B86768 /* JSApplePayPaymentAuthorizedEvent.h in Headers */,
-				E1FF8F601807442100132674 /* SubtleCrypto.h in Headers */,
 				93B2D8160F9920D2006AE6B2 /* SuddenTermination.h in Headers */,
 				97C078501165D5BE003A32EF /* SuffixTree.h in Headers */,
 				97627B9814FB5424002CDCA1 /* Supplementable.h in Headers */,
@@ -29324,6 +29324,8 @@
 			isa = PBXSourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				5709E8CE1D413D5B003244AC /* JSWebKitSubtleCryptoCustom.cpp in Sources */,
+				5709E8CD1D413D47003244AC /* WebKitSubtleCrypto.cpp in Sources */,
 				41E1B1D00FF5986900576B3B /* AbstractWorker.cpp in Sources */,
 				37F57AB91A50726900876F98 /* AccessibilityARIAGrid.cpp in Sources */,
 				37F57ABA1A50726F00876F98 /* AccessibilityARIAGridCell.cpp in Sources */,
@@ -30347,6 +30349,7 @@
 				0707568B142262D600414161 /* HTMLTrackElement.cpp in Sources */,
 				977B37251228721700B81FF8 /* HTMLTreeBuilder.cpp in Sources */,
 				A8EA79F30A1916DF00A8EF5F /* HTMLUListElement.cpp in Sources */,
+				570A99DA1D417408004EC630 /* JSWebKitSubtleCrypto.cpp in Sources */,
 				E44613AA0CD6331000FADA75 /* HTMLVideoElement.cpp in Sources */,
 				839AAFEC1A0C0C8D00605F99 /* HTMLWBRElement.cpp in Sources */,
 				0B8C56D40F28627F000502E1 /* HTTPHeaderMap.cpp in Sources */,
@@ -30959,8 +30962,6 @@
 				BC98A27D0C0C9950004BEBF7 /* JSStyleSheetCustom.cpp in Sources */,
 				A84EBD840CB8C97700079609 /* JSStyleSheetList.cpp in Sources */,
 				A84EBD780CB8C89200079609 /* JSStyleSheetListCustom.cpp in Sources */,
-				E1FF8F64180745D800132674 /* JSSubtleCrypto.cpp in Sources */,
-				E1FF8F681807460800132674 /* JSSubtleCryptoCustom.cpp in Sources */,
 				B20111070AB7740500DB0E68 /* JSSVGAElement.cpp in Sources */,
 				24D9129113CA951E00D21915 /* JSSVGAltGlyphDefElement.cpp in Sources */,
 				6515EC910D9723FF0063D49A /* JSSVGAltGlyphElement.cpp in Sources */,
@@ -32019,7 +32020,6 @@
 				93E227E40AF589AD00D48324 /* SubresourceLoader.cpp in Sources */,
 				7E37EF2E1339208800B29250 /* SubresourceLoaderCF.cpp in Sources */,
 				7E8FADC4199A95B100714968 /* SubresourceLoaderCocoa.mm in Sources */,
-				E1FF8F5F1807442100132674 /* SubtleCrypto.cpp in Sources */,
 				93B2D8180F9920EE006AE6B2 /* SuddenTermination.mm in Sources */,
 				087558C513B4A57D00F49307 /* SurrogatePairAwareTextIterator.cpp in Sources */,
 				62C1217C11AB9E77003C462C /* SuspendableTimer.cpp in Sources */,

Deleted: trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp (203695 => 203696)


--- trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp	2016-07-25 19:57:47 UTC (rev 203695)
+++ trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp	2016-07-25 20:35:16 UTC (rev 203696)
@@ -1,805 +0,0 @@
-/*
- * Copyright (C) 2013 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. AND ITS CONTRIBUTORS ``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 ITS 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 "JSSubtleCrypto.h"
-
-#if ENABLE(SUBTLE_CRYPTO)
-
-#include "CryptoAlgorithm.h"
-#include "CryptoAlgorithmParameters.h"
-#include "CryptoAlgorithmRegistry.h"
-#include "CryptoKeyData.h"
-#include "CryptoKeySerializationRaw.h"
-#include "Document.h"
-#include "ExceptionCode.h"
-#include "JSCryptoAlgorithmDictionary.h"
-#include "JSCryptoKey.h"
-#include "JSCryptoKeyPair.h"
-#include "JSCryptoKeySerializationJWK.h"
-#include "JSCryptoOperationData.h"
-#include "JSDOMPromise.h"
-#include <runtime/Error.h>
-
-using namespace JSC;
-
-namespace WebCore {
-
-enum class CryptoKeyFormat {
-    // An unformatted sequence of bytes. Intended for secret keys.
-    Raw,
-
-    // The DER encoding of the PrivateKeyInfo structure from RFC 5208.
-    PKCS8,
-
-    // The DER encoding of the SubjectPublicKeyInfo structure from RFC 5280.
-    SPKI,
-
-    // The key is represented as JSON according to the JSON Web Key format.
-    JWK
-};
-
-static RefPtr<CryptoAlgorithm> createAlgorithmFromJSValue(ExecState& state, JSValue value)
-{
-    CryptoAlgorithmIdentifier algorithmIdentifier;
-    if (!JSCryptoAlgorithmDictionary::getAlgorithmIdentifier(&state, value, algorithmIdentifier)) {
-        ASSERT(state.hadException());
-        return nullptr;
-    }
-
-    auto result = CryptoAlgorithmRegistry::singleton().create(algorithmIdentifier);
-    if (!result)
-        setDOMException(&state, NOT_SUPPORTED_ERR);
-    return result;
-}
-
-static bool cryptoKeyFormatFromJSValue(ExecState& state, JSValue value, CryptoKeyFormat& result)
-{
-    String keyFormatString = value.toString(&state)->value(&state);
-    if (state.hadException())
-        return false;
-    if (keyFormatString == "raw")
-        result = CryptoKeyFormat::Raw;
-    else if (keyFormatString == "pkcs8")
-        result = CryptoKeyFormat::PKCS8;
-    else if (keyFormatString == "spki")
-        result = CryptoKeyFormat::SPKI;
-    else if (keyFormatString == "jwk")
-        result = CryptoKeyFormat::JWK;
-    else {
-        throwTypeError(&state, ASCIILiteral("Unknown key format"));
-        return false;
-    }
-    return true;
-}
-
-static bool cryptoKeyUsagesFromJSValue(ExecState& state, JSValue value, CryptoKeyUsage& result)
-{
-    if (!isJSArray(value)) {
-        throwTypeError(&state);
-        return false;
-    }
-
-    result = 0;
-
-    JSArray* array = asArray(value);
-    for (size_t i = 0; i < array->length(); ++i) {
-        JSValue element = array->getIndex(&state, i);
-        String usageString = element.toString(&state)->value(&state);
-        if (state.hadException())
-            return false;
-        if (usageString == "encrypt")
-            result |= CryptoKeyUsageEncrypt;
-        else if (usageString == "decrypt")
-            result |= CryptoKeyUsageDecrypt;
-        else if (usageString == "sign")
-            result |= CryptoKeyUsageSign;
-        else if (usageString == "verify")
-            result |= CryptoKeyUsageVerify;
-        else if (usageString == "deriveKey")
-            result |= CryptoKeyUsageDeriveKey;
-        else if (usageString == "deriveBits")
-            result |= CryptoKeyUsageDeriveBits;
-        else if (usageString == "wrapKey")
-            result |= CryptoKeyUsageWrapKey;
-        else if (usageString == "unwrapKey")
-            result |= CryptoKeyUsageUnwrapKey;
-    }
-    return true;
-}
-
-JSValue JSSubtleCrypto::encrypt(ExecState& state)
-{
-    if (state.argumentCount() < 3)
-        return state.vm().throwException(&state, createNotEnoughArgumentsError(&state));
-
-    auto algorithm = createAlgorithmFromJSValue(state, state.uncheckedArgument(0));
-    if (!algorithm) {
-        ASSERT(state.hadException());
-        return jsUndefined();
-    }
-
-    auto parameters = JSCryptoAlgorithmDictionary::createParametersForEncrypt(&state, algorithm->identifier(), state.uncheckedArgument(0));
-    if (!parameters) {
-        ASSERT(state.hadException());
-        return jsUndefined();
-    }
-
-    RefPtr<CryptoKey> key = JSCryptoKey::toWrapped(state.uncheckedArgument(1));
-    if (!key)
-        return throwTypeError(&state);
-
-    if (!key->allows(CryptoKeyUsageEncrypt)) {
-        wrapped().document()->addConsoleMessage(MessageSource::JS, MessageLevel::Error, ASCIILiteral("Key usages do not include 'encrypt'"));
-        setDOMException(&state, NOT_SUPPORTED_ERR);
-        return jsUndefined();
-    }
-
-    CryptoOperationData data;
-    if (!cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(2), data)) {
-        ASSERT(state.hadException());
-        return jsUndefined();
-    }
-
-    
-    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(&state, globalObject());
-    DeferredWrapper wrapper(&state, globalObject(), promiseDeferred);
-    auto successCallback = [wrapper](const Vector<uint8_t>& result) mutable {
-        fulfillPromiseWithArrayBuffer(wrapper, result.data(), result.size());
-    };
-    auto failureCallback = [wrapper]() mutable {
-        wrapper.reject(nullptr);
-    };
-
-    ExceptionCode ec = 0;
-    algorithm->encrypt(*parameters, *key, data, WTFMove(successCallback), WTFMove(failureCallback), ec);
-    if (ec) {
-        setDOMException(&state, ec);
-        return jsUndefined();
-    }
-
-    return promiseDeferred->promise();
-}
-
-JSValue JSSubtleCrypto::decrypt(ExecState& state)
-{
-    if (state.argumentCount() < 3)
-        return state.vm().throwException(&state, createNotEnoughArgumentsError(&state));
-
-    auto algorithm = createAlgorithmFromJSValue(state, state.uncheckedArgument(0));
-    if (!algorithm) {
-        ASSERT(state.hadException());
-        return jsUndefined();
-    }
-
-    auto parameters = JSCryptoAlgorithmDictionary::createParametersForDecrypt(&state, algorithm->identifier(), state.uncheckedArgument(0));
-    if (!parameters) {
-        ASSERT(state.hadException());
-        return jsUndefined();
-    }
-
-    RefPtr<CryptoKey> key = JSCryptoKey::toWrapped(state.uncheckedArgument(1));
-    if (!key)
-        return throwTypeError(&state);
-
-    if (!key->allows(CryptoKeyUsageDecrypt)) {
-        wrapped().document()->addConsoleMessage(MessageSource::JS, MessageLevel::Error, ASCIILiteral("Key usages do not include 'decrypt'"));
-        setDOMException(&state, NOT_SUPPORTED_ERR);
-        return jsUndefined();
-    }
-
-    CryptoOperationData data;
-    if (!cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(2), data)) {
-        ASSERT(state.hadException());
-        return jsUndefined();
-    }
-
-    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(&state, globalObject());
-    DeferredWrapper wrapper(&state, globalObject(), promiseDeferred);
-    auto successCallback = [wrapper](const Vector<uint8_t>& result) mutable {
-        fulfillPromiseWithArrayBuffer(wrapper, result.data(), result.size());
-    };
-    auto failureCallback = [wrapper]() mutable {
-        wrapper.reject(nullptr);
-    };
-
-    ExceptionCode ec = 0;
-    algorithm->decrypt(*parameters, *key, data, WTFMove(successCallback), WTFMove(failureCallback), ec);
-    if (ec) {
-        setDOMException(&state, ec);
-        return jsUndefined();
-    }
-
-    return promiseDeferred->promise();
-}
-
-JSValue JSSubtleCrypto::sign(ExecState& state)
-{
-    if (state.argumentCount() < 3)
-        return state.vm().throwException(&state, createNotEnoughArgumentsError(&state));
-
-    auto algorithm = createAlgorithmFromJSValue(state, state.uncheckedArgument(0));
-    if (!algorithm) {
-        ASSERT(state.hadException());
-        return jsUndefined();
-    }
-
-    auto parameters = JSCryptoAlgorithmDictionary::createParametersForSign(&state, algorithm->identifier(), state.uncheckedArgument(0));
-    if (!parameters) {
-        ASSERT(state.hadException());
-        return jsUndefined();
-    }
-
-    RefPtr<CryptoKey> key = JSCryptoKey::toWrapped(state.uncheckedArgument(1));
-    if (!key)
-        return throwTypeError(&state);
-
-    if (!key->allows(CryptoKeyUsageSign)) {
-        wrapped().document()->addConsoleMessage(MessageSource::JS, MessageLevel::Error, ASCIILiteral("Key usages do not include 'sign'"));
-        setDOMException(&state, NOT_SUPPORTED_ERR);
-        return jsUndefined();
-    }
-
-    CryptoOperationData data;
-    if (!cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(2), data)) {
-        ASSERT(state.hadException());
-        return jsUndefined();
-    }
-
-    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(&state, globalObject());
-    DeferredWrapper wrapper(&state, globalObject(), promiseDeferred);
-    auto successCallback = [wrapper](const Vector<uint8_t>& result) mutable {
-        fulfillPromiseWithArrayBuffer(wrapper, result.data(), result.size());
-    };
-    auto failureCallback = [wrapper]() mutable {
-        wrapper.reject(nullptr);
-    };
-
-    ExceptionCode ec = 0;
-    algorithm->sign(*parameters, *key, data, WTFMove(successCallback), WTFMove(failureCallback), ec);
-    if (ec) {
-        setDOMException(&state, ec);
-        return jsUndefined();
-    }
-
-    return promiseDeferred->promise();
-}
-
-JSValue JSSubtleCrypto::verify(ExecState& state)
-{
-    if (state.argumentCount() < 4)
-        return state.vm().throwException(&state, createNotEnoughArgumentsError(&state));
-
-    auto algorithm = createAlgorithmFromJSValue(state, state.uncheckedArgument(0));
-    if (!algorithm) {
-        ASSERT(state.hadException());
-        return jsUndefined();
-    }
-
-    auto parameters = JSCryptoAlgorithmDictionary::createParametersForVerify(&state, algorithm->identifier(), state.uncheckedArgument(0));
-    if (!parameters) {
-        ASSERT(state.hadException());
-        return jsUndefined();
-    }
-
-    RefPtr<CryptoKey> key = JSCryptoKey::toWrapped(state.uncheckedArgument(1));
-    if (!key)
-        return throwTypeError(&state);
-
-    if (!key->allows(CryptoKeyUsageVerify)) {
-        wrapped().document()->addConsoleMessage(MessageSource::JS, MessageLevel::Error, ASCIILiteral("Key usages do not include 'verify'"));
-        setDOMException(&state, NOT_SUPPORTED_ERR);
-        return jsUndefined();
-    }
-
-    CryptoOperationData signature;
-    if (!cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(2), signature)) {
-        ASSERT(state.hadException());
-        return jsUndefined();
-    }
-
-    CryptoOperationData data;
-    if (!cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(3), data)) {
-        ASSERT(state.hadException());
-        return jsUndefined();
-    }
-
-    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(&state, globalObject());
-    DeferredWrapper wrapper(&state, globalObject(), promiseDeferred);
-    auto successCallback = [wrapper](bool result) mutable {
-        wrapper.resolve(result);
-    };
-    auto failureCallback = [wrapper]() mutable {
-        wrapper.reject(nullptr);
-    };
-
-    ExceptionCode ec = 0;
-    algorithm->verify(*parameters, *key, signature, data, WTFMove(successCallback), WTFMove(failureCallback), ec);
-    if (ec) {
-        setDOMException(&state, ec);
-        return jsUndefined();
-    }
-
-    return promiseDeferred->promise();
-}
-
-JSValue JSSubtleCrypto::digest(ExecState& state)
-{
-    if (state.argumentCount() < 2)
-        return state.vm().throwException(&state, createNotEnoughArgumentsError(&state));
-
-    auto algorithm = createAlgorithmFromJSValue(state, state.uncheckedArgument(0));
-    if (!algorithm) {
-        ASSERT(state.hadException());
-        return jsUndefined();
-    }
-
-    auto parameters = JSCryptoAlgorithmDictionary::createParametersForDigest(&state, algorithm->identifier(), state.uncheckedArgument(0));
-    if (!parameters) {
-        ASSERT(state.hadException());
-        return jsUndefined();
-    }
-
-    CryptoOperationData data;
-    if (!cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(1), data)) {
-        ASSERT(state.hadException());
-        return jsUndefined();
-    }
-
-    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(&state, globalObject());
-    DeferredWrapper wrapper(&state, globalObject(), promiseDeferred);
-    auto successCallback = [wrapper](const Vector<uint8_t>& result) mutable {
-        fulfillPromiseWithArrayBuffer(wrapper, result.data(), result.size());
-    };
-    auto failureCallback = [wrapper]() mutable {
-        wrapper.reject(nullptr);
-    };
-
-    ExceptionCode ec = 0;
-    algorithm->digest(*parameters, data, WTFMove(successCallback), WTFMove(failureCallback), ec);
-    if (ec) {
-        setDOMException(&state, ec);
-        return jsUndefined();
-    }
-
-    return promiseDeferred->promise();
-}
-
-JSValue JSSubtleCrypto::generateKey(ExecState& state)
-{
-    if (state.argumentCount() < 1)
-        return state.vm().throwException(&state, createNotEnoughArgumentsError(&state));
-
-    auto algorithm = createAlgorithmFromJSValue(state, state.uncheckedArgument(0));
-    if (!algorithm) {
-        ASSERT(state.hadException());
-        return jsUndefined();
-    }
-
-    auto parameters = JSCryptoAlgorithmDictionary::createParametersForGenerateKey(&state, algorithm->identifier(), state.uncheckedArgument(0));
-    if (!parameters) {
-        ASSERT(state.hadException());
-        return jsUndefined();
-    }
-
-    bool extractable = false;
-    if (state.argumentCount() >= 2) {
-        extractable = state.uncheckedArgument(1).toBoolean(&state);
-        if (state.hadException())
-            return jsUndefined();
-    }
-
-    CryptoKeyUsage keyUsages = 0;
-    if (state.argumentCount() >= 3) {
-        if (!cryptoKeyUsagesFromJSValue(state, state.argument(2), keyUsages)) {
-            ASSERT(state.hadException());
-            return jsUndefined();
-        }
-    }
-
-    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(&state, globalObject());
-    DeferredWrapper wrapper(&state, globalObject(), promiseDeferred);
-    auto successCallback = [wrapper](CryptoKey* key, CryptoKeyPair* keyPair) mutable {
-        ASSERT(key || keyPair);
-        ASSERT(!key || !keyPair);
-        if (key)
-            wrapper.resolve(key);
-        else
-            wrapper.resolve(keyPair);
-    };
-    auto failureCallback = [wrapper]() mutable {
-        wrapper.reject(nullptr);
-    };
-
-    ExceptionCode ec = 0;
-    algorithm->generateKey(*parameters, extractable, keyUsages, WTFMove(successCallback), WTFMove(failureCallback), ec);
-    if (ec) {
-        setDOMException(&state, ec);
-        return jsUndefined();
-    }
-
-    return promiseDeferred->promise();
-}
-
-static void importKey(ExecState& state, CryptoKeyFormat keyFormat, CryptoOperationData data, RefPtr<CryptoAlgorithm> algorithm, RefPtr<CryptoAlgorithmParameters> parameters, bool extractable, CryptoKeyUsage keyUsages, CryptoAlgorithm::KeyCallback callback, CryptoAlgorithm::VoidCallback failureCallback)
-{
-    std::unique_ptr<CryptoKeySerialization> keySerialization;
-    switch (keyFormat) {
-    case CryptoKeyFormat::Raw:
-        keySerialization = CryptoKeySerializationRaw::create(data);
-        break;
-    case CryptoKeyFormat::JWK: {
-        String jwkString = String::fromUTF8(data.first, data.second);
-        if (jwkString.isNull()) {
-            throwTypeError(&state, ASCIILiteral("JWK JSON serialization is not valid UTF-8"));
-            return;
-        }
-        keySerialization = std::make_unique<JSCryptoKeySerializationJWK>(&state, jwkString);
-        if (state.hadException())
-            return;
-        break;
-    }
-    default:
-        throwTypeError(&state, ASCIILiteral("Unsupported key format for import"));
-        return;
-    }
-
-    ASSERT(keySerialization);
-
-    Optional<CryptoAlgorithmPair> reconciledResult = keySerialization->reconcileAlgorithm(algorithm.get(), parameters.get());
-    if (!reconciledResult) {
-        if (!state.hadException())
-            throwTypeError(&state, ASCIILiteral("Algorithm specified in key is not compatible with one passed to importKey as argument"));
-        return;
-    }
-    if (state.hadException())
-        return;
-
-    algorithm = reconciledResult->algorithm;
-    parameters = reconciledResult->parameters;
-    if (!algorithm) {
-        throwTypeError(&state, ASCIILiteral("Neither key nor function argument has crypto algorithm specified"));
-        return;
-    }
-    ASSERT(parameters);
-
-    keySerialization->reconcileExtractable(extractable);
-    if (state.hadException())
-        return;
-
-    keySerialization->reconcileUsages(keyUsages);
-    if (state.hadException())
-        return;
-
-    auto keyData = keySerialization->keyData();
-    if (state.hadException())
-        return;
-
-    ExceptionCode ec = 0;
-    algorithm->importKey(*parameters, *keyData, extractable, keyUsages, WTFMove(callback), WTFMove(failureCallback), ec);
-    if (ec)
-        setDOMException(&state, ec);
-}
-
-JSValue JSSubtleCrypto::importKey(ExecState& state)
-{
-    if (state.argumentCount() < 3)
-        return state.vm().throwException(&state, createNotEnoughArgumentsError(&state));
-
-    CryptoKeyFormat keyFormat;
-    if (!cryptoKeyFormatFromJSValue(state, state.argument(0), keyFormat)) {
-        ASSERT(state.hadException());
-        return jsUndefined();
-    }
-
-    CryptoOperationData data;
-    if (!cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(1), data)) {
-        ASSERT(state.hadException());
-        return jsUndefined();
-    }
-
-    RefPtr<CryptoAlgorithm> algorithm;
-    RefPtr<CryptoAlgorithmParameters> parameters;
-    if (!state.uncheckedArgument(2).isNull()) {
-        algorithm = createAlgorithmFromJSValue(state, state.uncheckedArgument(2));
-        if (!algorithm) {
-            ASSERT(state.hadException());
-            return jsUndefined();
-        }
-        parameters = JSCryptoAlgorithmDictionary::createParametersForImportKey(&state, algorithm->identifier(), state.uncheckedArgument(2));
-        if (!parameters) {
-            ASSERT(state.hadException());
-            return jsUndefined();
-        }
-    }
-
-    bool extractable = false;
-    if (state.argumentCount() >= 4) {
-        extractable = state.uncheckedArgument(3).toBoolean(&state);
-        if (state.hadException())
-            return jsUndefined();
-    }
-
-    CryptoKeyUsage keyUsages = 0;
-    if (state.argumentCount() >= 5) {
-        if (!cryptoKeyUsagesFromJSValue(state, state.argument(4), keyUsages)) {
-            ASSERT(state.hadException());
-            return jsUndefined();
-        }
-    }
-
-    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(&state, globalObject());
-    DeferredWrapper wrapper(&state, globalObject(), promiseDeferred);
-    auto successCallback = [wrapper](CryptoKey& result) mutable {
-        wrapper.resolve(result);
-    };
-    auto failureCallback = [wrapper]() mutable {
-        wrapper.reject(nullptr);
-    };
-
-    WebCore::importKey(state, keyFormat, data, WTFMove(algorithm), WTFMove(parameters), extractable, keyUsages, WTFMove(successCallback), WTFMove(failureCallback));
-    if (state.hadException())
-        return jsUndefined();
-
-    return promiseDeferred->promise();
-}
-
-static void exportKey(ExecState& state, CryptoKeyFormat keyFormat, const CryptoKey& key, CryptoAlgorithm::VectorCallback callback, CryptoAlgorithm::VoidCallback failureCallback)
-{
-    if (!key.extractable()) {
-        throwTypeError(&state, ASCIILiteral("Key is not extractable"));
-        return;
-    }
-
-    switch (keyFormat) {
-    case CryptoKeyFormat::Raw: {
-        Vector<uint8_t> result;
-        if (CryptoKeySerializationRaw::serialize(key, result))
-            callback(result);
-        else
-            failureCallback();
-        break;
-    }
-    case CryptoKeyFormat::JWK: {
-        String result = JSCryptoKeySerializationJWK::serialize(&state, key);
-        if (state.hadException())
-            return;
-        CString utf8String = result.utf8(StrictConversion);
-        Vector<uint8_t> resultBuffer;
-        resultBuffer.append(utf8String.data(), utf8String.length());
-        callback(resultBuffer);
-        break;
-    }
-    default:
-        throwTypeError(&state, ASCIILiteral("Unsupported key format for export"));
-        break;
-    }
-}
-
-JSValue JSSubtleCrypto::exportKey(ExecState& state)
-{
-    if (state.argumentCount() < 2)
-        return state.vm().throwException(&state, createNotEnoughArgumentsError(&state));
-
-    CryptoKeyFormat keyFormat;
-    if (!cryptoKeyFormatFromJSValue(state, state.argument(0), keyFormat)) {
-        ASSERT(state.hadException());
-        return jsUndefined();
-    }
-
-    RefPtr<CryptoKey> key = JSCryptoKey::toWrapped(state.uncheckedArgument(1));
-    if (!key)
-        return throwTypeError(&state);
-
-    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(&state, globalObject());
-    DeferredWrapper wrapper(&state, globalObject(), promiseDeferred);
-    auto successCallback = [wrapper](const Vector<uint8_t>& result) mutable {
-        fulfillPromiseWithArrayBuffer(wrapper, result.data(), result.size());
-    };
-    auto failureCallback = [wrapper]() mutable {
-        wrapper.reject(nullptr);
-    };
-
-    WebCore::exportKey(state, keyFormat, *key, WTFMove(successCallback), WTFMove(failureCallback));
-    if (state.hadException())
-        return jsUndefined();
-
-    return promiseDeferred->promise();
-}
-
-JSValue JSSubtleCrypto::wrapKey(ExecState& state)
-{
-    if (state.argumentCount() < 4)
-        return state.vm().throwException(&state, createNotEnoughArgumentsError(&state));
-
-    CryptoKeyFormat keyFormat;
-    if (!cryptoKeyFormatFromJSValue(state, state.argument(0), keyFormat)) {
-        ASSERT(state.hadException());
-        return jsUndefined();
-    }
-
-    RefPtr<CryptoKey> key = JSCryptoKey::toWrapped(state.uncheckedArgument(1));
-    if (!key)
-        return throwTypeError(&state);
-
-    RefPtr<CryptoKey> wrappingKey = JSCryptoKey::toWrapped(state.uncheckedArgument(2));
-    if (!key)
-        return throwTypeError(&state);
-
-    if (!wrappingKey->allows(CryptoKeyUsageWrapKey)) {
-        wrapped().document()->addConsoleMessage(MessageSource::JS, MessageLevel::Error, ASCIILiteral("Key usages do not include 'wrapKey'"));
-        setDOMException(&state, NOT_SUPPORTED_ERR);
-        return jsUndefined();
-    }
-
-    auto algorithm = createAlgorithmFromJSValue(state, state.uncheckedArgument(3));
-    if (!algorithm) {
-        ASSERT(state.hadException());
-        return jsUndefined();
-    }
-
-    auto parameters = JSCryptoAlgorithmDictionary::createParametersForEncrypt(&state, algorithm->identifier(), state.uncheckedArgument(3));
-    if (!parameters) {
-        ASSERT(state.hadException());
-        return jsUndefined();
-    }
-
-    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(&state, globalObject());
-    DeferredWrapper wrapper(&state, globalObject(), promiseDeferred);
-
-    auto exportSuccessCallback = [keyFormat, algorithm, parameters, wrappingKey, wrapper](const Vector<uint8_t>& exportedKeyData) mutable {
-        auto encryptSuccessCallback = [wrapper](const Vector<uint8_t>& encryptedData) mutable {
-            fulfillPromiseWithArrayBuffer(wrapper, encryptedData.data(), encryptedData.size());
-        };
-        auto encryptFailureCallback = [wrapper]() mutable {
-            wrapper.reject(nullptr);
-        };
-        ExceptionCode ec = 0;
-        algorithm->encryptForWrapKey(*parameters, *wrappingKey, std::make_pair(exportedKeyData.data(), exportedKeyData.size()), WTFMove(encryptSuccessCallback), WTFMove(encryptFailureCallback), ec);
-        if (ec) {
-            // FIXME: Report failure details to console, and possibly to calling script once there is a standardized way to pass errors to WebCrypto promise reject functions.
-            wrapper.reject(nullptr);
-        }
-    };
-
-    auto exportFailureCallback = [wrapper]() mutable {
-        wrapper.reject(nullptr);
-    };
-
-    ExceptionCode ec = 0;
-    WebCore::exportKey(state, keyFormat, *key, WTFMove(exportSuccessCallback), WTFMove(exportFailureCallback));
-    if (ec) {
-        setDOMException(&state, ec);
-        return jsUndefined();
-    }
-
-    return promiseDeferred->promise();
-}
-
-JSValue JSSubtleCrypto::unwrapKey(ExecState& state)
-{
-    if (state.argumentCount() < 5)
-        return state.vm().throwException(&state, createNotEnoughArgumentsError(&state));
-
-    CryptoKeyFormat keyFormat;
-    if (!cryptoKeyFormatFromJSValue(state, state.argument(0), keyFormat)) {
-        ASSERT(state.hadException());
-        return jsUndefined();
-    }
-
-    CryptoOperationData wrappedKeyData;
-    if (!cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(1), wrappedKeyData)) {
-        ASSERT(state.hadException());
-        return jsUndefined();
-    }
-
-    RefPtr<CryptoKey> unwrappingKey = JSCryptoKey::toWrapped(state.uncheckedArgument(2));
-    if (!unwrappingKey)
-        return throwTypeError(&state);
-
-    if (!unwrappingKey->allows(CryptoKeyUsageUnwrapKey)) {
-        wrapped().document()->addConsoleMessage(MessageSource::JS, MessageLevel::Error, ASCIILiteral("Key usages do not include 'unwrapKey'"));
-        setDOMException(&state, NOT_SUPPORTED_ERR);
-        return jsUndefined();
-    }
-
-    auto unwrapAlgorithm = createAlgorithmFromJSValue(state, state.uncheckedArgument(3));
-    if (!unwrapAlgorithm) {
-        ASSERT(state.hadException());
-        return jsUndefined();
-    }
-    auto unwrapAlgorithmParameters = JSCryptoAlgorithmDictionary::createParametersForDecrypt(&state, unwrapAlgorithm->identifier(), state.uncheckedArgument(3));
-    if (!unwrapAlgorithmParameters) {
-        ASSERT(state.hadException());
-        return jsUndefined();
-    }
-
-    RefPtr<CryptoAlgorithm> unwrappedKeyAlgorithm;
-    RefPtr<CryptoAlgorithmParameters> unwrappedKeyAlgorithmParameters;
-    if (!state.uncheckedArgument(4).isNull()) {
-        unwrappedKeyAlgorithm = createAlgorithmFromJSValue(state, state.uncheckedArgument(4));
-        if (!unwrappedKeyAlgorithm) {
-            ASSERT(state.hadException());
-            return jsUndefined();
-        }
-        unwrappedKeyAlgorithmParameters = JSCryptoAlgorithmDictionary::createParametersForImportKey(&state, unwrappedKeyAlgorithm->identifier(), state.uncheckedArgument(4));
-        if (!unwrappedKeyAlgorithmParameters) {
-            ASSERT(state.hadException());
-            return jsUndefined();
-        }
-    }
-
-    bool extractable = false;
-    if (state.argumentCount() >= 6) {
-        extractable = state.uncheckedArgument(5).toBoolean(&state);
-        if (state.hadException())
-            return jsUndefined();
-    }
-
-    CryptoKeyUsage keyUsages = 0;
-    if (state.argumentCount() >= 7) {
-        if (!cryptoKeyUsagesFromJSValue(state, state.argument(6), keyUsages)) {
-            ASSERT(state.hadException());
-            return jsUndefined();
-        }
-    }
-
-    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(&state, globalObject());
-    DeferredWrapper wrapper(&state, globalObject(), promiseDeferred);
-    Strong<JSDOMGlobalObject> domGlobalObject(state.vm(), globalObject());
-
-    auto decryptSuccessCallback = [domGlobalObject, keyFormat, unwrappedKeyAlgorithm, unwrappedKeyAlgorithmParameters, extractable, keyUsages, wrapper](const Vector<uint8_t>& result) mutable {
-        auto importSuccessCallback = [wrapper](CryptoKey& key) mutable {
-            wrapper.resolve(key);
-        };
-        auto importFailureCallback = [wrapper]() mutable {
-            wrapper.reject(nullptr);
-        };
-        ExecState& state = *domGlobalObject->globalExec();
-        WebCore::importKey(state, keyFormat, std::make_pair(result.data(), result.size()), unwrappedKeyAlgorithm, unwrappedKeyAlgorithmParameters, extractable, keyUsages, WTFMove(importSuccessCallback), WTFMove(importFailureCallback));
-        if (state.hadException()) {
-            // FIXME: Report exception details to console, and possibly to calling script once there is a standardized way to pass errors to WebCrypto promise reject functions.
-            state.clearException();
-            wrapper.reject(nullptr);
-        }
-    };
-
-    auto decryptFailureCallback = [wrapper]() mutable {
-        wrapper.reject(nullptr);
-    };
-
-    ExceptionCode ec = 0;
-    unwrapAlgorithm->decryptForUnwrapKey(*unwrapAlgorithmParameters, *unwrappingKey, wrappedKeyData, WTFMove(decryptSuccessCallback), WTFMove(decryptFailureCallback), ec);
-    if (ec) {
-        setDOMException(&state, ec);
-        return jsUndefined();
-    }
-
-    return promiseDeferred->promise();
-}
-
-} // namespace WebCore
-
-#endif

Copied: trunk/Source/WebCore/bindings/js/JSWebKitSubtleCryptoCustom.cpp (from rev 203695, trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp) (0 => 203696)


--- trunk/Source/WebCore/bindings/js/JSWebKitSubtleCryptoCustom.cpp	                        (rev 0)
+++ trunk/Source/WebCore/bindings/js/JSWebKitSubtleCryptoCustom.cpp	2016-07-25 20:35:16 UTC (rev 203696)
@@ -0,0 +1,805 @@
+/*
+ * Copyright (C) 2013 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. AND ITS CONTRIBUTORS ``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 ITS 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 "JSWebKitSubtleCrypto.h"
+
+#if ENABLE(SUBTLE_CRYPTO)
+
+#include "CryptoAlgorithm.h"
+#include "CryptoAlgorithmParameters.h"
+#include "CryptoAlgorithmRegistry.h"
+#include "CryptoKeyData.h"
+#include "CryptoKeySerializationRaw.h"
+#include "Document.h"
+#include "ExceptionCode.h"
+#include "JSCryptoAlgorithmDictionary.h"
+#include "JSCryptoKey.h"
+#include "JSCryptoKeyPair.h"
+#include "JSCryptoKeySerializationJWK.h"
+#include "JSCryptoOperationData.h"
+#include "JSDOMPromise.h"
+#include <runtime/Error.h>
+
+using namespace JSC;
+
+namespace WebCore {
+
+enum class CryptoKeyFormat {
+    // An unformatted sequence of bytes. Intended for secret keys.
+    Raw,
+
+    // The DER encoding of the PrivateKeyInfo structure from RFC 5208.
+    PKCS8,
+
+    // The DER encoding of the SubjectPublicKeyInfo structure from RFC 5280.
+    SPKI,
+
+    // The key is represented as JSON according to the JSON Web Key format.
+    JWK
+};
+
+static RefPtr<CryptoAlgorithm> createAlgorithmFromJSValue(ExecState& state, JSValue value)
+{
+    CryptoAlgorithmIdentifier algorithmIdentifier;
+    if (!JSCryptoAlgorithmDictionary::getAlgorithmIdentifier(&state, value, algorithmIdentifier)) {
+        ASSERT(state.hadException());
+        return nullptr;
+    }
+
+    auto result = CryptoAlgorithmRegistry::singleton().create(algorithmIdentifier);
+    if (!result)
+        setDOMException(&state, NOT_SUPPORTED_ERR);
+    return result;
+}
+
+static bool cryptoKeyFormatFromJSValue(ExecState& state, JSValue value, CryptoKeyFormat& result)
+{
+    String keyFormatString = value.toString(&state)->value(&state);
+    if (state.hadException())
+        return false;
+    if (keyFormatString == "raw")
+        result = CryptoKeyFormat::Raw;
+    else if (keyFormatString == "pkcs8")
+        result = CryptoKeyFormat::PKCS8;
+    else if (keyFormatString == "spki")
+        result = CryptoKeyFormat::SPKI;
+    else if (keyFormatString == "jwk")
+        result = CryptoKeyFormat::JWK;
+    else {
+        throwTypeError(&state, ASCIILiteral("Unknown key format"));
+        return false;
+    }
+    return true;
+}
+
+static bool cryptoKeyUsagesFromJSValue(ExecState& state, JSValue value, CryptoKeyUsage& result)
+{
+    if (!isJSArray(value)) {
+        throwTypeError(&state);
+        return false;
+    }
+
+    result = 0;
+
+    JSArray* array = asArray(value);
+    for (size_t i = 0; i < array->length(); ++i) {
+        JSValue element = array->getIndex(&state, i);
+        String usageString = element.toString(&state)->value(&state);
+        if (state.hadException())
+            return false;
+        if (usageString == "encrypt")
+            result |= CryptoKeyUsageEncrypt;
+        else if (usageString == "decrypt")
+            result |= CryptoKeyUsageDecrypt;
+        else if (usageString == "sign")
+            result |= CryptoKeyUsageSign;
+        else if (usageString == "verify")
+            result |= CryptoKeyUsageVerify;
+        else if (usageString == "deriveKey")
+            result |= CryptoKeyUsageDeriveKey;
+        else if (usageString == "deriveBits")
+            result |= CryptoKeyUsageDeriveBits;
+        else if (usageString == "wrapKey")
+            result |= CryptoKeyUsageWrapKey;
+        else if (usageString == "unwrapKey")
+            result |= CryptoKeyUsageUnwrapKey;
+    }
+    return true;
+}
+
+JSValue JSWebKitSubtleCrypto::encrypt(ExecState& state)
+{
+    if (state.argumentCount() < 3)
+        return state.vm().throwException(&state, createNotEnoughArgumentsError(&state));
+
+    auto algorithm = createAlgorithmFromJSValue(state, state.uncheckedArgument(0));
+    if (!algorithm) {
+        ASSERT(state.hadException());
+        return jsUndefined();
+    }
+
+    auto parameters = JSCryptoAlgorithmDictionary::createParametersForEncrypt(&state, algorithm->identifier(), state.uncheckedArgument(0));
+    if (!parameters) {
+        ASSERT(state.hadException());
+        return jsUndefined();
+    }
+
+    RefPtr<CryptoKey> key = JSCryptoKey::toWrapped(state.uncheckedArgument(1));
+    if (!key)
+        return throwTypeError(&state);
+
+    if (!key->allows(CryptoKeyUsageEncrypt)) {
+        wrapped().document()->addConsoleMessage(MessageSource::JS, MessageLevel::Error, ASCIILiteral("Key usages do not include 'encrypt'"));
+        setDOMException(&state, NOT_SUPPORTED_ERR);
+        return jsUndefined();
+    }
+
+    CryptoOperationData data;
+    if (!cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(2), data)) {
+        ASSERT(state.hadException());
+        return jsUndefined();
+    }
+
+    
+    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(&state, globalObject());
+    DeferredWrapper wrapper(&state, globalObject(), promiseDeferred);
+    auto successCallback = [wrapper](const Vector<uint8_t>& result) mutable {
+        fulfillPromiseWithArrayBuffer(wrapper, result.data(), result.size());
+    };
+    auto failureCallback = [wrapper]() mutable {
+        wrapper.reject(nullptr);
+    };
+
+    ExceptionCode ec = 0;
+    algorithm->encrypt(*parameters, *key, data, WTFMove(successCallback), WTFMove(failureCallback), ec);
+    if (ec) {
+        setDOMException(&state, ec);
+        return jsUndefined();
+    }
+
+    return promiseDeferred->promise();
+}
+
+JSValue JSWebKitSubtleCrypto::decrypt(ExecState& state)
+{
+    if (state.argumentCount() < 3)
+        return state.vm().throwException(&state, createNotEnoughArgumentsError(&state));
+
+    auto algorithm = createAlgorithmFromJSValue(state, state.uncheckedArgument(0));
+    if (!algorithm) {
+        ASSERT(state.hadException());
+        return jsUndefined();
+    }
+
+    auto parameters = JSCryptoAlgorithmDictionary::createParametersForDecrypt(&state, algorithm->identifier(), state.uncheckedArgument(0));
+    if (!parameters) {
+        ASSERT(state.hadException());
+        return jsUndefined();
+    }
+
+    RefPtr<CryptoKey> key = JSCryptoKey::toWrapped(state.uncheckedArgument(1));
+    if (!key)
+        return throwTypeError(&state);
+
+    if (!key->allows(CryptoKeyUsageDecrypt)) {
+        wrapped().document()->addConsoleMessage(MessageSource::JS, MessageLevel::Error, ASCIILiteral("Key usages do not include 'decrypt'"));
+        setDOMException(&state, NOT_SUPPORTED_ERR);
+        return jsUndefined();
+    }
+
+    CryptoOperationData data;
+    if (!cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(2), data)) {
+        ASSERT(state.hadException());
+        return jsUndefined();
+    }
+
+    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(&state, globalObject());
+    DeferredWrapper wrapper(&state, globalObject(), promiseDeferred);
+    auto successCallback = [wrapper](const Vector<uint8_t>& result) mutable {
+        fulfillPromiseWithArrayBuffer(wrapper, result.data(), result.size());
+    };
+    auto failureCallback = [wrapper]() mutable {
+        wrapper.reject(nullptr);
+    };
+
+    ExceptionCode ec = 0;
+    algorithm->decrypt(*parameters, *key, data, WTFMove(successCallback), WTFMove(failureCallback), ec);
+    if (ec) {
+        setDOMException(&state, ec);
+        return jsUndefined();
+    }
+
+    return promiseDeferred->promise();
+}
+
+JSValue JSWebKitSubtleCrypto::sign(ExecState& state)
+{
+    if (state.argumentCount() < 3)
+        return state.vm().throwException(&state, createNotEnoughArgumentsError(&state));
+
+    auto algorithm = createAlgorithmFromJSValue(state, state.uncheckedArgument(0));
+    if (!algorithm) {
+        ASSERT(state.hadException());
+        return jsUndefined();
+    }
+
+    auto parameters = JSCryptoAlgorithmDictionary::createParametersForSign(&state, algorithm->identifier(), state.uncheckedArgument(0));
+    if (!parameters) {
+        ASSERT(state.hadException());
+        return jsUndefined();
+    }
+
+    RefPtr<CryptoKey> key = JSCryptoKey::toWrapped(state.uncheckedArgument(1));
+    if (!key)
+        return throwTypeError(&state);
+
+    if (!key->allows(CryptoKeyUsageSign)) {
+        wrapped().document()->addConsoleMessage(MessageSource::JS, MessageLevel::Error, ASCIILiteral("Key usages do not include 'sign'"));
+        setDOMException(&state, NOT_SUPPORTED_ERR);
+        return jsUndefined();
+    }
+
+    CryptoOperationData data;
+    if (!cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(2), data)) {
+        ASSERT(state.hadException());
+        return jsUndefined();
+    }
+
+    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(&state, globalObject());
+    DeferredWrapper wrapper(&state, globalObject(), promiseDeferred);
+    auto successCallback = [wrapper](const Vector<uint8_t>& result) mutable {
+        fulfillPromiseWithArrayBuffer(wrapper, result.data(), result.size());
+    };
+    auto failureCallback = [wrapper]() mutable {
+        wrapper.reject(nullptr);
+    };
+
+    ExceptionCode ec = 0;
+    algorithm->sign(*parameters, *key, data, WTFMove(successCallback), WTFMove(failureCallback), ec);
+    if (ec) {
+        setDOMException(&state, ec);
+        return jsUndefined();
+    }
+
+    return promiseDeferred->promise();
+}
+
+JSValue JSWebKitSubtleCrypto::verify(ExecState& state)
+{
+    if (state.argumentCount() < 4)
+        return state.vm().throwException(&state, createNotEnoughArgumentsError(&state));
+
+    auto algorithm = createAlgorithmFromJSValue(state, state.uncheckedArgument(0));
+    if (!algorithm) {
+        ASSERT(state.hadException());
+        return jsUndefined();
+    }
+
+    auto parameters = JSCryptoAlgorithmDictionary::createParametersForVerify(&state, algorithm->identifier(), state.uncheckedArgument(0));
+    if (!parameters) {
+        ASSERT(state.hadException());
+        return jsUndefined();
+    }
+
+    RefPtr<CryptoKey> key = JSCryptoKey::toWrapped(state.uncheckedArgument(1));
+    if (!key)
+        return throwTypeError(&state);
+
+    if (!key->allows(CryptoKeyUsageVerify)) {
+        wrapped().document()->addConsoleMessage(MessageSource::JS, MessageLevel::Error, ASCIILiteral("Key usages do not include 'verify'"));
+        setDOMException(&state, NOT_SUPPORTED_ERR);
+        return jsUndefined();
+    }
+
+    CryptoOperationData signature;
+    if (!cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(2), signature)) {
+        ASSERT(state.hadException());
+        return jsUndefined();
+    }
+
+    CryptoOperationData data;
+    if (!cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(3), data)) {
+        ASSERT(state.hadException());
+        return jsUndefined();
+    }
+
+    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(&state, globalObject());
+    DeferredWrapper wrapper(&state, globalObject(), promiseDeferred);
+    auto successCallback = [wrapper](bool result) mutable {
+        wrapper.resolve(result);
+    };
+    auto failureCallback = [wrapper]() mutable {
+        wrapper.reject(nullptr);
+    };
+
+    ExceptionCode ec = 0;
+    algorithm->verify(*parameters, *key, signature, data, WTFMove(successCallback), WTFMove(failureCallback), ec);
+    if (ec) {
+        setDOMException(&state, ec);
+        return jsUndefined();
+    }
+
+    return promiseDeferred->promise();
+}
+
+JSValue JSWebKitSubtleCrypto::digest(ExecState& state)
+{
+    if (state.argumentCount() < 2)
+        return state.vm().throwException(&state, createNotEnoughArgumentsError(&state));
+
+    auto algorithm = createAlgorithmFromJSValue(state, state.uncheckedArgument(0));
+    if (!algorithm) {
+        ASSERT(state.hadException());
+        return jsUndefined();
+    }
+
+    auto parameters = JSCryptoAlgorithmDictionary::createParametersForDigest(&state, algorithm->identifier(), state.uncheckedArgument(0));
+    if (!parameters) {
+        ASSERT(state.hadException());
+        return jsUndefined();
+    }
+
+    CryptoOperationData data;
+    if (!cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(1), data)) {
+        ASSERT(state.hadException());
+        return jsUndefined();
+    }
+
+    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(&state, globalObject());
+    DeferredWrapper wrapper(&state, globalObject(), promiseDeferred);
+    auto successCallback = [wrapper](const Vector<uint8_t>& result) mutable {
+        fulfillPromiseWithArrayBuffer(wrapper, result.data(), result.size());
+    };
+    auto failureCallback = [wrapper]() mutable {
+        wrapper.reject(nullptr);
+    };
+
+    ExceptionCode ec = 0;
+    algorithm->digest(*parameters, data, WTFMove(successCallback), WTFMove(failureCallback), ec);
+    if (ec) {
+        setDOMException(&state, ec);
+        return jsUndefined();
+    }
+
+    return promiseDeferred->promise();
+}
+
+JSValue JSWebKitSubtleCrypto::generateKey(ExecState& state)
+{
+    if (state.argumentCount() < 1)
+        return state.vm().throwException(&state, createNotEnoughArgumentsError(&state));
+
+    auto algorithm = createAlgorithmFromJSValue(state, state.uncheckedArgument(0));
+    if (!algorithm) {
+        ASSERT(state.hadException());
+        return jsUndefined();
+    }
+
+    auto parameters = JSCryptoAlgorithmDictionary::createParametersForGenerateKey(&state, algorithm->identifier(), state.uncheckedArgument(0));
+    if (!parameters) {
+        ASSERT(state.hadException());
+        return jsUndefined();
+    }
+
+    bool extractable = false;
+    if (state.argumentCount() >= 2) {
+        extractable = state.uncheckedArgument(1).toBoolean(&state);
+        if (state.hadException())
+            return jsUndefined();
+    }
+
+    CryptoKeyUsage keyUsages = 0;
+    if (state.argumentCount() >= 3) {
+        if (!cryptoKeyUsagesFromJSValue(state, state.argument(2), keyUsages)) {
+            ASSERT(state.hadException());
+            return jsUndefined();
+        }
+    }
+
+    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(&state, globalObject());
+    DeferredWrapper wrapper(&state, globalObject(), promiseDeferred);
+    auto successCallback = [wrapper](CryptoKey* key, CryptoKeyPair* keyPair) mutable {
+        ASSERT(key || keyPair);
+        ASSERT(!key || !keyPair);
+        if (key)
+            wrapper.resolve(key);
+        else
+            wrapper.resolve(keyPair);
+    };
+    auto failureCallback = [wrapper]() mutable {
+        wrapper.reject(nullptr);
+    };
+
+    ExceptionCode ec = 0;
+    algorithm->generateKey(*parameters, extractable, keyUsages, WTFMove(successCallback), WTFMove(failureCallback), ec);
+    if (ec) {
+        setDOMException(&state, ec);
+        return jsUndefined();
+    }
+
+    return promiseDeferred->promise();
+}
+
+static void importKey(ExecState& state, CryptoKeyFormat keyFormat, CryptoOperationData data, RefPtr<CryptoAlgorithm> algorithm, RefPtr<CryptoAlgorithmParameters> parameters, bool extractable, CryptoKeyUsage keyUsages, CryptoAlgorithm::KeyCallback callback, CryptoAlgorithm::VoidCallback failureCallback)
+{
+    std::unique_ptr<CryptoKeySerialization> keySerialization;
+    switch (keyFormat) {
+    case CryptoKeyFormat::Raw:
+        keySerialization = CryptoKeySerializationRaw::create(data);
+        break;
+    case CryptoKeyFormat::JWK: {
+        String jwkString = String::fromUTF8(data.first, data.second);
+        if (jwkString.isNull()) {
+            throwTypeError(&state, ASCIILiteral("JWK JSON serialization is not valid UTF-8"));
+            return;
+        }
+        keySerialization = std::make_unique<JSCryptoKeySerializationJWK>(&state, jwkString);
+        if (state.hadException())
+            return;
+        break;
+    }
+    default:
+        throwTypeError(&state, ASCIILiteral("Unsupported key format for import"));
+        return;
+    }
+
+    ASSERT(keySerialization);
+
+    Optional<CryptoAlgorithmPair> reconciledResult = keySerialization->reconcileAlgorithm(algorithm.get(), parameters.get());
+    if (!reconciledResult) {
+        if (!state.hadException())
+            throwTypeError(&state, ASCIILiteral("Algorithm specified in key is not compatible with one passed to importKey as argument"));
+        return;
+    }
+    if (state.hadException())
+        return;
+
+    algorithm = reconciledResult->algorithm;
+    parameters = reconciledResult->parameters;
+    if (!algorithm) {
+        throwTypeError(&state, ASCIILiteral("Neither key nor function argument has crypto algorithm specified"));
+        return;
+    }
+    ASSERT(parameters);
+
+    keySerialization->reconcileExtractable(extractable);
+    if (state.hadException())
+        return;
+
+    keySerialization->reconcileUsages(keyUsages);
+    if (state.hadException())
+        return;
+
+    auto keyData = keySerialization->keyData();
+    if (state.hadException())
+        return;
+
+    ExceptionCode ec = 0;
+    algorithm->importKey(*parameters, *keyData, extractable, keyUsages, WTFMove(callback), WTFMove(failureCallback), ec);
+    if (ec)
+        setDOMException(&state, ec);
+}
+
+JSValue JSWebKitSubtleCrypto::importKey(ExecState& state)
+{
+    if (state.argumentCount() < 3)
+        return state.vm().throwException(&state, createNotEnoughArgumentsError(&state));
+
+    CryptoKeyFormat keyFormat;
+    if (!cryptoKeyFormatFromJSValue(state, state.argument(0), keyFormat)) {
+        ASSERT(state.hadException());
+        return jsUndefined();
+    }
+
+    CryptoOperationData data;
+    if (!cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(1), data)) {
+        ASSERT(state.hadException());
+        return jsUndefined();
+    }
+
+    RefPtr<CryptoAlgorithm> algorithm;
+    RefPtr<CryptoAlgorithmParameters> parameters;
+    if (!state.uncheckedArgument(2).isNull()) {
+        algorithm = createAlgorithmFromJSValue(state, state.uncheckedArgument(2));
+        if (!algorithm) {
+            ASSERT(state.hadException());
+            return jsUndefined();
+        }
+        parameters = JSCryptoAlgorithmDictionary::createParametersForImportKey(&state, algorithm->identifier(), state.uncheckedArgument(2));
+        if (!parameters) {
+            ASSERT(state.hadException());
+            return jsUndefined();
+        }
+    }
+
+    bool extractable = false;
+    if (state.argumentCount() >= 4) {
+        extractable = state.uncheckedArgument(3).toBoolean(&state);
+        if (state.hadException())
+            return jsUndefined();
+    }
+
+    CryptoKeyUsage keyUsages = 0;
+    if (state.argumentCount() >= 5) {
+        if (!cryptoKeyUsagesFromJSValue(state, state.argument(4), keyUsages)) {
+            ASSERT(state.hadException());
+            return jsUndefined();
+        }
+    }
+
+    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(&state, globalObject());
+    DeferredWrapper wrapper(&state, globalObject(), promiseDeferred);
+    auto successCallback = [wrapper](CryptoKey& result) mutable {
+        wrapper.resolve(result);
+    };
+    auto failureCallback = [wrapper]() mutable {
+        wrapper.reject(nullptr);
+    };
+
+    WebCore::importKey(state, keyFormat, data, WTFMove(algorithm), WTFMove(parameters), extractable, keyUsages, WTFMove(successCallback), WTFMove(failureCallback));
+    if (state.hadException())
+        return jsUndefined();
+
+    return promiseDeferred->promise();
+}
+
+static void exportKey(ExecState& state, CryptoKeyFormat keyFormat, const CryptoKey& key, CryptoAlgorithm::VectorCallback callback, CryptoAlgorithm::VoidCallback failureCallback)
+{
+    if (!key.extractable()) {
+        throwTypeError(&state, ASCIILiteral("Key is not extractable"));
+        return;
+    }
+
+    switch (keyFormat) {
+    case CryptoKeyFormat::Raw: {
+        Vector<uint8_t> result;
+        if (CryptoKeySerializationRaw::serialize(key, result))
+            callback(result);
+        else
+            failureCallback();
+        break;
+    }
+    case CryptoKeyFormat::JWK: {
+        String result = JSCryptoKeySerializationJWK::serialize(&state, key);
+        if (state.hadException())
+            return;
+        CString utf8String = result.utf8(StrictConversion);
+        Vector<uint8_t> resultBuffer;
+        resultBuffer.append(utf8String.data(), utf8String.length());
+        callback(resultBuffer);
+        break;
+    }
+    default:
+        throwTypeError(&state, ASCIILiteral("Unsupported key format for export"));
+        break;
+    }
+}
+
+JSValue JSWebKitSubtleCrypto::exportKey(ExecState& state)
+{
+    if (state.argumentCount() < 2)
+        return state.vm().throwException(&state, createNotEnoughArgumentsError(&state));
+
+    CryptoKeyFormat keyFormat;
+    if (!cryptoKeyFormatFromJSValue(state, state.argument(0), keyFormat)) {
+        ASSERT(state.hadException());
+        return jsUndefined();
+    }
+
+    RefPtr<CryptoKey> key = JSCryptoKey::toWrapped(state.uncheckedArgument(1));
+    if (!key)
+        return throwTypeError(&state);
+
+    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(&state, globalObject());
+    DeferredWrapper wrapper(&state, globalObject(), promiseDeferred);
+    auto successCallback = [wrapper](const Vector<uint8_t>& result) mutable {
+        fulfillPromiseWithArrayBuffer(wrapper, result.data(), result.size());
+    };
+    auto failureCallback = [wrapper]() mutable {
+        wrapper.reject(nullptr);
+    };
+
+    WebCore::exportKey(state, keyFormat, *key, WTFMove(successCallback), WTFMove(failureCallback));
+    if (state.hadException())
+        return jsUndefined();
+
+    return promiseDeferred->promise();
+}
+
+JSValue JSWebKitSubtleCrypto::wrapKey(ExecState& state)
+{
+    if (state.argumentCount() < 4)
+        return state.vm().throwException(&state, createNotEnoughArgumentsError(&state));
+
+    CryptoKeyFormat keyFormat;
+    if (!cryptoKeyFormatFromJSValue(state, state.argument(0), keyFormat)) {
+        ASSERT(state.hadException());
+        return jsUndefined();
+    }
+
+    RefPtr<CryptoKey> key = JSCryptoKey::toWrapped(state.uncheckedArgument(1));
+    if (!key)
+        return throwTypeError(&state);
+
+    RefPtr<CryptoKey> wrappingKey = JSCryptoKey::toWrapped(state.uncheckedArgument(2));
+    if (!key)
+        return throwTypeError(&state);
+
+    if (!wrappingKey->allows(CryptoKeyUsageWrapKey)) {
+        wrapped().document()->addConsoleMessage(MessageSource::JS, MessageLevel::Error, ASCIILiteral("Key usages do not include 'wrapKey'"));
+        setDOMException(&state, NOT_SUPPORTED_ERR);
+        return jsUndefined();
+    }
+
+    auto algorithm = createAlgorithmFromJSValue(state, state.uncheckedArgument(3));
+    if (!algorithm) {
+        ASSERT(state.hadException());
+        return jsUndefined();
+    }
+
+    auto parameters = JSCryptoAlgorithmDictionary::createParametersForEncrypt(&state, algorithm->identifier(), state.uncheckedArgument(3));
+    if (!parameters) {
+        ASSERT(state.hadException());
+        return jsUndefined();
+    }
+
+    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(&state, globalObject());
+    DeferredWrapper wrapper(&state, globalObject(), promiseDeferred);
+
+    auto exportSuccessCallback = [keyFormat, algorithm, parameters, wrappingKey, wrapper](const Vector<uint8_t>& exportedKeyData) mutable {
+        auto encryptSuccessCallback = [wrapper](const Vector<uint8_t>& encryptedData) mutable {
+            fulfillPromiseWithArrayBuffer(wrapper, encryptedData.data(), encryptedData.size());
+        };
+        auto encryptFailureCallback = [wrapper]() mutable {
+            wrapper.reject(nullptr);
+        };
+        ExceptionCode ec = 0;
+        algorithm->encryptForWrapKey(*parameters, *wrappingKey, std::make_pair(exportedKeyData.data(), exportedKeyData.size()), WTFMove(encryptSuccessCallback), WTFMove(encryptFailureCallback), ec);
+        if (ec) {
+            // FIXME: Report failure details to console, and possibly to calling script once there is a standardized way to pass errors to WebCrypto promise reject functions.
+            wrapper.reject(nullptr);
+        }
+    };
+
+    auto exportFailureCallback = [wrapper]() mutable {
+        wrapper.reject(nullptr);
+    };
+
+    ExceptionCode ec = 0;
+    WebCore::exportKey(state, keyFormat, *key, WTFMove(exportSuccessCallback), WTFMove(exportFailureCallback));
+    if (ec) {
+        setDOMException(&state, ec);
+        return jsUndefined();
+    }
+
+    return promiseDeferred->promise();
+}
+
+JSValue JSWebKitSubtleCrypto::unwrapKey(ExecState& state)
+{
+    if (state.argumentCount() < 5)
+        return state.vm().throwException(&state, createNotEnoughArgumentsError(&state));
+
+    CryptoKeyFormat keyFormat;
+    if (!cryptoKeyFormatFromJSValue(state, state.argument(0), keyFormat)) {
+        ASSERT(state.hadException());
+        return jsUndefined();
+    }
+
+    CryptoOperationData wrappedKeyData;
+    if (!cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(1), wrappedKeyData)) {
+        ASSERT(state.hadException());
+        return jsUndefined();
+    }
+
+    RefPtr<CryptoKey> unwrappingKey = JSCryptoKey::toWrapped(state.uncheckedArgument(2));
+    if (!unwrappingKey)
+        return throwTypeError(&state);
+
+    if (!unwrappingKey->allows(CryptoKeyUsageUnwrapKey)) {
+        wrapped().document()->addConsoleMessage(MessageSource::JS, MessageLevel::Error, ASCIILiteral("Key usages do not include 'unwrapKey'"));
+        setDOMException(&state, NOT_SUPPORTED_ERR);
+        return jsUndefined();
+    }
+
+    auto unwrapAlgorithm = createAlgorithmFromJSValue(state, state.uncheckedArgument(3));
+    if (!unwrapAlgorithm) {
+        ASSERT(state.hadException());
+        return jsUndefined();
+    }
+    auto unwrapAlgorithmParameters = JSCryptoAlgorithmDictionary::createParametersForDecrypt(&state, unwrapAlgorithm->identifier(), state.uncheckedArgument(3));
+    if (!unwrapAlgorithmParameters) {
+        ASSERT(state.hadException());
+        return jsUndefined();
+    }
+
+    RefPtr<CryptoAlgorithm> unwrappedKeyAlgorithm;
+    RefPtr<CryptoAlgorithmParameters> unwrappedKeyAlgorithmParameters;
+    if (!state.uncheckedArgument(4).isNull()) {
+        unwrappedKeyAlgorithm = createAlgorithmFromJSValue(state, state.uncheckedArgument(4));
+        if (!unwrappedKeyAlgorithm) {
+            ASSERT(state.hadException());
+            return jsUndefined();
+        }
+        unwrappedKeyAlgorithmParameters = JSCryptoAlgorithmDictionary::createParametersForImportKey(&state, unwrappedKeyAlgorithm->identifier(), state.uncheckedArgument(4));
+        if (!unwrappedKeyAlgorithmParameters) {
+            ASSERT(state.hadException());
+            return jsUndefined();
+        }
+    }
+
+    bool extractable = false;
+    if (state.argumentCount() >= 6) {
+        extractable = state.uncheckedArgument(5).toBoolean(&state);
+        if (state.hadException())
+            return jsUndefined();
+    }
+
+    CryptoKeyUsage keyUsages = 0;
+    if (state.argumentCount() >= 7) {
+        if (!cryptoKeyUsagesFromJSValue(state, state.argument(6), keyUsages)) {
+            ASSERT(state.hadException());
+            return jsUndefined();
+        }
+    }
+
+    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(&state, globalObject());
+    DeferredWrapper wrapper(&state, globalObject(), promiseDeferred);
+    Strong<JSDOMGlobalObject> domGlobalObject(state.vm(), globalObject());
+
+    auto decryptSuccessCallback = [domGlobalObject, keyFormat, unwrappedKeyAlgorithm, unwrappedKeyAlgorithmParameters, extractable, keyUsages, wrapper](const Vector<uint8_t>& result) mutable {
+        auto importSuccessCallback = [wrapper](CryptoKey& key) mutable {
+            wrapper.resolve(key);
+        };
+        auto importFailureCallback = [wrapper]() mutable {
+            wrapper.reject(nullptr);
+        };
+        ExecState& state = *domGlobalObject->globalExec();
+        WebCore::importKey(state, keyFormat, std::make_pair(result.data(), result.size()), unwrappedKeyAlgorithm, unwrappedKeyAlgorithmParameters, extractable, keyUsages, WTFMove(importSuccessCallback), WTFMove(importFailureCallback));
+        if (state.hadException()) {
+            // FIXME: Report exception details to console, and possibly to calling script once there is a standardized way to pass errors to WebCrypto promise reject functions.
+            state.clearException();
+            wrapper.reject(nullptr);
+        }
+    };
+
+    auto decryptFailureCallback = [wrapper]() mutable {
+        wrapper.reject(nullptr);
+    };
+
+    ExceptionCode ec = 0;
+    unwrapAlgorithm->decryptForUnwrapKey(*unwrapAlgorithmParameters, *unwrappingKey, wrappedKeyData, WTFMove(decryptSuccessCallback), WTFMove(decryptFailureCallback), ec);
+    if (ec) {
+        setDOMException(&state, ec);
+        return jsUndefined();
+    }
+
+    return promiseDeferred->promise();
+}
+
+} // namespace WebCore
+
+#endif

Deleted: trunk/Source/WebCore/crypto/SubtleCrypto.cpp (203695 => 203696)


--- trunk/Source/WebCore/crypto/SubtleCrypto.cpp	2016-07-25 19:57:47 UTC (rev 203695)
+++ trunk/Source/WebCore/crypto/SubtleCrypto.cpp	2016-07-25 20:35:16 UTC (rev 203696)
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2013 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. AND ITS CONTRIBUTORS ``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 ITS 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 "SubtleCrypto.h"
-
-#if ENABLE(SUBTLE_CRYPTO)
-
-#include "Document.h"
-
-namespace WebCore {
-
-SubtleCrypto::SubtleCrypto(Document& document)
-    : ContextDestructionObserver(&document)
-{
-}
-
-Document* SubtleCrypto::document() const
-{
-    return downcast<Document>(scriptExecutionContext());
-}
-
-}
-
-#endif

Deleted: trunk/Source/WebCore/crypto/SubtleCrypto.h (203695 => 203696)


--- trunk/Source/WebCore/crypto/SubtleCrypto.h	2016-07-25 19:57:47 UTC (rev 203695)
+++ trunk/Source/WebCore/crypto/SubtleCrypto.h	2016-07-25 20:35:16 UTC (rev 203696)
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2013 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. AND ITS CONTRIBUTORS ``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 ITS 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.
- */
-
-#ifndef SubtleCrypto_h
-#define SubtleCrypto_h
-
-#include "ContextDestructionObserver.h" 
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-
-#if ENABLE(SUBTLE_CRYPTO)
-
-namespace WebCore {
-
-class Document;
-
-class SubtleCrypto : public ContextDestructionObserver, public RefCounted<SubtleCrypto> {
-public:
-    static Ref<SubtleCrypto> create(Document& document) { return adoptRef(*new SubtleCrypto(document)); }
-
-    Document* document() const;
-
-private:
-    SubtleCrypto(Document&);
-};
-
-}
-
-#endif
-
-#endif // SubtleCrypto_h

Deleted: trunk/Source/WebCore/crypto/SubtleCrypto.idl (203695 => 203696)


--- trunk/Source/WebCore/crypto/SubtleCrypto.idl	2016-07-25 19:57:47 UTC (rev 203695)
+++ trunk/Source/WebCore/crypto/SubtleCrypto.idl	2016-07-25 20:35:16 UTC (rev 203696)
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2013 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. AND ITS CONTRIBUTORS ``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 ITS 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.
- */
-
-[
-    Conditional=SUBTLE_CRYPTO,
-    InterfaceName=WebKitSubtleCrypto,
-    GenerateIsReachable=ImplDocument,
-    NoInterfaceObject,
-] interface SubtleCrypto {
-    [Custom] Promise encrypt(AlgorithmIdentifier algorithm, Key key, sequence<CryptoOperationData> data);
-    [Custom] Promise decrypt(AlgorithmIdentifier algorithm, Key key, sequence<CryptoOperationData> data);
-    [Custom] Promise sign(AlgorithmIdentifier algorithm, Key key, sequence<CryptoOperationData> data);
-    [Custom] Promise verify(AlgorithmIdentifier algorithm, Key key, CryptoOperationData signature, sequence<CryptoOperationData> data);
-    [Custom] Promise digest(AlgorithmIdentifier algorithm, sequence<CryptoOperationData> data);
-    [Custom] Promise generateKey(AlgorithmIdentifier algorithm, optional boolean extractable, optional sequence<KeyUsage> keyUsages);
-    [Custom] Promise importKey(KeyFormat format, CryptoOperationData keyData, AlgorithmIdentifier? algorithm, optional boolean extractable, optional sequence<KeyUsage> keyUsages);
-    [Custom] Promise exportKey(KeyFormat format, Key key);
-    [Custom] Promise wrapKey(KeyFormat format, Key key, Key wrappingKey, AlgorithmIdentifier wrapAlgorithm);
-    [Custom] Promise unwrapKey(KeyFormat format, CryptoOperationData wrappedKey, Key unwrappingKey, AlgorithmIdentifier unwrapAlgorithm, AlgorithmIdentifier? unwrappedKeyAlgorithm, optional boolean extractable, optional sequence<KeyUsage> keyUsages);
-};

Copied: trunk/Source/WebCore/crypto/WebKitSubtleCrypto.cpp (from rev 203695, trunk/Source/WebCore/crypto/SubtleCrypto.cpp) (0 => 203696)


--- trunk/Source/WebCore/crypto/WebKitSubtleCrypto.cpp	                        (rev 0)
+++ trunk/Source/WebCore/crypto/WebKitSubtleCrypto.cpp	2016-07-25 20:35:16 UTC (rev 203696)
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2013 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. AND ITS CONTRIBUTORS ``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 ITS 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 "WebKitSubtleCrypto.h"
+
+#if ENABLE(SUBTLE_CRYPTO)
+
+#include "Document.h"
+
+namespace WebCore {
+
+WebKitSubtleCrypto::WebKitSubtleCrypto(Document& document)
+    : ContextDestructionObserver(&document)
+{
+}
+
+Document* WebKitSubtleCrypto::document() const
+{
+    return downcast<Document>(scriptExecutionContext());
+}
+
+}
+
+#endif

Copied: trunk/Source/WebCore/crypto/WebKitSubtleCrypto.h (from rev 203695, trunk/Source/WebCore/crypto/SubtleCrypto.h) (0 => 203696)


--- trunk/Source/WebCore/crypto/WebKitSubtleCrypto.h	                        (rev 0)
+++ trunk/Source/WebCore/crypto/WebKitSubtleCrypto.h	2016-07-25 20:35:16 UTC (rev 203696)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2013 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. AND ITS CONTRIBUTORS ``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 ITS 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.
+ */
+
+#pragma once
+
+#include "ContextDestructionObserver.h" 
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+
+#if ENABLE(SUBTLE_CRYPTO)
+
+namespace WebCore {
+
+class Document;
+
+class WebKitSubtleCrypto : public ContextDestructionObserver, public RefCounted<WebKitSubtleCrypto> {
+public:
+    static Ref<WebKitSubtleCrypto> create(Document& document) { return adoptRef(*new WebKitSubtleCrypto(document)); }
+
+    Document* document() const;
+
+private:
+    WebKitSubtleCrypto(Document&);
+};
+
+}
+
+#endif

Copied: trunk/Source/WebCore/crypto/WebKitSubtleCrypto.idl (from rev 203695, trunk/Source/WebCore/crypto/SubtleCrypto.idl) (0 => 203696)


--- trunk/Source/WebCore/crypto/WebKitSubtleCrypto.idl	                        (rev 0)
+++ trunk/Source/WebCore/crypto/WebKitSubtleCrypto.idl	2016-07-25 20:35:16 UTC (rev 203696)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2013 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. AND ITS CONTRIBUTORS ``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 ITS 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.
+ */
+
+[
+    Conditional=SUBTLE_CRYPTO,
+    GenerateIsReachable=ImplDocument,
+    NoInterfaceObject,
+] interface WebKitSubtleCrypto {
+    [Custom] Promise encrypt(AlgorithmIdentifier algorithm, Key key, sequence<CryptoOperationData> data);
+    [Custom] Promise decrypt(AlgorithmIdentifier algorithm, Key key, sequence<CryptoOperationData> data);
+    [Custom] Promise sign(AlgorithmIdentifier algorithm, Key key, sequence<CryptoOperationData> data);
+    [Custom] Promise verify(AlgorithmIdentifier algorithm, Key key, CryptoOperationData signature, sequence<CryptoOperationData> data);
+    [Custom] Promise digest(AlgorithmIdentifier algorithm, sequence<CryptoOperationData> data);
+    [Custom] Promise generateKey(AlgorithmIdentifier algorithm, optional boolean extractable, optional sequence<KeyUsage> keyUsages);
+    [Custom] Promise importKey(KeyFormat format, CryptoOperationData keyData, AlgorithmIdentifier? algorithm, optional boolean extractable, optional sequence<KeyUsage> keyUsages);
+    [Custom] Promise exportKey(KeyFormat format, Key key);
+    [Custom] Promise wrapKey(KeyFormat format, Key key, Key wrappingKey, AlgorithmIdentifier wrapAlgorithm);
+    [Custom] Promise unwrapKey(KeyFormat format, CryptoOperationData wrappedKey, Key unwrappingKey, AlgorithmIdentifier unwrapAlgorithm, AlgorithmIdentifier? unwrappedKeyAlgorithm, optional boolean extractable, optional sequence<KeyUsage> keyUsages);
+};

Modified: trunk/Source/WebCore/page/Crypto.cpp (203695 => 203696)


--- trunk/Source/WebCore/page/Crypto.cpp	2016-07-25 19:57:47 UTC (rev 203695)
+++ trunk/Source/WebCore/page/Crypto.cpp	2016-07-25 20:35:16 UTC (rev 203696)
@@ -33,7 +33,7 @@
 
 #include "Document.h"
 #include "ExceptionCode.h"
-#include "SubtleCrypto.h"
+#include "WebKitSubtleCrypto.h"
 #include <runtime/ArrayBufferView.h>
 #include <wtf/CryptographicallyRandomNumber.h>
 
@@ -67,13 +67,13 @@
 }
 
 #if ENABLE(SUBTLE_CRYPTO)
-SubtleCrypto* Crypto::subtle()
+WebKitSubtleCrypto* Crypto::webkitSubtle()
 {
     ASSERT(isMainThread());
-    if (!m_subtle)
-        m_subtle = SubtleCrypto::create(*document());
+    if (!m_webkitSubtle)
+        m_webkitSubtle = WebKitSubtleCrypto::create(*document());
 
-    return m_subtle.get();
+    return m_webkitSubtle.get();
 }
 #endif
 

Modified: trunk/Source/WebCore/page/Crypto.h (203695 => 203696)


--- trunk/Source/WebCore/page/Crypto.h	2016-07-25 19:57:47 UTC (rev 203695)
+++ trunk/Source/WebCore/page/Crypto.h	2016-07-25 20:35:16 UTC (rev 203696)
@@ -45,7 +45,7 @@
 typedef int ExceptionCode;
 
 class Document;
-class SubtleCrypto;
+class WebKitSubtleCrypto;
 
 class Crypto : public ContextDestructionObserver, public RefCounted<Crypto> {
 public:
@@ -57,7 +57,7 @@
     void getRandomValues(JSC::ArrayBufferView*, ExceptionCode&);
 
 #if ENABLE(SUBTLE_CRYPTO)
-    SubtleCrypto* subtle();
+    WebKitSubtleCrypto* webkitSubtle();
 #endif
 
 private:
@@ -64,7 +64,7 @@
     Crypto(Document&);
 
 #if ENABLE(SUBTLE_CRYPTO)
-    RefPtr<SubtleCrypto> m_subtle;
+    RefPtr<WebKitSubtleCrypto> m_webkitSubtle;
 #endif
 };
 

Modified: trunk/Source/WebCore/page/Crypto.idl (203695 => 203696)


--- trunk/Source/WebCore/page/Crypto.idl	2016-07-25 19:57:47 UTC (rev 203695)
+++ trunk/Source/WebCore/page/Crypto.idl	2016-07-25 20:35:16 UTC (rev 203696)
@@ -32,5 +32,5 @@
 ] interface Crypto {
     [Custom, RaisesException] ArrayBufferView getRandomValues(ArrayBufferView array);
 
-    [Conditional=SUBTLE_CRYPTO, ImplementedAs=subtle] readonly attribute SubtleCrypto webkitSubtle;
+    [Conditional=SUBTLE_CRYPTO] readonly attribute WebKitSubtleCrypto webkitSubtle;
 };
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to