Update SubtleCrypto::verify to match the latest spec
authorjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Nov 2016 21:19:20 +0000 (21:19 +0000)
committerjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Nov 2016 21:19:20 +0000 (21:19 +0000)
commit82d4eaf6df703e1201368c64a58f417606af1afb
tree74724793e3c9da254fca1cdcf5005b59f75392fc
parent219e12c0a057fc56bbf2eb7d3d3ae2378a1bbc84
Update SubtleCrypto::verify to match the latest spec
https://bugs.webkit.org/show_bug.cgi?id=164741
<rdar://problem/29257935>

Reviewed by Brent Fulgham.

LayoutTests/imported/w3c:

* WebCryptoAPI/idlharness-expected.txt:

Source/WebCore:

This patch does following few things:
1. It updates the SubtleCrypto::verify method to match the latest spec:
   https://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-verify.
   It also refers to the latest Editor's Draft to a certain degree:
   https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-verify.
2. It implements verify operations of the following algorithms: HMAC, and
   RSASSA-PKCS1-V1_5.

Tests: crypto/subtle/hmac-generate-key-sign-verify.html
       crypto/subtle/hmac-import-key-verify-sha1.html
       crypto/subtle/hmac-import-key-verify-sha224.html
       crypto/subtle/hmac-import-key-verify-sha256.html
       crypto/subtle/hmac-import-key-verify-sha384.html
       crypto/subtle/hmac-import-key-verify-sha512.html
       crypto/subtle/rsassa-pkcs1-v1_5-generate-key-sign-verify.html
       crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha1.html
       crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha224.html
       crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha256.html
       crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha384.html
       crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha512.html
       crypto/subtle/verify-malformed-parameters.html
       crypto/workers/subtle/hmac-import-key-verify.html
       crypto/workers/subtle/rsassa-pkcs1-v1_5-import-key-verify.html

* bindings/js/JSSubtleCryptoCustom.cpp:
(WebCore::normalizeCryptoAlgorithmParameters):
(WebCore::jsSubtleCryptoFunctionVerifyPromise):
(WebCore::JSSubtleCrypto::verify):
* crypto/CryptoAlgorithm.cpp:
(WebCore::CryptoAlgorithm::verify):
* crypto/CryptoAlgorithm.h:
* crypto/SubtleCrypto.idl:
* crypto/algorithms/CryptoAlgorithmHMAC.cpp:
(WebCore::CryptoAlgorithmHMAC::verify):
* crypto/algorithms/CryptoAlgorithmHMAC.h:
* crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp:
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::verify):
* crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h:
* crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp:
(WebCore::CryptoAlgorithmHMAC::platformVerify):
* crypto/gnutls/CryptoAlgorithmHMACGnuTLS.cpp:
(WebCore::CryptoAlgorithmHMAC::platformVerify):
* crypto/gnutls/CryptoAlgorithmRSASSA_PKCS1_v1_5GnuTLS.cpp:
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerify):
* crypto/mac/CryptoAlgorithmHMACMac.cpp:
(WebCore::CryptoAlgorithmHMAC::platformVerify):
* crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp:
(WebCore::verifyRSASSA_PKCS1_v1_5):
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerify):

LayoutTests:

Besides adding tests for SubtleCrypto::verify, it also enhances
*generate-key-encrypt-decrypt tests.

* crypto/subtle/aes-cbc-generate-key-encrypt-decrypt-expected.txt:
* crypto/subtle/aes-cbc-generate-key-encrypt-decrypt.html:
* crypto/subtle/hmac-generate-key-sign-verify-expected.txt: Added.
* crypto/subtle/hmac-generate-key-sign-verify.html: Added.
* crypto/subtle/hmac-import-key-verify-sha1-expected.txt: Added.
* crypto/subtle/hmac-import-key-verify-sha1.html: Added.
* crypto/subtle/hmac-import-key-verify-sha224-expected.txt: Added.
* crypto/subtle/hmac-import-key-verify-sha224.html: Added.
* crypto/subtle/hmac-import-key-verify-sha256-expected.txt: Added.
* crypto/subtle/hmac-import-key-verify-sha256.html: Added.
* crypto/subtle/hmac-import-key-verify-sha384-expected.txt: Added.
* crypto/subtle/hmac-import-key-verify-sha384.html: Added.
* crypto/subtle/hmac-import-key-verify-sha512-expected.txt: Added.
* crypto/subtle/hmac-import-key-verify-sha512.html: Added.
* crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-expected.txt:
* crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-label-expected.txt:
* crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-label.html:
* crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt.html:
* crypto/subtle/rsaes-pkcs1-v1_5-generate-key-encrypt-decrypt-expected.txt:
* crypto/subtle/rsaes-pkcs1-v1_5-generate-key-encrypt-decrypt.html:
* crypto/subtle/rsassa-pkcs1-v1_5-generate-key-sign-verify-expected.txt: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-generate-key-sign-verify.html: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha1-expected.txt: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha1.html: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha224-expected.txt: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha224.html: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha256-expected.txt: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha256.html: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha384-expected.txt: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha384.html: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha512-expected.txt: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha512.html: Added.
* crypto/subtle/verify-malformed-parameters-expected.txt: Added.
* crypto/subtle/verify-malformed-parameters.html: Added.
* crypto/workers/subtle/hmac-import-key-verify-expected.txt: Added.
* crypto/workers/subtle/hmac-import-key-verify.html: Added.
* crypto/workers/subtle/resources/hmac-import-key-verify.js: Added.
* crypto/workers/subtle/resources/rsassa-pkcs1-v1_5-import-key-verify.js: Added.
* crypto/workers/subtle/rsassa-pkcs1-v1_5-import-key-verify-expected.txt: Added.
* crypto/workers/subtle/rsassa-pkcs1-v1_5-import-key-verify.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@209150 268f45cc-cd09-0410-ab3c-d52691b4dbfc
57 files changed:
LayoutTests/ChangeLog
LayoutTests/crypto/subtle/aes-cbc-generate-key-encrypt-decrypt-expected.txt
LayoutTests/crypto/subtle/aes-cbc-generate-key-encrypt-decrypt.html
LayoutTests/crypto/subtle/hmac-generate-key-sign-verify-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/hmac-generate-key-sign-verify.html [new file with mode: 0644]
LayoutTests/crypto/subtle/hmac-import-key-verify-sha1-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/hmac-import-key-verify-sha1.html [new file with mode: 0644]
LayoutTests/crypto/subtle/hmac-import-key-verify-sha224-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/hmac-import-key-verify-sha224.html [new file with mode: 0644]
LayoutTests/crypto/subtle/hmac-import-key-verify-sha256-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/hmac-import-key-verify-sha256.html [new file with mode: 0644]
LayoutTests/crypto/subtle/hmac-import-key-verify-sha384-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/hmac-import-key-verify-sha384.html [new file with mode: 0644]
LayoutTests/crypto/subtle/hmac-import-key-verify-sha512-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/hmac-import-key-verify-sha512.html [new file with mode: 0644]
LayoutTests/crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-expected.txt
LayoutTests/crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-label-expected.txt
LayoutTests/crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-label.html
LayoutTests/crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt.html
LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-generate-key-encrypt-decrypt-expected.txt
LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-generate-key-encrypt-decrypt.html
LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-key-sign-verify-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-key-sign-verify.html [new file with mode: 0644]
LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha1-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha1.html [new file with mode: 0644]
LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha224-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha224.html [new file with mode: 0644]
LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha256-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha256.html [new file with mode: 0644]
LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha384-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha384.html [new file with mode: 0644]
LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha512-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha512.html [new file with mode: 0644]
LayoutTests/crypto/subtle/verify-malformed-parameters-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/verify-malformed-parameters.html [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/hmac-import-key-verify-expected.txt [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/hmac-import-key-verify.html [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/resources/hmac-import-key-verify.js [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/resources/rsassa-pkcs1-v1_5-import-key-verify.js [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/rsassa-pkcs1-v1_5-import-key-verify-expected.txt [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/rsassa-pkcs1-v1_5-import-key-verify.html [new file with mode: 0644]
LayoutTests/imported/w3c/ChangeLog
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/CryptoAlgorithmHMAC.cpp
Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.h
Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp
Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h
Source/WebCore/crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp
Source/WebCore/crypto/gnutls/CryptoAlgorithmHMACGnuTLS.cpp
Source/WebCore/crypto/gnutls/CryptoAlgorithmRSASSA_PKCS1_v1_5GnuTLS.cpp
Source/WebCore/crypto/mac/CryptoAlgorithmHMACMac.cpp
Source/WebCore/crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp