Update SubtleCrypto::digest to match the latest spec
authorjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Dec 2016 00:28:04 +0000 (00:28 +0000)
committerjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Dec 2016 00:28:04 +0000 (00:28 +0000)
commit6f28ce7d6a54ec301851d2027b0e9bb4d58ad78c
tree064c417fc8bad32a07dedffe602b8f8180316de0
parente42d31e8f7ebdfd9ec51cc9143515668111c68be
Update SubtleCrypto::digest to match the latest spec
https://bugs.webkit.org/show_bug.cgi?id=164742
<rdar://problem/29258037>

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

* WebCryptoAPI/digest/test_digest-expected.txt:
* WebCryptoAPI/idlharness-expected.txt:

Source/WebCore:

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:

LayoutTests:

* 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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@209164 268f45cc-cd09-0410-ab3c-d52691b4dbfc
46 files changed:
LayoutTests/ChangeLog
LayoutTests/crypto/subtle/digest-malformed-parameters-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/digest-malformed-parameters.html [new file with mode: 0644]
LayoutTests/crypto/subtle/sha1-digest-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/sha1-digest.html [new file with mode: 0644]
LayoutTests/crypto/subtle/sha224-digest-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/sha224-digest.html [new file with mode: 0644]
LayoutTests/crypto/subtle/sha256-digest-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/sha256-digest.html [new file with mode: 0644]
LayoutTests/crypto/subtle/sha384-digest-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/sha384-digest.html [new file with mode: 0644]
LayoutTests/crypto/subtle/sha512-digest-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/sha512-digest.html [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/resources/sha1-digest.js [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/resources/sha224-digest.js [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/resources/sha256-digest.js [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/resources/sha384-digest.js [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/resources/sha512-digest.js [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/sha1-digest-expected.txt [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/sha1-digest.html [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/sha224-digest-expected.txt [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/sha224-digest.html [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/sha256-digest-expected.txt [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/sha256-digest.html [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/sha384-digest-expected.txt [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/sha384-digest.html [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/sha512-digest-expected.txt [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/sha512-digest.html [new file with mode: 0644]
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/WebCryptoAPI/digest/test_digest-expected.txt
LayoutTests/imported/w3c/WebCryptoAPI/idlharness-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp
Source/WebCore/crypto/CryptoAlgorithm.cpp
Source/WebCore/crypto/CryptoAlgorithm.h
Source/WebCore/crypto/SubtleCrypto.idl
Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA1.cpp
Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA1.h
Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA224.cpp
Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA224.h
Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA256.cpp
Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA256.h
Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA384.cpp
Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA384.h
Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA512.cpp
Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA512.h