Diff
Modified: trunk/LayoutTests/ChangeLog (209163 => 209164)
--- trunk/LayoutTests/ChangeLog 2016-12-01 00:14:19 UTC (rev 209163)
+++ trunk/LayoutTests/ChangeLog 2016-12-01 00:28:04 UTC (rev 209164)
@@ -1,3 +1,39 @@
+2016-11-26 Jiewen Tan <jiewen_...@apple.com>
+
+ Update SubtleCrypto::digest to match the latest spec
+ https://bugs.webkit.org/show_bug.cgi?id=164742
+ <rdar://problem/29258037>
+
+ Reviewed by Darin Adler.
+
+ * crypto/subtle/digest-malformed-parameters-expected.txt: Added.
+ * crypto/subtle/digest-malformed-parameters.html: Added.
+ * crypto/subtle/sha1-digest-expected.txt: Added.
+ * crypto/subtle/sha1-digest.html: Added.
+ * crypto/subtle/sha224-digest-expected.txt: Added.
+ * crypto/subtle/sha224-digest.html: Added.
+ * crypto/subtle/sha256-digest-expected.txt: Added.
+ * crypto/subtle/sha256-digest.html: Added.
+ * crypto/subtle/sha384-digest-expected.txt: Added.
+ * crypto/subtle/sha384-digest.html: Added.
+ * crypto/subtle/sha512-digest-expected.txt: Added.
+ * crypto/subtle/sha512-digest.html: Added.
+ * crypto/workers/subtle/resources/sha1-digest.js: Added.
+ * crypto/workers/subtle/resources/sha224-digest.js: Added.
+ * crypto/workers/subtle/resources/sha256-digest.js: Added.
+ * crypto/workers/subtle/resources/sha384-digest.js: Added.
+ * crypto/workers/subtle/resources/sha512-digest.js: Added.
+ * crypto/workers/subtle/sha1-digest-expected.txt: Added.
+ * crypto/workers/subtle/sha1-digest.html: Added.
+ * crypto/workers/subtle/sha224-digest-expected.txt: Added.
+ * crypto/workers/subtle/sha224-digest.html: Added.
+ * crypto/workers/subtle/sha256-digest-expected.txt: Added.
+ * crypto/workers/subtle/sha256-digest.html: Added.
+ * crypto/workers/subtle/sha384-digest-expected.txt: Added.
+ * crypto/workers/subtle/sha384-digest.html: Added.
+ * crypto/workers/subtle/sha512-digest-expected.txt: Added.
+ * crypto/workers/subtle/sha512-digest.html: Added.
+
2016-11-30 Antoine Quint <grao...@apple.com>
[Modern Media Controls] UI Library: <audio> controls
Added: trunk/LayoutTests/crypto/subtle/digest-malformed-parameters-expected.txt (0 => 209164)
--- trunk/LayoutTests/crypto/subtle/digest-malformed-parameters-expected.txt (rev 0)
+++ trunk/LayoutTests/crypto/subtle/digest-malformed-parameters-expected.txt 2016-12-01 00:28:04 UTC (rev 209164)
@@ -0,0 +1,11 @@
+Test digest with malformed parameters
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS crypto.subtle.digest() rejected promise with TypeError: Not enough arguments.
+PASS crypto.subtle.digest(1) rejected promise with TypeError: Not enough arguments.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/crypto/subtle/digest-malformed-parameters.html (0 => 209164)
--- trunk/LayoutTests/crypto/subtle/digest-malformed-parameters.html (rev 0)
+++ trunk/LayoutTests/crypto/subtle/digest-malformed-parameters.html 2016-12-01 00:28:04 UTC (rev 209164)
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test digest with malformed parameters");
+
+var message = asciiToUint8Array("Hello, World!");
+
+// Not enough arguments.
+shouldReject('crypto.subtle.digest()');
+shouldReject('crypto.subtle.digest(1)');
+
+</script>
+
+<script src=""
+</body>
+</html>
Added: trunk/LayoutTests/crypto/subtle/sha1-digest-expected.txt (0 => 209164)
--- trunk/LayoutTests/crypto/subtle/sha1-digest-expected.txt (rev 0)
+++ trunk/LayoutTests/crypto/subtle/sha1-digest-expected.txt 2016-12-01 00:28:04 UTC (rev 209164)
@@ -0,0 +1,10 @@
+Test digest with SHA-1
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS bytesToHexString(digest) is expectedDigest
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/crypto/subtle/sha1-digest.html (0 => 209164)
--- trunk/LayoutTests/crypto/subtle/sha1-digest.html (rev 0)
+++ trunk/LayoutTests/crypto/subtle/sha1-digest.html 2016-12-01 00:28:04 UTC (rev 209164)
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test digest with SHA-1");
+
+jsTestIsAsync = true;
+
+var message = asciiToUint8Array("Hello, World!");
+var expectedDigest = "0a0a9f2a6772942557ab5355d76af442f8f65e01";
+
+crypto.subtle.digest("sha-1", message).then(function(result){
+ digest = result;
+ shouldBe("bytesToHexString(digest)", "expectedDigest");
+ finishJSTest();
+});
+
+</script>
+
+<script src=""
+</body>
+</html>
Added: trunk/LayoutTests/crypto/subtle/sha224-digest-expected.txt (0 => 209164)
--- trunk/LayoutTests/crypto/subtle/sha224-digest-expected.txt (rev 0)
+++ trunk/LayoutTests/crypto/subtle/sha224-digest-expected.txt 2016-12-01 00:28:04 UTC (rev 209164)
@@ -0,0 +1,10 @@
+Test digest with SHA-224
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS bytesToHexString(digest) is expectedDigest
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/crypto/subtle/sha224-digest.html (0 => 209164)
--- trunk/LayoutTests/crypto/subtle/sha224-digest.html (rev 0)
+++ trunk/LayoutTests/crypto/subtle/sha224-digest.html 2016-12-01 00:28:04 UTC (rev 209164)
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test digest with SHA-224");
+
+jsTestIsAsync = true;
+
+var message = asciiToUint8Array("Hello, World!");
+var expectedDigest = "72a23dfa411ba6fde01dbfabf3b00a709c93ebf273dc29e2d8b261ff";
+
+crypto.subtle.digest("sha-224", message).then(function(result){
+ digest = result;
+ shouldBe("bytesToHexString(digest)", "expectedDigest");
+ finishJSTest();
+});
+
+</script>
+
+<script src=""
+</body>
+</html>
Added: trunk/LayoutTests/crypto/subtle/sha256-digest-expected.txt (0 => 209164)
--- trunk/LayoutTests/crypto/subtle/sha256-digest-expected.txt (rev 0)
+++ trunk/LayoutTests/crypto/subtle/sha256-digest-expected.txt 2016-12-01 00:28:04 UTC (rev 209164)
@@ -0,0 +1,10 @@
+Test digest with SHA-256
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS bytesToHexString(digest) is expectedDigest
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/crypto/subtle/sha256-digest.html (0 => 209164)
--- trunk/LayoutTests/crypto/subtle/sha256-digest.html (rev 0)
+++ trunk/LayoutTests/crypto/subtle/sha256-digest.html 2016-12-01 00:28:04 UTC (rev 209164)
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test digest with SHA-256");
+
+jsTestIsAsync = true;
+
+var message = asciiToUint8Array("Hello, World!");
+var expectedDigest = "dffd6021bb2bd5b0af676290809ec3a53191dd81c7f70a4b28688a362182986f";
+
+crypto.subtle.digest("sha-256", message).then(function(result){
+ digest = result;
+ shouldBe("bytesToHexString(digest)", "expectedDigest");
+ finishJSTest();
+});
+
+</script>
+
+<script src=""
+</body>
+</html>
Added: trunk/LayoutTests/crypto/subtle/sha384-digest-expected.txt (0 => 209164)
--- trunk/LayoutTests/crypto/subtle/sha384-digest-expected.txt (rev 0)
+++ trunk/LayoutTests/crypto/subtle/sha384-digest-expected.txt 2016-12-01 00:28:04 UTC (rev 209164)
@@ -0,0 +1,10 @@
+Test digest with SHA-384
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS bytesToHexString(digest) is expectedDigest
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/crypto/subtle/sha384-digest.html (0 => 209164)
--- trunk/LayoutTests/crypto/subtle/sha384-digest.html (rev 0)
+++ trunk/LayoutTests/crypto/subtle/sha384-digest.html 2016-12-01 00:28:04 UTC (rev 209164)
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test digest with SHA-384");
+
+jsTestIsAsync = true;
+
+var message = asciiToUint8Array("Hello, World!");
+var expectedDigest = "5485cc9b3365b4305dfb4e8337e0a598a574f8242bf17289e0dd6c20a3cd44a089de16ab4ab308f63e44b1170eb5f515";
+
+crypto.subtle.digest("sha-384", message).then(function(result){
+ digest = result;
+ shouldBe("bytesToHexString(digest)", "expectedDigest");
+ finishJSTest();
+});
+
+</script>
+
+<script src=""
+</body>
+</html>
Added: trunk/LayoutTests/crypto/subtle/sha512-digest-expected.txt (0 => 209164)
--- trunk/LayoutTests/crypto/subtle/sha512-digest-expected.txt (rev 0)
+++ trunk/LayoutTests/crypto/subtle/sha512-digest-expected.txt 2016-12-01 00:28:04 UTC (rev 209164)
@@ -0,0 +1,10 @@
+Test digest with SHA-512
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS bytesToHexString(digest) is expectedDigest
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/crypto/subtle/sha512-digest.html (0 => 209164)
--- trunk/LayoutTests/crypto/subtle/sha512-digest.html (rev 0)
+++ trunk/LayoutTests/crypto/subtle/sha512-digest.html 2016-12-01 00:28:04 UTC (rev 209164)
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test digest with SHA-512");
+
+jsTestIsAsync = true;
+
+var message = asciiToUint8Array("Hello, World!");
+var expectedDigest = "374d794a95cdcfd8b35993185fef9ba368f160d8daf432d08ba9f1ed1e5abe6cc69291e0fa2fe0006a52570ef18c19def4e617c33ce52ef0a6e5fbe318cb0387";
+
+crypto.subtle.digest("sha-512", message).then(function(result){
+ digest = result;
+ shouldBe("bytesToHexString(digest)", "expectedDigest");
+ finishJSTest();
+});
+
+</script>
+
+<script src=""
+</body>
+</html>
Added: trunk/LayoutTests/crypto/workers/subtle/resources/sha1-digest.js (0 => 209164)
--- trunk/LayoutTests/crypto/workers/subtle/resources/sha1-digest.js (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/resources/sha1-digest.js 2016-12-01 00:28:04 UTC (rev 209164)
@@ -0,0 +1,15 @@
+importScripts('../../../../resources/js-test-pre.js');
+importScripts('../../../resources/common.js');
+
+description("Test digest with SHA-1 in workers");
+
+jsTestIsAsync = true;
+
+var message = asciiToUint8Array("Hello, World!");
+var expectedDigest = "0a0a9f2a6772942557ab5355d76af442f8f65e01";
+
+crypto.subtle.digest("sha-1", message).then(function(result){
+ digest = result;
+ shouldBe("bytesToHexString(digest)", "expectedDigest");
+ finishJSTest();
+});
Added: trunk/LayoutTests/crypto/workers/subtle/resources/sha224-digest.js (0 => 209164)
--- trunk/LayoutTests/crypto/workers/subtle/resources/sha224-digest.js (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/resources/sha224-digest.js 2016-12-01 00:28:04 UTC (rev 209164)
@@ -0,0 +1,15 @@
+importScripts('../../../../resources/js-test-pre.js');
+importScripts('../../../resources/common.js');
+
+description("Test digest with SHA-224 in workers");
+
+jsTestIsAsync = true;
+
+var message = asciiToUint8Array("Hello, World!");
+var expectedDigest = "72a23dfa411ba6fde01dbfabf3b00a709c93ebf273dc29e2d8b261ff";
+
+crypto.subtle.digest("sha-224", message).then(function(result){
+ digest = result;
+ shouldBe("bytesToHexString(digest)", "expectedDigest");
+ finishJSTest();
+});
Added: trunk/LayoutTests/crypto/workers/subtle/resources/sha256-digest.js (0 => 209164)
--- trunk/LayoutTests/crypto/workers/subtle/resources/sha256-digest.js (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/resources/sha256-digest.js 2016-12-01 00:28:04 UTC (rev 209164)
@@ -0,0 +1,15 @@
+importScripts('../../../../resources/js-test-pre.js');
+importScripts('../../../resources/common.js');
+
+description("Test digest with SHA-256 in workers");
+
+jsTestIsAsync = true;
+
+var message = asciiToUint8Array("Hello, World!");
+var expectedDigest = "dffd6021bb2bd5b0af676290809ec3a53191dd81c7f70a4b28688a362182986f";
+
+crypto.subtle.digest("sha-256", message).then(function(result){
+ digest = result;
+ shouldBe("bytesToHexString(digest)", "expectedDigest");
+ finishJSTest();
+});
Added: trunk/LayoutTests/crypto/workers/subtle/resources/sha384-digest.js (0 => 209164)
--- trunk/LayoutTests/crypto/workers/subtle/resources/sha384-digest.js (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/resources/sha384-digest.js 2016-12-01 00:28:04 UTC (rev 209164)
@@ -0,0 +1,15 @@
+importScripts('../../../../resources/js-test-pre.js');
+importScripts('../../../resources/common.js');
+
+description("Test digest with SHA-384 in workers");
+
+jsTestIsAsync = true;
+
+var message = asciiToUint8Array("Hello, World!");
+var expectedDigest = "5485cc9b3365b4305dfb4e8337e0a598a574f8242bf17289e0dd6c20a3cd44a089de16ab4ab308f63e44b1170eb5f515";
+
+crypto.subtle.digest("sha-384", message).then(function(result){
+ digest = result;
+ shouldBe("bytesToHexString(digest)", "expectedDigest");
+ finishJSTest();
+});
Added: trunk/LayoutTests/crypto/workers/subtle/resources/sha512-digest.js (0 => 209164)
--- trunk/LayoutTests/crypto/workers/subtle/resources/sha512-digest.js (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/resources/sha512-digest.js 2016-12-01 00:28:04 UTC (rev 209164)
@@ -0,0 +1,15 @@
+importScripts('../../../../resources/js-test-pre.js');
+importScripts('../../../resources/common.js');
+
+description("Test digest with SHA-512 in workers");
+
+jsTestIsAsync = true;
+
+var message = asciiToUint8Array("Hello, World!");
+var expectedDigest = "374d794a95cdcfd8b35993185fef9ba368f160d8daf432d08ba9f1ed1e5abe6cc69291e0fa2fe0006a52570ef18c19def4e617c33ce52ef0a6e5fbe318cb0387";
+
+crypto.subtle.digest("sha-512", message).then(function(result){
+ digest = result;
+ shouldBe("bytesToHexString(digest)", "expectedDigest");
+ finishJSTest();
+});
Added: trunk/LayoutTests/crypto/workers/subtle/sha1-digest-expected.txt (0 => 209164)
--- trunk/LayoutTests/crypto/workers/subtle/sha1-digest-expected.txt (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/sha1-digest-expected.txt 2016-12-01 00:28:04 UTC (rev 209164)
@@ -0,0 +1,11 @@
+[Worker] Test digest with SHA-1 in workers
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Starting worker: resources/sha1-digest.js
+PASS [Worker] bytesToHexString(digest) is expectedDigest
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/crypto/workers/subtle/sha1-digest.html (0 => 209164)
--- trunk/LayoutTests/crypto/workers/subtle/sha1-digest.html (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/sha1-digest.html 2016-12-01 00:28:04 UTC (rev 209164)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src=""
+</head>
+<body>
+ <script>
+ worker = startWorker('resources/sha1-digest.js');
+ </script>
+ <script src=""
+</body>
+</html>
Added: trunk/LayoutTests/crypto/workers/subtle/sha224-digest-expected.txt (0 => 209164)
--- trunk/LayoutTests/crypto/workers/subtle/sha224-digest-expected.txt (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/sha224-digest-expected.txt 2016-12-01 00:28:04 UTC (rev 209164)
@@ -0,0 +1,11 @@
+[Worker] Test digest with SHA-224 in workers
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Starting worker: resources/sha224-digest.js
+PASS [Worker] bytesToHexString(digest) is expectedDigest
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/crypto/workers/subtle/sha224-digest.html (0 => 209164)
--- trunk/LayoutTests/crypto/workers/subtle/sha224-digest.html (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/sha224-digest.html 2016-12-01 00:28:04 UTC (rev 209164)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src=""
+</head>
+<body>
+ <script>
+ worker = startWorker('resources/sha224-digest.js');
+ </script>
+ <script src=""
+</body>
+</html>
Added: trunk/LayoutTests/crypto/workers/subtle/sha256-digest-expected.txt (0 => 209164)
--- trunk/LayoutTests/crypto/workers/subtle/sha256-digest-expected.txt (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/sha256-digest-expected.txt 2016-12-01 00:28:04 UTC (rev 209164)
@@ -0,0 +1,11 @@
+[Worker] Test digest with SHA-256 in workers
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Starting worker: resources/sha256-digest.js
+PASS [Worker] bytesToHexString(digest) is expectedDigest
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/crypto/workers/subtle/sha256-digest.html (0 => 209164)
--- trunk/LayoutTests/crypto/workers/subtle/sha256-digest.html (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/sha256-digest.html 2016-12-01 00:28:04 UTC (rev 209164)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src=""
+</head>
+<body>
+ <script>
+ worker = startWorker('resources/sha256-digest.js');
+ </script>
+ <script src=""
+</body>
+</html>
Added: trunk/LayoutTests/crypto/workers/subtle/sha384-digest-expected.txt (0 => 209164)
--- trunk/LayoutTests/crypto/workers/subtle/sha384-digest-expected.txt (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/sha384-digest-expected.txt 2016-12-01 00:28:04 UTC (rev 209164)
@@ -0,0 +1,11 @@
+[Worker] Test digest with SHA-384 in workers
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Starting worker: resources/sha384-digest.js
+PASS [Worker] bytesToHexString(digest) is expectedDigest
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/crypto/workers/subtle/sha384-digest.html (0 => 209164)
--- trunk/LayoutTests/crypto/workers/subtle/sha384-digest.html (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/sha384-digest.html 2016-12-01 00:28:04 UTC (rev 209164)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src=""
+</head>
+<body>
+ <script>
+ worker = startWorker('resources/sha384-digest.js');
+ </script>
+ <script src=""
+</body>
+</html>
Added: trunk/LayoutTests/crypto/workers/subtle/sha512-digest-expected.txt (0 => 209164)
--- trunk/LayoutTests/crypto/workers/subtle/sha512-digest-expected.txt (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/sha512-digest-expected.txt 2016-12-01 00:28:04 UTC (rev 209164)
@@ -0,0 +1,11 @@
+[Worker] Test digest with SHA-512 in workers
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Starting worker: resources/sha512-digest.js
+PASS [Worker] bytesToHexString(digest) is expectedDigest
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/crypto/workers/subtle/sha512-digest.html (0 => 209164)
--- trunk/LayoutTests/crypto/workers/subtle/sha512-digest.html (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/sha512-digest.html 2016-12-01 00:28:04 UTC (rev 209164)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src=""
+</head>
+<body>
+ <script>
+ worker = startWorker('resources/sha512-digest.js');
+ </script>
+ <script src=""
+</body>
+</html>
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (209163 => 209164)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2016-12-01 00:14:19 UTC (rev 209163)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2016-12-01 00:28:04 UTC (rev 209164)
@@ -1,3 +1,14 @@
+2016-11-26 Jiewen Tan <jiewen_...@apple.com>
+
+ Update SubtleCrypto::digest to match the latest spec
+ https://bugs.webkit.org/show_bug.cgi?id=164742
+ <rdar://problem/29258037>
+
+ Reviewed by Darin Adler.
+
+ * WebCryptoAPI/digest/test_digest-expected.txt:
+ * WebCryptoAPI/idlharness-expected.txt:
+
2016-11-30 Jiewen Tan <jiewen_...@apple.com>
Update SubtleCrypto::wrapKey to match the latest spec
Modified: trunk/LayoutTests/imported/w3c/WebCryptoAPI/digest/test_digest-expected.txt (209163 => 209164)
--- trunk/LayoutTests/imported/w3c/WebCryptoAPI/digest/test_digest-expected.txt 2016-12-01 00:14:19 UTC (rev 209163)
+++ trunk/LayoutTests/imported/w3c/WebCryptoAPI/digest/test_digest-expected.txt 2016-12-01 00:28:04 UTC (rev 209164)
@@ -1,84 +1,84 @@
encrypt Tests for digest method
-FAIL SHA-1 with empty source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL sha-1 with empty source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL Sha-1 with empty source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL SHA-1 with empty source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined)
-FAIL SHA-256 with empty source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL sha-256 with empty source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL Sha-256 with empty source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL SHA-256 with empty source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined)
-FAIL SHA-384 with empty source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL sha-384 with empty source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL Sha-384 with empty source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL SHA-384 with empty source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined)
-FAIL SHA-512 with empty source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL sha-512 with empty source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL Sha-512 with empty source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL SHA-512 with empty source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined)
-FAIL SHA-1 with short source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL sha-1 with short source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL Sha-1 with short source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL SHA-1 with short source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined)
-FAIL SHA-256 with short source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL sha-256 with short source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL Sha-256 with short source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL SHA-256 with short source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined)
-FAIL SHA-384 with short source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL sha-384 with short source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL Sha-384 with short source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL SHA-384 with short source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined)
-FAIL SHA-512 with short source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL sha-512 with short source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL Sha-512 with short source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL SHA-512 with short source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined)
-FAIL SHA-1 with medium source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL sha-1 with medium source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL Sha-1 with medium source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL SHA-1 with medium source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined)
-FAIL SHA-256 with medium source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL sha-256 with medium source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL Sha-256 with medium source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL SHA-256 with medium source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined)
-FAIL SHA-384 with medium source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL sha-384 with medium source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL Sha-384 with medium source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL SHA-384 with medium source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined)
-FAIL SHA-512 with medium source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL sha-512 with medium source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL Sha-512 with medium source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL SHA-512 with medium source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined)
-FAIL SHA-1 with long source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL sha-1 with long source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL Sha-1 with long source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL SHA-1 with long source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined)
-FAIL SHA-256 with long source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL sha-256 with long source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL Sha-256 with long source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL SHA-256 with long source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined)
-FAIL SHA-384 with long source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL sha-384 with long source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL Sha-384 with long source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL SHA-384 with long source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined)
-FAIL SHA-512 with long source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL sha-512 with long source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL Sha-512 with long source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL SHA-512 with long source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined)
-FAIL AES-GCM with empty subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL RSA-OAEP with empty subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL PBKDF2 with empty subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL AES-KW with empty subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL AES-GCM with short subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL RSA-OAEP with short subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL PBKDF2 with short subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL AES-KW with short subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL AES-GCM with medium subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL RSA-OAEP with medium subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL PBKDF2 with medium subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL AES-KW with medium subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL AES-GCM with long subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL RSA-OAEP with long subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL PBKDF2 with long subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined)
-FAIL AES-KW with long subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined)
+PASS SHA-1 with empty source data
+PASS sha-1 with empty source data
+PASS Sha-1 with empty source data
+PASS SHA-1 with empty source data and altered buffer after call
+PASS SHA-256 with empty source data
+PASS sha-256 with empty source data
+PASS Sha-256 with empty source data
+PASS SHA-256 with empty source data and altered buffer after call
+PASS SHA-384 with empty source data
+PASS sha-384 with empty source data
+PASS Sha-384 with empty source data
+PASS SHA-384 with empty source data and altered buffer after call
+PASS SHA-512 with empty source data
+PASS sha-512 with empty source data
+PASS Sha-512 with empty source data
+PASS SHA-512 with empty source data and altered buffer after call
+PASS SHA-1 with short source data
+PASS sha-1 with short source data
+PASS Sha-1 with short source data
+PASS SHA-1 with short source data and altered buffer after call
+PASS SHA-256 with short source data
+PASS sha-256 with short source data
+PASS Sha-256 with short source data
+PASS SHA-256 with short source data and altered buffer after call
+PASS SHA-384 with short source data
+PASS sha-384 with short source data
+PASS Sha-384 with short source data
+PASS SHA-384 with short source data and altered buffer after call
+PASS SHA-512 with short source data
+PASS sha-512 with short source data
+PASS Sha-512 with short source data
+PASS SHA-512 with short source data and altered buffer after call
+PASS SHA-1 with medium source data
+PASS sha-1 with medium source data
+PASS Sha-1 with medium source data
+PASS SHA-1 with medium source data and altered buffer after call
+PASS SHA-256 with medium source data
+PASS sha-256 with medium source data
+PASS Sha-256 with medium source data
+PASS SHA-256 with medium source data and altered buffer after call
+PASS SHA-384 with medium source data
+PASS sha-384 with medium source data
+PASS Sha-384 with medium source data
+PASS SHA-384 with medium source data and altered buffer after call
+PASS SHA-512 with medium source data
+PASS sha-512 with medium source data
+PASS Sha-512 with medium source data
+PASS SHA-512 with medium source data and altered buffer after call
+PASS SHA-1 with long source data
+PASS sha-1 with long source data
+PASS Sha-1 with long source data
+PASS SHA-1 with long source data and altered buffer after call
+PASS SHA-256 with long source data
+PASS sha-256 with long source data
+PASS Sha-256 with long source data
+PASS SHA-256 with long source data and altered buffer after call
+PASS SHA-384 with long source data
+PASS sha-384 with long source data
+PASS Sha-384 with long source data
+PASS SHA-384 with long source data and altered buffer after call
+PASS SHA-512 with long source data
+PASS sha-512 with long source data
+PASS Sha-512 with long source data
+PASS SHA-512 with long source data and altered buffer after call
+PASS AES-GCM with empty
+PASS RSA-OAEP with empty
+PASS PBKDF2 with empty
+PASS AES-KW with empty
+PASS AES-GCM with short
+PASS RSA-OAEP with short
+PASS PBKDF2 with short
+PASS AES-KW with short
+PASS AES-GCM with medium
+PASS RSA-OAEP with medium
+PASS PBKDF2 with medium
+PASS AES-KW with medium
+PASS AES-GCM with long
+PASS RSA-OAEP with long
+PASS PBKDF2 with long
+PASS AES-KW with long
Modified: trunk/LayoutTests/imported/w3c/WebCryptoAPI/idlharness-expected.txt (209163 => 209164)
--- trunk/LayoutTests/imported/w3c/WebCryptoAPI/idlharness-expected.txt 2016-12-01 00:14:19 UTC (rev 209163)
+++ trunk/LayoutTests/imported/w3c/WebCryptoAPI/idlharness-expected.txt 2016-12-01 00:28:04 UTC (rev 209164)
@@ -51,8 +51,8 @@
PASS SubtleCrypto interface: calling sign(AlgorithmIdentifier,CryptoKey,BufferSource) on crypto.subtle with too few arguments must throw TypeError
PASS SubtleCrypto interface: crypto.subtle must inherit property "verify" with the proper type (3)
PASS SubtleCrypto interface: calling verify(AlgorithmIdentifier,CryptoKey,BufferSource,BufferSource) on crypto.subtle with too few arguments must throw TypeError
-FAIL SubtleCrypto interface: crypto.subtle must inherit property "digest" with the proper type (4) assert_inherits: property "digest" not found in prototype chain
-FAIL SubtleCrypto interface: calling digest(AlgorithmIdentifier,BufferSource) on crypto.subtle with too few arguments must throw TypeError assert_inherits: property "digest" not found in prototype chain
+PASS SubtleCrypto interface: crypto.subtle must inherit property "digest" with the proper type (4)
+PASS SubtleCrypto interface: calling digest(AlgorithmIdentifier,BufferSource) on crypto.subtle with too few arguments must throw TypeError
PASS SubtleCrypto interface: crypto.subtle must inherit property "generateKey" with the proper type (5)
PASS SubtleCrypto interface: calling generateKey(AlgorithmIdentifier,boolean,[object Object]) on crypto.subtle with too few arguments must throw TypeError
FAIL SubtleCrypto interface: crypto.subtle must inherit property "deriveKey" with the proper type (6) assert_inherits: property "deriveKey" not found in prototype chain
Modified: trunk/Source/WebCore/ChangeLog (209163 => 209164)
--- trunk/Source/WebCore/ChangeLog 2016-12-01 00:14:19 UTC (rev 209163)
+++ trunk/Source/WebCore/ChangeLog 2016-12-01 00:28:04 UTC (rev 209164)
@@ -1,3 +1,53 @@
+2016-11-26 Jiewen Tan <jiewen_...@apple.com>
+
+ Update SubtleCrypto::digest to match the latest spec
+ https://bugs.webkit.org/show_bug.cgi?id=164742
+ <rdar://problem/29258037>
+
+ Reviewed by Darin Adler.
+
+ This patch updates the SubtleCrypto::digest method to match the latest spec:
+ https://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-digest.
+ It also refers to the latest Editor's Draft to a certain degree:
+ https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-digest.
+ Currently supported digest algorithms are SHA-1, SHA-224, SHA-256, SHA-384,
+ and SHA-512.
+
+ Tests: crypto/subtle/digest-malformed-parameters.html
+ crypto/subtle/sha1-digest.html
+ crypto/subtle/sha224-digest.html
+ crypto/subtle/sha256-digest.html
+ crypto/subtle/sha384-digest.html
+ crypto/subtle/sha512-digest.html
+ crypto/workers/subtle/sha1-digest.html
+ crypto/workers/subtle/sha224-digest.html
+ crypto/workers/subtle/sha256-digest.html
+ crypto/workers/subtle/sha384-digest.html
+ crypto/workers/subtle/sha512-digest.html
+
+ * bindings/js/JSSubtleCryptoCustom.cpp:
+ (WebCore::jsSubtleCryptoFunctionDigestPromise):
+ (WebCore::JSSubtleCrypto::digest):
+ * crypto/CryptoAlgorithm.cpp:
+ (WebCore::CryptoAlgorithm::digest):
+ * crypto/CryptoAlgorithm.h:
+ * crypto/SubtleCrypto.idl:
+ * crypto/algorithms/CryptoAlgorithmSHA1.cpp:
+ (WebCore::CryptoAlgorithmSHA1::digest):
+ * crypto/algorithms/CryptoAlgorithmSHA1.h:
+ * crypto/algorithms/CryptoAlgorithmSHA224.cpp:
+ (WebCore::CryptoAlgorithmSHA224::digest):
+ * crypto/algorithms/CryptoAlgorithmSHA224.h:
+ * crypto/algorithms/CryptoAlgorithmSHA256.cpp:
+ (WebCore::CryptoAlgorithmSHA256::digest):
+ * crypto/algorithms/CryptoAlgorithmSHA256.h:
+ * crypto/algorithms/CryptoAlgorithmSHA384.cpp:
+ (WebCore::CryptoAlgorithmSHA384::digest):
+ * crypto/algorithms/CryptoAlgorithmSHA384.h:
+ * crypto/algorithms/CryptoAlgorithmSHA512.cpp:
+ (WebCore::CryptoAlgorithmSHA512::digest):
+ * crypto/algorithms/CryptoAlgorithmSHA512.h:
+
2016-11-30 Antoine Quint <grao...@apple.com>
[Modern Media Controls] UI Library: <audio> controls
Modified: trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp (209163 => 209164)
--- trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp 2016-12-01 00:14:19 UTC (rev 209163)
+++ trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp 2016-12-01 00:28:04 UTC (rev 209164)
@@ -645,6 +645,38 @@
algorithm->verify(key.releaseNonNull(), WTFMove(signature), WTFMove(data), WTFMove(callback), WTFMove(exceptionCallback), *scriptExecutionContextFromExecState(&state), subtle->wrapped().workQueue());
}
+static void jsSubtleCryptoFunctionDigestPromise(ExecState& state, Ref<DeferredPromise>&& promise)
+{
+ VM& vm = state.vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ if (UNLIKELY(state.argumentCount() < 2)) {
+ promise->reject<JSValue>(createNotEnoughArgumentsError(&state));
+ return;
+ }
+
+ auto params = normalizeCryptoAlgorithmParameters(state, state.uncheckedArgument(0), Operations::Digest);
+ RETURN_IF_EXCEPTION(scope, void());
+
+ auto data = "" state.uncheckedArgument(1));
+ RETURN_IF_EXCEPTION(scope, void());
+
+ auto algorithm = createAlgorithm(state, params->identifier);
+ RETURN_IF_EXCEPTION(scope, void());
+
+ auto callback = [capturedPromise = promise.copyRef()](const Vector<uint8_t>& digest) mutable {
+ fulfillPromiseWithArrayBuffer(WTFMove(capturedPromise), digest.data(), digest.size());
+ return;
+ };
+ auto exceptionCallback = [capturedPromise = WTFMove(promise)](ExceptionCode ec) mutable {
+ rejectWithException(WTFMove(capturedPromise), ec);
+ };
+
+ auto subtle = jsDynamicDowncast<JSSubtleCrypto*>(state.thisValue());
+ ASSERT(subtle);
+ algorithm->digest(WTFMove(data), WTFMove(callback), WTFMove(exceptionCallback), *scriptExecutionContextFromExecState(&state), subtle->wrapped().workQueue());
+}
+
static void jsSubtleCryptoFunctionGenerateKeyPromise(ExecState& state, Ref<DeferredPromise>&& promise)
{
VM& vm = state.vm();
@@ -910,6 +942,11 @@
return callPromiseFunction<jsSubtleCryptoFunctionVerifyPromise, PromiseExecutionScope::WindowOrWorker>(state);
}
+JSValue JSSubtleCrypto::digest(ExecState& state)
+{
+ return callPromiseFunction<jsSubtleCryptoFunctionDigestPromise, PromiseExecutionScope::WindowOrWorker>(state);
+}
+
JSValue JSSubtleCrypto::generateKey(ExecState& state)
{
return callPromiseFunction<jsSubtleCryptoFunctionGenerateKeyPromise, PromiseExecutionScope::WindowOrWorker>(state);
Modified: trunk/Source/WebCore/crypto/CryptoAlgorithm.cpp (209163 => 209164)
--- trunk/Source/WebCore/crypto/CryptoAlgorithm.cpp 2016-12-01 00:14:19 UTC (rev 209163)
+++ trunk/Source/WebCore/crypto/CryptoAlgorithm.cpp 2016-12-01 00:28:04 UTC (rev 209164)
@@ -52,6 +52,11 @@
exceptionCallback(NOT_SUPPORTED_ERR);
}
+void CryptoAlgorithm::digest(Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&, WorkQueue&)
+{
+ exceptionCallback(NOT_SUPPORTED_ERR);
+}
+
void CryptoAlgorithm::generateKey(const CryptoAlgorithmParameters&, bool, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&)
{
exceptionCallback(NOT_SUPPORTED_ERR);
Modified: trunk/Source/WebCore/crypto/CryptoAlgorithm.h (209163 => 209164)
--- trunk/Source/WebCore/crypto/CryptoAlgorithm.h 2016-12-01 00:14:19 UTC (rev 209163)
+++ trunk/Source/WebCore/crypto/CryptoAlgorithm.h 2016-12-01 00:28:04 UTC (rev 209164)
@@ -68,6 +68,7 @@
virtual void decrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
virtual void sign(Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
virtual void verify(Ref<CryptoKey>&&, Vector<uint8_t>&& signature, Vector<uint8_t>&&, BoolCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
+ virtual void digest(Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
virtual void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&);
virtual void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&);
virtual void exportKey(SubtleCrypto::KeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&);
Modified: trunk/Source/WebCore/crypto/SubtleCrypto.idl (209163 => 209164)
--- trunk/Source/WebCore/crypto/SubtleCrypto.idl 2016-12-01 00:14:19 UTC (rev 209163)
+++ trunk/Source/WebCore/crypto/SubtleCrypto.idl 2016-12-01 00:28:04 UTC (rev 209164)
@@ -35,6 +35,7 @@
[Custom] Promise<any> decrypt(AlgorithmIdentifier algorithm, CryptoKey key, BufferSource data);
[Custom] Promise<any> sign(AlgorithmIdentifier algorithm, CryptoKey key, BufferSource data);
[Custom] Promise<any> verify(AlgorithmIdentifier algorithm, CryptoKey key, BufferSource signature, BufferSource data);
+ [Custom] Promise<any> digest(AlgorithmIdentifier algorithm, BufferSource data);
// FIXME: Should this return a Promise<(CryptoKey or CryptoKeyPair)>?
[Custom] Promise<any> generateKey(AlgorithmIdentifier algorithm, boolean extractable, sequence<CryptoKeyUsage> keyUsages);
[Custom] Promise<CryptoKey> importKey(KeyFormat format, (BufferSource or JsonWebKey) keyData, AlgorithmIdentifier algorithm, boolen extractable, sequence<CryptoKeyUsage> keyUsages);
Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA1.cpp (209163 => 209164)
--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA1.cpp 2016-12-01 00:14:19 UTC (rev 209163)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA1.cpp 2016-12-01 00:28:04 UTC (rev 209164)
@@ -29,6 +29,8 @@
#if ENABLE(SUBTLE_CRYPTO)
#include "CryptoDigest.h"
+#include "ExceptionCode.h"
+#include "ScriptExecutionContext.h"
namespace WebCore {
@@ -42,6 +44,25 @@
return s_identifier;
}
+void CryptoAlgorithmSHA1::digest(Vector<uint8_t>&& message, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
+{
+ auto digest = CryptoDigest::create(CryptoDigest::Algorithm::SHA_1);
+ if (!digest) {
+ exceptionCallback(OperationError);
+ return;
+ }
+
+ context.ref();
+ workQueue.dispatch([digest = WTFMove(digest), message = WTFMove(message), callback = WTFMove(callback), &context]() mutable {
+ digest->addBytes(message.data(), message.size());
+ auto result = digest->computeHash();
+ context.postTask([callback = WTFMove(callback), result = WTFMove(result)](ScriptExecutionContext& context) {
+ callback(result);
+ context.deref();
+ });
+ });
+}
+
ExceptionOr<void> CryptoAlgorithmSHA1::digest(const CryptoAlgorithmParametersDeprecated&, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback)
{
auto digest = CryptoDigest::create(CryptoDigest::Algorithm::SHA_1);
Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA1.h (209163 => 209164)
--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA1.h 2016-12-01 00:14:19 UTC (rev 209163)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA1.h 2016-12-01 00:28:04 UTC (rev 209164)
@@ -40,6 +40,7 @@
private:
CryptoAlgorithmSHA1() = default;
CryptoAlgorithmIdentifier identifier() const final;
+ void digest(Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
ExceptionOr<void> digest(const CryptoAlgorithmParametersDeprecated&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback) final;
};
Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA224.cpp (209163 => 209164)
--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA224.cpp 2016-12-01 00:14:19 UTC (rev 209163)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA224.cpp 2016-12-01 00:28:04 UTC (rev 209164)
@@ -29,6 +29,8 @@
#if ENABLE(SUBTLE_CRYPTO)
#include "CryptoDigest.h"
+#include "ExceptionCode.h"
+#include "ScriptExecutionContext.h"
namespace WebCore {
@@ -42,6 +44,25 @@
return s_identifier;
}
+void CryptoAlgorithmSHA224::digest(Vector<uint8_t>&& message, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
+{
+ auto digest = CryptoDigest::create(CryptoDigest::Algorithm::SHA_224);
+ if (!digest) {
+ exceptionCallback(OperationError);
+ return;
+ }
+
+ context.ref();
+ workQueue.dispatch([digest = WTFMove(digest), message = WTFMove(message), callback = WTFMove(callback), &context]() mutable {
+ digest->addBytes(message.data(), message.size());
+ auto result = digest->computeHash();
+ context.postTask([callback = WTFMove(callback), result = WTFMove(result)](ScriptExecutionContext& context) {
+ callback(result);
+ context.deref();
+ });
+ });
+}
+
ExceptionOr<void> CryptoAlgorithmSHA224::digest(const CryptoAlgorithmParametersDeprecated&, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback)
{
auto digest = CryptoDigest::create(CryptoDigest::Algorithm::SHA_224);
Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA224.h (209163 => 209164)
--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA224.h 2016-12-01 00:14:19 UTC (rev 209163)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA224.h 2016-12-01 00:28:04 UTC (rev 209164)
@@ -40,6 +40,7 @@
private:
CryptoAlgorithmSHA224() = default;
CryptoAlgorithmIdentifier identifier() const final;
+ void digest(Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
ExceptionOr<void> digest(const CryptoAlgorithmParametersDeprecated&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback) final;
};
Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA256.cpp (209163 => 209164)
--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA256.cpp 2016-12-01 00:14:19 UTC (rev 209163)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA256.cpp 2016-12-01 00:28:04 UTC (rev 209164)
@@ -29,6 +29,8 @@
#if ENABLE(SUBTLE_CRYPTO)
#include "CryptoDigest.h"
+#include "ExceptionCode.h"
+#include "ScriptExecutionContext.h"
namespace WebCore {
@@ -42,6 +44,25 @@
return s_identifier;
}
+void CryptoAlgorithmSHA256::digest(Vector<uint8_t>&& message, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
+{
+ auto digest = CryptoDigest::create(CryptoDigest::Algorithm::SHA_256);
+ if (!digest) {
+ exceptionCallback(OperationError);
+ return;
+ }
+
+ context.ref();
+ workQueue.dispatch([digest = WTFMove(digest), message = WTFMove(message), callback = WTFMove(callback), &context]() mutable {
+ digest->addBytes(message.data(), message.size());
+ auto result = digest->computeHash();
+ context.postTask([callback = WTFMove(callback), result = WTFMove(result)](ScriptExecutionContext& context) {
+ callback(result);
+ context.deref();
+ });
+ });
+}
+
ExceptionOr<void> CryptoAlgorithmSHA256::digest(const CryptoAlgorithmParametersDeprecated&, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback)
{
auto digest = CryptoDigest::create(CryptoDigest::Algorithm::SHA_256);
Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA256.h (209163 => 209164)
--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA256.h 2016-12-01 00:14:19 UTC (rev 209163)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA256.h 2016-12-01 00:28:04 UTC (rev 209164)
@@ -40,6 +40,7 @@
private:
CryptoAlgorithmSHA256() = default;
CryptoAlgorithmIdentifier identifier() const final;
+ void digest(Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
ExceptionOr<void> digest(const CryptoAlgorithmParametersDeprecated&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback) final;
};
Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA384.cpp (209163 => 209164)
--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA384.cpp 2016-12-01 00:14:19 UTC (rev 209163)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA384.cpp 2016-12-01 00:28:04 UTC (rev 209164)
@@ -29,6 +29,8 @@
#if ENABLE(SUBTLE_CRYPTO)
#include "CryptoDigest.h"
+#include "ExceptionCode.h"
+#include "ScriptExecutionContext.h"
namespace WebCore {
@@ -42,6 +44,25 @@
return s_identifier;
}
+void CryptoAlgorithmSHA384::digest(Vector<uint8_t>&& message, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
+{
+ auto digest = CryptoDigest::create(CryptoDigest::Algorithm::SHA_384);
+ if (!digest) {
+ exceptionCallback(OperationError);
+ return;
+ }
+
+ context.ref();
+ workQueue.dispatch([digest = WTFMove(digest), message = WTFMove(message), callback = WTFMove(callback), &context]() mutable {
+ digest->addBytes(message.data(), message.size());
+ auto result = digest->computeHash();
+ context.postTask([callback = WTFMove(callback), result = WTFMove(result)](ScriptExecutionContext& context) {
+ callback(result);
+ context.deref();
+ });
+ });
+}
+
ExceptionOr<void> CryptoAlgorithmSHA384::digest(const CryptoAlgorithmParametersDeprecated&, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback)
{
auto digest = CryptoDigest::create(CryptoDigest::Algorithm::SHA_384);
Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA384.h (209163 => 209164)
--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA384.h 2016-12-01 00:14:19 UTC (rev 209163)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA384.h 2016-12-01 00:28:04 UTC (rev 209164)
@@ -40,6 +40,7 @@
private:
CryptoAlgorithmSHA384() = default;
CryptoAlgorithmIdentifier identifier() const final;
+ void digest(Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
ExceptionOr<void> digest(const CryptoAlgorithmParametersDeprecated&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback) final;
};
Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA512.cpp (209163 => 209164)
--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA512.cpp 2016-12-01 00:14:19 UTC (rev 209163)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA512.cpp 2016-12-01 00:28:04 UTC (rev 209164)
@@ -29,6 +29,8 @@
#if ENABLE(SUBTLE_CRYPTO)
#include "CryptoDigest.h"
+#include "ExceptionCode.h"
+#include "ScriptExecutionContext.h"
namespace WebCore {
@@ -42,6 +44,25 @@
return s_identifier;
}
+void CryptoAlgorithmSHA512::digest(Vector<uint8_t>&& message, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
+{
+ auto digest = CryptoDigest::create(CryptoDigest::Algorithm::SHA_512);
+ if (!digest) {
+ exceptionCallback(OperationError);
+ return;
+ }
+
+ context.ref();
+ workQueue.dispatch([digest = WTFMove(digest), message = WTFMove(message), callback = WTFMove(callback), &context]() mutable {
+ digest->addBytes(message.data(), message.size());
+ auto result = digest->computeHash();
+ context.postTask([callback = WTFMove(callback), result = WTFMove(result)](ScriptExecutionContext& context) {
+ callback(result);
+ context.deref();
+ });
+ });
+}
+
ExceptionOr<void> CryptoAlgorithmSHA512::digest(const CryptoAlgorithmParametersDeprecated&, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback)
{
auto digest = CryptoDigest::create(CryptoDigest::Algorithm::SHA_512);
Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA512.h (209163 => 209164)
--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA512.h 2016-12-01 00:14:19 UTC (rev 209163)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA512.h 2016-12-01 00:28:04 UTC (rev 209164)
@@ -40,6 +40,7 @@
private:
CryptoAlgorithmSHA512() = default;
CryptoAlgorithmIdentifier identifier() const final;
+ void digest(Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
ExceptionOr<void> digest(const CryptoAlgorithmParametersDeprecated&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback) final;
};