Update SubtleCrypto::importKey to match the latest spec
authorjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Nov 2016 18:36:44 +0000 (18:36 +0000)
committerjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Nov 2016 18:36:44 +0000 (18:36 +0000)
https://bugs.webkit.org/show_bug.cgi?id=164446
<rdar://problem/29123621>

Reviewed by Brent Fulgham.

LayoutTests/imported/w3c:

* WebCryptoAPI/idlharness-expected.txt:

Source/WebCore:

This patch does following few things:
1. It updates the SubtleCrypto::importKey method to match the latest spec:
   https://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-importKey.
   It also refers to the latest Editor's Draft at a certain degree:
   https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-importKey.
2. It implements importKey operations of following algorithms: AES-CBC, AES-KW,
   HMAC, RSAES-PKCS1-V1_5, RSASSA-PKCS1-V1_5, and RSA-OAEP.
3. It fixes some minor problems of SubtleCrypto::generateKey.
4. It addes move constructors for CryptoKeyAES, CryptoKeyHMAC, CryptoKeyRSA and
   CryptoKeyDataRSAComponents.
5. It renames HmacKeyGenParams to HmacKeyParams to serve the purpose of both
   HmacKeyGenParams and HmacImportParams which are essentially the same.
6. It enforces the key length in bits of CryptoKeyHMAC to be multiples of 8.
7. It also fixes the following bugs:
   https://bugs.webkit.org/show_bug.cgi?id=126033,
   https://bugs.webkit.org/show_bug.cgi?id=126034,
   https://bugs.webkit.org/show_bug.cgi?id=151308.
P.S. We currently only support Raw and Jwk key format.

Tests: crypto/subtle/aes-cbc-import-jwk-key-length-128.html
       crypto/subtle/aes-cbc-import-jwk-key-length-192.html
       crypto/subtle/aes-cbc-import-jwk-key-length-256.html
       crypto/subtle/aes-cbc-import-jwk-key-minimum.html
       crypto/subtle/aes-cbc-import-jwk-key-non-extractable.html
       crypto/subtle/aes-cbc-import-raw-key-length-128.html
       crypto/subtle/aes-cbc-import-raw-key-length-192.html
       crypto/subtle/aes-cbc-import-raw-key-length-256.html
       crypto/subtle/aes-import-key-malformed-parameters.html
       crypto/subtle/aes-kw-import-jwk-key-length-128.html
       crypto/subtle/aes-kw-import-jwk-key-length-192.html
       crypto/subtle/aes-kw-import-jwk-key-length-256.html
       crypto/subtle/aes-kw-import-raw-key.html
       crypto/subtle/generate-key-malformed-parameters.html
       crypto/subtle/hmac-import-jwk-key-minimum.html
       crypto/subtle/hmac-import-jwk-key-non-extractable.html
       crypto/subtle/hmac-import-jwk-key-sha1.html
       crypto/subtle/hmac-import-jwk-key-sha224.html
       crypto/subtle/hmac-import-jwk-key-sha256.html
       crypto/subtle/hmac-import-jwk-key-sha384.html
       crypto/subtle/hmac-import-jwk-key-sha512.html
       crypto/subtle/hmac-import-malformed-parameters.html
       crypto/subtle/hmac-import-raw-key-customized-length.html
       crypto/subtle/hmac-import-raw-key.html
       crypto/subtle/import-key-malformed-parameters.html
       crypto/subtle/rsa-import-key-malformed-parameters.html
       crypto/subtle/rsa-oaep-import-jwk-private-key.html
       crypto/subtle/rsa-oaep-import-jwk-public-key-sha1.html
       crypto/subtle/rsa-oaep-import-jwk-public-key-sha224.html
       crypto/subtle/rsa-oaep-import-jwk-public-key-sha256.html
       crypto/subtle/rsa-oaep-import-jwk-public-key-sha384.html
       crypto/subtle/rsa-oaep-import-jwk-public-key-sha512.html
       crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-private-key.html
       crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-leading-zero.html
       crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-minimum.html
       crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-non-extractable.html
       crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key.html
       crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-private-key.html
       crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha1.html
       crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha224.html
       crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha256.html
       crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha384.html
       crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha512.html
       crypto/workers/subtle/aes-import-jwk-key.html
       crypto/workers/subtle/aes-import-raw-key.html
       crypto/workers/subtle/hmac-import-jwk-key.html
       crypto/workers/subtle/hmac-import-raw-key.html
       crypto/workers/subtle/rsa-import-jwk-private-key.html
       crypto/workers/subtle/rsa-import-jwk-public-key.html

* CMakeLists.txt:
* DerivedSources.make:
* PlatformEfl.cmake:
* PlatformGTK.cmake:
* PlatformMac.cmake:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSSubtleCryptoCustom.cpp:
(WebCore::normalizeCryptoAlgorithmParameters):
(WebCore::cryptoKeyUsageFromString):
(WebCore::cryptoKeyUsagesFromJSValue):
(WebCore::toKeyData):
(WebCore::jsSubtleCryptoFunctionGenerateKeyPromise):
(WebCore::jsSubtleCryptoFunctionImportKeyPromise):
(WebCore::JSSubtleCrypto::importKey):
* crypto/CryptoAlgorithm.cpp:
(WebCore::CryptoAlgorithm::importKey):
* crypto/CryptoAlgorithm.h:
* crypto/CryptoAlgorithmParameters.h:
* crypto/JsonWebKey.h: Added.
* crypto/JsonWebKey.idl: Added.
* crypto/RsaOtherPrimesInfo.h: Added.
* crypto/RsaOtherPrimesInfo.idl: Added.
* crypto/SubtleCrypto.h:
* crypto/SubtleCrypto.idl:
* crypto/algorithms/CryptoAlgorithmAES_CBC.cpp:
(WebCore::CryptoAlgorithmAES_CBC::generateKey):
(WebCore::CryptoAlgorithmAES_CBC::importKey):
* crypto/algorithms/CryptoAlgorithmAES_CBC.h:
* crypto/algorithms/CryptoAlgorithmAES_KW.cpp:
(WebCore::CryptoAlgorithmAES_KW::generateKey):
(WebCore::CryptoAlgorithmAES_KW::importKey):
* crypto/algorithms/CryptoAlgorithmAES_KW.h:
* crypto/algorithms/CryptoAlgorithmHMAC.cpp:
(WebCore::CryptoAlgorithmHMAC::generateKey):
(WebCore::CryptoAlgorithmHMAC::importKey):
* crypto/algorithms/CryptoAlgorithmHMAC.h:
* crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp:
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::importKey):
* crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h:
* crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp:
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::importKey):
* crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h:
* crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp:
(WebCore::CryptoAlgorithmRSA_OAEP::importKey):
* crypto/algorithms/CryptoAlgorithmRSA_OAEP.h:
* crypto/keys/CryptoKeyAES.cpp:
(WebCore::CryptoKeyAES::CryptoKeyAES):
(WebCore::CryptoKeyAES::generate):
(WebCore::CryptoKeyAES::importRaw):
(WebCore::CryptoKeyAES::importJwk):
* crypto/keys/CryptoKeyAES.h:
* crypto/keys/CryptoKeyDataRSAComponents.cpp:
(WebCore::CryptoKeyDataRSAComponents::CryptoKeyDataRSAComponents):
* crypto/keys/CryptoKeyDataRSAComponents.h:
* crypto/keys/CryptoKeyHMAC.cpp:
(WebCore::CryptoKeyHMAC::CryptoKeyHMAC):
(WebCore::CryptoKeyHMAC::generate):
(WebCore::CryptoKeyHMAC::importRaw):
(WebCore::CryptoKeyHMAC::importJwk):
(WebCore::CryptoKeyHMAC::buildAlgorithm):
* crypto/keys/CryptoKeyHMAC.h:
* crypto/keys/CryptoKeyRSA.cpp: Added.
(WebCore::CryptoKeyRSA::importJwk):
* crypto/keys/CryptoKeyRSA.h:
* crypto/parameters/CryptoAlgorithmHmacKeyParams.h: Renamed from Source/WebCore/crypto/parameters/CryptoAlgorithmHmacKeyGenParams.h.
* crypto/parameters/CryptoAlgorithmRsaHashedImportParams.h: Added.
* crypto/parameters/HmacKeyParams.idl: Renamed from Source/WebCore/crypto/parameters/HmacKeyGenParams.idl.
* crypto/parameters/RsaHashedImportParams.idl: Added.

LayoutTests:

Besides adding test cases for SubtleCrypto::importKey. This patch also corrects a typo:
generate-key-malformed-paramters*.

* crypto/subtle/aes-cbc-import-jwk-key-length-128-expected.txt: Added.
* crypto/subtle/aes-cbc-import-jwk-key-length-128.html: Added.
* crypto/subtle/aes-cbc-import-jwk-key-length-192-expected.txt: Added.
* crypto/subtle/aes-cbc-import-jwk-key-length-192.html: Added.
* crypto/subtle/aes-cbc-import-jwk-key-length-256-expected.txt: Added.
* crypto/subtle/aes-cbc-import-jwk-key-length-256.html: Added.
* crypto/subtle/aes-cbc-import-jwk-key-minimum-expected.txt: Added.
* crypto/subtle/aes-cbc-import-jwk-key-minimum.html: Added.
* crypto/subtle/aes-cbc-import-jwk-key-non-extractable-expected.txt: Added.
* crypto/subtle/aes-cbc-import-jwk-key-non-extractable.html: Added.
* crypto/subtle/aes-cbc-import-raw-key-length-128-expected.txt: Added.
* crypto/subtle/aes-cbc-import-raw-key-length-128.html: Added.
* crypto/subtle/aes-cbc-import-raw-key-length-192-expected.txt: Added.
* crypto/subtle/aes-cbc-import-raw-key-length-192.html: Added.
* crypto/subtle/aes-cbc-import-raw-key-length-256-expected.txt: Added.
* crypto/subtle/aes-cbc-import-raw-key-length-256.html: Added.
* crypto/subtle/aes-import-key-malformed-parameters-expected.txt: Added.
* crypto/subtle/aes-import-key-malformed-parameters.html: Added.
* crypto/subtle/aes-kw-import-jwk-key-length-128-expected.txt: Added.
* crypto/subtle/aes-kw-import-jwk-key-length-128.html: Added.
* crypto/subtle/aes-kw-import-jwk-key-length-192-expected.txt: Added.
* crypto/subtle/aes-kw-import-jwk-key-length-192.html: Added.
* crypto/subtle/aes-kw-import-jwk-key-length-256-expected.txt: Added.
* crypto/subtle/aes-kw-import-jwk-key-length-256.html: Added.
* crypto/subtle/aes-kw-import-raw-key-expected.txt: Added.
* crypto/subtle/aes-kw-import-raw-key.html: Added.
* crypto/subtle/generate-key-malformed-parameters-expected.txt: Renamed from LayoutTests/crypto/subtle/generate-key-malformed-paramters-expected.txt.
* crypto/subtle/generate-key-malformed-parameters.html: Renamed from LayoutTests/crypto/subtle/generate-key-malformed-paramters.html.
* crypto/subtle/hmac-generate-key-customized-length-expected.txt:
* crypto/subtle/hmac-generate-key-customized-length.html:
* crypto/subtle/hmac-generate-key-malformed-parameters-expected.txt:
* crypto/subtle/hmac-generate-key-malformed-parameters.html:
* crypto/subtle/hmac-import-raw-key-customized-length-expected.txt:
* crypto/subtle/hmac-import-raw-key-customized-length.html:
* crypto/subtle/hmac-import-jwk-key-minimum-expected.txt: Added.
* crypto/subtle/hmac-import-jwk-key-minimum.html: Added.
* crypto/subtle/hmac-import-jwk-key-non-extractable-expected.txt: Added.
* crypto/subtle/hmac-import-jwk-key-non-extractable.html: Added.
* crypto/subtle/hmac-import-jwk-key-sha1-expected.txt: Added.
* crypto/subtle/hmac-import-jwk-key-sha1.html: Added.
* crypto/subtle/hmac-import-jwk-key-sha224-expected.txt: Added.
* crypto/subtle/hmac-import-jwk-key-sha224.html: Added.
* crypto/subtle/hmac-import-jwk-key-sha256-expected.txt: Added.
* crypto/subtle/hmac-import-jwk-key-sha256.html: Added.
* crypto/subtle/hmac-import-jwk-key-sha384-expected.txt: Added.
* crypto/subtle/hmac-import-jwk-key-sha384.html: Added.
* crypto/subtle/hmac-import-jwk-key-sha512-expected.txt: Added.
* crypto/subtle/hmac-import-jwk-key-sha512.html: Added.
* crypto/subtle/hmac-import-malformed-parameters-expected.txt: Added.
* crypto/subtle/hmac-import-malformed-parameters.html: Added.
* crypto/subtle/hmac-import-raw-key-customized-length-expected.txt: Added.
* crypto/subtle/hmac-import-raw-key-customized-length.html: Added.
* crypto/subtle/hmac-import-raw-key-expected.txt: Added.
* crypto/subtle/hmac-import-raw-key.html: Added.
* crypto/subtle/import-key-malformed-parameters-expected.txt: Added.
* crypto/subtle/import-key-malformed-parameters.html: Added.
* crypto/subtle/rsa-import-key-malformed-parameters-expected.txt: Added.
* crypto/subtle/rsa-import-key-malformed-parameters.html: Added.
* crypto/subtle/rsa-oaep-import-jwk-private-key-expected.txt: Added.
* crypto/subtle/rsa-oaep-import-jwk-private-key.html: Added.
* crypto/subtle/rsa-oaep-import-jwk-public-key-sha1-expected.txt: Added.
* crypto/subtle/rsa-oaep-import-jwk-public-key-sha1.html: Added.
* crypto/subtle/rsa-oaep-import-jwk-public-key-sha224-expected.txt: Added.
* crypto/subtle/rsa-oaep-import-jwk-public-key-sha224.html: Added.
* crypto/subtle/rsa-oaep-import-jwk-public-key-sha256-expected.txt: Added.
* crypto/subtle/rsa-oaep-import-jwk-public-key-sha256.html: Added.
* crypto/subtle/rsa-oaep-import-jwk-public-key-sha384-expected.txt: Added.
* crypto/subtle/rsa-oaep-import-jwk-public-key-sha384.html: Added.
* crypto/subtle/rsa-oaep-import-jwk-public-key-sha512-expected.txt: Added.
* crypto/subtle/rsa-oaep-import-jwk-public-key-sha512.html: Added.
* crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-private-key-expected.txt: Added.
* crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-private-key.html: Added.
* crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-expected.txt: Added.
* crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-leading-zero-expected.txt: Added.
* crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-leading-zero.html: Added.
* crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-minimum-expected.txt: Added.
* crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-minimum.html: Added.
* crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-non-extractable-expected.txt: Added.
* crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-non-extractable.html: Added.
* crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key.html: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-private-key-expected.txt: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-private-key.html: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha1-expected.txt: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha1.html: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha224-expected.txt: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha224.html: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha256-expected.txt: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha256.html: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha384-expected.txt: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha384.html: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha512-expected.txt: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha512.html: Added.
* crypto/webkitSubtle/hmac-generate-key-expected.txt:
* crypto/webkitSubtle/hmac-generate-key.html:
* crypto/webkitSubtle/hmac-import-jwk-expected.txt:
* crypto/webkitSubtle/hmac-import-jwk.html:
* crypto/webkitSubtle/hmac-postMessage-expected.txt:
* crypto/webkitSubtle/hmac-postMessage.html:
* crypto/webkitSubtle/hmac-sign-verify-expected.txt:
* crypto/webkitSubtle/hmac-sign-verify.html:
* crypto/workers/subtle/aes-import-jwk-key-expected.txt: Added.
* crypto/workers/subtle/aes-import-jwk-key.html: Added.
* crypto/workers/subtle/aes-import-raw-key-expected.txt: Added.
* crypto/workers/subtle/aes-import-raw-key.html: Added.
* crypto/workers/subtle/hmac-import-jwk-key-expected.txt: Added.
* crypto/workers/subtle/hmac-import-jwk-key.html: Added.
* crypto/workers/subtle/hmac-import-raw-key-expected.txt: Added.
* crypto/workers/subtle/hmac-import-raw-key.html: Added.
* crypto/workers/subtle/hmac-postMessage-worker-expected.txt:
* crypto/workers/subtle/hmac-postMessage-worker.html:
* crypto/workers/subtle/resources/aes-import-jwk-key.js: Added.
* crypto/workers/subtle/resources/aes-import-raw-key.js: Added.
* crypto/workers/subtle/resources/hmac-import-jwk-key.js: Added.
* crypto/workers/subtle/resources/hmac-import-raw-key.js: Added.
* crypto/workers/subtle/resources/hmac-postMessage-worker.js:
* crypto/workers/subtle/resources/rsa-import-jwk-private-key.js: Added.
* crypto/workers/subtle/resources/rsa-import-jwk-public-key.js: Added.
* crypto/workers/subtle/rsa-import-jwk-private-key-expected.txt: Added.
* crypto/workers/subtle/rsa-import-jwk-private-key.html: Added.
* crypto/workers/subtle/rsa-import-jwk-public-key-expected.txt: Added.
* crypto/workers/subtle/rsa-import-jwk-public-key.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208548 268f45cc-cd09-0410-ab3c-d52691b4dbfc

163 files changed:
LayoutTests/ChangeLog
LayoutTests/crypto/subtle/aes-cbc-import-jwk-key-length-128-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-cbc-import-jwk-key-length-128.html [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-cbc-import-jwk-key-length-192-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-cbc-import-jwk-key-length-192.html [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-cbc-import-jwk-key-length-256-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-cbc-import-jwk-key-length-256.html [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-cbc-import-jwk-key-minimum-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-cbc-import-jwk-key-minimum.html [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-cbc-import-jwk-key-non-extractable-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-cbc-import-jwk-key-non-extractable.html [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-cbc-import-raw-key-length-128-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-cbc-import-raw-key-length-128.html [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-cbc-import-raw-key-length-192-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-cbc-import-raw-key-length-192.html [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-cbc-import-raw-key-length-256-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-cbc-import-raw-key-length-256.html [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-import-key-malformed-parameters-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-import-key-malformed-parameters.html [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-kw-import-jwk-key-length-128-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-kw-import-jwk-key-length-128.html [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-kw-import-jwk-key-length-192-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-kw-import-jwk-key-length-192.html [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-kw-import-jwk-key-length-256-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-kw-import-jwk-key-length-256.html [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-kw-import-raw-key-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-kw-import-raw-key.html [new file with mode: 0644]
LayoutTests/crypto/subtle/generate-key-malformed-parameters-expected.txt [moved from LayoutTests/crypto/subtle/generate-key-malformed-paramters-expected.txt with 96% similarity]
LayoutTests/crypto/subtle/generate-key-malformed-parameters.html [moved from LayoutTests/crypto/subtle/generate-key-malformed-paramters.html with 97% similarity]
LayoutTests/crypto/subtle/hmac-generate-key-customized-length-expected.txt
LayoutTests/crypto/subtle/hmac-generate-key-customized-length.html
LayoutTests/crypto/subtle/hmac-generate-key-malformed-parameters-expected.txt
LayoutTests/crypto/subtle/hmac-generate-key-malformed-parameters.html
LayoutTests/crypto/subtle/hmac-import-jwk-key-minimum-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/hmac-import-jwk-key-minimum.html [new file with mode: 0644]
LayoutTests/crypto/subtle/hmac-import-jwk-key-non-extractable-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/hmac-import-jwk-key-non-extractable.html [new file with mode: 0644]
LayoutTests/crypto/subtle/hmac-import-jwk-key-sha1-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/hmac-import-jwk-key-sha1.html [new file with mode: 0644]
LayoutTests/crypto/subtle/hmac-import-jwk-key-sha224-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/hmac-import-jwk-key-sha224.html [new file with mode: 0644]
LayoutTests/crypto/subtle/hmac-import-jwk-key-sha256-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/hmac-import-jwk-key-sha256.html [new file with mode: 0644]
LayoutTests/crypto/subtle/hmac-import-jwk-key-sha384-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/hmac-import-jwk-key-sha384.html [new file with mode: 0644]
LayoutTests/crypto/subtle/hmac-import-jwk-key-sha512-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/hmac-import-jwk-key-sha512.html [new file with mode: 0644]
LayoutTests/crypto/subtle/hmac-import-malformed-parameters-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/hmac-import-malformed-parameters.html [new file with mode: 0644]
LayoutTests/crypto/subtle/hmac-import-raw-key-customized-length-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/hmac-import-raw-key-customized-length.html [new file with mode: 0644]
LayoutTests/crypto/subtle/hmac-import-raw-key-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/hmac-import-raw-key.html [new file with mode: 0644]
LayoutTests/crypto/subtle/import-key-malformed-parameters-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/import-key-malformed-parameters.html [new file with mode: 0644]
LayoutTests/crypto/subtle/rsa-import-key-malformed-parameters-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/rsa-import-key-malformed-parameters.html [new file with mode: 0644]
LayoutTests/crypto/subtle/rsa-oaep-import-jwk-private-key-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/rsa-oaep-import-jwk-private-key.html [new file with mode: 0644]
LayoutTests/crypto/subtle/rsa-oaep-import-jwk-public-key-sha1-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/rsa-oaep-import-jwk-public-key-sha1.html [new file with mode: 0644]
LayoutTests/crypto/subtle/rsa-oaep-import-jwk-public-key-sha224-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/rsa-oaep-import-jwk-public-key-sha224.html [new file with mode: 0644]
LayoutTests/crypto/subtle/rsa-oaep-import-jwk-public-key-sha256-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/rsa-oaep-import-jwk-public-key-sha256.html [new file with mode: 0644]
LayoutTests/crypto/subtle/rsa-oaep-import-jwk-public-key-sha384-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/rsa-oaep-import-jwk-public-key-sha384.html [new file with mode: 0644]
LayoutTests/crypto/subtle/rsa-oaep-import-jwk-public-key-sha512-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/rsa-oaep-import-jwk-public-key-sha512.html [new file with mode: 0644]
LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-private-key-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-private-key.html [new file with mode: 0644]
LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-leading-zero-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-leading-zero.html [new file with mode: 0644]
LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-minimum-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-minimum.html [new file with mode: 0644]
LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-non-extractable-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-non-extractable.html [new file with mode: 0644]
LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key.html [new file with mode: 0644]
LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-private-key-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-private-key.html [new file with mode: 0644]
LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha1-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha1.html [new file with mode: 0644]
LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha224-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha224.html [new file with mode: 0644]
LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha256-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha256.html [new file with mode: 0644]
LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha384-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha384.html [new file with mode: 0644]
LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha512-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha512.html [new file with mode: 0644]
LayoutTests/crypto/webkitSubtle/hmac-generate-key-expected.txt
LayoutTests/crypto/webkitSubtle/hmac-generate-key.html
LayoutTests/crypto/webkitSubtle/hmac-import-jwk-expected.txt
LayoutTests/crypto/webkitSubtle/hmac-import-jwk.html
LayoutTests/crypto/webkitSubtle/hmac-postMessage-expected.txt
LayoutTests/crypto/webkitSubtle/hmac-postMessage.html
LayoutTests/crypto/webkitSubtle/hmac-sign-verify-expected.txt
LayoutTests/crypto/webkitSubtle/hmac-sign-verify.html
LayoutTests/crypto/workers/subtle/aes-import-jwk-key-expected.txt [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/aes-import-jwk-key.html [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/aes-import-raw-key-expected.txt [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/aes-import-raw-key.html [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/hmac-import-jwk-key-expected.txt [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/hmac-import-jwk-key.html [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/hmac-import-raw-key-expected.txt [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/hmac-import-raw-key.html [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/hmac-postMessage-worker-expected.txt
LayoutTests/crypto/workers/subtle/hmac-postMessage-worker.html
LayoutTests/crypto/workers/subtle/resources/aes-import-jwk-key.js [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/resources/aes-import-raw-key.js [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/resources/hmac-import-jwk-key.js [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/resources/hmac-import-raw-key.js [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/resources/hmac-postMessage-worker.js
LayoutTests/crypto/workers/subtle/resources/rsa-import-jwk-private-key.js [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/resources/rsa-import-jwk-public-key.js [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/rsa-import-jwk-private-key-expected.txt [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/rsa-import-jwk-private-key.html [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/rsa-import-jwk-public-key-expected.txt [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/rsa-import-jwk-public-key.html [new file with mode: 0644]
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/WebCryptoAPI/idlharness-expected.txt
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.make
Source/WebCore/PlatformEfl.cmake
Source/WebCore/PlatformGTK.cmake
Source/WebCore/PlatformMac.cmake
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp
Source/WebCore/crypto/CryptoAlgorithm.cpp
Source/WebCore/crypto/CryptoAlgorithm.h
Source/WebCore/crypto/CryptoAlgorithmParameters.h
Source/WebCore/crypto/JsonWebKey.h [new file with mode: 0644]
Source/WebCore/crypto/JsonWebKey.idl [new file with mode: 0644]
Source/WebCore/crypto/RsaOtherPrimesInfo.h [new file with mode: 0644]
Source/WebCore/crypto/RsaOtherPrimesInfo.idl [new file with mode: 0644]
Source/WebCore/crypto/SubtleCrypto.h
Source/WebCore/crypto/SubtleCrypto.idl
Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.cpp
Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.h
Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.cpp
Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.h
Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp
Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.h
Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp
Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h
Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp
Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h
Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp
Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.h
Source/WebCore/crypto/keys/CryptoKeyAES.cpp
Source/WebCore/crypto/keys/CryptoKeyAES.h
Source/WebCore/crypto/keys/CryptoKeyDataRSAComponents.cpp
Source/WebCore/crypto/keys/CryptoKeyDataRSAComponents.h
Source/WebCore/crypto/keys/CryptoKeyHMAC.cpp
Source/WebCore/crypto/keys/CryptoKeyHMAC.h
Source/WebCore/crypto/keys/CryptoKeyRSA.cpp [new file with mode: 0644]
Source/WebCore/crypto/keys/CryptoKeyRSA.h
Source/WebCore/crypto/parameters/CryptoAlgorithmHmacKeyParams.h [moved from Source/WebCore/crypto/parameters/CryptoAlgorithmHmacKeyGenParams.h with 88% similarity]
Source/WebCore/crypto/parameters/CryptoAlgorithmRsaHashedImportParams.h [new file with mode: 0644]
Source/WebCore/crypto/parameters/HmacKeyParams.idl [moved from Source/WebCore/crypto/parameters/HmacKeyGenParams.idl with 84% similarity]
Source/WebCore/crypto/parameters/RsaHashedImportParams.idl [new file with mode: 0644]

index 17f0961..5d6585c 100644 (file)
@@ -1,3 +1,136 @@
+2016-11-04  Jiewen Tan  <jiewen_tan@apple.com>
+
+        Update SubtleCrypto::importKey to match the latest spec
+        https://bugs.webkit.org/show_bug.cgi?id=164446
+        <rdar://problem/29123621>
+
+        Reviewed by Brent Fulgham.
+
+        Besides adding test cases for SubtleCrypto::importKey. This patch also corrects a typo:
+        generate-key-malformed-paramters*.
+
+        * crypto/subtle/aes-cbc-import-jwk-key-length-128-expected.txt: Added.
+        * crypto/subtle/aes-cbc-import-jwk-key-length-128.html: Added.
+        * crypto/subtle/aes-cbc-import-jwk-key-length-192-expected.txt: Added.
+        * crypto/subtle/aes-cbc-import-jwk-key-length-192.html: Added.
+        * crypto/subtle/aes-cbc-import-jwk-key-length-256-expected.txt: Added.
+        * crypto/subtle/aes-cbc-import-jwk-key-length-256.html: Added.
+        * crypto/subtle/aes-cbc-import-jwk-key-minimum-expected.txt: Added.
+        * crypto/subtle/aes-cbc-import-jwk-key-minimum.html: Added.
+        * crypto/subtle/aes-cbc-import-jwk-key-non-extractable-expected.txt: Added.
+        * crypto/subtle/aes-cbc-import-jwk-key-non-extractable.html: Added.
+        * crypto/subtle/aes-cbc-import-raw-key-length-128-expected.txt: Added.
+        * crypto/subtle/aes-cbc-import-raw-key-length-128.html: Added.
+        * crypto/subtle/aes-cbc-import-raw-key-length-192-expected.txt: Added.
+        * crypto/subtle/aes-cbc-import-raw-key-length-192.html: Added.
+        * crypto/subtle/aes-cbc-import-raw-key-length-256-expected.txt: Added.
+        * crypto/subtle/aes-cbc-import-raw-key-length-256.html: Added.
+        * crypto/subtle/aes-import-key-malformed-parameters-expected.txt: Added.
+        * crypto/subtle/aes-import-key-malformed-parameters.html: Added.
+        * crypto/subtle/aes-kw-import-jwk-key-length-128-expected.txt: Added.
+        * crypto/subtle/aes-kw-import-jwk-key-length-128.html: Added.
+        * crypto/subtle/aes-kw-import-jwk-key-length-192-expected.txt: Added.
+        * crypto/subtle/aes-kw-import-jwk-key-length-192.html: Added.
+        * crypto/subtle/aes-kw-import-jwk-key-length-256-expected.txt: Added.
+        * crypto/subtle/aes-kw-import-jwk-key-length-256.html: Added.
+        * crypto/subtle/aes-kw-import-raw-key-expected.txt: Added.
+        * crypto/subtle/aes-kw-import-raw-key.html: Added.
+        * crypto/subtle/generate-key-malformed-parameters-expected.txt: Renamed from LayoutTests/crypto/subtle/generate-key-malformed-paramters-expected.txt.
+        * crypto/subtle/generate-key-malformed-parameters.html: Renamed from LayoutTests/crypto/subtle/generate-key-malformed-paramters.html.
+        * crypto/subtle/hmac-generate-key-customized-length-expected.txt:
+        * crypto/subtle/hmac-generate-key-customized-length.html:
+        * crypto/subtle/hmac-generate-key-malformed-parameters-expected.txt:
+        * crypto/subtle/hmac-generate-key-malformed-parameters.html:
+        * crypto/subtle/hmac-import-raw-key-customized-length-expected.txt:
+        * crypto/subtle/hmac-import-raw-key-customized-length.html:
+        * crypto/subtle/hmac-import-jwk-key-minimum-expected.txt: Added.
+        * crypto/subtle/hmac-import-jwk-key-minimum.html: Added.
+        * crypto/subtle/hmac-import-jwk-key-non-extractable-expected.txt: Added.
+        * crypto/subtle/hmac-import-jwk-key-non-extractable.html: Added.
+        * crypto/subtle/hmac-import-jwk-key-sha1-expected.txt: Added.
+        * crypto/subtle/hmac-import-jwk-key-sha1.html: Added.
+        * crypto/subtle/hmac-import-jwk-key-sha224-expected.txt: Added.
+        * crypto/subtle/hmac-import-jwk-key-sha224.html: Added.
+        * crypto/subtle/hmac-import-jwk-key-sha256-expected.txt: Added.
+        * crypto/subtle/hmac-import-jwk-key-sha256.html: Added.
+        * crypto/subtle/hmac-import-jwk-key-sha384-expected.txt: Added.
+        * crypto/subtle/hmac-import-jwk-key-sha384.html: Added.
+        * crypto/subtle/hmac-import-jwk-key-sha512-expected.txt: Added.
+        * crypto/subtle/hmac-import-jwk-key-sha512.html: Added.
+        * crypto/subtle/hmac-import-malformed-parameters-expected.txt: Added.
+        * crypto/subtle/hmac-import-malformed-parameters.html: Added.
+        * crypto/subtle/hmac-import-raw-key-customized-length-expected.txt: Added.
+        * crypto/subtle/hmac-import-raw-key-customized-length.html: Added.
+        * crypto/subtle/hmac-import-raw-key-expected.txt: Added.
+        * crypto/subtle/hmac-import-raw-key.html: Added.
+        * crypto/subtle/import-key-malformed-parameters-expected.txt: Added.
+        * crypto/subtle/import-key-malformed-parameters.html: Added.
+        * crypto/subtle/rsa-import-key-malformed-parameters-expected.txt: Added.
+        * crypto/subtle/rsa-import-key-malformed-parameters.html: Added.
+        * crypto/subtle/rsa-oaep-import-jwk-private-key-expected.txt: Added.
+        * crypto/subtle/rsa-oaep-import-jwk-private-key.html: Added.
+        * crypto/subtle/rsa-oaep-import-jwk-public-key-sha1-expected.txt: Added.
+        * crypto/subtle/rsa-oaep-import-jwk-public-key-sha1.html: Added.
+        * crypto/subtle/rsa-oaep-import-jwk-public-key-sha224-expected.txt: Added.
+        * crypto/subtle/rsa-oaep-import-jwk-public-key-sha224.html: Added.
+        * crypto/subtle/rsa-oaep-import-jwk-public-key-sha256-expected.txt: Added.
+        * crypto/subtle/rsa-oaep-import-jwk-public-key-sha256.html: Added.
+        * crypto/subtle/rsa-oaep-import-jwk-public-key-sha384-expected.txt: Added.
+        * crypto/subtle/rsa-oaep-import-jwk-public-key-sha384.html: Added.
+        * crypto/subtle/rsa-oaep-import-jwk-public-key-sha512-expected.txt: Added.
+        * crypto/subtle/rsa-oaep-import-jwk-public-key-sha512.html: Added.
+        * crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-private-key-expected.txt: Added.
+        * crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-private-key.html: Added.
+        * crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-expected.txt: Added.
+        * crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-leading-zero-expected.txt: Added.
+        * crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-leading-zero.html: Added.
+        * crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-minimum-expected.txt: Added.
+        * crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-minimum.html: Added.
+        * crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-non-extractable-expected.txt: Added.
+        * crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-non-extractable.html: Added.
+        * crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key.html: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-private-key-expected.txt: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-private-key.html: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha1-expected.txt: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha1.html: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha224-expected.txt: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha224.html: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha256-expected.txt: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha256.html: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha384-expected.txt: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha384.html: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha512-expected.txt: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha512.html: Added.
+        * crypto/webkitSubtle/hmac-generate-key-expected.txt:
+        * crypto/webkitSubtle/hmac-generate-key.html:
+        * crypto/webkitSubtle/hmac-import-jwk-expected.txt:
+        * crypto/webkitSubtle/hmac-import-jwk.html:
+        * crypto/webkitSubtle/hmac-postMessage-expected.txt:
+        * crypto/webkitSubtle/hmac-postMessage.html:
+        * crypto/webkitSubtle/hmac-sign-verify-expected.txt:
+        * crypto/webkitSubtle/hmac-sign-verify.html:
+        * crypto/workers/subtle/aes-import-jwk-key-expected.txt: Added.
+        * crypto/workers/subtle/aes-import-jwk-key.html: Added.
+        * crypto/workers/subtle/aes-import-raw-key-expected.txt: Added.
+        * crypto/workers/subtle/aes-import-raw-key.html: Added.
+        * crypto/workers/subtle/hmac-import-jwk-key-expected.txt: Added.
+        * crypto/workers/subtle/hmac-import-jwk-key.html: Added.
+        * crypto/workers/subtle/hmac-import-raw-key-expected.txt: Added.
+        * crypto/workers/subtle/hmac-import-raw-key.html: Added.
+        * crypto/workers/subtle/hmac-postMessage-worker-expected.txt:
+        * crypto/workers/subtle/hmac-postMessage-worker.html:
+        * crypto/workers/subtle/resources/aes-import-jwk-key.js: Added.
+        * crypto/workers/subtle/resources/aes-import-raw-key.js: Added.
+        * crypto/workers/subtle/resources/hmac-import-jwk-key.js: Added.
+        * crypto/workers/subtle/resources/hmac-import-raw-key.js: Added.
+        * crypto/workers/subtle/resources/hmac-postMessage-worker.js:
+        * crypto/workers/subtle/resources/rsa-import-jwk-private-key.js: Added.
+        * crypto/workers/subtle/resources/rsa-import-jwk-public-key.js: Added.
+        * crypto/workers/subtle/rsa-import-jwk-private-key-expected.txt: Added.
+        * crypto/workers/subtle/rsa-import-jwk-private-key.html: Added.
+        * crypto/workers/subtle/rsa-import-jwk-public-key-expected.txt: Added.
+        * crypto/workers/subtle/rsa-import-jwk-public-key.html: Added.
+
 2016-11-10  Ryan Haddad  <ryanhaddad@apple.com>
 
         Marking media/modern-media-controls/ios-inline-media-controls/ios-inline-media-controls-buttons-styles.html as flaky.
diff --git a/LayoutTests/crypto/subtle/aes-cbc-import-jwk-key-length-128-expected.txt b/LayoutTests/crypto/subtle/aes-cbc-import-jwk-key-length-128-expected.txt
new file mode 100644 (file)
index 0000000..a907f1e
--- /dev/null
@@ -0,0 +1,15 @@
+Test importing a JWK AES-CBC key with legnth 128
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS key.type is 'secret'
+PASS key.extractable is true
+PASS key.algorithm.name is 'AES-CBC'
+PASS key.algorithm.length is 128
+PASS key.usages is ['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/aes-cbc-import-jwk-key-length-128.html b/LayoutTests/crypto/subtle/aes-cbc-import-jwk-key-length-128.html
new file mode 100644 (file)
index 0000000..8ee2403
--- /dev/null
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a JWK AES-CBC key with legnth 128");
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: "oct",
+    k: "YWJjZGVmZ2gxMjM0NTY3OA",
+    alg: "A128CBC",
+    use: "enc",
+    key_ops: ["encrypt", "decrypt", "wrapKey", "unwrapKey"],
+    ext: true,
+};
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("jwk", jwkKey, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]).then(function(result) {
+    key = result;
+
+    shouldBe("key.type", "'secret'");
+    shouldBe("key.extractable", "true");
+    shouldBe("key.algorithm.name", "'AES-CBC'");
+    shouldBe("key.algorithm.length", "128");
+    shouldBe("key.usages", "['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/crypto/subtle/aes-cbc-import-jwk-key-length-192-expected.txt b/LayoutTests/crypto/subtle/aes-cbc-import-jwk-key-length-192-expected.txt
new file mode 100644 (file)
index 0000000..6c43f7a
--- /dev/null
@@ -0,0 +1,15 @@
+Test importing a JWK AES-CBC key with legnth 192
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS key.type is 'secret'
+PASS key.extractable is true
+PASS key.algorithm.name is 'AES-CBC'
+PASS key.algorithm.length is 192
+PASS key.usages is ['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/aes-cbc-import-jwk-key-length-192.html b/LayoutTests/crypto/subtle/aes-cbc-import-jwk-key-length-192.html
new file mode 100644 (file)
index 0000000..1f22d14
--- /dev/null
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a JWK AES-CBC key with legnth 192");
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: "oct",
+    k: "A72FD48989ED7E92A3B3A080F74FA80B",
+    alg: "A192CBC",
+    use: "enc",
+    key_ops: ["encrypt", "decrypt", "wrapKey", "unwrapKey"],
+    ext: true,
+};
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("jwk", jwkKey, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]).then(function(result) {
+    key = result;
+
+    shouldBe("key.type", "'secret'");
+    shouldBe("key.extractable", "true");
+    shouldBe("key.algorithm.name", "'AES-CBC'");
+    shouldBe("key.algorithm.length", "192");
+    shouldBe("key.usages", "['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/crypto/subtle/aes-cbc-import-jwk-key-length-256-expected.txt b/LayoutTests/crypto/subtle/aes-cbc-import-jwk-key-length-256-expected.txt
new file mode 100644 (file)
index 0000000..69bfea1
--- /dev/null
@@ -0,0 +1,15 @@
+Test importing a JWK AES-CBC key with legnth 256
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS key.type is 'secret'
+PASS key.extractable is true
+PASS key.algorithm.name is 'AES-CBC'
+PASS key.algorithm.length is 256
+PASS key.usages is ['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/aes-cbc-import-jwk-key-length-256.html b/LayoutTests/crypto/subtle/aes-cbc-import-jwk-key-length-256.html
new file mode 100644 (file)
index 0000000..7ab9dee
--- /dev/null
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a JWK AES-CBC key with legnth 256");
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: "oct",
+    k: "YWJjZGVmZ2gxMjM0NTY3OGFiY2RlZmdoMTIzNDU2Nzg",
+    alg: "A256CBC",
+    use: "enc",
+    key_ops: ["encrypt", "decrypt", "wrapKey", "unwrapKey"],
+    ext: true,
+};
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("jwk", jwkKey, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]).then(function(result) {
+    key = result;
+
+    shouldBe("key.type", "'secret'");
+    shouldBe("key.extractable", "true");
+    shouldBe("key.algorithm.name", "'AES-CBC'");
+    shouldBe("key.algorithm.length", "256");
+    shouldBe("key.usages", "['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/crypto/subtle/aes-cbc-import-jwk-key-minimum-expected.txt b/LayoutTests/crypto/subtle/aes-cbc-import-jwk-key-minimum-expected.txt
new file mode 100644 (file)
index 0000000..5b6b582
--- /dev/null
@@ -0,0 +1,15 @@
+Test importing a JWK AES-CBC key with minimum JWK information
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS key.type is 'secret'
+PASS key.extractable is true
+PASS key.algorithm.name is 'AES-CBC'
+PASS key.algorithm.length is 128
+PASS key.usages is ['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/aes-cbc-import-jwk-key-minimum.html b/LayoutTests/crypto/subtle/aes-cbc-import-jwk-key-minimum.html
new file mode 100644 (file)
index 0000000..3c06994
--- /dev/null
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a JWK AES-CBC key with minimum JWK information");
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: "oct",
+    k: "YWJjZGVmZ2gxMjM0NTY3OA",
+};
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("jwk", jwkKey, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]).then(function(result) {
+    key = result;
+
+    shouldBe("key.type", "'secret'");
+    shouldBe("key.extractable", "true");
+    shouldBe("key.algorithm.name", "'AES-CBC'");
+    shouldBe("key.algorithm.length", "128");
+    shouldBe("key.usages", "['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/crypto/subtle/aes-cbc-import-jwk-key-non-extractable-expected.txt b/LayoutTests/crypto/subtle/aes-cbc-import-jwk-key-non-extractable-expected.txt
new file mode 100644 (file)
index 0000000..11b6d8f
--- /dev/null
@@ -0,0 +1,15 @@
+Test importing a JWK AES-CBC non-extractable key
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS key.type is 'secret'
+PASS key.extractable is false
+PASS key.algorithm.name is 'AES-CBC'
+PASS key.algorithm.length is 128
+PASS key.usages is ['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/aes-cbc-import-jwk-key-non-extractable.html b/LayoutTests/crypto/subtle/aes-cbc-import-jwk-key-non-extractable.html
new file mode 100644 (file)
index 0000000..5e4c9a4
--- /dev/null
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a JWK AES-CBC non-extractable key");
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: "oct",
+    k: "YWJjZGVmZ2gxMjM0NTY3OA",
+    ext: true,
+};
+var nonExtractable = false;
+
+debug("Importing a key...");
+crypto.subtle.importKey("jwk", jwkKey, "aes-cbc", nonExtractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]).then(function(result) {
+    key = result;
+
+    shouldBe("key.type", "'secret'");
+    shouldBe("key.extractable", "false");
+    shouldBe("key.algorithm.name", "'AES-CBC'");
+    shouldBe("key.algorithm.length", "128");
+    shouldBe("key.usages", "['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/crypto/subtle/aes-cbc-import-raw-key-length-128-expected.txt b/LayoutTests/crypto/subtle/aes-cbc-import-raw-key-length-128-expected.txt
new file mode 100644 (file)
index 0000000..d713d1e
--- /dev/null
@@ -0,0 +1,15 @@
+Test importing a raw AES-CBC key with legnth 128
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS key.type is 'secret'
+PASS key.extractable is true
+PASS key.algorithm.name is 'AES-CBC'
+PASS key.algorithm.length is 128
+PASS key.usages is ['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/aes-cbc-import-raw-key-length-128.html b/LayoutTests/crypto/subtle/aes-cbc-import-raw-key-length-128.html
new file mode 100644 (file)
index 0000000..8f6297b
--- /dev/null
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a raw AES-CBC key with legnth 128");
+
+jsTestIsAsync = true;
+
+var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("raw", rawKey, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]).then(function(result) {
+    key = result;
+
+    shouldBe("key.type", "'secret'");
+    shouldBe("key.extractable", "true");
+    shouldBe("key.algorithm.name", "'AES-CBC'");
+    shouldBe("key.algorithm.length", "128");
+    shouldBe("key.usages", "['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/crypto/subtle/aes-cbc-import-raw-key-length-192-expected.txt b/LayoutTests/crypto/subtle/aes-cbc-import-raw-key-length-192-expected.txt
new file mode 100644 (file)
index 0000000..6d5e668
--- /dev/null
@@ -0,0 +1,15 @@
+Test importing a raw AES-CBC key with legnth 192
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS key.type is 'secret'
+PASS key.extractable is true
+PASS key.algorithm.name is 'AES-CBC'
+PASS key.algorithm.length is 192
+PASS key.usages is ['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/aes-cbc-import-raw-key-length-192.html b/LayoutTests/crypto/subtle/aes-cbc-import-raw-key-length-192.html
new file mode 100644 (file)
index 0000000..11c574f
--- /dev/null
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a raw AES-CBC key with legnth 192");
+
+jsTestIsAsync = true;
+
+var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMrgJB55WL4");
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("raw", rawKey, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]).then(function(result) {
+    key = result;
+
+    shouldBe("key.type", "'secret'");
+    shouldBe("key.extractable", "true");
+    shouldBe("key.algorithm.name", "'AES-CBC'");
+    shouldBe("key.algorithm.length", "192");
+    shouldBe("key.usages", "['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/crypto/subtle/aes-cbc-import-raw-key-length-256-expected.txt b/LayoutTests/crypto/subtle/aes-cbc-import-raw-key-length-256-expected.txt
new file mode 100644 (file)
index 0000000..6ceb871
--- /dev/null
@@ -0,0 +1,15 @@
+Test importing a raw AES-CBC key with legnth 256
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS key.type is 'secret'
+PASS key.extractable is true
+PASS key.algorithm.name is 'AES-CBC'
+PASS key.algorithm.length is 256
+PASS key.usages is ['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/aes-cbc-import-raw-key-length-256.html b/LayoutTests/crypto/subtle/aes-cbc-import-raw-key-length-256.html
new file mode 100644 (file)
index 0000000..b80c0c9
--- /dev/null
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a raw AES-CBC key with legnth 256");
+
+jsTestIsAsync = true;
+
+var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMrgJB55WL46tJSLGt7");
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("raw", rawKey, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]).then(function(result) {
+    key = result;
+
+    shouldBe("key.type", "'secret'");
+    shouldBe("key.extractable", "true");
+    shouldBe("key.algorithm.name", "'AES-CBC'");
+    shouldBe("key.algorithm.length", "256");
+    shouldBe("key.usages", "['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/crypto/subtle/aes-import-key-malformed-parameters-expected.txt b/LayoutTests/crypto/subtle/aes-import-key-malformed-parameters-expected.txt
new file mode 100644 (file)
index 0000000..82b98b6
--- /dev/null
@@ -0,0 +1,23 @@
+Test importing an AES key with malformed parameters
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS crypto.subtle.importKey("raw", asciiToUint8Array("jnOw97"), "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "RSA"}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "oct"}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k128, alg: "A192CBC"}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k192, alg: "A256CBC"}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k256, alg: "A128CBC"}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k128, alg: "A192KW"}, "aes-kw", extractable, ["wrapKey", "unwrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k192, alg: "A256KW"}, "aes-kw", extractable, ["wrapKey", "unwrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k256, alg: "A128KW"}, "aes-kw", extractable, ["wrapKey", "unwrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "oct", k: "A72F", alg: "foo"}, "aes-cbc", extractable, ["wrapKey", "unwrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "oct", k: "!!!", alg: "foo"}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k128, alg: "A128CBC", use: "sig"}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k128, alg: "A128CBC", key_ops: ["encrypt", "decrypt"]}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k128, alg: "A128CBC", ext: false}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/aes-import-key-malformed-parameters.html b/LayoutTests/crypto/subtle/aes-import-key-malformed-parameters.html
new file mode 100644 (file)
index 0000000..950be0f
--- /dev/null
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing an AES key with malformed parameters");
+
+var k128 = "YWJjZGVmZ2gxMjM0NTY3OA";
+var k192 = "A72FD48989ED7E92A3B3A080F74FA80B";
+var k256 = "YWJjZGVmZ2gxMjM0NTY3OGFiY2RlZmdoMTIzNDU2Nzg";
+var extractable = true;
+
+// Raw: wrong length
+shouldReject('crypto.subtle.importKey("raw", asciiToUint8Array("jnOw97"), "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
+// Jwk: Wrong kty
+shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA"}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
+// Jwk: missing k
+shouldReject('crypto.subtle.importKey("jwk", {kty: "oct"}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
+// Jwk: wrong length and alg
+shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k128, alg: "A192CBC"}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
+shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k192, alg: "A256CBC"}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
+shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k256, alg: "A128CBC"}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
+shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k128, alg: "A192KW"}, "aes-kw", extractable, ["wrapKey", "unwrapKey"])');
+shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k192, alg: "A256KW"}, "aes-kw", extractable, ["wrapKey", "unwrapKey"])');
+shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k256, alg: "A128KW"}, "aes-kw", extractable, ["wrapKey", "unwrapKey"])');
+shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: "A72F", alg: "foo"}, "aes-cbc", extractable, ["wrapKey", "unwrapKey"])');
+// Jwk: wrong k format
+shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: "!!!", alg: "foo"}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
+// Jwk: wrong use
+shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k128, alg: "A128CBC", use: "sig"}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
+// Jwk: wrong key_ops
+shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k128, alg: "A128CBC", key_ops: ["encrypt", "decrypt"]}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
+// Jwk: wrong ext
+shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k128, alg: "A128CBC", ext: false}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/crypto/subtle/aes-kw-import-jwk-key-length-128-expected.txt b/LayoutTests/crypto/subtle/aes-kw-import-jwk-key-length-128-expected.txt
new file mode 100644 (file)
index 0000000..1b41b69
--- /dev/null
@@ -0,0 +1,15 @@
+Test importing a JWK AES-KW key with legnth 128
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS key.type is 'secret'
+PASS key.extractable is true
+PASS key.algorithm.name is 'AES-KW'
+PASS key.algorithm.length is 128
+PASS key.usages is ['unwrapKey', 'wrapKey']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/aes-kw-import-jwk-key-length-128.html b/LayoutTests/crypto/subtle/aes-kw-import-jwk-key-length-128.html
new file mode 100644 (file)
index 0000000..3fbfc75
--- /dev/null
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a JWK AES-KW key with legnth 128");
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: "oct",
+    k: "YWJjZGVmZ2gxMjM0NTY3OA",
+    alg: "A128KW",
+};
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("jwk", jwkKey, "aes-kw", extractable, ["wrapKey", "unwrapKey"]).then(function(result) {
+    key = result;
+
+    shouldBe("key.type", "'secret'");
+    shouldBe("key.extractable", "true");
+    shouldBe("key.algorithm.name", "'AES-KW'");
+    shouldBe("key.algorithm.length", "128");
+    shouldBe("key.usages", "['unwrapKey', 'wrapKey']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/crypto/subtle/aes-kw-import-jwk-key-length-192-expected.txt b/LayoutTests/crypto/subtle/aes-kw-import-jwk-key-length-192-expected.txt
new file mode 100644 (file)
index 0000000..a167017
--- /dev/null
@@ -0,0 +1,15 @@
+Test importing a JWK AES-KW key with legnth 192
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS key.type is 'secret'
+PASS key.extractable is true
+PASS key.algorithm.name is 'AES-KW'
+PASS key.algorithm.length is 192
+PASS key.usages is ['unwrapKey', 'wrapKey']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/aes-kw-import-jwk-key-length-192.html b/LayoutTests/crypto/subtle/aes-kw-import-jwk-key-length-192.html
new file mode 100644 (file)
index 0000000..93d9894
--- /dev/null
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a JWK AES-KW key with legnth 192");
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: "oct",
+    k: "A72FD48989ED7E92A3B3A080F74FA80B",
+    alg: "A192KW",
+};
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("jwk", jwkKey, "aes-kw", extractable, ["wrapKey", "unwrapKey"]).then(function(result) {
+    key = result;
+
+    shouldBe("key.type", "'secret'");
+    shouldBe("key.extractable", "true");
+    shouldBe("key.algorithm.name", "'AES-KW'");
+    shouldBe("key.algorithm.length", "192");
+    shouldBe("key.usages", "['unwrapKey', 'wrapKey']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/crypto/subtle/aes-kw-import-jwk-key-length-256-expected.txt b/LayoutTests/crypto/subtle/aes-kw-import-jwk-key-length-256-expected.txt
new file mode 100644 (file)
index 0000000..c25d7f8
--- /dev/null
@@ -0,0 +1,15 @@
+Test importing a JWK AES-KW key with legnth 256
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS key.type is 'secret'
+PASS key.extractable is true
+PASS key.algorithm.name is 'AES-KW'
+PASS key.algorithm.length is 256
+PASS key.usages is ['unwrapKey', 'wrapKey']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/aes-kw-import-jwk-key-length-256.html b/LayoutTests/crypto/subtle/aes-kw-import-jwk-key-length-256.html
new file mode 100644 (file)
index 0000000..b26dd35
--- /dev/null
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a JWK AES-KW key with legnth 256");
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: "oct",
+    k: "YWJjZGVmZ2gxMjM0NTY3OGFiY2RlZmdoMTIzNDU2Nzg",
+    alg: "A256KW",
+};
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("jwk", jwkKey, "aes-kw", extractable, ["wrapKey", "unwrapKey"]).then(function(result) {
+    key = result;
+
+    shouldBe("key.type", "'secret'");
+    shouldBe("key.extractable", "true");
+    shouldBe("key.algorithm.name", "'AES-KW'");
+    shouldBe("key.algorithm.length", "256");
+    shouldBe("key.usages", "['unwrapKey', 'wrapKey']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/crypto/subtle/aes-kw-import-raw-key-expected.txt b/LayoutTests/crypto/subtle/aes-kw-import-raw-key-expected.txt
new file mode 100644 (file)
index 0000000..36e583f
--- /dev/null
@@ -0,0 +1,15 @@
+Test importing a raw AES-KW key with legnth 128
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS key.type is 'secret'
+PASS key.extractable is true
+PASS key.algorithm.name is 'AES-KW'
+PASS key.algorithm.length is 128
+PASS key.usages is ['unwrapKey', 'wrapKey']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/aes-kw-import-raw-key.html b/LayoutTests/crypto/subtle/aes-kw-import-raw-key.html
new file mode 100644 (file)
index 0000000..175c383
--- /dev/null
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a raw AES-KW key with legnth 128");
+
+jsTestIsAsync = true;
+
+var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("raw", rawKey, "aes-kw", extractable, ["wrapKey", "unwrapKey"]).then(function(result) {
+    key = result;
+
+    shouldBe("key.type", "'secret'");
+    shouldBe("key.extractable", "true");
+    shouldBe("key.algorithm.name", "'AES-KW'");
+    shouldBe("key.algorithm.length", "128");
+    shouldBe("key.usages", "['unwrapKey', 'wrapKey']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
\ No newline at end of file
@@ -6,7 +6,6 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 PASS crypto.subtle.generateKey() rejected promise  with TypeError: Not enough arguments.
 PASS crypto.subtle.generateKey(1) rejected promise  with TypeError: Not enough arguments.
 PASS crypto.subtle.generateKey(1, 2) rejected promise  with TypeError: Not enough arguments.
-PASS crypto.subtle.generateKey(1, 2, 3) rejected promise  with TypeError: Invalid AlgorithmIdentifier.
 PASS crypto.subtle.generateKey("foo", 2, 3) rejected promise  with NotSupportedError (DOM Exception 9): The operation is not supported..
 PASS crypto.subtle.generateKey({name: 1}, 2, 3) rejected promise  with NotSupportedError (DOM Exception 9): The operation is not supported..
 PASS crypto.subtle.generateKey({name: true}, 2, 3) rejected promise  with NotSupportedError (DOM Exception 9): The operation is not supported..
@@ -18,7 +17,7 @@ PASS crypto.subtle.generateKey({name: "foo"}, 2, 3) rejected promise  with NotSu
 PASS crypto.subtle.generateKey({name: "hmac", hash: true}, extractable, ["sign", "verify"]) rejected promise  with TypeError: Invalid AlgorithmIdentifier.
 PASS crypto.subtle.generateKey({name: "hmac", hash: 1}, extractable, ["sign", "verify"]) rejected promise  with TypeError: Invalid AlgorithmIdentifier.
 PASS crypto.subtle.generateKey({name: "hmac", hash: null}, extractable, ["sign", "verify"]) rejected promise  with TypeError: Invalid AlgorithmIdentifier.
-PASS crypto.subtle.generateKey({name: "hmac", hash: undefined}, extractable, ["sign", "verify"]) rejected promise  with TypeError: Member HmacKeyGenParams.hash is required and must be an instance of any.
+PASS crypto.subtle.generateKey({name: "hmac", hash: undefined}, extractable, ["sign", "verify"]) rejected promise  with TypeError: Member HmacKeyParams.hash is required and must be an instance of any.
 PASS crypto.subtle.generateKey({name: "hmac", hash: Symbol()}, extractable, ["sign", "verify"]) rejected promise  with TypeError: Invalid AlgorithmIdentifier.
 PASS crypto.subtle.generateKey({name: "hmac", hash: { }}, extractable, ["sign", "verify"]) rejected promise  with TypeError: Member CryptoAlgorithmParameters.name is required and must be an instance of DOMString.
 PASS crypto.subtle.generateKey({name: "hmac", hash: "foo"}, extractable, ["sign", "verify"]) rejected promise  with NotSupportedError (DOM Exception 9): The operation is not supported..
@@ -40,6 +39,7 @@ PASS crypto.subtle.generateKey({name: "AES-CBC", length: 128}, extractable, unde
 PASS crypto.subtle.generateKey({name: "AES-CBC", length: 128}, extractable, Symbol()) rejected promise  with TypeError: Type error.
 PASS crypto.subtle.generateKey({name: "AES-CBC", length: 128}, extractable, { }) rejected promise  with TypeError: Type error.
 PASS crypto.subtle.generateKey({name: "AES-CBC", length: 128}, extractable, "foo") rejected promise  with TypeError: Invalid KeyUsages.
+PASS crypto.subtle.generateKey({name: "AES-CBC", length: 128}, extractable, ["foo"]) rejected promise  with TypeError: Invalid KeyUsages.
 PASS crypto.subtle.generateKey({name: "AES-CBC", length: 128}, extractable, [ ]) rejected promise  with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
 PASS crypto.subtle.generateKey({name: "RSAES-PKCS1-v1_5", modulusLength: 2048, publicExponent: new Uint8Array([0x01, 0x00, 0x01])}, extractable, [ ]) rejected promise  with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
 PASS successfullyParsed is true
@@ -19,7 +19,6 @@ var extractable = true;
 shouldReject('crypto.subtle.generateKey()');
 shouldReject('crypto.subtle.generateKey(1)');
 shouldReject('crypto.subtle.generateKey(1, 2)');
-shouldReject('crypto.subtle.generateKey(1, 2, 3)');
 // Malformed AlgorithmIdentifiers.
 shouldReject('crypto.subtle.generateKey("foo", 2, 3)');
 shouldReject('crypto.subtle.generateKey({name: 1}, 2, 3)');
@@ -57,6 +56,7 @@ shouldReject('crypto.subtle.generateKey({name: "AES-CBC", length: 128}, extracta
 shouldReject('crypto.subtle.generateKey({name: "AES-CBC", length: 128}, extractable, Symbol())');
 shouldReject('crypto.subtle.generateKey({name: "AES-CBC", length: 128}, extractable, { })');
 shouldReject('crypto.subtle.generateKey({name: "AES-CBC", length: 128}, extractable, "foo")');
+shouldReject('crypto.subtle.generateKey({name: "AES-CBC", length: 128}, extractable, ["foo"])');
 // Syntax error.
 shouldReject('crypto.subtle.generateKey({name: "AES-CBC", length: 128}, extractable, [ ])');
 shouldReject('crypto.subtle.generateKey({name: "RSAES-PKCS1-v1_5", modulusLength: 2048, publicExponent: new Uint8Array([0x01, 0x00, 0x01])}, extractable, [ ])', finishJSTest);
index 283bddf..e2e78a4 100644 (file)
@@ -8,7 +8,7 @@ Generating a key...
 PASS key.type is 'secret'
 PASS key.extractable is true
 PASS key.algorithm.name is 'HMAC'
-PASS key.algorithm.length is 111
+PASS key.algorithm.length is 120
 PASS key.algorithm.hash.name is 'SHA-512'
 PASS key.usages is ["sign", "verify"]
 PASS successfullyParsed is true
index 8be230f..c32f021 100644 (file)
@@ -16,13 +16,13 @@ jsTestIsAsync = true;
 var extractable = true;
 
 debug("\nGenerating a key...");
-crypto.subtle.generateKey({name: "hmac", hash: "sha-512", length: 111}, extractable, ["sign", "verify"]).then(function(result) {
+crypto.subtle.generateKey({name: "hmac", hash: "sha-512", length: 120}, extractable, ["sign", "verify"]).then(function(result) {
     key = result;
 
     shouldBe("key.type", "'secret'");
     shouldBe("key.extractable", "true");
     shouldBe("key.algorithm.name", "'HMAC'");
-    shouldBe("key.algorithm.length", "111");
+    shouldBe("key.algorithm.length", "120");
     shouldBe("key.algorithm.hash.name", "'SHA-512'");
     shouldBe("key.usages", '["sign", "verify"]');
 
index 0d04ca7..796264c 100644 (file)
@@ -3,8 +3,8 @@ Test generating an HMAC key with malformed-paramters.
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS crypto.subtle.generateKey("hmac", extractable, ["sign", "verify"]) rejected promise  with TypeError: Member HmacKeyGenParams.hash is required and must be an instance of any.
-PASS crypto.subtle.generateKey({name: "hmac"}, extractable, ["sign", "verify"]) rejected promise  with TypeError: Member HmacKeyGenParams.hash is required and must be an instance of any.
+PASS crypto.subtle.generateKey("hmac", extractable, ["sign", "verify"]) rejected promise  with TypeError: Member HmacKeyParams.hash is required and must be an instance of any.
+PASS crypto.subtle.generateKey({name: "hmac"}, extractable, ["sign", "verify"]) rejected promise  with TypeError: Member HmacKeyParams.hash is required and must be an instance of any.
 PASS crypto.subtle.generateKey({name: "hmac", hash: "sha-1", length: null}, extractable, ["sign", "verify"]) rejected promise  with OperationError (DOM Exception 34): The operation failed for an operation-specific reason.
 PASS crypto.subtle.generateKey({name: "hmac", hash: "sha-1", length: Symbol()}, extractable, ["sign", "verify"]) rejected promise  with TypeError: Cannot convert a symbol to a number.
 PASS crypto.subtle.generateKey({name: "hmac", hash: "sha-1", length: { }}, extractable, ["sign", "verify"]) rejected promise  with OperationError (DOM Exception 34): The operation failed for an operation-specific reason.
@@ -16,6 +16,7 @@ PASS crypto.subtle.generateKey({name: "hmac", hash: "sha-1"}, extractable, ["der
 PASS crypto.subtle.generateKey({name: "hmac", hash: "sha-1"}, extractable, ["wrapKey"]) rejected promise  with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
 PASS crypto.subtle.generateKey({name: "hmac", hash: "sha-1"}, extractable, ["unwrapKey"]) rejected promise  with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
 PASS crypto.subtle.generateKey({name: "hmac", hash: "sha-1", length: 0}, extractable, ["sign", "verify"]) rejected promise  with OperationError (DOM Exception 34): The operation failed for an operation-specific reason.
+PASS crypto.subtle.generateKey({name: "hmac", hash: "sha-1", length: 5}, extractable, ["sign", "verify"]) rejected promise  with OperationError (DOM Exception 34): The operation failed for an operation-specific reason.
 PASS successfullyParsed is true
 
 TEST COMPLETE
index abf8918..1a49c32 100644 (file)
@@ -29,6 +29,7 @@ shouldReject('crypto.subtle.generateKey({name: "hmac", hash: "sha-1"}, extractab
 shouldReject('crypto.subtle.generateKey({name: "hmac", hash: "sha-1"}, extractable, ["unwrapKey"])');
 // Wrong length
 shouldReject('crypto.subtle.generateKey({name: "hmac", hash: "sha-1", length: 0}, extractable, ["sign", "verify"])');
+shouldReject('crypto.subtle.generateKey({name: "hmac", hash: "sha-1", length: 5}, extractable, ["sign", "verify"])');
 </script>
 
 <script src="../../resources/js-test-post.js"></script>
diff --git a/LayoutTests/crypto/subtle/hmac-import-jwk-key-minimum-expected.txt b/LayoutTests/crypto/subtle/hmac-import-jwk-key-minimum-expected.txt
new file mode 100644 (file)
index 0000000..beab11a
--- /dev/null
@@ -0,0 +1,16 @@
+Test importing a JWK HMAC key with minimum JWK information
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS key.type is 'secret'
+PASS key.extractable is true
+PASS key.algorithm.name is 'HMAC'
+PASS key.algorithm.length is 128
+PASS key.algorithm.hash.name is 'SHA-1'
+PASS key.usages is ['sign', 'verify']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/hmac-import-jwk-key-minimum.html b/LayoutTests/crypto/subtle/hmac-import-jwk-key-minimum.html
new file mode 100644 (file)
index 0000000..9ae3108
--- /dev/null
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a JWK HMAC key with minimum JWK information");
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: "oct",
+    k: "YWJjZGVmZ2gxMjM0NTY3OA",
+};
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("jwk", jwkKey, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"]).then(function(result) {
+    key = result;
+
+    shouldBe("key.type", "'secret'");
+    shouldBe("key.extractable", "true");
+    shouldBe("key.algorithm.name", "'HMAC'");
+    shouldBe("key.algorithm.length", "128");
+    shouldBe("key.algorithm.hash.name", "'SHA-1'");
+    shouldBe("key.usages", "['sign', 'verify']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/crypto/subtle/hmac-import-jwk-key-non-extractable-expected.txt b/LayoutTests/crypto/subtle/hmac-import-jwk-key-non-extractable-expected.txt
new file mode 100644 (file)
index 0000000..b942a33
--- /dev/null
@@ -0,0 +1,16 @@
+Test importing a non-extractable JWK HMAC key
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS key.type is 'secret'
+PASS key.extractable is false
+PASS key.algorithm.name is 'HMAC'
+PASS key.algorithm.length is 128
+PASS key.algorithm.hash.name is 'SHA-1'
+PASS key.usages is ['sign', 'verify']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/hmac-import-jwk-key-non-extractable.html b/LayoutTests/crypto/subtle/hmac-import-jwk-key-non-extractable.html
new file mode 100644 (file)
index 0000000..50bedbc
--- /dev/null
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a non-extractable JWK HMAC key");
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: "oct",
+    k: "YWJjZGVmZ2gxMjM0NTY3OA",
+    ext: true,
+};
+var nonExtractable = false;
+
+debug("Importing a key...");
+crypto.subtle.importKey("jwk", jwkKey, {name: "hmac", hash: "sha-1"}, nonExtractable, ["sign", "verify"]).then(function(result) {
+    key = result;
+
+    shouldBe("key.type", "'secret'");
+    shouldBe("key.extractable", "false");
+    shouldBe("key.algorithm.name", "'HMAC'");
+    shouldBe("key.algorithm.length", "128");
+    shouldBe("key.algorithm.hash.name", "'SHA-1'");
+    shouldBe("key.usages", "['sign', 'verify']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/crypto/subtle/hmac-import-jwk-key-sha1-expected.txt b/LayoutTests/crypto/subtle/hmac-import-jwk-key-sha1-expected.txt
new file mode 100644 (file)
index 0000000..ebae22c
--- /dev/null
@@ -0,0 +1,16 @@
+Test importing a JWK HMAC key with SHA-1
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS key.type is 'secret'
+PASS key.extractable is true
+PASS key.algorithm.name is 'HMAC'
+PASS key.algorithm.length is 128
+PASS key.algorithm.hash.name is 'SHA-1'
+PASS key.usages is ['sign', 'verify']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/hmac-import-jwk-key-sha1.html b/LayoutTests/crypto/subtle/hmac-import-jwk-key-sha1.html
new file mode 100644 (file)
index 0000000..d2c03f9
--- /dev/null
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a JWK HMAC key with SHA-1");
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: "oct",
+    k: "YWJjZGVmZ2gxMjM0NTY3OA",
+    alg: "HS1",
+    use: "sig",
+    key_ops: ["sign", "verify"],
+    ext: true,
+};
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("jwk", jwkKey, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"]).then(function(result) {
+    key = result;
+
+    shouldBe("key.type", "'secret'");
+    shouldBe("key.extractable", "true");
+    shouldBe("key.algorithm.name", "'HMAC'");
+    shouldBe("key.algorithm.length", "128");
+    shouldBe("key.algorithm.hash.name", "'SHA-1'");
+    shouldBe("key.usages", "['sign', 'verify']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/crypto/subtle/hmac-import-jwk-key-sha224-expected.txt b/LayoutTests/crypto/subtle/hmac-import-jwk-key-sha224-expected.txt
new file mode 100644 (file)
index 0000000..c73edd2
--- /dev/null
@@ -0,0 +1,16 @@
+Test importing a JWK HMAC key with SHA-224
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS key.type is 'secret'
+PASS key.extractable is true
+PASS key.algorithm.name is 'HMAC'
+PASS key.algorithm.length is 128
+PASS key.algorithm.hash.name is 'SHA-224'
+PASS key.usages is ['sign', 'verify']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/hmac-import-jwk-key-sha224.html b/LayoutTests/crypto/subtle/hmac-import-jwk-key-sha224.html
new file mode 100644 (file)
index 0000000..e846d05
--- /dev/null
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a JWK HMAC key with SHA-224");
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: "oct",
+    k: "YWJjZGVmZ2gxMjM0NTY3OA",
+    alg: "HS224",
+    use: "sig",
+    key_ops: ["sign", "verify"],
+    ext: true,
+};
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("jwk", jwkKey, {name: "hmac", hash: "sha-224"}, extractable, ["sign", "verify"]).then(function(result) {
+    key = result;
+
+    shouldBe("key.type", "'secret'");
+    shouldBe("key.extractable", "true");
+    shouldBe("key.algorithm.name", "'HMAC'");
+    shouldBe("key.algorithm.length", "128");
+    shouldBe("key.algorithm.hash.name", "'SHA-224'");
+    shouldBe("key.usages", "['sign', 'verify']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/crypto/subtle/hmac-import-jwk-key-sha256-expected.txt b/LayoutTests/crypto/subtle/hmac-import-jwk-key-sha256-expected.txt
new file mode 100644 (file)
index 0000000..1be8809
--- /dev/null
@@ -0,0 +1,16 @@
+Test importing a JWK HMAC key with SHA-256
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS key.type is 'secret'
+PASS key.extractable is true
+PASS key.algorithm.name is 'HMAC'
+PASS key.algorithm.length is 128
+PASS key.algorithm.hash.name is 'SHA-256'
+PASS key.usages is ['sign', 'verify']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/hmac-import-jwk-key-sha256.html b/LayoutTests/crypto/subtle/hmac-import-jwk-key-sha256.html
new file mode 100644 (file)
index 0000000..c3dcb60
--- /dev/null
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a JWK HMAC key with SHA-256");
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: "oct",
+    k: "YWJjZGVmZ2gxMjM0NTY3OA",
+    alg: "HS256",
+    use: "sig",
+    key_ops: ["sign", "verify"],
+    ext: true,
+};
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("jwk", jwkKey, {name: "hmac", hash: "sha-256"}, extractable, ["sign", "verify"]).then(function(result) {
+    key = result;
+
+    shouldBe("key.type", "'secret'");
+    shouldBe("key.extractable", "true");
+    shouldBe("key.algorithm.name", "'HMAC'");
+    shouldBe("key.algorithm.length", "128");
+    shouldBe("key.algorithm.hash.name", "'SHA-256'");
+    shouldBe("key.usages", "['sign', 'verify']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/crypto/subtle/hmac-import-jwk-key-sha384-expected.txt b/LayoutTests/crypto/subtle/hmac-import-jwk-key-sha384-expected.txt
new file mode 100644 (file)
index 0000000..effb1df
--- /dev/null
@@ -0,0 +1,16 @@
+Test importing a JWK HMAC key with SHA-384
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS key.type is 'secret'
+PASS key.extractable is true
+PASS key.algorithm.name is 'HMAC'
+PASS key.algorithm.length is 128
+PASS key.algorithm.hash.name is 'SHA-384'
+PASS key.usages is ['sign', 'verify']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/hmac-import-jwk-key-sha384.html b/LayoutTests/crypto/subtle/hmac-import-jwk-key-sha384.html
new file mode 100644 (file)
index 0000000..44fa76f
--- /dev/null
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a JWK HMAC key with SHA-384");
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: "oct",
+    k: "YWJjZGVmZ2gxMjM0NTY3OA",
+    alg: "HS384",
+    use: "sig",
+    key_ops: ["sign", "verify"],
+    ext: true,
+};
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("jwk", jwkKey, {name: "hmac", hash: "sha-384"}, extractable, ["sign", "verify"]).then(function(result) {
+    key = result;
+
+    shouldBe("key.type", "'secret'");
+    shouldBe("key.extractable", "true");
+    shouldBe("key.algorithm.name", "'HMAC'");
+    shouldBe("key.algorithm.length", "128");
+    shouldBe("key.algorithm.hash.name", "'SHA-384'");
+    shouldBe("key.usages", "['sign', 'verify']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/crypto/subtle/hmac-import-jwk-key-sha512-expected.txt b/LayoutTests/crypto/subtle/hmac-import-jwk-key-sha512-expected.txt
new file mode 100644 (file)
index 0000000..f6f65fe
--- /dev/null
@@ -0,0 +1,16 @@
+Test importing a JWK HMAC key with SHA-512
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS key.type is 'secret'
+PASS key.extractable is true
+PASS key.algorithm.name is 'HMAC'
+PASS key.algorithm.length is 128
+PASS key.algorithm.hash.name is 'SHA-512'
+PASS key.usages is ['sign', 'verify']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/hmac-import-jwk-key-sha512.html b/LayoutTests/crypto/subtle/hmac-import-jwk-key-sha512.html
new file mode 100644 (file)
index 0000000..cb19e9b
--- /dev/null
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a JWK HMAC key with SHA-512");
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: "oct",
+    k: "YWJjZGVmZ2gxMjM0NTY3OA",
+    alg: "HS512",
+    use: "sig",
+    key_ops: ["sign", "verify"],
+    ext: true,
+};
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("jwk", jwkKey, {name: "hmac", hash: "sha-512"}, extractable, ["sign", "verify"]).then(function(result) {
+    key = result;
+
+    shouldBe("key.type", "'secret'");
+    shouldBe("key.extractable", "true");
+    shouldBe("key.algorithm.name", "'HMAC'");
+    shouldBe("key.algorithm.length", "128");
+    shouldBe("key.algorithm.hash.name", "'SHA-512'");
+    shouldBe("key.usages", "['sign', 'verify']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/crypto/subtle/hmac-import-malformed-parameters-expected.txt b/LayoutTests/crypto/subtle/hmac-import-malformed-parameters-expected.txt
new file mode 100644 (file)
index 0000000..19bac1b
--- /dev/null
@@ -0,0 +1,23 @@
+Test importing an HMAC key with malformed parameters
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS crypto.subtle.importKey("raw", asciiToUint8Array(""), {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("raw", rawKey, {name: "hmac", hash: "sha-1", length: 257}, extractable, ["sign", "verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("raw", rawKey, {name: "hmac", hash: "sha-1", length: 248}, extractable, ["sign", "verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "RSA"}, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "oct"}, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: "HS224"}, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: "HS256"}, {name: "hmac", hash: "sha-224"}, extractable, ["sign", "verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: "HS384"}, {name: "hmac", hash: "sha-256"}, extractable, ["sign", "verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: "HS512"}, {name: "hmac", hash: "sha-384"}, extractable, ["sign", "verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: "HS1"}, {name: "hmac", hash: "sha-512"}, extractable, ["sign", "verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "oct", k: "!!!", alg: "foo"}, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: "HS1", use: "enc"}, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: "HS1", key_ops: ["sign"]}, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: "HS1", ext: false}, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/hmac-import-malformed-parameters.html b/LayoutTests/crypto/subtle/hmac-import-malformed-parameters.html
new file mode 100644 (file)
index 0000000..d2e2b50
--- /dev/null
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing an HMAC key with malformed parameters");
+
+var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMrgJB55WL46tJSLGt7");
+var extractable = true;
+
+var k = "YWJjZGVmZ2gxMjM0NTY3OA";
+
+// wrong length
+shouldReject('crypto.subtle.importKey("raw", asciiToUint8Array(""), {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"])');
+shouldReject('crypto.subtle.importKey("raw", rawKey, {name: "hmac", hash: "sha-1", length: 257}, extractable, ["sign", "verify"])');
+shouldReject('crypto.subtle.importKey("raw", rawKey, {name: "hmac", hash: "sha-1", length: 248}, extractable, ["sign", "verify"])');
+// Jwk: Wrong kty
+shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA"}, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"])');
+// Jwk: missing k
+shouldReject('crypto.subtle.importKey("jwk", {kty: "oct"}, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"])');
+// Jwk: wrong hash and alg
+shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: "HS224"}, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"])');
+shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: "HS256"}, {name: "hmac", hash: "sha-224"}, extractable, ["sign", "verify"])');
+shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: "HS384"}, {name: "hmac", hash: "sha-256"}, extractable, ["sign", "verify"])');
+shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: "HS512"}, {name: "hmac", hash: "sha-384"}, extractable, ["sign", "verify"])');
+shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: "HS1"}, {name: "hmac", hash: "sha-512"}, extractable, ["sign", "verify"])');
+// Jwk: wrong k format
+shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: "!!!", alg: "foo"}, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"])');
+// Jwk: wrong use
+shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: "HS1", use: "enc"}, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"])');
+// Jwk: wrong key_ops
+shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: "HS1", key_ops: ["sign"]}, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"])');
+// Jwk: wrong ext
+shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: "HS1", ext: false}, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"])');
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/crypto/subtle/hmac-import-raw-key-customized-length-expected.txt b/LayoutTests/crypto/subtle/hmac-import-raw-key-customized-length-expected.txt
new file mode 100644 (file)
index 0000000..c42529e
--- /dev/null
@@ -0,0 +1,16 @@
+Test importing a raw HMAC key with customized length
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS key.type is 'secret'
+PASS key.extractable is true
+PASS key.algorithm.name is 'HMAC'
+PASS key.algorithm.length is 128
+PASS key.algorithm.hash.name is 'SHA-1'
+PASS key.usages is ['sign', 'verify']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/hmac-import-raw-key-customized-length.html b/LayoutTests/crypto/subtle/hmac-import-raw-key-customized-length.html
new file mode 100644 (file)
index 0000000..2167c52
--- /dev/null
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a raw HMAC key with customized length");
+
+jsTestIsAsync = true;
+
+var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("raw", rawKey, {name: "hmac", hash: "sha-1", length: 128}, extractable, ["sign", "verify"]).then(function(result) {
+    key = result;
+
+    shouldBe("key.type", "'secret'");
+    shouldBe("key.extractable", "true");
+    shouldBe("key.algorithm.name", "'HMAC'");
+    shouldBe("key.algorithm.length", "128");
+    shouldBe("key.algorithm.hash.name", "'SHA-1'");
+    shouldBe("key.usages", "['sign', 'verify']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/crypto/subtle/hmac-import-raw-key-expected.txt b/LayoutTests/crypto/subtle/hmac-import-raw-key-expected.txt
new file mode 100644 (file)
index 0000000..04e2c0f
--- /dev/null
@@ -0,0 +1,16 @@
+Test importing a raw HMAC key
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS key.type is 'secret'
+PASS key.extractable is true
+PASS key.algorithm.name is 'HMAC'
+PASS key.algorithm.length is 128
+PASS key.algorithm.hash.name is 'SHA-1'
+PASS key.usages is ['sign', 'verify']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/hmac-import-raw-key.html b/LayoutTests/crypto/subtle/hmac-import-raw-key.html
new file mode 100644 (file)
index 0000000..129a6cb
--- /dev/null
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a raw HMAC key");
+
+jsTestIsAsync = true;
+
+var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("raw", rawKey, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"]).then(function(result) {
+    key = result;
+
+    shouldBe("key.type", "'secret'");
+    shouldBe("key.extractable", "true");
+    shouldBe("key.algorithm.name", "'HMAC'");
+    shouldBe("key.algorithm.length", "128");
+    shouldBe("key.algorithm.hash.name", "'SHA-1'");
+    shouldBe("key.usages", "['sign', 'verify']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/crypto/subtle/import-key-malformed-parameters-expected.txt b/LayoutTests/crypto/subtle/import-key-malformed-parameters-expected.txt
new file mode 100644 (file)
index 0000000..69c4b87
--- /dev/null
@@ -0,0 +1,43 @@
+Test importing a key with malformed parameters
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS crypto.subtle.importKey() rejected promise  with TypeError: Not enough arguments.
+PASS crypto.subtle.importKey(1) rejected promise  with TypeError: Not enough arguments.
+PASS crypto.subtle.importKey(1, 2) rejected promise  with TypeError: Not enough arguments.
+PASS crypto.subtle.importKey(1, 2, 3) rejected promise  with TypeError: Not enough arguments.
+PASS crypto.subtle.importKey(1, 2, 3, 4) rejected promise  with TypeError: Not enough arguments.
+PASS crypto.subtle.importKey(1, rawKey, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with TypeError: Type error.
+PASS crypto.subtle.importKey(true, rawKey, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with TypeError: Type error.
+PASS crypto.subtle.importKey(null, rawKey, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with TypeError: Type error.
+PASS crypto.subtle.importKey(undefined, rawKey, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with TypeError: Type error.
+PASS crypto.subtle.importKey(Symbol(), rawKey, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with TypeError: Type error.
+PASS crypto.subtle.importKey({ }, rawKey, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with TypeError: Type error.
+PASS crypto.subtle.importKey("foo", rawKey, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with TypeError: Type error.
+PASS crypto.subtle.importKey("pkcs8", rawKey, "rsaes-pkcs1-v1_5", extractable, ["encrypt", "decrypt"]) rejected promise  with NotSupportedError (DOM Exception 9): The operation is not supported..
+PASS crypto.subtle.importKey("spki", rawKey, "rsaes-pkcs1-v1_5", extractable, ["encrypt", "decrypt"]) rejected promise  with NotSupportedError (DOM Exception 9): The operation is not supported..
+PASS crypto.subtle.importKey("raw", jwkKey, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with TypeError: Type error.
+PASS crypto.subtle.importKey("raw", 1, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with TypeError: Type error.
+PASS crypto.subtle.importKey("raw", true, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with TypeError: Type error.
+PASS crypto.subtle.importKey("raw", null, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with TypeError: Type error.
+PASS crypto.subtle.importKey("raw", undefined, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with TypeError: Type error.
+PASS crypto.subtle.importKey("raw", Symbol(), "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with TypeError: Type error.
+PASS crypto.subtle.importKey("raw", { }, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with TypeError: Type error.
+PASS crypto.subtle.importKey("raw", "foo", "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with TypeError: Type error.
+PASS crypto.subtle.importKey("jwk", rawKey, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with TypeError: Member JsonWebKey.kty is required and must be an instance of DOMString.
+PASS crypto.subtle.importKey("jwk", 1, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with TypeError: Type error.
+PASS crypto.subtle.importKey("jwk", true, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with TypeError: Type error.
+PASS crypto.subtle.importKey("jwk", Symbol(), "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with TypeError: Type error.
+PASS crypto.subtle.importKey("jwk", { }, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with TypeError: Member JsonWebKey.kty is required and must be an instance of DOMString.
+PASS crypto.subtle.importKey("jwk", "foo", "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with TypeError: Type error.
+PASS crypto.subtle.importKey("jwk", undefined, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with TypeError: Member JsonWebKey.kty is required and must be an instance of DOMString.
+PASS crypto.subtle.importKey("jwk", null, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with TypeError: Member JsonWebKey.kty is required and must be an instance of DOMString.
+PASS crypto.subtle.importKey("raw", rawKey, "aes-cbc", extractable, [ ]) rejected promise  with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
+PASS crypto.subtle.importKey("jwk", jwkPrivateKey, "rsaes-pkcs1-v1_5", extractable, [ ]) rejected promise  with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
+PASS crypto.subtle.importKey("jwk", {kty: undefined}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with TypeError: Member JsonWebKey.kty is required and must be an instance of DOMString.
+PASS crypto.subtle.importKey("jwk", {kty: "oct", key_ops: ["foo"]}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with TypeError: Invalid key_ops.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/import-key-malformed-parameters.html b/LayoutTests/crypto/subtle/import-key-malformed-parameters.html
new file mode 100644 (file)
index 0000000..2ff1f95
--- /dev/null
@@ -0,0 +1,82 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a key with malformed parameters");
+
+var jwkKey = {
+    kty: "oct",
+    k: "YWJjZGVmZ2gxMjM0NTY3OA",
+    alg: "A128CBC"
+};
+var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMrgJB55WL46tJSLGt7");
+var jwkPrivateKey = {
+    kty: "RSA",
+    alg: "RSA1_5",
+    use: "enc",
+    key_ops: ["decrypt"],
+    ext: true,
+    n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
+    e: "AQAB",
+    d: "eNLS37aCz7RXSNPD_DtLBJ6j5T8cSxdzRBCjPaI6WcGqJp16lq3UTwuoDLAqlA9oGYm238dsIWpuucP_lQtbWe-7SpxoI6_vmYGf7YVUHv1-DF9qiOmSrMmdxMnVOzYXY8RaT6thPjn_J5cfLV2xI_LwsrMtmpdSyNlgX0zTUhwtuahgAKMEChYjH2EnjHdHw6sY2-wApdcQI7ULE0oo5RzbQZpmuhcN9hiBc0L3hhF0qo50mbl02_65_GQ7DpVkXBxNgRBLzlPabmzzG2oAhfefLgYmSC1opaCkXE6vRWQNWNL45RZNZFYM3uoJghOMqGeocM0BpjdChHrPOlFvSQ",
+    p: "4miTuAjKMeH5uJ5KB397QUwhbkYEgSbcA2mifmSkvE2018gb55qkBHK1eVryf1_m43LNlc6O_ak6gfzdZIZvS5NCGjPl0q09plUpu8qFOSspBwA67qGH76lFlZLn_d4yglS7wfLru4_5Ys8qLLs-DqVLviwposOnyyWqwM5AXp0",
+    q: "xHYrzkivtmnz_sGchnWGc0q-pDOkKicptRpv2pMFIIXxnFX5aMeEXIZjVujXtwUy1UlFIN2GZJSvy5KJ79mu_XyNnFHMzedH-A3ee3u8h1UUrZF-vUu1_e4U_x67NN1dedzUSKynN7pFl3OkuShMBWGV-cwzOPdcVAfVuZlxUMc",
+    dp: "fBzDzYDUBmBQGop7Hn0dvf_T27V6RqpctWo074CQZcFbP2atFVtKSj3viWT3xid2VHzcgiDHdfpM3nEVlEO1wwIonGCSvdjGEOZiiFVOjrZAOVxA8guOjyyFvqbXke06VwPIIVvfKeSU2zuhbP__1tt6F_fxow4Kb2xonGT0GGk",
+    dq: "jmE2DiIPdhwDgLXAQpIaBqQ81bO3XfVT_LRULAwwwwlPuQV148H04zlh9TJ6Y2GZHYokV1U0eOBpJxfkb7dLYtpJpuiBjRf4yIUEoGlkkI_QlJnFSFr-YjGRdfNHqWBkxlSMZL770R9mIATndGkH7z5x-r9KwBZFC4FCG2hg_zE",
+    qi: "YCX_pLwbMBA1ThVH0WcwmnytqNcrMCEwTm7ByA2eU6nWbQrULvf7m9_kzfLUcjsnpAVlBQG5JMXMy0Sq4ptwbywsa5-G8KAOOOR2L3v4hC-Eys9ftgFM_3i0o40eeQH4b3haPbntrIeMg8IzlOuVYKf9-2QuKDoWeRdd7NsdxTk",
+};
+var extractable = true;
+
+// Not enough arguments.
+shouldReject('crypto.subtle.importKey()');
+shouldReject('crypto.subtle.importKey(1)');
+shouldReject('crypto.subtle.importKey(1, 2)');
+shouldReject('crypto.subtle.importKey(1, 2, 3)');
+shouldReject('crypto.subtle.importKey(1, 2, 3, 4)');
+// Wrong formats.
+shouldReject('crypto.subtle.importKey(1, rawKey, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
+shouldReject('crypto.subtle.importKey(true, rawKey, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
+shouldReject('crypto.subtle.importKey(null, rawKey, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
+shouldReject('crypto.subtle.importKey(undefined, rawKey, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
+shouldReject('crypto.subtle.importKey(Symbol(), rawKey, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
+shouldReject('crypto.subtle.importKey({ }, rawKey, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
+shouldReject('crypto.subtle.importKey("foo", rawKey, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
+// Currently not support formats.
+shouldReject('crypto.subtle.importKey("pkcs8", rawKey, "rsaes-pkcs1-v1_5", extractable, ["encrypt", "decrypt"])');
+shouldReject('crypto.subtle.importKey("spki", rawKey, "rsaes-pkcs1-v1_5", extractable, ["encrypt", "decrypt"])');
+// Wrong KeyData.
+shouldReject('crypto.subtle.importKey("raw", jwkKey, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
+shouldReject('crypto.subtle.importKey("raw", 1, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
+shouldReject('crypto.subtle.importKey("raw", true, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
+shouldReject('crypto.subtle.importKey("raw", null, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
+shouldReject('crypto.subtle.importKey("raw", undefined, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
+shouldReject('crypto.subtle.importKey("raw", Symbol(), "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
+shouldReject('crypto.subtle.importKey("raw", { }, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
+shouldReject('crypto.subtle.importKey("raw", "foo", "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
+shouldReject('crypto.subtle.importKey("jwk", rawKey, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
+shouldReject('crypto.subtle.importKey("jwk", 1, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
+shouldReject('crypto.subtle.importKey("jwk", true, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
+shouldReject('crypto.subtle.importKey("jwk", Symbol(), "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
+shouldReject('crypto.subtle.importKey("jwk", { }, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
+shouldReject('crypto.subtle.importKey("jwk", "foo", "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
+shouldReject('crypto.subtle.importKey("jwk", undefined, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
+shouldReject('crypto.subtle.importKey("jwk", null, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
+// Null usages.
+shouldReject('crypto.subtle.importKey("raw", rawKey, "aes-cbc", extractable, [ ])');
+shouldReject('crypto.subtle.importKey("jwk", jwkPrivateKey, "rsaes-pkcs1-v1_5", extractable, [ ])');
+// JWK: missing kty.
+shouldReject('crypto.subtle.importKey("jwk", {kty: undefined}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
+// JWK: wrong key_ops.
+shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", key_ops: ["foo"]}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/crypto/subtle/rsa-import-key-malformed-parameters-expected.txt b/LayoutTests/crypto/subtle/rsa-import-key-malformed-parameters-expected.txt
new file mode 100644 (file)
index 0000000..d932e77
--- /dev/null
@@ -0,0 +1,42 @@
+Test importing a RSA key with malformed parameters
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e}, "RSAES-PKCS1-v1_5", extractable, ["decrypt"]) rejected promise  with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
+PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: d}, "RSAES-PKCS1-v1_5", extractable, ["encrypt"]) rejected promise  with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
+PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-1"}, extractable, ["sign"]) rejected promise  with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
+PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: d}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-1"}, extractable, ["verify"]) rejected promise  with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
+PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e}, {name: "RSA-OAEP", hash: "sha-1"}, extractable, ["decrypt", "unwrapKey"]) rejected promise  with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
+PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: d}, {name: "RSA-OAEP", hash: "sha-1"}, extractable, ["encrypt", "wrapKey"]) rejected promise  with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
+PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, use: "sig"}, "RSAES-PKCS1-v1_5", extractable, ["encrypt"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, use: "enc"}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-1"}, extractable, ["verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, use: "sig"}, {name: "RSA-OAEP", hash: "sha-1"}, extractable, ["encrypt", "wrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "foo"}, "RSAES-PKCS1-v1_5", extractable, ["encrypt"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "RS224"}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-1"}, extractable, ["verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "RS256"}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-224"}, extractable, ["verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "RS384"}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-256"}, extractable, ["verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "RS512"}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-384"}, extractable, ["verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "RS1"}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-512"}, extractable, ["verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "RSA-OAEP-224"}, {name: "RSA-OAEP", hash: "sha-1"}, extractable, ["encrypt", "wrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "RSA-OAEP-256"}, {name: "RSA-OAEP", hash: "sha-224"}, extractable, ["encrypt", "wrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "RSA-OAEP-384"}, {name: "RSA-OAEP", hash: "sha-256"}, extractable, ["encrypt", "wrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "RSA-OAEP-512"}, {name: "RSA-OAEP", hash: "sha-384"}, extractable, ["encrypt", "wrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "RSA-OAEP"}, {name: "RSA-OAEP", hash: "sha-512"}, extractable, ["encrypt", "wrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "oct", n: n, e: e}, "RSAES-PKCS1-v1_5", extractable, ["encrypt"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, key_ops: ["sign", "verify"]}, "RSAES-PKCS1-v1_5", extractable, ["encrypt"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, ext: false}, "RSAES-PKCS1-v1_5", extractable, ["encrypt"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "RSA"}, "RSAES-PKCS1-v1_5", extractable, ["encrypt"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n}, "RSAES-PKCS1-v1_5", extractable, ["encrypt"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "RSA", e: e}, "RSAES-PKCS1-v1_5", extractable, ["encrypt"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: d}, "RSAES-PKCS1-v1_5", extractable, ["decrypt"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: d, p: p, q: q, dp: dp, dq: dq, qi: qi, oth: [{r: q, d: dq, t: qi}]}, "RSAES-PKCS1-v1_5", extractable, ["decrypt"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: d, q: q, dp: dp, dq: dq, qi: qi}, "RSAES-PKCS1-v1_5", extractable, ["decrypt"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: d, p: p, dp: dp, dq: dq, qi: qi}, "RSAES-PKCS1-v1_5", extractable, ["decrypt"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: d, p: p, q: q, dq: dq, qi: qi}, "RSAES-PKCS1-v1_5", extractable, ["decrypt"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: d, p: p, q: q, dp: dp, qi: qi}, "RSAES-PKCS1-v1_5", extractable, ["decrypt"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: d, p: p, q: q, dp: dp, dq: dq}, "RSAES-PKCS1-v1_5", extractable, ["decrypt"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/rsa-import-key-malformed-parameters.html b/LayoutTests/crypto/subtle/rsa-import-key-malformed-parameters.html
new file mode 100644 (file)
index 0000000..57db37e
--- /dev/null
@@ -0,0 +1,71 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a RSA key with malformed parameters");
+
+var extractable = true;
+
+var n = "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw";
+var e = "AQAB";
+var d = "eNLS37aCz7RXSNPD_DtLBJ6j5T8cSxdzRBCjPaI6WcGqJp16lq3UTwuoDLAqlA9oGYm238dsIWpuucP_lQtbWe-7SpxoI6_vmYGf7YVUHv1-DF9qiOmSrMmdxMnVOzYXY8RaT6thPjn_J5cfLV2xI_LwsrMtmpdSyNlgX0zTUhwtuahgAKMEChYjH2EnjHdHw6sY2-wApdcQI7ULE0oo5RzbQZpmuhcN9hiBc0L3hhF0qo50mbl02_65_GQ7DpVkXBxNgRBLzlPabmzzG2oAhfefLgYmSC1opaCkXE6vRWQNWNL45RZNZFYM3uoJghOMqGeocM0BpjdChHrPOlFvSQ";
+var p = "4miTuAjKMeH5uJ5KB397QUwhbkYEgSbcA2mifmSkvE2018gb55qkBHK1eVryf1_m43LNlc6O_ak6gfzdZIZvS5NCGjPl0q09plUpu8qFOSspBwA67qGH76lFlZLn_d4yglS7wfLru4_5Ys8qLLs-DqVLviwposOnyyWqwM5AXp0";
+var q = "xHYrzkivtmnz_sGchnWGc0q-pDOkKicptRpv2pMFIIXxnFX5aMeEXIZjVujXtwUy1UlFIN2GZJSvy5KJ79mu_XyNnFHMzedH-A3ee3u8h1UUrZF-vUu1_e4U_x67NN1dedzUSKynN7pFl3OkuShMBWGV-cwzOPdcVAfVuZlxUMc";
+var dp = "fBzDzYDUBmBQGop7Hn0dvf_T27V6RqpctWo074CQZcFbP2atFVtKSj3viWT3xid2VHzcgiDHdfpM3nEVlEO1wwIonGCSvdjGEOZiiFVOjrZAOVxA8guOjyyFvqbXke06VwPIIVvfKeSU2zuhbP__1tt6F_fxow4Kb2xonGT0GGk";
+var dq = "jmE2DiIPdhwDgLXAQpIaBqQ81bO3XfVT_LRULAwwwwlPuQV148H04zlh9TJ6Y2GZHYokV1U0eOBpJxfkb7dLYtpJpuiBjRf4yIUEoGlkkI_QlJnFSFr-YjGRdfNHqWBkxlSMZL770R9mIATndGkH7z5x-r9KwBZFC4FCG2hg_zE";
+var qi = "YCX_pLwbMBA1ThVH0WcwmnytqNcrMCEwTm7ByA2eU6nWbQrULvf7m9_kzfLUcjsnpAVlBQG5JMXMy0Sq4ptwbywsa5-G8KAOOOR2L3v4hC-Eys9ftgFM_3i0o40eeQH4b3haPbntrIeMg8IzlOuVYKf9-2QuKDoWeRdd7NsdxTk";
+
+// Jwk: Wrong usages
+shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e}, "RSAES-PKCS1-v1_5", extractable, ["decrypt"])');
+shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: d}, "RSAES-PKCS1-v1_5", extractable, ["encrypt"])');
+shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-1"}, extractable, ["sign"])');
+shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: d}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-1"}, extractable, ["verify"])');
+shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e}, {name: "RSA-OAEP", hash: "sha-1"}, extractable, ["decrypt", "unwrapKey"])');
+shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: d}, {name: "RSA-OAEP", hash: "sha-1"}, extractable, ["encrypt", "wrapKey"])');
+// Jwk: Wrong use
+shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, use: "sig"}, "RSAES-PKCS1-v1_5", extractable, ["encrypt"])');
+shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, use: "enc"}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-1"}, extractable, ["verify"])');
+shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, use: "sig"}, {name: "RSA-OAEP", hash: "sha-1"}, extractable, ["encrypt", "wrapKey"])');
+// Jwk: Wrong alg
+shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "foo"}, "RSAES-PKCS1-v1_5", extractable, ["encrypt"])');
+shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "RS224"}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-1"}, extractable, ["verify"])');
+shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "RS256"}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-224"}, extractable, ["verify"])');
+shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "RS384"}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-256"}, extractable, ["verify"])');
+shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "RS512"}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-384"}, extractable, ["verify"])');
+shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "RS1"}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-512"}, extractable, ["verify"])');
+shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "RSA-OAEP-224"}, {name: "RSA-OAEP", hash: "sha-1"}, extractable, ["encrypt", "wrapKey"])');
+shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "RSA-OAEP-256"}, {name: "RSA-OAEP", hash: "sha-224"}, extractable, ["encrypt", "wrapKey"])');
+shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "RSA-OAEP-384"}, {name: "RSA-OAEP", hash: "sha-256"}, extractable, ["encrypt", "wrapKey"])');
+shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "RSA-OAEP-512"}, {name: "RSA-OAEP", hash: "sha-384"}, extractable, ["encrypt", "wrapKey"])');
+shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "RSA-OAEP"}, {name: "RSA-OAEP", hash: "sha-512"}, extractable, ["encrypt", "wrapKey"])');
+// Jwk: Wrong kty
+shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", n: n, e: e}, "RSAES-PKCS1-v1_5", extractable, ["encrypt"])');
+// Jwk: Wrong key_ops
+shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, key_ops: ["sign", "verify"]}, "RSAES-PKCS1-v1_5", extractable, ["encrypt"])');
+// Jwk: Wrong ext
+shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, ext: false}, "RSAES-PKCS1-v1_5", extractable, ["encrypt"])');
+// Jwk: Missing n or e
+shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA"}, "RSAES-PKCS1-v1_5", extractable, ["encrypt"])');
+shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n}, "RSAES-PKCS1-v1_5", extractable, ["encrypt"])');
+shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", e: e}, "RSAES-PKCS1-v1_5", extractable, ["encrypt"])');
+// Jwk: We currently only support import private key with two prime factors
+shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: d}, "RSAES-PKCS1-v1_5", extractable, ["decrypt"])');
+shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: d, p: p, q: q, dp: dp, dq: dq, qi: qi, oth: [{r: q, d: dq, t: qi}]}, "RSAES-PKCS1-v1_5", extractable, ["decrypt"])');
+// Jwk: miss any of p, q, dp, dq, qi
+shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: d, q: q, dp: dp, dq: dq, qi: qi}, "RSAES-PKCS1-v1_5", extractable, ["decrypt"])');
+shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: d, p: p, dp: dp, dq: dq, qi: qi}, "RSAES-PKCS1-v1_5", extractable, ["decrypt"])');
+shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: d, p: p, q: q, dq: dq, qi: qi}, "RSAES-PKCS1-v1_5", extractable, ["decrypt"])');
+shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: d, p: p, q: q, dp: dp, qi: qi}, "RSAES-PKCS1-v1_5", extractable, ["decrypt"])');
+shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: d, p: p, q: q, dp: dp, dq: dq}, "RSAES-PKCS1-v1_5", extractable, ["decrypt"])');
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/crypto/subtle/rsa-oaep-import-jwk-private-key-expected.txt b/LayoutTests/crypto/subtle/rsa-oaep-import-jwk-private-key-expected.txt
new file mode 100644 (file)
index 0000000..d909d18
--- /dev/null
@@ -0,0 +1,18 @@
+Test importing a JWK RSA-OAEP private key with SHA-1
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS privateKey.toString() is '[object CryptoKey]'
+PASS privateKey.type is 'private'
+PASS privateKey.extractable is true
+PASS privateKey.algorithm.name is 'RSA-OAEP'
+PASS privateKey.algorithm.modulusLength is 2048
+PASS bytesToHexString(privateKey.algorithm.publicExponent) is '010001'
+PASS privateKey.algorithm.hash.name is 'SHA-1'
+PASS privateKey.usages is ['decrypt', 'unwrapKey']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/rsa-oaep-import-jwk-private-key.html b/LayoutTests/crypto/subtle/rsa-oaep-import-jwk-private-key.html
new file mode 100644 (file)
index 0000000..70b72c8
--- /dev/null
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a JWK RSA-OAEP private key with SHA-1");
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: "RSA",
+    alg: "RSA-OAEP",
+    use: "enc",
+    key_ops: ["decrypt", "unwrapKey"],
+    ext: true,
+    n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
+    e: "AQAB",
+    d: "eNLS37aCz7RXSNPD_DtLBJ6j5T8cSxdzRBCjPaI6WcGqJp16lq3UTwuoDLAqlA9oGYm238dsIWpuucP_lQtbWe-7SpxoI6_vmYGf7YVUHv1-DF9qiOmSrMmdxMnVOzYXY8RaT6thPjn_J5cfLV2xI_LwsrMtmpdSyNlgX0zTUhwtuahgAKMEChYjH2EnjHdHw6sY2-wApdcQI7ULE0oo5RzbQZpmuhcN9hiBc0L3hhF0qo50mbl02_65_GQ7DpVkXBxNgRBLzlPabmzzG2oAhfefLgYmSC1opaCkXE6vRWQNWNL45RZNZFYM3uoJghOMqGeocM0BpjdChHrPOlFvSQ",
+    p: "4miTuAjKMeH5uJ5KB397QUwhbkYEgSbcA2mifmSkvE2018gb55qkBHK1eVryf1_m43LNlc6O_ak6gfzdZIZvS5NCGjPl0q09plUpu8qFOSspBwA67qGH76lFlZLn_d4yglS7wfLru4_5Ys8qLLs-DqVLviwposOnyyWqwM5AXp0",
+    q: "xHYrzkivtmnz_sGchnWGc0q-pDOkKicptRpv2pMFIIXxnFX5aMeEXIZjVujXtwUy1UlFIN2GZJSvy5KJ79mu_XyNnFHMzedH-A3ee3u8h1UUrZF-vUu1_e4U_x67NN1dedzUSKynN7pFl3OkuShMBWGV-cwzOPdcVAfVuZlxUMc",
+    dp: "fBzDzYDUBmBQGop7Hn0dvf_T27V6RqpctWo074CQZcFbP2atFVtKSj3viWT3xid2VHzcgiDHdfpM3nEVlEO1wwIonGCSvdjGEOZiiFVOjrZAOVxA8guOjyyFvqbXke06VwPIIVvfKeSU2zuhbP__1tt6F_fxow4Kb2xonGT0GGk",
+    dq: "jmE2DiIPdhwDgLXAQpIaBqQ81bO3XfVT_LRULAwwwwlPuQV148H04zlh9TJ6Y2GZHYokV1U0eOBpJxfkb7dLYtpJpuiBjRf4yIUEoGlkkI_QlJnFSFr-YjGRdfNHqWBkxlSMZL770R9mIATndGkH7z5x-r9KwBZFC4FCG2hg_zE",
+    qi: "YCX_pLwbMBA1ThVH0WcwmnytqNcrMCEwTm7ByA2eU6nWbQrULvf7m9_kzfLUcjsnpAVlBQG5JMXMy0Sq4ptwbywsa5-G8KAOOOR2L3v4hC-Eys9ftgFM_3i0o40eeQH4b3haPbntrIeMg8IzlOuVYKf9-2QuKDoWeRdd7NsdxTk",
+};
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("jwk", jwkKey, {name: "RSA-OAEP", hash: "SHA-1"}, extractable, ["decrypt", "unwrapKey"]).then(function(result) {
+    privateKey = result;
+
+    shouldBe("privateKey.toString()", "'[object CryptoKey]'");
+    shouldBe("privateKey.type", "'private'");
+    shouldBe("privateKey.extractable", "true");
+    shouldBe("privateKey.algorithm.name", "'RSA-OAEP'");
+    shouldBe("privateKey.algorithm.modulusLength", "2048");
+    shouldBe("bytesToHexString(privateKey.algorithm.publicExponent)", "'010001'");
+    shouldBe("privateKey.algorithm.hash.name", "'SHA-1'");
+    shouldBe("privateKey.usages", "['decrypt', 'unwrapKey']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/crypto/subtle/rsa-oaep-import-jwk-public-key-sha1-expected.txt b/LayoutTests/crypto/subtle/rsa-oaep-import-jwk-public-key-sha1-expected.txt
new file mode 100644 (file)
index 0000000..9982b2a
--- /dev/null
@@ -0,0 +1,18 @@
+Test importing a JWK RSA-OAEP public key with SHA-1
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS publicKey.toString() is '[object CryptoKey]'
+PASS publicKey.type is 'public'
+PASS publicKey.extractable is true
+PASS publicKey.algorithm.name is 'RSA-OAEP'
+PASS publicKey.algorithm.modulusLength is 2048
+PASS bytesToHexString(publicKey.algorithm.publicExponent) is '010001'
+PASS publicKey.algorithm.hash.name is 'SHA-1'
+PASS publicKey.usages is ['encrypt', 'wrapKey']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/rsa-oaep-import-jwk-public-key-sha1.html b/LayoutTests/crypto/subtle/rsa-oaep-import-jwk-public-key-sha1.html
new file mode 100644 (file)
index 0000000..f73a285
--- /dev/null
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a JWK RSA-OAEP public key with SHA-1");
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: "RSA",
+    alg: "RSA-OAEP",
+    use: "enc",
+    key_ops: ["encrypt", "wrapKey"],
+    ext: true,
+    n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
+    e: "AQAB"
+};
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("jwk", jwkKey, {name: "RSA-OAEP", hash: "SHA-1"}, extractable, ["encrypt", "wrapKey"]).then(function(result) {
+    publicKey = result;
+
+    shouldBe("publicKey.toString()", "'[object CryptoKey]'");
+    shouldBe("publicKey.type", "'public'");
+    shouldBe("publicKey.extractable", "true");
+    shouldBe("publicKey.algorithm.name", "'RSA-OAEP'");
+    shouldBe("publicKey.algorithm.modulusLength", "2048");
+    shouldBe("bytesToHexString(publicKey.algorithm.publicExponent)", "'010001'");
+    shouldBe("publicKey.algorithm.hash.name", "'SHA-1'");
+    shouldBe("publicKey.usages", "['encrypt', 'wrapKey']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/crypto/subtle/rsa-oaep-import-jwk-public-key-sha224-expected.txt b/LayoutTests/crypto/subtle/rsa-oaep-import-jwk-public-key-sha224-expected.txt
new file mode 100644 (file)
index 0000000..735230d
--- /dev/null
@@ -0,0 +1,18 @@
+Test importing a JWK RSA-OAEP public key with SHA-224
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS publicKey.toString() is '[object CryptoKey]'
+PASS publicKey.type is 'public'
+PASS publicKey.extractable is true
+PASS publicKey.algorithm.name is 'RSA-OAEP'
+PASS publicKey.algorithm.modulusLength is 2048
+PASS bytesToHexString(publicKey.algorithm.publicExponent) is '010001'
+PASS publicKey.algorithm.hash.name is 'SHA-224'
+PASS publicKey.usages is ['encrypt', 'wrapKey']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/rsa-oaep-import-jwk-public-key-sha224.html b/LayoutTests/crypto/subtle/rsa-oaep-import-jwk-public-key-sha224.html
new file mode 100644 (file)
index 0000000..a204c02
--- /dev/null
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a JWK RSA-OAEP public key with SHA-224");
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: "RSA",
+    alg: "RSA-OAEP-224",
+    use: "enc",
+    key_ops: ["encrypt", "wrapKey"],
+    ext: true,
+    n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
+    e: "AQAB"
+};
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("jwk", jwkKey, {name: "RSA-OAEP", hash: "SHA-224"}, extractable, ["encrypt", "wrapKey"]).then(function(result) {
+    publicKey = result;
+
+    shouldBe("publicKey.toString()", "'[object CryptoKey]'");
+    shouldBe("publicKey.type", "'public'");
+    shouldBe("publicKey.extractable", "true");
+    shouldBe("publicKey.algorithm.name", "'RSA-OAEP'");
+    shouldBe("publicKey.algorithm.modulusLength", "2048");
+    shouldBe("bytesToHexString(publicKey.algorithm.publicExponent)", "'010001'");
+    shouldBe("publicKey.algorithm.hash.name", "'SHA-224'");
+    shouldBe("publicKey.usages", "['encrypt', 'wrapKey']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/crypto/subtle/rsa-oaep-import-jwk-public-key-sha256-expected.txt b/LayoutTests/crypto/subtle/rsa-oaep-import-jwk-public-key-sha256-expected.txt
new file mode 100644 (file)
index 0000000..42bfcb9
--- /dev/null
@@ -0,0 +1,18 @@
+Test importing a JWK RSA-OAEP public key with SHA-256
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS publicKey.toString() is '[object CryptoKey]'
+PASS publicKey.type is 'public'
+PASS publicKey.extractable is true
+PASS publicKey.algorithm.name is 'RSA-OAEP'
+PASS publicKey.algorithm.modulusLength is 2048
+PASS bytesToHexString(publicKey.algorithm.publicExponent) is '010001'
+PASS publicKey.algorithm.hash.name is 'SHA-256'
+PASS publicKey.usages is ['encrypt', 'wrapKey']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/rsa-oaep-import-jwk-public-key-sha256.html b/LayoutTests/crypto/subtle/rsa-oaep-import-jwk-public-key-sha256.html
new file mode 100644 (file)
index 0000000..587fa23
--- /dev/null
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a JWK RSA-OAEP public key with SHA-256");
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: "RSA",
+    alg: "RSA-OAEP-256",
+    use: "enc",
+    key_ops: ["encrypt", "wrapKey"],
+    ext: true,
+    n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
+    e: "AQAB"
+};
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("jwk", jwkKey, {name: "RSA-OAEP", hash: "SHA-256"}, extractable, ["encrypt", "wrapKey"]).then(function(result) {
+    publicKey = result;
+
+    shouldBe("publicKey.toString()", "'[object CryptoKey]'");
+    shouldBe("publicKey.type", "'public'");
+    shouldBe("publicKey.extractable", "true");
+    shouldBe("publicKey.algorithm.name", "'RSA-OAEP'");
+    shouldBe("publicKey.algorithm.modulusLength", "2048");
+    shouldBe("bytesToHexString(publicKey.algorithm.publicExponent)", "'010001'");
+    shouldBe("publicKey.algorithm.hash.name", "'SHA-256'");
+    shouldBe("publicKey.usages", "['encrypt', 'wrapKey']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/crypto/subtle/rsa-oaep-import-jwk-public-key-sha384-expected.txt b/LayoutTests/crypto/subtle/rsa-oaep-import-jwk-public-key-sha384-expected.txt
new file mode 100644 (file)
index 0000000..375d332
--- /dev/null
@@ -0,0 +1,18 @@
+Test importing a JWK RSA-OAEP public key with SHA-384
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS publicKey.toString() is '[object CryptoKey]'
+PASS publicKey.type is 'public'
+PASS publicKey.extractable is true
+PASS publicKey.algorithm.name is 'RSA-OAEP'
+PASS publicKey.algorithm.modulusLength is 2048
+PASS bytesToHexString(publicKey.algorithm.publicExponent) is '010001'
+PASS publicKey.algorithm.hash.name is 'SHA-384'
+PASS publicKey.usages is ['encrypt', 'wrapKey']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/rsa-oaep-import-jwk-public-key-sha384.html b/LayoutTests/crypto/subtle/rsa-oaep-import-jwk-public-key-sha384.html
new file mode 100644 (file)
index 0000000..a1decd0
--- /dev/null
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a JWK RSA-OAEP public key with SHA-384");
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: "RSA",
+    alg: "RSA-OAEP-384",
+    use: "enc",
+    key_ops: ["encrypt", "wrapKey"],
+    ext: true,
+    n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
+    e: "AQAB"
+};
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("jwk", jwkKey, {name: "RSA-OAEP", hash: "SHA-384"}, extractable, ["encrypt", "wrapKey"]).then(function(result) {
+    publicKey = result;
+
+    shouldBe("publicKey.toString()", "'[object CryptoKey]'");
+    shouldBe("publicKey.type", "'public'");
+    shouldBe("publicKey.extractable", "true");
+    shouldBe("publicKey.algorithm.name", "'RSA-OAEP'");
+    shouldBe("publicKey.algorithm.modulusLength", "2048");
+    shouldBe("bytesToHexString(publicKey.algorithm.publicExponent)", "'010001'");
+    shouldBe("publicKey.algorithm.hash.name", "'SHA-384'");
+    shouldBe("publicKey.usages", "['encrypt', 'wrapKey']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/crypto/subtle/rsa-oaep-import-jwk-public-key-sha512-expected.txt b/LayoutTests/crypto/subtle/rsa-oaep-import-jwk-public-key-sha512-expected.txt
new file mode 100644 (file)
index 0000000..5e47095
--- /dev/null
@@ -0,0 +1,18 @@
+Test importing a JWK RSA-OAEP public key with SHA-512
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS publicKey.toString() is '[object CryptoKey]'
+PASS publicKey.type is 'public'
+PASS publicKey.extractable is true
+PASS publicKey.algorithm.name is 'RSA-OAEP'
+PASS publicKey.algorithm.modulusLength is 2048
+PASS bytesToHexString(publicKey.algorithm.publicExponent) is '010001'
+PASS publicKey.algorithm.hash.name is 'SHA-512'
+PASS publicKey.usages is ['encrypt', 'wrapKey']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/rsa-oaep-import-jwk-public-key-sha512.html b/LayoutTests/crypto/subtle/rsa-oaep-import-jwk-public-key-sha512.html
new file mode 100644 (file)
index 0000000..083af6f
--- /dev/null
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a JWK RSA-OAEP public key with SHA-512");
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: "RSA",
+    alg: "RSA-OAEP-512",
+    use: "enc",
+    key_ops: ["encrypt", "wrapKey"],
+    ext: true,
+    n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
+    e: "AQAB"
+};
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("jwk", jwkKey, {name: "RSA-OAEP", hash: "SHA-512"}, extractable, ["encrypt", "wrapKey"]).then(function(result) {
+    publicKey = result;
+
+    shouldBe("publicKey.toString()", "'[object CryptoKey]'");
+    shouldBe("publicKey.type", "'public'");
+    shouldBe("publicKey.extractable", "true");
+    shouldBe("publicKey.algorithm.name", "'RSA-OAEP'");
+    shouldBe("publicKey.algorithm.modulusLength", "2048");
+    shouldBe("bytesToHexString(publicKey.algorithm.publicExponent)", "'010001'");
+    shouldBe("publicKey.algorithm.hash.name", "'SHA-512'");
+    shouldBe("publicKey.usages", "['encrypt', 'wrapKey']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-private-key-expected.txt b/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-private-key-expected.txt
new file mode 100644 (file)
index 0000000..ae99c6a
--- /dev/null
@@ -0,0 +1,18 @@
+Test importing a JWK RSAES-PKCS1-v1_5 private key
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS privateKey.toString() is '[object CryptoKey]'
+PASS privateKey.type is 'private'
+PASS privateKey.extractable is true
+PASS privateKey.algorithm.name is 'RSAES-PKCS1-v1_5'
+PASS privateKey.algorithm.modulusLength is 2048
+PASS bytesToHexString(privateKey.algorithm.publicExponent) is '010001'
+PASS privateKey.algorithm.hash is undefined.
+PASS privateKey.usages is ['decrypt']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-private-key.html b/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-private-key.html
new file mode 100644 (file)
index 0000000..11f1b64
--- /dev/null
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a JWK RSAES-PKCS1-v1_5 private key");
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: "RSA",
+    alg: "RSA1_5",
+    use: "enc",
+    key_ops: ["decrypt"],
+    ext: true,
+    n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
+    e: "AQAB",
+    d: "eNLS37aCz7RXSNPD_DtLBJ6j5T8cSxdzRBCjPaI6WcGqJp16lq3UTwuoDLAqlA9oGYm238dsIWpuucP_lQtbWe-7SpxoI6_vmYGf7YVUHv1-DF9qiOmSrMmdxMnVOzYXY8RaT6thPjn_J5cfLV2xI_LwsrMtmpdSyNlgX0zTUhwtuahgAKMEChYjH2EnjHdHw6sY2-wApdcQI7ULE0oo5RzbQZpmuhcN9hiBc0L3hhF0qo50mbl02_65_GQ7DpVkXBxNgRBLzlPabmzzG2oAhfefLgYmSC1opaCkXE6vRWQNWNL45RZNZFYM3uoJghOMqGeocM0BpjdChHrPOlFvSQ",
+    p: "4miTuAjKMeH5uJ5KB397QUwhbkYEgSbcA2mifmSkvE2018gb55qkBHK1eVryf1_m43LNlc6O_ak6gfzdZIZvS5NCGjPl0q09plUpu8qFOSspBwA67qGH76lFlZLn_d4yglS7wfLru4_5Ys8qLLs-DqVLviwposOnyyWqwM5AXp0",
+    q: "xHYrzkivtmnz_sGchnWGc0q-pDOkKicptRpv2pMFIIXxnFX5aMeEXIZjVujXtwUy1UlFIN2GZJSvy5KJ79mu_XyNnFHMzedH-A3ee3u8h1UUrZF-vUu1_e4U_x67NN1dedzUSKynN7pFl3OkuShMBWGV-cwzOPdcVAfVuZlxUMc",
+    dp: "fBzDzYDUBmBQGop7Hn0dvf_T27V6RqpctWo074CQZcFbP2atFVtKSj3viWT3xid2VHzcgiDHdfpM3nEVlEO1wwIonGCSvdjGEOZiiFVOjrZAOVxA8guOjyyFvqbXke06VwPIIVvfKeSU2zuhbP__1tt6F_fxow4Kb2xonGT0GGk",
+    dq: "jmE2DiIPdhwDgLXAQpIaBqQ81bO3XfVT_LRULAwwwwlPuQV148H04zlh9TJ6Y2GZHYokV1U0eOBpJxfkb7dLYtpJpuiBjRf4yIUEoGlkkI_QlJnFSFr-YjGRdfNHqWBkxlSMZL770R9mIATndGkH7z5x-r9KwBZFC4FCG2hg_zE",
+    qi: "YCX_pLwbMBA1ThVH0WcwmnytqNcrMCEwTm7ByA2eU6nWbQrULvf7m9_kzfLUcjsnpAVlBQG5JMXMy0Sq4ptwbywsa5-G8KAOOOR2L3v4hC-Eys9ftgFM_3i0o40eeQH4b3haPbntrIeMg8IzlOuVYKf9-2QuKDoWeRdd7NsdxTk",
+};
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("jwk", jwkKey, "RSAES-PKCS1-v1_5", extractable, ["decrypt"]).then(function(result) {
+    privateKey = result;
+
+    shouldBe("privateKey.toString()", "'[object CryptoKey]'");
+    shouldBe("privateKey.type", "'private'");
+    shouldBe("privateKey.extractable", "true");
+    shouldBe("privateKey.algorithm.name", "'RSAES-PKCS1-v1_5'");
+    shouldBe("privateKey.algorithm.modulusLength", "2048");
+    shouldBe("bytesToHexString(privateKey.algorithm.publicExponent)", "'010001'");
+    shouldBeUndefined("privateKey.algorithm.hash");
+    shouldBe("privateKey.usages", "['decrypt']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-expected.txt b/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-expected.txt
new file mode 100644 (file)
index 0000000..c44d64f
--- /dev/null
@@ -0,0 +1,18 @@
+Test importing a JWK RSAES-PKCS1-v1_5 public key
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS publicKey.toString() is '[object CryptoKey]'
+PASS publicKey.type is 'public'
+PASS publicKey.extractable is true
+PASS publicKey.algorithm.name is 'RSAES-PKCS1-v1_5'
+PASS publicKey.algorithm.modulusLength is 2048
+PASS bytesToHexString(publicKey.algorithm.publicExponent) is '010001'
+PASS publicKey.algorithm.hash is undefined.
+PASS publicKey.usages is ['encrypt']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-leading-zero-expected.txt b/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-leading-zero-expected.txt
new file mode 100644 (file)
index 0000000..94a6a2a
--- /dev/null
@@ -0,0 +1,17 @@
+Test importing a JWK RSAES-PKCS1-v1_5 public key with leading zero
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS publicKey.type is 'public'
+PASS publicKey.extractable is true
+PASS publicKey.algorithm.name is 'RSAES-PKCS1-v1_5'
+PASS publicKey.algorithm.modulusLength is 2048
+PASS bytesToHexString(publicKey.algorithm.publicExponent) is '010001'
+PASS publicKey.algorithm.hash is undefined.
+PASS publicKey.usages is ['encrypt']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-leading-zero.html b/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-leading-zero.html
new file mode 100644 (file)
index 0000000..5c3d530
--- /dev/null
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a JWK RSAES-PKCS1-v1_5 public key with leading zero");
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: "RSA",
+    n: "AGFiY2RlZmdoYWJjZGVmZ2hhYmNkZWZnaGFiY2RlZmdoYWJjZGVmZ2hhYmNkZWZnaGFiY2RlZmdoYWJjZGVmZ2hhYmNkZWZnaGFiY2RlZmdoYWJjZGVmZ2hhYmNkZWZnaGFiY2RlZmdoYWJjZGVmZ2hhYmNkZWZnaGFiY2RlZmdoYWJjZGVmZ2hhYmNkZWZnaGFiY2RlZmdoYWJjZGVmZ2hhYmNkZWZnaGFiY2RlZmdoYWJjZGVmZ2hhYmNkZWZnaGFiY2RlZmdoYWJjZGVmZ2hhYmNkZWZnaGFiY2RlZmdoYWJjZGVmZ2hhYmNkZWZnaGFiY2RlZmdoYWJjZGVmZ2g",
+    e: "AQAB"
+};
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("jwk", jwkKey, "RSAES-PKCS1-v1_5", extractable, ["encrypt"]).then(function(result) {
+    publicKey = result;
+
+    shouldBe("publicKey.type", "'public'");
+    shouldBe("publicKey.extractable", "true");
+    shouldBe("publicKey.algorithm.name", "'RSAES-PKCS1-v1_5'");
+    shouldBe("publicKey.algorithm.modulusLength", "2048");
+    shouldBe("bytesToHexString(publicKey.algorithm.publicExponent)", "'010001'");
+    shouldBeUndefined("publicKey.algorithm.hash");
+    shouldBe("publicKey.usages", "['encrypt']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-minimum-expected.txt b/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-minimum-expected.txt
new file mode 100644 (file)
index 0000000..39ac2d3
--- /dev/null
@@ -0,0 +1,17 @@
+Test importing a JWK RSAES-PKCS1-v1_5 public key with minimum information
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS publicKey.type is 'public'
+PASS publicKey.extractable is true
+PASS publicKey.algorithm.name is 'RSAES-PKCS1-v1_5'
+PASS publicKey.algorithm.modulusLength is 2048
+PASS bytesToHexString(publicKey.algorithm.publicExponent) is '010001'
+PASS publicKey.algorithm.hash is undefined.
+PASS publicKey.usages is ['encrypt']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-minimum.html b/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-minimum.html
new file mode 100644 (file)
index 0000000..23efc35
--- /dev/null
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a JWK RSAES-PKCS1-v1_5 public key with minimum information");
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: "RSA",
+    n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
+    e: "AQAB"
+};
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("jwk", jwkKey, "RSAES-PKCS1-v1_5", extractable, ["encrypt"]).then(function(result) {
+    publicKey = result;
+
+    shouldBe("publicKey.type", "'public'");
+    shouldBe("publicKey.extractable", "true");
+    shouldBe("publicKey.algorithm.name", "'RSAES-PKCS1-v1_5'");
+    shouldBe("publicKey.algorithm.modulusLength", "2048");
+    shouldBe("bytesToHexString(publicKey.algorithm.publicExponent)", "'010001'");
+    shouldBeUndefined("publicKey.algorithm.hash");
+    shouldBe("publicKey.usages", "['encrypt']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-non-extractable-expected.txt b/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-non-extractable-expected.txt
new file mode 100644 (file)
index 0000000..6d5b208
--- /dev/null
@@ -0,0 +1,17 @@
+Test importing a non-extractable JWK RSAES-PKCS1-v1_5 public key
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS publicKey.type is 'public'
+PASS publicKey.extractable is false
+PASS publicKey.algorithm.name is 'RSAES-PKCS1-v1_5'
+PASS publicKey.algorithm.modulusLength is 2048
+PASS bytesToHexString(publicKey.algorithm.publicExponent) is '010001'
+PASS publicKey.algorithm.hash is undefined.
+PASS publicKey.usages is ['encrypt']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-non-extractable.html b/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-non-extractable.html
new file mode 100644 (file)
index 0000000..66f6ddf
--- /dev/null
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a non-extractable JWK RSAES-PKCS1-v1_5 public key");
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: "RSA",
+    alg: "RSA1_5",
+    use: "enc",
+    key_ops: ["encrypt"],
+    ext: true,
+    n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
+    e: "AQAB"
+};
+var nonExtractable = false;
+
+debug("Importing a key...");
+crypto.subtle.importKey("jwk", jwkKey, "RSAES-PKCS1-v1_5", nonExtractable, ["encrypt"]).then(function(result) {
+    publicKey = result;
+
+    shouldBe("publicKey.type", "'public'");
+    shouldBe("publicKey.extractable", "false");
+    shouldBe("publicKey.algorithm.name", "'RSAES-PKCS1-v1_5'");
+    shouldBe("publicKey.algorithm.modulusLength", "2048");
+    shouldBe("bytesToHexString(publicKey.algorithm.publicExponent)", "'010001'");
+    shouldBeUndefined("publicKey.algorithm.hash");
+    shouldBe("publicKey.usages", "['encrypt']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key.html b/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key.html
new file mode 100644 (file)
index 0000000..f60ec18
--- /dev/null
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a JWK RSAES-PKCS1-v1_5 public key");
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: "RSA",
+    alg: "RSA1_5",
+    use: "enc",
+    key_ops: ["encrypt"],
+    ext: true,
+    n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
+    e: "AQAB"
+};
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("jwk", jwkKey, "RSAES-PKCS1-v1_5", extractable, ["encrypt"]).then(function(result) {
+    publicKey = result;
+
+    shouldBe("publicKey.toString()", "'[object CryptoKey]'");
+    shouldBe("publicKey.type", "'public'");
+    shouldBe("publicKey.extractable", "true");
+    shouldBe("publicKey.algorithm.name", "'RSAES-PKCS1-v1_5'");
+    shouldBe("publicKey.algorithm.modulusLength", "2048");
+    shouldBe("bytesToHexString(publicKey.algorithm.publicExponent)", "'010001'");
+    shouldBeUndefined("publicKey.algorithm.hash");
+    shouldBe("publicKey.usages", "['encrypt']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-private-key-expected.txt b/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-private-key-expected.txt
new file mode 100644 (file)
index 0000000..5aaae4f
--- /dev/null
@@ -0,0 +1,18 @@
+Test importing a JWK RSASSA-PKCS1-v1_5 private key with SHA-1
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS privateKey.toString() is '[object CryptoKey]'
+PASS privateKey.type is 'private'
+PASS privateKey.extractable is true
+PASS privateKey.algorithm.name is 'RSASSA-PKCS1-v1_5'
+PASS privateKey.algorithm.modulusLength is 2048
+PASS bytesToHexString(privateKey.algorithm.publicExponent) is '010001'
+PASS privateKey.algorithm.hash.name is 'SHA-1'
+PASS privateKey.usages is ['sign']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-private-key.html b/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-private-key.html
new file mode 100644 (file)
index 0000000..3f5a026
--- /dev/null
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a JWK RSASSA-PKCS1-v1_5 private key with SHA-1");
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: "RSA",
+    alg: "RS1",
+    use: "sig",
+    key_ops: ["sign"],
+    ext: true,
+    n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
+    e: "AQAB",
+    d: "eNLS37aCz7RXSNPD_DtLBJ6j5T8cSxdzRBCjPaI6WcGqJp16lq3UTwuoDLAqlA9oGYm238dsIWpuucP_lQtbWe-7SpxoI6_vmYGf7YVUHv1-DF9qiOmSrMmdxMnVOzYXY8RaT6thPjn_J5cfLV2xI_LwsrMtmpdSyNlgX0zTUhwtuahgAKMEChYjH2EnjHdHw6sY2-wApdcQI7ULE0oo5RzbQZpmuhcN9hiBc0L3hhF0qo50mbl02_65_GQ7DpVkXBxNgRBLzlPabmzzG2oAhfefLgYmSC1opaCkXE6vRWQNWNL45RZNZFYM3uoJghOMqGeocM0BpjdChHrPOlFvSQ",
+    p: "4miTuAjKMeH5uJ5KB397QUwhbkYEgSbcA2mifmSkvE2018gb55qkBHK1eVryf1_m43LNlc6O_ak6gfzdZIZvS5NCGjPl0q09plUpu8qFOSspBwA67qGH76lFlZLn_d4yglS7wfLru4_5Ys8qLLs-DqVLviwposOnyyWqwM5AXp0",
+    q: "xHYrzkivtmnz_sGchnWGc0q-pDOkKicptRpv2pMFIIXxnFX5aMeEXIZjVujXtwUy1UlFIN2GZJSvy5KJ79mu_XyNnFHMzedH-A3ee3u8h1UUrZF-vUu1_e4U_x67NN1dedzUSKynN7pFl3OkuShMBWGV-cwzOPdcVAfVuZlxUMc",
+    dp: "fBzDzYDUBmBQGop7Hn0dvf_T27V6RqpctWo074CQZcFbP2atFVtKSj3viWT3xid2VHzcgiDHdfpM3nEVlEO1wwIonGCSvdjGEOZiiFVOjrZAOVxA8guOjyyFvqbXke06VwPIIVvfKeSU2zuhbP__1tt6F_fxow4Kb2xonGT0GGk",
+    dq: "jmE2DiIPdhwDgLXAQpIaBqQ81bO3XfVT_LRULAwwwwlPuQV148H04zlh9TJ6Y2GZHYokV1U0eOBpJxfkb7dLYtpJpuiBjRf4yIUEoGlkkI_QlJnFSFr-YjGRdfNHqWBkxlSMZL770R9mIATndGkH7z5x-r9KwBZFC4FCG2hg_zE",
+    qi: "YCX_pLwbMBA1ThVH0WcwmnytqNcrMCEwTm7ByA2eU6nWbQrULvf7m9_kzfLUcjsnpAVlBQG5JMXMy0Sq4ptwbywsa5-G8KAOOOR2L3v4hC-Eys9ftgFM_3i0o40eeQH4b3haPbntrIeMg8IzlOuVYKf9-2QuKDoWeRdd7NsdxTk",
+};
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("jwk", jwkKey, {name: "RSASSA-PKCS1-v1_5", hash: "SHA-1"}, extractable, ["sign"]).then(function(result) {
+    privateKey = result;
+
+    shouldBe("privateKey.toString()", "'[object CryptoKey]'");
+    shouldBe("privateKey.type", "'private'");
+    shouldBe("privateKey.extractable", "true");
+    shouldBe("privateKey.algorithm.name", "'RSASSA-PKCS1-v1_5'");
+    shouldBe("privateKey.algorithm.modulusLength", "2048");
+    shouldBe("bytesToHexString(privateKey.algorithm.publicExponent)", "'010001'");
+    shouldBe("privateKey.algorithm.hash.name", "'SHA-1'");
+    shouldBe("privateKey.usages", "['sign']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha1-expected.txt b/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha1-expected.txt
new file mode 100644 (file)
index 0000000..2112945
--- /dev/null
@@ -0,0 +1,18 @@
+Test importing a JWK RSASSA-PKCS1-v1_5 public key with SHA-1
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS publicKey.toString() is '[object CryptoKey]'
+PASS publicKey.type is 'public'
+PASS publicKey.extractable is true
+PASS publicKey.algorithm.name is 'RSASSA-PKCS1-v1_5'
+PASS publicKey.algorithm.modulusLength is 2048
+PASS bytesToHexString(publicKey.algorithm.publicExponent) is '010001'
+PASS publicKey.algorithm.hash.name is 'SHA-1'
+PASS publicKey.usages is ['verify']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha1.html b/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha1.html
new file mode 100644 (file)
index 0000000..061e6e1
--- /dev/null
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a JWK RSASSA-PKCS1-v1_5 public key with SHA-1");
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: "RSA",
+    alg: "RS1",
+    use: "sig",
+    key_ops: ["verify"],
+    ext: true,
+    n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
+    e: "AQAB"
+};
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("jwk", jwkKey, {name: "RSASSA-PKCS1-v1_5", hash: "SHA-1"}, extractable, ["verify"]).then(function(result) {
+    publicKey = result;
+
+    shouldBe("publicKey.toString()", "'[object CryptoKey]'");
+    shouldBe("publicKey.type", "'public'");
+    shouldBe("publicKey.extractable", "true");
+    shouldBe("publicKey.algorithm.name", "'RSASSA-PKCS1-v1_5'");
+    shouldBe("publicKey.algorithm.modulusLength", "2048");
+    shouldBe("bytesToHexString(publicKey.algorithm.publicExponent)", "'010001'");
+    shouldBe("publicKey.algorithm.hash.name", "'SHA-1'");
+    shouldBe("publicKey.usages", "['verify']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha224-expected.txt b/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha224-expected.txt
new file mode 100644 (file)
index 0000000..77f65d0
--- /dev/null
@@ -0,0 +1,18 @@
+Test importing a JWK RSASSA-PKCS1-v1_5 public key with SHA-224
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS publicKey.toString() is '[object CryptoKey]'
+PASS publicKey.type is 'public'
+PASS publicKey.extractable is true
+PASS publicKey.algorithm.name is 'RSASSA-PKCS1-v1_5'
+PASS publicKey.algorithm.modulusLength is 2048
+PASS bytesToHexString(publicKey.algorithm.publicExponent) is '010001'
+PASS publicKey.algorithm.hash.name is 'SHA-224'
+PASS publicKey.usages is ['verify']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha224.html b/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha224.html
new file mode 100644 (file)
index 0000000..0a3c840
--- /dev/null
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a JWK RSASSA-PKCS1-v1_5 public key with SHA-224");
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: "RSA",
+    alg: "RS224",
+    use: "sig",
+    key_ops: ["verify"],
+    ext: true,
+    n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
+    e: "AQAB"
+};
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("jwk", jwkKey, {name: "RSASSA-PKCS1-v1_5", hash: "SHA-224"}, extractable, ["verify"]).then(function(result) {
+    publicKey = result;
+
+    shouldBe("publicKey.toString()", "'[object CryptoKey]'");
+    shouldBe("publicKey.type", "'public'");
+    shouldBe("publicKey.extractable", "true");
+    shouldBe("publicKey.algorithm.name", "'RSASSA-PKCS1-v1_5'");
+    shouldBe("publicKey.algorithm.modulusLength", "2048");
+    shouldBe("bytesToHexString(publicKey.algorithm.publicExponent)", "'010001'");
+    shouldBe("publicKey.algorithm.hash.name", "'SHA-224'");
+    shouldBe("publicKey.usages", "['verify']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha256-expected.txt b/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha256-expected.txt
new file mode 100644 (file)
index 0000000..772b1f2
--- /dev/null
@@ -0,0 +1,18 @@
+Test importing a JWK RSASSA-PKCS1-v1_5 public key with SHA-256
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS publicKey.toString() is '[object CryptoKey]'
+PASS publicKey.type is 'public'
+PASS publicKey.extractable is true
+PASS publicKey.algorithm.name is 'RSASSA-PKCS1-v1_5'
+PASS publicKey.algorithm.modulusLength is 2048
+PASS bytesToHexString(publicKey.algorithm.publicExponent) is '010001'
+PASS publicKey.algorithm.hash.name is 'SHA-256'
+PASS publicKey.usages is ['verify']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha256.html b/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha256.html
new file mode 100644 (file)
index 0000000..684de7c
--- /dev/null
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a JWK RSASSA-PKCS1-v1_5 public key with SHA-256");
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: "RSA",
+    alg: "RS256",
+    use: "sig",
+    key_ops: ["verify"],
+    ext: true,
+    n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
+    e: "AQAB"
+};
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("jwk", jwkKey, {name: "RSASSA-PKCS1-v1_5", hash: "SHA-256"}, extractable, ["verify"]).then(function(result) {
+    publicKey = result;
+
+    shouldBe("publicKey.toString()", "'[object CryptoKey]'");
+    shouldBe("publicKey.type", "'public'");
+    shouldBe("publicKey.extractable", "true");
+    shouldBe("publicKey.algorithm.name", "'RSASSA-PKCS1-v1_5'");
+    shouldBe("publicKey.algorithm.modulusLength", "2048");
+    shouldBe("bytesToHexString(publicKey.algorithm.publicExponent)", "'010001'");
+    shouldBe("publicKey.algorithm.hash.name", "'SHA-256'");
+    shouldBe("publicKey.usages", "['verify']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha384-expected.txt b/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha384-expected.txt
new file mode 100644 (file)
index 0000000..45d4bde
--- /dev/null
@@ -0,0 +1,18 @@
+Test importing a JWK RSASSA-PKCS1-v1_5 public key with SHA-384
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS publicKey.toString() is '[object CryptoKey]'
+PASS publicKey.type is 'public'
+PASS publicKey.extractable is true
+PASS publicKey.algorithm.name is 'RSASSA-PKCS1-v1_5'
+PASS publicKey.algorithm.modulusLength is 2048
+PASS bytesToHexString(publicKey.algorithm.publicExponent) is '010001'
+PASS publicKey.algorithm.hash.name is 'SHA-384'
+PASS publicKey.usages is ['verify']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha384.html b/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha384.html
new file mode 100644 (file)
index 0000000..ad3363c
--- /dev/null
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a JWK RSASSA-PKCS1-v1_5 public key with SHA-384");
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: "RSA",
+    alg: "RS384",
+    use: "sig",
+    key_ops: ["verify"],
+    ext: true,
+    n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
+    e: "AQAB"
+};
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("jwk", jwkKey, {name: "RSASSA-PKCS1-v1_5", hash: "SHA-384"}, extractable, ["verify"]).then(function(result) {
+    publicKey = result;
+
+    shouldBe("publicKey.toString()", "'[object CryptoKey]'");
+    shouldBe("publicKey.type", "'public'");
+    shouldBe("publicKey.extractable", "true");
+    shouldBe("publicKey.algorithm.name", "'RSASSA-PKCS1-v1_5'");
+    shouldBe("publicKey.algorithm.modulusLength", "2048");
+    shouldBe("bytesToHexString(publicKey.algorithm.publicExponent)", "'010001'");
+    shouldBe("publicKey.algorithm.hash.name", "'SHA-384'");
+    shouldBe("publicKey.usages", "['verify']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha512-expected.txt b/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha512-expected.txt
new file mode 100644 (file)
index 0000000..1d4aeeb
--- /dev/null
@@ -0,0 +1,18 @@
+Test importing a JWK RSASSA-PKCS1-v1_5 public key with SHA-512
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS publicKey.toString() is '[object CryptoKey]'
+PASS publicKey.type is 'public'
+PASS publicKey.extractable is true
+PASS publicKey.algorithm.name is 'RSASSA-PKCS1-v1_5'
+PASS publicKey.algorithm.modulusLength is 2048
+PASS bytesToHexString(publicKey.algorithm.publicExponent) is '010001'
+PASS publicKey.algorithm.hash.name is 'SHA-512'
+PASS publicKey.usages is ['verify']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha512.html b/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha512.html
new file mode 100644 (file)
index 0000000..c1ce135
--- /dev/null
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a JWK RSASSA-PKCS1-v1_5 public key with SHA-512");
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: "RSA",
+    alg: "RS512",
+    use: "sig",
+    key_ops: ["verify"],
+    ext: true,
+    n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
+    e: "AQAB"
+};
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("jwk", jwkKey, {name: "RSASSA-PKCS1-v1_5", hash: "SHA-512"}, extractable, ["verify"]).then(function(result) {
+    publicKey = result;
+
+    shouldBe("publicKey.toString()", "'[object CryptoKey]'");
+    shouldBe("publicKey.type", "'public'");
+    shouldBe("publicKey.extractable", "true");
+    shouldBe("publicKey.algorithm.name", "'RSASSA-PKCS1-v1_5'");
+    shouldBe("publicKey.algorithm.modulusLength", "2048");
+    shouldBe("bytesToHexString(publicKey.algorithm.publicExponent)", "'010001'");
+    shouldBe("publicKey.algorithm.hash.name", "'SHA-512'");
+    shouldBe("publicKey.usages", "['verify']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
index 015131a..179a398 100644 (file)
@@ -20,7 +20,7 @@ Generating a key with custom length...
 PASS key.type is 'secret'
 PASS key.extractable is true
 PASS key.algorithm.name is 'HMAC'
-PASS key.algorithm.length is 5
+PASS key.algorithm.length is 8
 PASS key.algorithm.hash.name is 'SHA-1'
 PASS key.usages is ["sign"]
 PASS successfullyParsed is true
index 6cde55a..6160839 100644 (file)
@@ -32,14 +32,14 @@ crypto.webkitSubtle.generateKey({name: "hmac", hash: "sha-1"}, extractable, ["si
     shouldBe("key.usages", '["sign", "verify"]');
 
     debug("\nGenerating a key with custom length...");
-    return crypto.webkitSubtle.generateKey({name: "hmac", hash: "sha-1", length: 5}, extractable, ["sign"]);
+    return crypto.webkitSubtle.generateKey({name: "hmac", hash: "sha-1", length: 8}, extractable, ["sign"]);
 }).then(function(result) {
     key = result;
 
     shouldBe("key.type", "'secret'");
     shouldBe("key.extractable", "true");
     shouldBe("key.algorithm.name", "'HMAC'");
-    shouldBe("key.algorithm.length", "5");
+    shouldBe("key.algorithm.length", "8");
     shouldBe("key.algorithm.hash.name", "'SHA-1'");
     shouldBe("key.usages", '["sign"]');
     finishJSTest();
index 89cb253..7ea266d 100644 (file)
@@ -8,7 +8,7 @@ Importing a key...
 PASS key.type is 'secret'
 PASS key.extractable is false
 PASS key.algorithm.name is 'HMAC'
-PASS key.algorithm.length is 32
+PASS key.algorithm.length is 256
 PASS key.usages is ["sign", "verify"]
 
 Using the key to sign message 'foo'...
index 02df916..30109ad 100644 (file)
@@ -32,7 +32,7 @@ crypto.webkitSubtle.importKey("jwk", hmacKeyAsArrayBuffer, null, extractable, ["
     shouldBe("key.type", "'secret'");
     shouldBe("key.extractable", "false");
     shouldBe("key.algorithm.name", "'HMAC'");
-    shouldBe("key.algorithm.length", "32");
+    shouldBe("key.algorithm.length", "256");
     shouldBe("key.usages", '["sign", "verify"]');
 
     debug("\nUsing the key to sign message 'foo'...");
index 0f0342a..c797515 100644 (file)
@@ -6,7 +6,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 PASS key.type is 'secret'
 PASS key.extractable is true
 PASS key.algorithm.name is 'HMAC'
-PASS key.algorithm.length is 16
+PASS key.algorithm.length is 128
 PASS key.usages is ["sign", "verify"]
 PASS successfullyParsed is true
 
index 76da11a..26f2f2f 100644 (file)
@@ -17,7 +17,7 @@ window.addEventListener("message", function(evt) {
     shouldBe("key.type", "'secret'");
     shouldBe("key.extractable", "true");
     shouldBe("key.algorithm.name", "'HMAC'");
-    shouldBe("key.algorithm.length", "16");
+    shouldBe("key.algorithm.length", "128");
     shouldBe("key.usages", '["sign", "verify"]');
 
     finishJSTest();
index 18da7e7..49c3c19 100644 (file)
@@ -7,7 +7,7 @@ Importing a raw HMAC key from string literal...
 PASS key.type is 'secret'
 PASS key.extractable is true
 PASS key.algorithm.name is 'HMAC'
-PASS key.algorithm.length is 1
+PASS key.algorithm.length is 8
 PASS key.algorithm.hash.name is 'SHA-1'
 PASS key.usages is ['sign', 'verify']
 Using the key to sign 'foo'...
index 49f4ca3..a0d5c99 100644 (file)
@@ -22,7 +22,7 @@ crypto.webkitSubtle.importKey("raw", hmacKey, {name: 'hmac', hash: {name: 'sha-1
     shouldBe("key.type", "'secret'");
     shouldBe("key.extractable", "true");
     shouldBe("key.algorithm.name", "'HMAC'");
-    shouldBe("key.algorithm.length", "1"); // See <https://www.w3.org/Bugs/Public/show_bug.cgi?id=23098>.
+    shouldBe("key.algorithm.length", "8"); // See <https://www.w3.org/Bugs/Public/show_bug.cgi?id=23098>.
     shouldBe("key.algorithm.hash.name", "'SHA-1'");
     shouldBe("key.usages", "['sign', 'verify']");
 
diff --git a/LayoutTests/crypto/workers/subtle/aes-import-jwk-key-expected.txt b/LayoutTests/crypto/workers/subtle/aes-import-jwk-key-expected.txt
new file mode 100644 (file)
index 0000000..504c51c
--- /dev/null
@@ -0,0 +1,17 @@
+[Worker] Test importing a JWK AES key using AES-CBC algorithm in workers.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Starting worker: resources/aes-import-jwk-key.js
+[Worker] Importing a key...
+PASS [Worker] crypto.subtle.importKey("jwk", {kty: "RSA"}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS [Worker] key.type is 'secret'
+PASS [Worker] key.extractable is true
+PASS [Worker] key.algorithm.name is 'AES-CBC'
+PASS [Worker] key.algorithm.length is 128
+PASS [Worker] key.usages is ['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/workers/subtle/aes-import-jwk-key.html b/LayoutTests/crypto/workers/subtle/aes-import-jwk-key.html
new file mode 100644 (file)
index 0000000..6fc2612
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src="../../../resources/js-test-pre.js"></script>
+</head>
+<body>
+    <script>
+        worker = startWorker('resources/aes-import-jwk-key.js');
+    </script>
+    <script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/crypto/workers/subtle/aes-import-raw-key-expected.txt b/LayoutTests/crypto/workers/subtle/aes-import-raw-key-expected.txt
new file mode 100644 (file)
index 0000000..272b01a
--- /dev/null
@@ -0,0 +1,17 @@
+[Worker] Test importing a raw AES key using AES-CBC algorithm in workers.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Starting worker: resources/aes-import-raw-key.js
+[Worker] Importing a key...
+PASS [Worker] crypto.subtle.importKey("raw", asciiToUint8Array("jnOw97"), "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS [Worker] key.type is 'secret'
+PASS [Worker] key.extractable is true
+PASS [Worker] key.algorithm.name is 'AES-CBC'
+PASS [Worker] key.algorithm.length is 128
+PASS [Worker] key.usages is ['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/workers/subtle/aes-import-raw-key.html b/LayoutTests/crypto/workers/subtle/aes-import-raw-key.html
new file mode 100644 (file)
index 0000000..44aac4a
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src="../../../resources/js-test-pre.js"></script>
+</head>
+<body>
+    <script>
+        worker = startWorker('resources/aes-import-raw-key.js');
+    </script>
+    <script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/crypto/workers/subtle/hmac-import-jwk-key-expected.txt b/LayoutTests/crypto/workers/subtle/hmac-import-jwk-key-expected.txt
new file mode 100644 (file)
index 0000000..e7c389e
--- /dev/null
@@ -0,0 +1,18 @@
+[Worker] Test importing a JWK HMAC key with SHA-1 in workers.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Starting worker: resources/hmac-import-jwk-key.js
+[Worker] Importing a key...
+PASS [Worker] crypto.subtle.importKey("jwk", {kty: "RSA"}, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS [Worker] key.type is 'secret'
+PASS [Worker] key.extractable is true
+PASS [Worker] key.algorithm.name is 'HMAC'
+PASS [Worker] key.algorithm.length is 128
+PASS [Worker] key.algorithm.hash.name is 'SHA-1'
+PASS [Worker] key.usages is ['sign', 'verify']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/workers/subtle/hmac-import-jwk-key.html b/LayoutTests/crypto/workers/subtle/hmac-import-jwk-key.html
new file mode 100644 (file)
index 0000000..312d40c
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src="../../../resources/js-test-pre.js"></script>
+</head>
+<body>
+    <script>
+        worker = startWorker('resources/hmac-import-jwk-key.js');
+    </script>
+    <script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/crypto/workers/subtle/hmac-import-raw-key-expected.txt b/LayoutTests/crypto/workers/subtle/hmac-import-raw-key-expected.txt
new file mode 100644 (file)
index 0000000..35d6516
--- /dev/null
@@ -0,0 +1,18 @@
+[Worker] Test importing a raw HMAC key with SHA-1 in workers.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Starting worker: resources/hmac-import-raw-key.js
+[Worker] Importing a key...
+PASS [Worker] crypto.subtle.importKey("raw", asciiToUint8Array(""), {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS [Worker] key.type is 'secret'
+PASS [Worker] key.extractable is true
+PASS [Worker] key.algorithm.name is 'HMAC'
+PASS [Worker] key.algorithm.length is 128
+PASS [Worker] key.algorithm.hash.name is 'SHA-1'
+PASS [Worker] key.usages is ['sign', 'verify']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/workers/subtle/hmac-import-raw-key.html b/LayoutTests/crypto/workers/subtle/hmac-import-raw-key.html
new file mode 100644 (file)
index 0000000..791aa11
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src="../../../resources/js-test-pre.js"></script>
+</head>
+<body>
+    <script>
+        worker = startWorker('resources/hmac-import-raw-key.js');
+    </script>
+    <script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
index f326b2e..e237ae8 100644 (file)
@@ -7,7 +7,7 @@ PASS All checks passed in worker
 PASS key.type is 'secret'
 PASS key.extractable is true
 PASS key.algorithm.name is 'HMAC'
-PASS key.algorithm.length is 16
+PASS key.algorithm.length is 128
 PASS key.algorithm.hash.name is 'SHA-1'
 PASS key.usages is ["sign", "verify"]
 PASS successfullyParsed is true
index ad6cc94..84ebb5d 100644 (file)
@@ -23,7 +23,7 @@ crypto.webkitSubtle.importKey("raw", asciiToUint8Array("16 bytes of key!"), {nam
             shouldBe("key.type", "'secret'");
             shouldBe("key.extractable", "true");
             shouldBe("key.algorithm.name", "'HMAC'");
-            shouldBe("key.algorithm.length", "16");
+            shouldBe("key.algorithm.length", "128");
             shouldBe("key.algorithm.hash.name", "'SHA-1'");
             shouldBe("key.usages", '["sign", "verify"]');
         }
diff --git a/LayoutTests/crypto/workers/subtle/resources/aes-import-jwk-key.js b/LayoutTests/crypto/workers/subtle/resources/aes-import-jwk-key.js
new file mode 100644 (file)
index 0000000..775d4c4
--- /dev/null
@@ -0,0 +1,29 @@
+importScripts('../../../../resources/js-test-pre.js');
+
+description("Test importing a JWK AES key using AES-CBC algorithm in workers.");
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: "oct",
+    k: "YWJjZGVmZ2gxMjM0NTY3OA",
+    alg: "A128CBC",
+    use: "enc",
+    key_ops: ["encrypt", "decrypt", "wrapKey", "unwrapKey"],
+    ext: true,
+};
+var extractable = true;
+
+shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA"}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
+
+debug("Importing a key...");
+crypto.subtle.importKey("jwk", jwkKey, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]).then(function(result) {
+    key = result;
+
+    shouldBe("key.type", "'secret'");
+    shouldBe("key.extractable", "true");
+    shouldBe("key.algorithm.name", "'AES-CBC'");
+    shouldBe("key.algorithm.length", "128");
+    shouldBe("key.usages", "['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']");
+
+    finishJSTest();
+});
diff --git a/LayoutTests/crypto/workers/subtle/resources/aes-import-raw-key.js b/LayoutTests/crypto/workers/subtle/resources/aes-import-raw-key.js
new file mode 100644 (file)
index 0000000..75b672e
--- /dev/null
@@ -0,0 +1,23 @@
+importScripts('../../../../resources/js-test-pre.js');
+importScripts("../../../resources/common.js");
+
+description("Test importing a raw AES key using AES-CBC algorithm in workers.");
+jsTestIsAsync = true;
+
+var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
+var extractable = true;
+
+shouldReject('crypto.subtle.importKey("raw", asciiToUint8Array("jnOw97"), "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
+
+debug("Importing a key...");
+crypto.subtle.importKey("raw", rawKey, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]).then(function(result) {
+    key = result;
+
+    shouldBe("key.type", "'secret'");
+    shouldBe("key.extractable", "true");
+    shouldBe("key.algorithm.name", "'AES-CBC'");
+    shouldBe("key.algorithm.length", "128");
+    shouldBe("key.usages", "['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']");
+
+    finishJSTest();
+});
diff --git a/LayoutTests/crypto/workers/subtle/resources/hmac-import-jwk-key.js b/LayoutTests/crypto/workers/subtle/resources/hmac-import-jwk-key.js
new file mode 100644 (file)
index 0000000..7ccbc8f
--- /dev/null
@@ -0,0 +1,30 @@
+importScripts('../../../../resources/js-test-pre.js');
+
+description("Test importing a JWK HMAC key with SHA-1 in workers.");
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: "oct",
+    k: "YWJjZGVmZ2gxMjM0NTY3OA",
+    alg: "HS1",
+    use: "sig",
+    key_ops: ["sign", "verify"],
+    ext: true,
+};
+var extractable = true;
+
+shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA"}, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"])');
+
+debug("Importing a key...");
+crypto.subtle.importKey("jwk", jwkKey, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"]).then(function(result) {
+    key = result;
+
+    shouldBe("key.type", "'secret'");
+    shouldBe("key.extractable", "true");
+    shouldBe("key.algorithm.name", "'HMAC'");
+    shouldBe("key.algorithm.length", "128");
+    shouldBe("key.algorithm.hash.name", "'SHA-1'");
+    shouldBe("key.usages", "['sign', 'verify']");
+
+    finishJSTest();
+});
diff --git a/LayoutTests/crypto/workers/subtle/resources/hmac-import-raw-key.js b/LayoutTests/crypto/workers/subtle/resources/hmac-import-raw-key.js
new file mode 100644 (file)
index 0000000..842205b
--- /dev/null
@@ -0,0 +1,24 @@
+importScripts('../../../../resources/js-test-pre.js');
+importScripts("../../../resources/common.js");
+
+description("Test importing a raw HMAC key with SHA-1 in workers.");
+jsTestIsAsync = true;
+
+var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
+var extractable = true;
+
+shouldReject('crypto.subtle.importKey("raw", asciiToUint8Array(""), {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"])');
+
+debug("Importing a key...");
+crypto.subtle.importKey("raw", rawKey, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"]).then(function(result) {
+    key = result;
+
+    shouldBe("key.type", "'secret'");
+    shouldBe("key.extractable", "true");
+    shouldBe("key.algorithm.name", "'HMAC'");
+    shouldBe("key.algorithm.length", "128");
+    shouldBe("key.algorithm.hash.name", "'SHA-1'");
+    shouldBe("key.usages", "['sign', 'verify']");
+
+    finishJSTest();
+});
index 2dba8ec..c017496 100644 (file)
@@ -9,8 +9,8 @@ onmessage = function(evt)
         postMessage({ result:false, message:'key.extractable should be true' });
     else if (key.algorithm.name != "HMAC")
         postMessage({ result:false, message:'key.algorithm.name should be "HMAC"' });
-    else if (key.algorithm.length != 16)
-        postMessage({ result:false, message:'key.algorithm.length should be 16' });
+    else if (key.algorithm.length != 128)
+        postMessage({ result:false, message:'key.algorithm.length should be 128' });
     else if (key.algorithm.hash.name != "SHA-1")
         postMessage({ result:false, message:'key.algorithm.hash.name should be "SHA-1"' });
     else if (key.usages.toString() != "sign,verify")
diff --git a/LayoutTests/crypto/workers/subtle/resources/rsa-import-jwk-private-key.js b/LayoutTests/crypto/workers/subtle/resources/rsa-import-jwk-private-key.js
new file mode 100644 (file)
index 0000000..fd1af30
--- /dev/null
@@ -0,0 +1,40 @@
+importScripts('../../../../resources/js-test-pre.js');
+importScripts("../../../resources/common.js");
+
+description("Test importing a JWK RSA-OAEP private key with SHA-1 in workers.");
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: "RSA",
+    alg: "RSA-OAEP",
+    use: "enc",
+    key_ops: ["decrypt", "unwrapKey"],
+    ext: true,
+    n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
+    e: "AQAB",
+    d: "eNLS37aCz7RXSNPD_DtLBJ6j5T8cSxdzRBCjPaI6WcGqJp16lq3UTwuoDLAqlA9oGYm238dsIWpuucP_lQtbWe-7SpxoI6_vmYGf7YVUHv1-DF9qiOmSrMmdxMnVOzYXY8RaT6thPjn_J5cfLV2xI_LwsrMtmpdSyNlgX0zTUhwtuahgAKMEChYjH2EnjHdHw6sY2-wApdcQI7ULE0oo5RzbQZpmuhcN9hiBc0L3hhF0qo50mbl02_65_GQ7DpVkXBxNgRBLzlPabmzzG2oAhfefLgYmSC1opaCkXE6vRWQNWNL45RZNZFYM3uoJghOMqGeocM0BpjdChHrPOlFvSQ",
+    p: "4miTuAjKMeH5uJ5KB397QUwhbkYEgSbcA2mifmSkvE2018gb55qkBHK1eVryf1_m43LNlc6O_ak6gfzdZIZvS5NCGjPl0q09plUpu8qFOSspBwA67qGH76lFlZLn_d4yglS7wfLru4_5Ys8qLLs-DqVLviwposOnyyWqwM5AXp0",
+    q: "xHYrzkivtmnz_sGchnWGc0q-pDOkKicptRpv2pMFIIXxnFX5aMeEXIZjVujXtwUy1UlFIN2GZJSvy5KJ79mu_XyNnFHMzedH-A3ee3u8h1UUrZF-vUu1_e4U_x67NN1dedzUSKynN7pFl3OkuShMBWGV-cwzOPdcVAfVuZlxUMc",
+    dp: "fBzDzYDUBmBQGop7Hn0dvf_T27V6RqpctWo074CQZcFbP2atFVtKSj3viWT3xid2VHzcgiDHdfpM3nEVlEO1wwIonGCSvdjGEOZiiFVOjrZAOVxA8guOjyyFvqbXke06VwPIIVvfKeSU2zuhbP__1tt6F_fxow4Kb2xonGT0GGk",
+    dq: "jmE2DiIPdhwDgLXAQpIaBqQ81bO3XfVT_LRULAwwwwlPuQV148H04zlh9TJ6Y2GZHYokV1U0eOBpJxfkb7dLYtpJpuiBjRf4yIUEoGlkkI_QlJnFSFr-YjGRdfNHqWBkxlSMZL770R9mIATndGkH7z5x-r9KwBZFC4FCG2hg_zE",
+    qi: "YCX_pLwbMBA1ThVH0WcwmnytqNcrMCEwTm7ByA2eU6nWbQrULvf7m9_kzfLUcjsnpAVlBQG5JMXMy0Sq4ptwbywsa5-G8KAOOOR2L3v4hC-Eys9ftgFM_3i0o40eeQH4b3haPbntrIeMg8IzlOuVYKf9-2QuKDoWeRdd7NsdxTk",
+};
+var extractable = true;
+
+shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: d}, {name: "RSA-OAEP", hash: "sha-1"}, extractable, ["encrypt", "wrapKey"])');
+
+debug("Importing a key...");
+crypto.subtle.importKey("jwk", jwkKey, {name: "RSA-OAEP", hash: "SHA-1"}, extractable, ["decrypt", "unwrapKey"]).then(function(result) {
+    privateKey = result;
+
+    shouldBe("privateKey.toString()", "'[object CryptoKey]'");
+    shouldBe("privateKey.type", "'private'");
+    shouldBe("privateKey.extractable", "true");
+    shouldBe("privateKey.algorithm.name", "'RSA-OAEP'");
+    shouldBe("privateKey.algorithm.modulusLength", "2048");
+    shouldBe("bytesToHexString(privateKey.algorithm.publicExponent)", "'010001'");
+    shouldBe("privateKey.algorithm.hash.name", "'SHA-1'");
+    shouldBe("privateKey.usages", "['decrypt', 'unwrapKey']");
+
+    finishJSTest();
+});
diff --git a/LayoutTests/crypto/workers/subtle/resources/rsa-import-jwk-public-key.js b/LayoutTests/crypto/workers/subtle/resources/rsa-import-jwk-public-key.js
new file mode 100644 (file)
index 0000000..c525286
--- /dev/null
@@ -0,0 +1,34 @@
+importScripts('../../../../resources/js-test-pre.js');
+importScripts("../../../resources/common.js");
+
+description("Test importing a JWK RSA-OAEP public key with SHA-1 in workers.");
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: "RSA",
+    alg: "RSA-OAEP",
+    use: "enc",
+    key_ops: ["encrypt", "wrapKey"],
+    ext: true,
+    n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
+    e: "AQAB"
+};
+var extractable = true;
+
+shouldReject('crypto.subtle.importKey("jwk", jwkKey, {name: "RSA-OAEP", hash: "sha-1"}, extractable, ["decrypt", "unwrapKey"])');
+
+debug("Importing a key...");
+crypto.subtle.importKey("jwk", jwkKey, {name: "RSA-OAEP", hash: "SHA-1"}, extractable, ["encrypt", "wrapKey"]).then(function(result) {
+    publicKey = result;
+
+    shouldBe("publicKey.toString()", "'[object CryptoKey]'");
+    shouldBe("publicKey.type", "'public'");
+    shouldBe("publicKey.extractable", "true");
+    shouldBe("publicKey.algorithm.name", "'RSA-OAEP'");
+    shouldBe("publicKey.algorithm.modulusLength", "2048");
+    shouldBe("bytesToHexString(publicKey.algorithm.publicExponent)", "'010001'");
+    shouldBe("publicKey.algorithm.hash.name", "'SHA-1'");
+    shouldBe("publicKey.usages", "['encrypt', 'wrapKey']");
+
+    finishJSTest();
+});
diff --git a/LayoutTests/crypto/workers/subtle/rsa-import-jwk-private-key-expected.txt b/LayoutTests/crypto/workers/subtle/rsa-import-jwk-private-key-expected.txt
new file mode 100644 (file)
index 0000000..4c745a8
--- /dev/null
@@ -0,0 +1,20 @@
+[Worker] Test importing a JWK RSA-OAEP private key with SHA-1 in workers.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Starting worker: resources/rsa-import-jwk-private-key.js
+FAIL [Worker] crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: d}, {name: "RSA-OAEP", hash: "sha-1"}, extractable, ["encrypt", "wrapKey"]) should not throw exception. Threw exception ReferenceError: Can't find variable: n.
+[Worker] Importing a key...
+PASS [Worker] privateKey.toString() is '[object CryptoKey]'
+PASS [Worker] privateKey.type is 'private'
+PASS [Worker] privateKey.extractable is true
+PASS [Worker] privateKey.algorithm.name is 'RSA-OAEP'
+PASS [Worker] privateKey.algorithm.modulusLength is 2048
+PASS [Worker] bytesToHexString(privateKey.algorithm.publicExponent) is '010001'
+PASS [Worker] privateKey.algorithm.hash.name is 'SHA-1'
+PASS [Worker] privateKey.usages is ['decrypt', 'unwrapKey']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/workers/subtle/rsa-import-jwk-private-key.html b/LayoutTests/crypto/workers/subtle/rsa-import-jwk-private-key.html
new file mode 100644 (file)
index 0000000..0e3caf2
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src="../../../resources/js-test-pre.js"></script>
+</head>
+<body>
+    <script>
+        worker = startWorker('resources/rsa-import-jwk-private-key.js');
+    </script>
+    <script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/crypto/workers/subtle/rsa-import-jwk-public-key-expected.txt b/LayoutTests/crypto/workers/subtle/rsa-import-jwk-public-key-expected.txt
new file mode 100644 (file)
index 0000000..006ab8e
--- /dev/null
@@ -0,0 +1,20 @@
+[Worker] Test importing a JWK RSA-OAEP public key with SHA-1 in workers.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Starting worker: resources/rsa-import-jwk-public-key.js
+[Worker] Importing a key...
+PASS [Worker] crypto.subtle.importKey("jwk", jwkKey, {name: "RSA-OAEP", hash: "sha-1"}, extractable, ["decrypt", "unwrapKey"]) rejected promise  with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
+PASS [Worker] publicKey.toString() is '[object CryptoKey]'
+PASS [Worker] publicKey.type is 'public'
+PASS [Worker] publicKey.extractable is true
+PASS [Worker] publicKey.algorithm.name is 'RSA-OAEP'
+PASS [Worker] publicKey.algorithm.modulusLength is 2048
+PASS [Worker] bytesToHexString(publicKey.algorithm.publicExponent) is '010001'
+PASS [Worker] publicKey.algorithm.hash.name is 'SHA-1'
+PASS [Worker] publicKey.usages is ['encrypt', 'wrapKey']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/workers/subtle/rsa-import-jwk-public-key.html b/LayoutTests/crypto/workers/subtle/rsa-import-jwk-public-key.html
new file mode 100644 (file)
index 0000000..754d2e2
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src="../../../resources/js-test-pre.js"></script>
+</head>
+<body>
+    <script>
+        worker = startWorker('resources/rsa-import-jwk-public-key.js');
+    </script>
+    <script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
index 6737966..cb50734 100644 (file)
@@ -1,3 +1,13 @@
+2016-11-05  Jiewen Tan  <jiewen_tan@apple.com>
+
+        Update SubtleCrypto::importKey to match the latest spec
+        https://bugs.webkit.org/show_bug.cgi?id=164446
+        <rdar://problem/29123621>
+
+        Reviewed by Brent Fulgham.
+
+        * WebCryptoAPI/idlharness-expected.txt:
+
 2016-11-10  Zan Dobersek  <zdobersek@igalia.com>
 
         [EME] Add no-op Web-facing APIs
index 09bc9d4..af84d11 100644 (file)
@@ -59,8 +59,8 @@ FAIL SubtleCrypto interface: crypto.subtle must inherit property "deriveKey" wit
 FAIL SubtleCrypto interface: calling deriveKey(AlgorithmIdentifier,CryptoKey,AlgorithmIdentifier,boolean,[object Object]) on crypto.subtle with too few arguments must throw TypeError assert_inherits: property "deriveKey" not found in prototype chain
 FAIL SubtleCrypto interface: crypto.subtle must inherit property "deriveBits" with the proper type (7) assert_inherits: property "deriveBits" not found in prototype chain
 FAIL SubtleCrypto interface: calling deriveBits(AlgorithmIdentifier,CryptoKey,unsigned long) on crypto.subtle with too few arguments must throw TypeError assert_inherits: property "deriveBits" not found in prototype chain
-FAIL SubtleCrypto interface: crypto.subtle must inherit property "importKey" with the proper type (8) assert_inherits: property "importKey" not found in prototype chain
-FAIL SubtleCrypto interface: calling importKey(KeyFormat,[object Object],[object Object],AlgorithmIdentifier,boolean,[object Object]) on crypto.subtle with too few arguments must throw TypeError assert_inherits: property "importKey" not found in prototype chain
+PASS SubtleCrypto interface: crypto.subtle must inherit property "importKey" with the proper type (8) 
+PASS SubtleCrypto interface: calling importKey(KeyFormat,[object Object],[object Object],AlgorithmIdentifier,boolean,[object Object]) on crypto.subtle with too few arguments must throw TypeError 
 FAIL SubtleCrypto interface: crypto.subtle must inherit property "exportKey" with the proper type (9) assert_inherits: property "exportKey" not found in prototype chain
 FAIL SubtleCrypto interface: calling exportKey(KeyFormat,CryptoKey) on crypto.subtle with too few arguments must throw TypeError assert_inherits: property "exportKey" not found in prototype chain
 FAIL SubtleCrypto interface: crypto.subtle must inherit property "wrapKey" with the proper type (10) assert_inherits: property "wrapKey" not found in prototype chain
index 8121ae5..add589d 100644 (file)
@@ -327,11 +327,14 @@ set(WebCore_NON_SVG_IDL_FILES
     crypto/CryptoAlgorithmParameters.idl
     crypto/CryptoKey.idl
     crypto/CryptoKeyPair.idl
+    crypto/JsonWebKey.idl
+    crypto/RsaOtherPrimesInfo.idl
     crypto/SubtleCrypto.idl
     crypto/WebKitSubtleCrypto.idl
 
     crypto/parameters/AesKeyGenParams.idl
-    crypto/parameters/HmacKeyGenParams.idl
+    crypto/parameters/HmacKeyParams.idl
+    crypto/parameters/RsaHashedImportParams.idl
     crypto/parameters/RsaHashedKeyGenParams.idl
     crypto/parameters/RsaKeyGenParams.idl
 
index ab47bef..aa5a4b8 100644 (file)
@@ -1,3 +1,149 @@
+2016-11-04  Jiewen Tan  <jiewen_tan@apple.com>
+
+        Update SubtleCrypto::importKey to match the latest spec
+        https://bugs.webkit.org/show_bug.cgi?id=164446
+        <rdar://problem/29123621>
+
+        Reviewed by Brent Fulgham.
+
+        This patch does following few things:
+        1. It updates the SubtleCrypto::importKey method to match the latest spec:
+           https://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-importKey.
+           It also refers to the latest Editor's Draft at a certain degree:
+           https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-importKey.
+        2. It implements importKey operations of following algorithms: AES-CBC, AES-KW,
+           HMAC, RSAES-PKCS1-V1_5, RSASSA-PKCS1-V1_5, and RSA-OAEP.
+        3. It fixes some minor problems of SubtleCrypto::generateKey.
+        4. It addes move constructors for CryptoKeyAES, CryptoKeyHMAC, CryptoKeyRSA and
+           CryptoKeyDataRSAComponents.
+        5. It renames HmacKeyGenParams to HmacKeyParams to serve the purpose of both
+           HmacKeyGenParams and HmacImportParams which are essentially the same.
+        6. It enforces the key length in bits of CryptoKeyHMAC to be multiples of 8.
+        7. It also fixes the following bugs:
+           https://bugs.webkit.org/show_bug.cgi?id=126033,
+           https://bugs.webkit.org/show_bug.cgi?id=126034,
+           https://bugs.webkit.org/show_bug.cgi?id=151308.
+        P.S. We currently only support Raw and Jwk key format.
+
+        Tests: crypto/subtle/aes-cbc-import-jwk-key-length-128.html
+               crypto/subtle/aes-cbc-import-jwk-key-length-192.html
+               crypto/subtle/aes-cbc-import-jwk-key-length-256.html
+               crypto/subtle/aes-cbc-import-jwk-key-minimum.html
+               crypto/subtle/aes-cbc-import-jwk-key-non-extractable.html
+               crypto/subtle/aes-cbc-import-raw-key-length-128.html
+               crypto/subtle/aes-cbc-import-raw-key-length-192.html
+               crypto/subtle/aes-cbc-import-raw-key-length-256.html
+               crypto/subtle/aes-import-key-malformed-parameters.html
+               crypto/subtle/aes-kw-import-jwk-key-length-128.html
+               crypto/subtle/aes-kw-import-jwk-key-length-192.html
+               crypto/subtle/aes-kw-import-jwk-key-length-256.html
+               crypto/subtle/aes-kw-import-raw-key.html
+               crypto/subtle/generate-key-malformed-parameters.html
+               crypto/subtle/hmac-import-jwk-key-minimum.html
+               crypto/subtle/hmac-import-jwk-key-non-extractable.html
+               crypto/subtle/hmac-import-jwk-key-sha1.html
+               crypto/subtle/hmac-import-jwk-key-sha224.html
+               crypto/subtle/hmac-import-jwk-key-sha256.html
+               crypto/subtle/hmac-import-jwk-key-sha384.html
+               crypto/subtle/hmac-import-jwk-key-sha512.html
+               crypto/subtle/hmac-import-malformed-parameters.html
+               crypto/subtle/hmac-import-raw-key-customized-length.html
+               crypto/subtle/hmac-import-raw-key.html
+               crypto/subtle/import-key-malformed-parameters.html
+               crypto/subtle/rsa-import-key-malformed-parameters.html
+               crypto/subtle/rsa-oaep-import-jwk-private-key.html
+               crypto/subtle/rsa-oaep-import-jwk-public-key-sha1.html
+               crypto/subtle/rsa-oaep-import-jwk-public-key-sha224.html
+               crypto/subtle/rsa-oaep-import-jwk-public-key-sha256.html
+               crypto/subtle/rsa-oaep-import-jwk-public-key-sha384.html
+               crypto/subtle/rsa-oaep-import-jwk-public-key-sha512.html
+               crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-private-key.html
+               crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-leading-zero.html
+               crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-minimum.html
+               crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-non-extractable.html
+               crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key.html
+               crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-private-key.html
+               crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha1.html
+               crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha224.html
+               crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha256.html
+               crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha384.html
+               crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha512.html
+               crypto/workers/subtle/aes-import-jwk-key.html
+               crypto/workers/subtle/aes-import-raw-key.html
+               crypto/workers/subtle/hmac-import-jwk-key.html
+               crypto/workers/subtle/hmac-import-raw-key.html
+               crypto/workers/subtle/rsa-import-jwk-private-key.html
+               crypto/workers/subtle/rsa-import-jwk-public-key.html
+
+        * CMakeLists.txt:
+        * DerivedSources.make:
+        * PlatformEfl.cmake:
+        * PlatformGTK.cmake:
+        * PlatformMac.cmake:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSSubtleCryptoCustom.cpp:
+        (WebCore::normalizeCryptoAlgorithmParameters):
+        (WebCore::cryptoKeyUsageFromString):
+        (WebCore::cryptoKeyUsagesFromJSValue):
+        (WebCore::toKeyData):
+        (WebCore::jsSubtleCryptoFunctionGenerateKeyPromise):
+        (WebCore::jsSubtleCryptoFunctionImportKeyPromise):
+        (WebCore::JSSubtleCrypto::importKey):
+        * crypto/CryptoAlgorithm.cpp:
+        (WebCore::CryptoAlgorithm::importKey):
+        * crypto/CryptoAlgorithm.h:
+        * crypto/CryptoAlgorithmParameters.h:
+        * crypto/JsonWebKey.h: Added.
+        * crypto/JsonWebKey.idl: Added.
+        * crypto/RsaOtherPrimesInfo.h: Added.
+        * crypto/RsaOtherPrimesInfo.idl: Added.
+        * crypto/SubtleCrypto.h:
+        * crypto/SubtleCrypto.idl:
+        * crypto/algorithms/CryptoAlgorithmAES_CBC.cpp:
+        (WebCore::CryptoAlgorithmAES_CBC::generateKey):
+        (WebCore::CryptoAlgorithmAES_CBC::importKey):
+        * crypto/algorithms/CryptoAlgorithmAES_CBC.h:
+        * crypto/algorithms/CryptoAlgorithmAES_KW.cpp:
+        (WebCore::CryptoAlgorithmAES_KW::generateKey):
+        (WebCore::CryptoAlgorithmAES_KW::importKey):
+        * crypto/algorithms/CryptoAlgorithmAES_KW.h:
+        * crypto/algorithms/CryptoAlgorithmHMAC.cpp:
+        (WebCore::CryptoAlgorithmHMAC::generateKey):
+        (WebCore::CryptoAlgorithmHMAC::importKey):
+        * crypto/algorithms/CryptoAlgorithmHMAC.h:
+        * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp:
+        (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::importKey):
+        * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h:
+        * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp:
+        (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::importKey):
+        * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h:
+        * crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp:
+        (WebCore::CryptoAlgorithmRSA_OAEP::importKey):
+        * crypto/algorithms/CryptoAlgorithmRSA_OAEP.h:
+        * crypto/keys/CryptoKeyAES.cpp:
+        (WebCore::CryptoKeyAES::CryptoKeyAES):
+        (WebCore::CryptoKeyAES::generate):
+        (WebCore::CryptoKeyAES::importRaw):
+        (WebCore::CryptoKeyAES::importJwk):
+        * crypto/keys/CryptoKeyAES.h:
+        * crypto/keys/CryptoKeyDataRSAComponents.cpp:
+        (WebCore::CryptoKeyDataRSAComponents::CryptoKeyDataRSAComponents):
+        * crypto/keys/CryptoKeyDataRSAComponents.h:
+        * crypto/keys/CryptoKeyHMAC.cpp:
+        (WebCore::CryptoKeyHMAC::CryptoKeyHMAC):
+        (WebCore::CryptoKeyHMAC::generate):
+        (WebCore::CryptoKeyHMAC::importRaw):
+        (WebCore::CryptoKeyHMAC::importJwk):
+        (WebCore::CryptoKeyHMAC::buildAlgorithm):
+        * crypto/keys/CryptoKeyHMAC.h:
+        * crypto/keys/CryptoKeyRSA.cpp: Added.
+        (WebCore::CryptoKeyRSA::importJwk):
+        * crypto/keys/CryptoKeyRSA.h:
+        * crypto/parameters/CryptoAlgorithmHmacKeyParams.h: Renamed from Source/WebCore/crypto/parameters/CryptoAlgorithmHmacKeyGenParams.h.
+        * crypto/parameters/CryptoAlgorithmRsaHashedImportParams.h: Added.
+        * crypto/parameters/HmacKeyParams.idl: Renamed from Source/WebCore/crypto/parameters/HmacKeyGenParams.idl.
+        * crypto/parameters/RsaHashedImportParams.idl: Added.
+
 2016-11-10  Brady Eidson  <beidson@apple.com>
 
         IndexedDB 2.0: REGRESSION(r208467) Fix flaky crashes in IDB GC-related code.
index 4f48bc5..18d5f30 100644 (file)
@@ -252,10 +252,13 @@ JS_BINDING_IDLS = \
     $(WebCore)/crypto/CryptoAlgorithmParameters.idl \
     $(WebCore)/crypto/CryptoKey.idl \
     $(WebCore)/crypto/CryptoKeyPair.idl \
+    $(WebCore)/crypto/JsonWebKey.idl \
     $(WebCore)/crypto/parameters/AesKeyGenParams.idl \
-    $(WebCore)/crypto/parameters/HmacKeyGenParams.idl \
+    $(WebCore)/crypto/parameters/HmacKeyParams.idl \
+    $(WebCore)/crypto/parameters/RsaHashedImportParams.idl \
     $(WebCore)/crypto/parameters/RsaHashedKeyGenParams.idl \
     $(WebCore)/crypto/parameters/RsaKeyGenParams.idl \
+    $(WebCore)/crypto/RsaOtherPrimesInfo.idl \
     $(WebCore)/crypto/SubtleCrypto.idl \
     $(WebCore)/crypto/WebKitSubtleCrypto.idl \
     $(WebCore)/css/CSSFontFaceLoadEvent.idl \
index 9339328..924973d 100644 (file)
@@ -438,6 +438,7 @@ if (ENABLE_SUBTLE_CRYPTO)
         crypto/keys/CryptoKeyDataOctetSequence.cpp
         crypto/keys/CryptoKeyDataRSAComponents.cpp
         crypto/keys/CryptoKeyHMAC.cpp
+        crypto/keys/CryptoKeyRSA.cpp
         crypto/keys/CryptoKeySerializationRaw.cpp
     )
 endif ()
index e46e68d..bace466 100644 (file)
@@ -435,6 +435,7 @@ if (ENABLE_SUBTLE_CRYPTO)
         crypto/keys/CryptoKeyDataOctetSequence.cpp
         crypto/keys/CryptoKeyDataRSAComponents.cpp
         crypto/keys/CryptoKeyHMAC.cpp
+        crypto/keys/CryptoKeyRSA.cpp
         crypto/keys/CryptoKeySerializationRaw.cpp
     )
 endif ()
index 659023d..4fd01ed 100644 (file)
@@ -200,6 +200,7 @@ list(APPEND WebCore_SOURCES
     crypto/keys/CryptoKeyDataOctetSequence.cpp
     crypto/keys/CryptoKeyDataRSAComponents.cpp
     crypto/keys/CryptoKeyHMAC.cpp
+    crypto/keys/CryptoKeyRSA.cpp
     crypto/keys/CryptoKeySerializationRaw.cpp
 
     crypto/mac/CryptoAlgorithmAES_CBCMac.cpp
index fa170f7..6f1a735 100644 (file)
                577483121DADC55D00716EF9 /* CryptoAlgorithmAesKeyGenParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 577483111DADC55D00716EF9 /* CryptoAlgorithmAesKeyGenParams.h */; };
                577483141DAEC2EB00716EF9 /* JSAesKeyGenParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 577483131DAEC2EA00716EF9 /* JSAesKeyGenParams.h */; };
                577483161DAEC32300716EF9 /* JSAesKeyGenParams.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 577483151DAEC32200716EF9 /* JSAesKeyGenParams.cpp */; };
-               577483191DB4491F00716EF9 /* CryptoAlgorithmHmacKeyGenParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 577483181DB4491F00716EF9 /* CryptoAlgorithmHmacKeyGenParams.h */; };
-               5774831B1DB459BA00716EF9 /* JSHmacKeyGenParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 5774831A1DB459BA00716EF9 /* JSHmacKeyGenParams.h */; };
-               5774831D1DB459DE00716EF9 /* JSHmacKeyGenParams.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5774831C1DB459DE00716EF9 /* JSHmacKeyGenParams.cpp */; };
+               577483191DB4491F00716EF9 /* CryptoAlgorithmHmacKeyParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 577483181DB4491F00716EF9 /* CryptoAlgorithmHmacKeyParams.h */; };
                5778BD821DA4806C009E3009 /* SubtleCrypto.h in Headers */ = {isa = PBXBuildFile; fileRef = 5778BD811DA4802C009E3009 /* SubtleCrypto.h */; };
                5778BD841DA4817B009E3009 /* SubtleCrypto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5778BD831DA4817B009E3009 /* SubtleCrypto.cpp */; };
+               579F6E051DCD7EE400546D80 /* CryptoAlgorithmRsaHashedKeyGenParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 57E233741DCD6D3B00F28D01 /* CryptoAlgorithmRsaHashedKeyGenParams.h */; };
                57A9C88E1DA70BF800BC7305 /* JSSubtleCryptoCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57A9C88D1DA70BF800BC7305 /* JSSubtleCryptoCustom.cpp */; };
+               57E2335B1DC7D5E500F28D01 /* JSJsonWebKey.h in Headers */ = {isa = PBXBuildFile; fileRef = 57E2335A1DC7D5E500F28D01 /* JSJsonWebKey.h */; };
+               57E2335D1DC7D60800F28D01 /* JSRsaOtherPrimesInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 57E2335C1DC7D60800F28D01 /* JSRsaOtherPrimesInfo.h */; };
+               57E2335F1DC7D67B00F28D01 /* JSJsonWebKey.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57E2335E1DC7D67B00F28D01 /* JSJsonWebKey.cpp */; };
+               57E233611DC7D6AA00F28D01 /* JSRsaOtherPrimesInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57E233601DC7D6AA00F28D01 /* JSRsaOtherPrimesInfo.cpp */; };
+               57E233631DC7DA2400F28D01 /* RsaOtherPrimesInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 57E233621DC7DA2400F28D01 /* RsaOtherPrimesInfo.h */; };
+               57E233651DC7DB1F00F28D01 /* JsonWebKey.h in Headers */ = {isa = PBXBuildFile; fileRef = 57E233641DC7DB1F00F28D01 /* JsonWebKey.h */; };
+               57E233671DCAB21C00F28D01 /* JSHmacKeyParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 57E233661DCAB21C00F28D01 /* JSHmacKeyParams.h */; };
+               57E233691DCAB24300F28D01 /* JSHmacKeyParams.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57E233681DCAB24300F28D01 /* JSHmacKeyParams.cpp */; };
+               57E2336B1DCC262400F28D01 /* CryptoKeyRSA.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57E2336A1DCC262400F28D01 /* CryptoKeyRSA.cpp */; };
+               57E2336E1DCD43FD00F28D01 /* CryptoAlgorithmRsaHashedImportParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 57E2336D1DCD43FD00F28D01 /* CryptoAlgorithmRsaHashedImportParams.h */; };
+               57E233711DCD468F00F28D01 /* JSRsaHashedImportParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 57E233701DCD468F00F28D01 /* JSRsaHashedImportParams.h */; };
+               57E233731DCD46B600F28D01 /* JSRsaHashedImportParams.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57E233721DCD46B600F28D01 /* JSRsaHashedImportParams.cpp */; };
                57EF5E601D20C83900171E60 /* TextCodecReplacement.h in Headers */ = {isa = PBXBuildFile; fileRef = 57EF5E5F1D20C83900171E60 /* TextCodecReplacement.h */; };
                57EF5E621D20D28700171E60 /* TextCodecReplacement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57EF5E611D20D28700171E60 /* TextCodecReplacement.cpp */; };
-               57F8273B1DB72D64009D2BF4 /* CryptoAlgorithmRsaHashedKeyGenParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 57F8273A1DB72D64009D2BF4 /* CryptoAlgorithmRsaHashedKeyGenParams.h */; };
                57FEDD3F1DB6D59200EB96F5 /* CryptoAlgorithmRsaKeyGenParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 57FEDD3E1DB6D59200EB96F5 /* CryptoAlgorithmRsaKeyGenParams.h */; };
                57FEDD411DB6D73A00EB96F5 /* JSRsaKeyGenParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 57FEDD401DB6D73A00EB96F5 /* JSRsaKeyGenParams.h */; };
                57FEDD431DB6D76000EB96F5 /* JSRsaKeyGenParams.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57FEDD421DB6D76000EB96F5 /* JSRsaKeyGenParams.cpp */; };
                577483111DADC55D00716EF9 /* CryptoAlgorithmAesKeyGenParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmAesKeyGenParams.h; sourceTree = "<group>"; };
                577483131DAEC2EA00716EF9 /* JSAesKeyGenParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSAesKeyGenParams.h; sourceTree = "<group>"; };
                577483151DAEC32200716EF9 /* JSAesKeyGenParams.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAesKeyGenParams.cpp; sourceTree = "<group>"; };
-               577483171DB1FE8900716EF9 /* HmacKeyGenParams.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = HmacKeyGenParams.idl; sourceTree = "<group>"; };
-               577483181DB4491F00716EF9 /* CryptoAlgorithmHmacKeyGenParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmHmacKeyGenParams.h; sourceTree = "<group>"; };
-               5774831A1DB459BA00716EF9 /* JSHmacKeyGenParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSHmacKeyGenParams.h; sourceTree = "<group>"; };
-               5774831C1DB459DE00716EF9 /* JSHmacKeyGenParams.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHmacKeyGenParams.cpp; sourceTree = "<group>"; };
+               577483171DB1FE8900716EF9 /* HmacKeyParams.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = HmacKeyParams.idl; sourceTree = "<group>"; };
+               577483181DB4491F00716EF9 /* CryptoAlgorithmHmacKeyParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmHmacKeyParams.h; sourceTree = "<group>"; };
                5778BD801DA4733E009E3009 /* SubtleCrypto.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SubtleCrypto.idl; sourceTree = "<group>"; };
                5778BD811DA4802C009E3009 /* SubtleCrypto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SubtleCrypto.h; sourceTree = "<group>"; };
                5778BD831DA4817B009E3009 /* SubtleCrypto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SubtleCrypto.cpp; sourceTree = "<group>"; };
                57A9C88D1DA70BF800BC7305 /* JSSubtleCryptoCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSubtleCryptoCustom.cpp; sourceTree = "<group>"; };
+               57E233571DC7D24800F28D01 /* JsonWebKey.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = JsonWebKey.idl; sourceTree = "<group>"; };
+               57E233591DC7D37200F28D01 /* RsaOtherPrimesInfo.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = RsaOtherPrimesInfo.idl; sourceTree = "<group>"; };
+               57E2335A1DC7D5E500F28D01 /* JSJsonWebKey.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSJsonWebKey.h; sourceTree = "<group>"; };
+               57E2335C1DC7D60800F28D01 /* JSRsaOtherPrimesInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSRsaOtherPrimesInfo.h; sourceTree = "<group>"; };
+               57E2335E1DC7D67B00F28D01 /* JSJsonWebKey.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSJsonWebKey.cpp; sourceTree = "<group>"; };
+               57E233601DC7D6AA00F28D01 /* JSRsaOtherPrimesInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSRsaOtherPrimesInfo.cpp; sourceTree = "<group>"; };
+               57E233621DC7DA2400F28D01 /* RsaOtherPrimesInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RsaOtherPrimesInfo.h; sourceTree = "<group>"; };
+               57E233641DC7DB1F00F28D01 /* JsonWebKey.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JsonWebKey.h; sourceTree = "<group>"; };
+               57E233661DCAB21C00F28D01 /* JSHmacKeyParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSHmacKeyParams.h; sourceTree = "<group>"; };
+               57E233681DCAB24300F28D01 /* JSHmacKeyParams.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHmacKeyParams.cpp; sourceTree = "<group>"; };
+               57E2336A1DCC262400F28D01 /* CryptoKeyRSA.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoKeyRSA.cpp; sourceTree = "<group>"; };
+               57E2336C1DCD437000F28D01 /* RsaHashedImportParams.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = RsaHashedImportParams.idl; sourceTree = "<group>"; };
+               57E2336D1DCD43FD00F28D01 /* CryptoAlgorithmRsaHashedImportParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmRsaHashedImportParams.h; sourceTree = "<group>"; };
+               57E233701DCD468F00F28D01 /* JSRsaHashedImportParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSRsaHashedImportParams.h; sourceTree = "<group>"; };
+               57E233721DCD46B600F28D01 /* JSRsaHashedImportParams.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSRsaHashedImportParams.cpp; sourceTree = "<group>"; };
+               57E233741DCD6D3B00F28D01 /* CryptoAlgorithmRsaHashedKeyGenParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmRsaHashedKeyGenParams.h; sourceTree = "<group>"; };
                57EF5E5F1D20C83900171E60 /* TextCodecReplacement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextCodecReplacement.h; sourceTree = "<group>"; };
                57EF5E611D20D28700171E60 /* TextCodecReplacement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextCodecReplacement.cpp; sourceTree = "<group>"; };
                57F827391DB72C22009D2BF4 /* RsaHashedKeyGenParams.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = RsaHashedKeyGenParams.idl; sourceTree = "<group>"; };
-               57F8273A1DB72D64009D2BF4 /* CryptoAlgorithmRsaHashedKeyGenParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmRsaHashedKeyGenParams.h; sourceTree = "<group>"; };
                57FEDD3D1DB6D47F00EB96F5 /* RsaKeyGenParams.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = RsaKeyGenParams.idl; sourceTree = "<group>"; };
                57FEDD3E1DB6D59200EB96F5 /* CryptoAlgorithmRsaKeyGenParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmRsaKeyGenParams.h; sourceTree = "<group>"; };
                57FEDD401DB6D73A00EB96F5 /* JSRsaKeyGenParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSRsaKeyGenParams.h; sourceTree = "<group>"; };
                                9908B0ED1BCACF9100ED0F65 /* ByteLengthQueuingStrategy.js */,
                                148B4FFF1B6904C500C954E4 /* CountQueuingStrategy.idl */,
                                9908B0EE1BCACF9100ED0F65 /* CountQueuingStrategy.js */,
-                               9908B0F11BCACF9100ED3F64 /* ReadableByteStreamInternals.js */,
                                41189EF71AD8232800B93F64 /* ReadableByteStreamController.idl */,
                                9908B0F01BCACF9100ED3F64 /* ReadableByteStreamController.js */,
+                               9908B0F11BCACF9100ED3F64 /* ReadableByteStreamInternals.js */,
                                41A023ED1A39DB7900F722CF /* ReadableStream.idl */,
                                9908B0EF1BCACF9100ED0F65 /* ReadableStream.js */,
                                41189EF71AD8232800B90A0D /* ReadableStreamDefaultController.idl */,
                                BC94D1500C275C8B006BC617 /* History.cpp */,
                                BC94D1510C275C8B006BC617 /* History.h */,
                                BC94D1520C275C8B006BC617 /* History.idl */,
-                               0F4710D61DB6FE22002DCEC3 /* IntersectionObserver.h */,
                                0F4710D51DB6FE22002DCEC3 /* IntersectionObserver.cpp */,
+                               0F4710D61DB6FE22002DCEC3 /* IntersectionObserver.h */,
                                0F4710D71DB6FE22002DCEC3 /* IntersectionObserver.idl */,
                                0F8B45711DC3FBA300443C3F /* IntersectionObserverCallback.h */,
                                0F8B456F1DC3FB1000443C3F /* IntersectionObserverCallback.idl */,
                71D6AA391DA4EAF700B23969 /* modern-media-controls */ = {
                        isa = PBXGroup;
                        children = (
-                               714131481DC9D6EF00336107 /* js-files */,
-                               71D02D901DB55C4E00DD5CF5 /* main.js */,
                                716FA0D71DB26591007323CC /* controls */,
                                71D6AA6F1DA4EAF700B23969 /* images */,
+                               714131481DC9D6EF00336107 /* js-files */,
                                71D02D911DB55C4E00DD5CF5 /* media */,
+                               71D02D901DB55C4E00DD5CF5 /* main.js */,
                        );
                        path = "modern-media-controls";
                        sourceTree = "<group>";
                                E1C266DD18319F31003F8B33 /* CryptoKeyDataRSAComponents.h */,
                                E125F8331822F18A00D84CD9 /* CryptoKeyHMAC.cpp */,
                                E125F8341822F18A00D84CD9 /* CryptoKeyHMAC.h */,
+                               57E2336A1DCC262400F28D01 /* CryptoKeyRSA.cpp */,
                                E164FAA218315BF400DB4E61 /* CryptoKeyRSA.h */,
                                E125F857182C1AA600D84CD9 /* CryptoKeySerializationRaw.cpp */,
                                E125F858182C1AA600D84CD9 /* CryptoKeySerializationRaw.h */,
                                E125F8391824104800D84CD9 /* CryptoAlgorithmAesCbcParamsDeprecated.h */,
                                577483111DADC55D00716EF9 /* CryptoAlgorithmAesKeyGenParams.h */,
                                E19AC3F61824E5D100349426 /* CryptoAlgorithmAesKeyGenParamsDeprecated.h */,
-                               577483181DB4491F00716EF9 /* CryptoAlgorithmHmacKeyGenParams.h */,
+                               577483181DB4491F00716EF9 /* CryptoAlgorithmHmacKeyParams.h */,
                                E19DA29B18189ADD00088BC8 /* CryptoAlgorithmHmacKeyParamsDeprecated.h */,
                                E1C6571E1816E50300256CDD /* CryptoAlgorithmHmacParamsDeprecated.h */,
-                               57F8273A1DB72D64009D2BF4 /* CryptoAlgorithmRsaHashedKeyGenParams.h */,
+                               57E2336D1DCD43FD00F28D01 /* CryptoAlgorithmRsaHashedImportParams.h */,
+                               57E233741DCD6D3B00F28D01 /* CryptoAlgorithmRsaHashedKeyGenParams.h */,
                                57FEDD3E1DB6D59200EB96F5 /* CryptoAlgorithmRsaKeyGenParams.h */,
                                E1BD331D182D8F4200C05D9F /* CryptoAlgorithmRsaKeyGenParamsDeprecated.h */,
                                E1C266DA18319935003F8B33 /* CryptoAlgorithmRsaKeyParamsWithHashDeprecated.h */,
                                E1FE1376184D1E3300892F13 /* CryptoAlgorithmRsaOaepParamsDeprecated.h */,
                                E1BD331B182D8EE900C05D9F /* CryptoAlgorithmRsaSsaParamsDeprecated.h */,
-                               577483171DB1FE8900716EF9 /* HmacKeyGenParams.idl */,
+                               577483171DB1FE8900716EF9 /* HmacKeyParams.idl */,
+                               57E2336C1DCD437000F28D01 /* RsaHashedImportParams.idl */,
                                57F827391DB72C22009D2BF4 /* RsaHashedKeyGenParams.idl */,
                                57FEDD3D1DB6D47F00EB96F5 /* RsaKeyGenParams.idl */,
                        );
                                E125F855182C0F8300D84CD9 /* CryptoKeySerialization.h */,
                                E19727151820549E00592D51 /* CryptoKeyType.h */,
                                E172AF6F180F289500FBADB9 /* CryptoKeyUsage.h */,
+                               57E233641DC7DB1F00F28D01 /* JsonWebKey.h */,
+                               57E233571DC7D24800F28D01 /* JsonWebKey.idl */,
+                               57E233621DC7DA2400F28D01 /* RsaOtherPrimesInfo.h */,
+                               57E233591DC7D37200F28D01 /* RsaOtherPrimesInfo.idl */,
                                E18DF33418AAF12C00773E59 /* SerializedCryptoKeyWrap.h */,
                                5778BD831DA4817B009E3009 /* SubtleCrypto.cpp */,
                                5778BD811DA4802C009E3009 /* SubtleCrypto.h */,
                                E157A8DF1817331C009F821D /* JSCryptoKey.h */,
                                E1F80B8B183172B5007885C3 /* JSCryptoKeyPair.cpp */,
                                E1F80B8C183172B5007885C3 /* JSCryptoKeyPair.h */,
-                               5774831C1DB459DE00716EF9 /* JSHmacKeyGenParams.cpp */,
-                               5774831A1DB459BA00716EF9 /* JSHmacKeyGenParams.h */,
+                               57E233681DCAB24300F28D01 /* JSHmacKeyParams.cpp */,
+                               57E233661DCAB21C00F28D01 /* JSHmacKeyParams.h */,
+                               57E2335E1DC7D67B00F28D01 /* JSJsonWebKey.cpp */,
+                               57E2335A1DC7D5E500F28D01 /* JSJsonWebKey.h */,
+                               57E233721DCD46B600F28D01 /* JSRsaHashedImportParams.cpp */,
+                               57E233701DCD468F00F28D01 /* JSRsaHashedImportParams.h */,
                                5768E4351DB7527300D0A4F7 /* JSRsaHashedKeyGenParams.cpp */,
                                5768E4331DB7524500D0A4F7 /* JSRsaHashedKeyGenParams.h */,
                                57FEDD421DB6D76000EB96F5 /* JSRsaKeyGenParams.cpp */,
                                57FEDD401DB6D73A00EB96F5 /* JSRsaKeyGenParams.h */,
+                               57E233601DC7D6AA00F28D01 /* JSRsaOtherPrimesInfo.cpp */,
+                               57E2335C1DC7D60800F28D01 /* JSRsaOtherPrimesInfo.h */,
                                571F218A1DA57C7A005C9EFD /* JSSubtleCrypto.cpp */,
                                571F21881DA57C54005C9EFD /* JSSubtleCrypto.h */,
                                E1FF8F62180745D800132674 /* JSWebKitSubtleCrypto.cpp */,
                                B5D31DFB11CF610B009F22B4 /* ActiveDOMCallback.h in Headers */,
                                7CD0BA051B8F79C9005CEBBE /* ActiveDOMCallbackMicrotask.h in Headers */,
                                E1C4DE690EA75C1E0023CCD6 /* ActiveDOMObject.h in Headers */,
+                               724EE5501DC80D7F00A91FFB /* ActivityState.h in Headers */,
+                               724EE5511DC80D8400A91FFB /* ActivityStateChangeObserver.h in Headers */,
                                BCF7E491137CD7C7001DDAE7 /* AdjustViewSizeOrNot.h in Headers */,
                                84D0C4061115F1EA0018AA34 /* AffineTransform.h in Headers */,
                                83BB5C881D5D6F45005A71F4 /* AllDescendantsCollection.h in Headers */,
                                577483121DADC55D00716EF9 /* CryptoAlgorithmAesKeyGenParams.h in Headers */,
                                E19AC3F71824E5D100349426 /* CryptoAlgorithmAesKeyGenParamsDeprecated.h in Headers */,
                                E125F8321822F11B00D84CD9 /* CryptoAlgorithmHMAC.h in Headers */,
-                               577483191DB4491F00716EF9 /* CryptoAlgorithmHmacKeyGenParams.h in Headers */,
+                               577483191DB4491F00716EF9 /* CryptoAlgorithmHmacKeyParams.h in Headers */,
                                E19DA29C18189ADD00088BC8 /* CryptoAlgorithmHmacKeyParamsDeprecated.h in Headers */,
                                E1C6571F1816E50300256CDD /* CryptoAlgorithmHmacParamsDeprecated.h in Headers */,
                                E1C657251816E69D00256CDD /* CryptoAlgorithmIdentifier.h in Headers */,
                                E1FF8F6D180DB5BE00132674 /* CryptoAlgorithmRegistry.h in Headers */,
                                E1FE136B183FE1AB00892F13 /* CryptoAlgorithmRSA_OAEP.h in Headers */,
                                E1233F0D185A3E3B008DFAF5 /* CryptoAlgorithmRSAES_PKCS1_v1_5.h in Headers */,
+                               57E2336E1DCD43FD00F28D01 /* CryptoAlgorithmRsaHashedImportParams.h in Headers */,
                                57F8273B1DB72D64009D2BF4 /* CryptoAlgorithmRsaHashedKeyGenParams.h in Headers */,
                                57FEDD3F1DB6D59200EB96F5 /* CryptoAlgorithmRsaKeyGenParams.h in Headers */,
                                E1BD331E182D8F4200C05D9F /* CryptoAlgorithmRsaKeyGenParamsDeprecated.h in Headers */,
                                E16A84FA14C85CCC002977DF /* CSSBorderImage.h in Headers */,
                                BC274B2F140EBEB200EADFA6 /* CSSBorderImageSliceValue.h in Headers */,
                                49AE2D8F134EE50C0072920A /* CSSCalculationValue.h in Headers */,
-                               519DBC6F1DC011A700329BF5 /* IDBGetAllRecordsData.h in Headers */,
                                BC6049CC0DB560C200204739 /* CSSCanvasValue.h in Headers */,
                                BCEA4790097CAAC80094C9E4 /* CSSComputedStyleDeclaration.h in Headers */,
                                9DAC7C551AF2CAA200437C44 /* CSSContentDistributionValue.h in Headers */,
                                2ED609BD1145B07100C8684E /* DOMFormData.h in Headers */,
                                A8185F3B09765766005826D9 /* DOMImplementation.h in Headers */,
                                E3150EA71DA7219300194012 /* DOMJITHelpers.h in Headers */,
+                               E3C99A091DC3D41C00794AD3 /* DOMJITCheckDOM.h in Headers */,
+                               E3A776671DC85D2800B690D8 /* DOMJITIDLConvert.h in Headers */,
+                               E3A776681DC85D2800B690D8 /* DOMJITIDLType.h in Headers */,
+                               E35802B61DC8435D00A9773C /* DOMJITIDLTypeFilter.h in Headers */,
                                A9C6E4E40D745E05006442E9 /* DOMMimeType.h in Headers */,
                                A9C6E4E80D745E18006442E9 /* DOMMimeTypeArray.h in Headers */,
                                52B6C9C315E3F4DF00690B05 /* DOMNamedFlowCollection.h in Headers */,
                                5148453F1BB9D07E006A72ED /* IDBError.h in Headers */,
                                5185FC8B1BB4C4E80012898F /* IDBEventDispatcher.h in Headers */,
                                5185FC8D1BB4C4E80012898F /* IDBFactory.h in Headers */,
+                               519DBC6F1DC011A700329BF5 /* IDBGetAllRecordsData.h in Headers */,
+                               519DBC721DC10F5200329BF5 /* IDBGetAllResult.h in Headers */,
                                5105F0691D4BA9D900FB80BC /* IDBGetRecordData.h in Headers */,
                                5185FC8F1BB4C4E80012898F /* IDBGetResult.h in Headers */,
                                5185FC911BB4C4E80012898F /* IDBIndex.h in Headers */,
                                A54A0C5E1DB6D9C40017A90B /* InspectorWorkerAgent.h in Headers */,
                                F3ABFE0C130E9DA000E7F7D1 /* InstrumentingAgents.h in Headers */,
                                0F4710DC1DB6FE22002DCEC3 /* IntersectionObserver.h in Headers */,
+                               0F8B45721DC3FBA300443C3F /* IntersectionObserverCallback.h in Headers */,
                                0F4710DF1DB6FE22002DCEC3 /* IntersectionObserverEntry.h in Headers */,
                                B27535720B053814002CE64F /* IntPoint.h in Headers */,
                                E462A4A1113E71BE004A4220 /* IntPointHash.h in Headers */,
                                460CBF361D4BCD0E0092E88E /* JSDOMWindowProperties.h in Headers */,
                                BCBFB53D0DCD29CF0019B3E5 /* JSDOMWindowShell.h in Headers */,
                                65E0E9441133C89F00B4CB10 /* JSDOMWrapper.h in Headers */,
-                               E3A776671DC85D2800B690D8 /* DOMJITIDLConvert.h in Headers */,
+                               E318039D1DC40099009932C2 /* JSDynamicDowncast.h in Headers */,
                                FD7868BA136B999200D403DF /* JSDynamicsCompressorNode.h in Headers */,
                                65DF31FA09D1CC60000BE325 /* JSElement.h in Headers */,
                                ADEC78F818EE5308001315C2 /* JSElementCustom.h in Headers */,
                                B6D9D27B14EAC0860090D75E /* JSFocusEvent.h in Headers */,
                                C280833F1C6DC26F001451B6 /* JSFontFace.h in Headers */,
                                1C24EEA91C72A7B40080F8FC /* JSFontFaceSet.h in Headers */,
-                               0F8B45721DC3FBA300443C3F /* IntersectionObserverCallback.h in Headers */,
                                FDA15EAC12B03EE1003A583A /* JSGainNode.h in Headers */,
                                518F5002194CAC3A0081BAAE /* JSGamepad.h in Headers */,
                                518F5004194CAC3A0081BAAE /* JSGamepadButton.h in Headers */,
                                0FDA7C1F188322FC00C954B5 /* JSGestureEvent.h in Headers */,
                                8482B7521198CB6B00BFB005 /* JSHashChangeEvent.h in Headers */,
                                BC94D14F0C275C68006BC617 /* JSHistory.h in Headers */,
-                               5774831B1DB459BA00716EF9 /* JSHmacKeyGenParams.h in Headers */,
+                               57E233671DCAB21C00F28D01 /* JSHmacKeyParams.h in Headers */,
                                BC97E413109154FA0010D361 /* JSHTMLAllCollection.h in Headers */,
                                1A4A2DF00A1B852A00C807F8 /* JSHTMLAnchorElement.h in Headers */,
                                1A4A2DF20A1B852A00C807F8 /* JSHTMLAppletElement.h in Headers */,
                                A86629D309DA2B48009633A6 /* JSInputEvent.h in Headers */,
                                7A0E771F10C00DB100A0276E /* JSInspectorFrontendHost.h in Headers */,
                                0F4710E61DB700C7002DCEC3 /* JSIntersectionObserver.h in Headers */,
+                               0F8B45761DC41DBA00443C3F /* JSIntersectionObserverCallback.h in Headers */,
                                0F4710E81DB700C7002DCEC3 /* JSIntersectionObserverEntry.h in Headers */,
+                               57E2335B1DC7D5E500F28D01 /* JSJsonWebKey.h in Headers */,
                                A86629D309DA2B48009633A5 /* JSKeyboardEvent.h in Headers */,
                                12A253E11C8FFF6600C22295 /* JSKeyframeEffect.h in Headers */,
                                935F45430F7C3B5F00D7C1FB /* JSLazyEventListener.h in Headers */,
                                77A17AA712F28B2A004E02F6 /* JSOESVertexArrayObject.h in Headers */,
                                FDF6BAF9134A4C9800822920 /* JSOfflineAudioCompletionEvent.h in Headers */,
                                FDA9326716703BA9008982DC /* JSOfflineAudioContext.h in Headers */,
+                               57E233651DC7DB1F00F28D01 /* JsonWebKey.h in Headers */,
                                FDEA6243152102E200479DF0 /* JSOscillatorNode.h in Headers */,
                                0704A40C1D6DFC690086DCDB /* JSOverconstrainedError.h in Headers */,
                                0704A4161D6F39FB0086DCDB /* JSOverconstrainedErrorEvent.h in Headers */,
                                BCFE2F120C1B58380020235F /* JSRect.h in Headers */,
                                4998AECE13F9D6C90090B1AA /* JSRequestAnimationFrameCallback.h in Headers */,
                                BC74DA491013F468007987AD /* JSRGBColor.h in Headers */,
+                               57E233711DCD468F00F28D01 /* JSRsaHashedImportParams.h in Headers */,
                                5768E4341DB7524500D0A4F7 /* JSRsaHashedKeyGenParams.h in Headers */,
                                57FEDD411DB6D73A00EB96F5 /* JSRsaKeyGenParams.h in Headers */,
+                               57E2335D1DC7D60800F28D01 /* JSRsaOtherPrimesInfo.h in Headers */,
                                073794E619EE2FF200E5A045 /* JSRTCConfiguration.h in Headers */,
                                07969DAC17D14151007FF842 /* JSRTCDataChannel.h in Headers */,
                                07969DAE17D14151007FF842 /* JSRTCDataChannelEvent.h in Headers */,
                                FFEFAB2A18380DA000514534 /* LineLayoutState.h in Headers */,
                                FFDBC047183D27B700407109 /* LineWidth.h in Headers */,
                                A7AD2F880EC89D07008AB002 /* LinkHash.h in Headers */,
-                               519DBC721DC10F5200329BF5 /* IDBGetAllResult.h in Headers */,
                                1A4DA4221CDD3A8300F4473C /* LinkIconCollector.h in Headers */,
                                1A250E0D1CDD632000D0BE63 /* LinkIconType.h in Headers */,
                                98CE432A129E00E5005821DC /* LinkLoader.h in Headers */,
                                C90843D01B18E47D00B68564 /* MediaRemoteControls.h in Headers */,
                                CD8ACA8F1D23971900ECC59E /* MediaRemoteSoftLink.h in Headers */,
                                CD8ACA8B1D23946400ECC59E /* MediaRemoteSPI.h in Headers */,
-                               724EE5511DC80D8400A91FFB /* ActivityStateChangeObserver.h in Headers */,
                                CEEFCD7A19DB31F7003876D7 /* MediaResourceLoader.h in Headers */,
                                1BF9DB3C1D3973AD0026AEB7 /* MediaSample.h in Headers */,
                                1B124D8D1D380B7000ECDFB0 /* MediaSampleAVFObjC.h in Headers */,
                                CDBEAEAD19D92B6C00BEBA88 /* MediaSelectionGroupAVFObjC.h in Headers */,
                                C9027F421B1D0AD200BFBFEF /* MediaSession.h in Headers */,
-                               83C45B8E1DC2B68A008871BA /* ValidationBubble.h in Headers */,
                                C9F87CFE1B28F40E00979B83 /* MediaSessionEvents.h in Headers */,
                                C96F5EC81B5872260091EA9D /* MediaSessionInterruptionProvider.h in Headers */,
                                C96F5EC51B5872260091EA9D /* MediaSessionInterruptionProviderMac.h in Headers */,
                                A8CFF5E10A155A05000A4234 /* RootInlineBox.h in Headers */,
                                49E911C90EF86D47009D0CAF /* RotateTransformOperation.h in Headers */,
                                A73F95FF12C97BFE0031AAF9 /* RoundedRect.h in Headers */,
+                               57E233631DC7DA2400F28D01 /* RsaOtherPrimesInfo.h in Headers */,
                                07AB996918DA3C010018771E /* RTCConfiguration.h in Headers */,
                                07AB996F18DA3C740018771E /* RTCConfigurationPrivate.h in Headers */,
                                078E091E17D14D1C00420AA1 /* RTCDataChannel.h in Headers */,
                                08525E631278C00100A84778 /* SVGAnimatedStaticPropertyTearOff.h in Headers */,
                                084DB59B128008CC002A6D64 /* SVGAnimatedString.h in Headers */,
                                08250939128BD4D800E2ED8E /* SVGAnimatedTransformList.h in Headers */,
-                               E3A776681DC85D2800B690D8 /* DOMJITIDLType.h in Headers */,
                                085A15931289A8DD002710E3 /* SVGAnimatedTransformListPropertyTearOff.h in Headers */,
                                439D334313A6911C00C20F4F /* SVGAnimatedType.h in Headers */,
                                439D334413A6911C00C20F4F /* SVGAnimatedTypeAnimator.h in Headers */,
                                B2227A8F0D00BF220071B782 /* SVGPolyElement.h in Headers */,
                                B2227A910D00BF220071B782 /* SVGPolygonElement.h in Headers */,
                                B2227A940D00BF220071B782 /* SVGPolylineElement.h in Headers */,
-                               E3C99A091DC3D41C00794AD3 /* DOMJITCheckDOM.h in Headers */,
                                B2227A970D00BF220071B782 /* SVGPreserveAspectRatio.h in Headers */,
                                088A0E0A126EF1DB00978F7A /* SVGProperty.h in Headers */,
                                081DD49C13BA1A6000DC7627 /* SVGPropertyInfo.h in Headers */,
                                B2C3DA400D006C1D00EF6F26 /* TextCodecUserDefined.h in Headers */,
                                B2C3DA420D006C1D00EF6F26 /* TextCodecUTF16.h in Headers */,
                                9343CB8212F25E510033C5EE /* TextCodecUTF8.h in Headers */,
-                               0F8B45761DC41DBA00443C3F /* JSIntersectionObserverCallback.h in Headers */,
                                142B97CA13138943008BEF4B /* TextControlInnerElements.h in Headers */,
                                582DE3251C30C85400BE02A8 /* TextDecorationPainter.h in Headers */,
                                97BC84B412371180000C6161 /* TextDocument.h in Headers */,
                                F55B3DDE1251F12D003EF269 /* URLInputType.h in Headers */,
                                5C6E65431D5CEFBF00F7862E /* URLParser.h in Headers */,
                                7CC289DF1AA0FE5D009A9CE3 /* URLRegistry.h in Headers */,
-                               E318039D1DC40099009932C2 /* JSDynamicDowncast.h in Headers */,
                                93D437A21D57B3FE00AB85EA /* URLUtils.h in Headers */,
                                A72763BF16689BFB002FCACB /* UserActionElementSet.h in Headers */,
                                868160D618766A130021E79D /* UserActivity.h in Headers */,
                                BCDF317C11F8D683003C5BF8 /* UserTypingGestureIndicator.h in Headers */,
                                1FAFBF1915A5FA7400083A20 /* UTIUtilities.h in Headers */,
                                2E3BBF081162DA1100B9409A /* UUID.h in Headers */,
+                               83C45B8E1DC2B68A008871BA /* ValidationBubble.h in Headers */,
                                F5A154281279534D00D0B0C0 /* ValidationMessage.h in Headers */,
                                F513A3EA15FF4841001526DB /* ValidationMessageClient.h in Headers */,
                                15C7708D100D3C6B005BA267 /* ValidityState.h in Headers */,
                                97AABD2314FA09D5007457AE /* WebSocketExtensionDispatcher.h in Headers */,
                                4A5A2ADC161E7E00005889DD /* WebSocketExtensionParser.h in Headers */,
                                97AABD2414FA09D5007457AE /* WebSocketExtensionProcessor.h in Headers */,
-                               E35802B61DC8435D00A9773C /* DOMJITIDLTypeFilter.h in Headers */,
                                97AABD2514FA09D5007457AE /* WebSocketFrame.h in Headers */,
                                97AABD2714FA09D5007457AE /* WebSocketHandshake.h in Headers */,
                                31DEA4561B39F4D900F77178 /* WebSystemBackdropLayer.h in Headers */,
                                B10B6980140C174000BC1C26 /* WebVTTToken.h in Headers */,
                                B10B6982140C174000BC1C26 /* WebVTTTokenizer.h in Headers */,
                                CD8203101395ACE700F956C6 /* WebWindowAnimation.h in Headers */,
-                               724EE5501DC80D7F00A91FFB /* ActivityState.h in Headers */,
                                F55B3DE01251F12D003EF269 /* WeekInputType.h in Headers */,
                                85031B510A44EFC700F992E0 /* WheelEvent.h in Headers */,
                                2EBBC3D81B65988300F5253D /* WheelEventDeltaFilter.h in Headers */,
                                FD31603D12B0267600C1A359 /* AnalyserNode.cpp in Sources */,
                                31A795C81888BCB500382F90 /* ANGLEInstancedArrays.cpp in Sources */,
                                490707E61219C04300D90E51 /* ANGLEWebKitBridge.cpp in Sources */,
-                               0F8B45751DC41DBA00443C3F /* JSIntersectionObserverCallback.cpp in Sources */,
                                49E912AA0EFAC906009D0CAF /* Animation.cpp in Sources */,
                                316FE1110E6E1DA700BF6088 /* AnimationBase.cpp in Sources */,
                                316FE1130E6E1DA700BF6088 /* AnimationController.cpp in Sources */,
                                CDEA76351460B71A008B31F1 /* Clock.cpp in Sources */,
                                CDEA76341460B56F008B31F1 /* ClockGeneric.cpp in Sources */,
                                9BD8A95A18BEFC7600987E9A /* CollectionIndexCache.cpp in Sources */,
-                               519DBC6E1DC011A200329BF5 /* IDBGetAllRecordsData.cpp in Sources */,
                                B27535660B053814002CE64F /* Color.cpp in Sources */,
                                0FCF33240F2B9715004B6795 /* ColorCG.cpp in Sources */,
                                1ABA76C911D20E47004C201C /* ColorData.cpp in Sources */,
                                E125F8351822F18A00D84CD9 /* CryptoKeyHMAC.cpp in Sources */,
                                E19AC3F9182566F700349426 /* CryptoKeyMac.cpp in Sources */,
                                E1F80B8718317252007885C3 /* CryptoKeyPair.cpp in Sources */,
+                               57E2336B1DCC262400F28D01 /* CryptoKeyRSA.cpp in Sources */,
                                E164FAA518315E1A00DB4E61 /* CryptoKeyRSAMac.cpp in Sources */,
                                E125F859182C1AA600D84CD9 /* CryptoKeySerializationRaw.cpp in Sources */,
                                31BC742D1AAFF45C006B4340 /* CSSAnimationTriggerScrollValue.cpp in Sources */,
                                CAE9F90F146441F000C245B0 /* CSSAspectRatioValue.cpp in Sources */,
                                94DE5C811D7F3A1400164F2A /* CSSAtRuleID.cpp in Sources */,
-                               41E408391DCB748900EFCE19 /* PeerConnectionBackend.cpp in Sources */,
                                FBD6AF8B15EF25E5008B7110 /* CSSBasicShapes.cpp in Sources */,
                                E16A84F914C85CCC002977DF /* CSSBorderImage.cpp in Sources */,
                                BC274B31140EBED800EADFA6 /* CSSBorderImageSliceValue.cpp in Sources */,
                                BC1BDF24156C1883001C1243 /* DOMError.cpp in Sources */,
                                2ED609BC1145B07100C8684E /* DOMFormData.cpp in Sources */,
                                A8185F3E09765766005826D9 /* DOMImplementation.cpp in Sources */,
+                               E398FC241DC32A20003C4684 /* DOMJITHelpers.cpp in Sources */,
                                A9C6E4E30D745E05006442E9 /* DOMMimeType.cpp in Sources */,
                                A9C6E4E70D745E18006442E9 /* DOMMimeTypeArray.cpp in Sources */,
                                52B6C9C215E3F4DF00690B05 /* DOMNamedFlowCollection.cpp in Sources */,
                                A871DE240A152AC800B12A68 /* HTMLIFrameElement.cpp in Sources */,
                                A8EA7D310A19385500A8EF5F /* HTMLImageElement.cpp in Sources */,
                                A8EA7D300A19385500A8EF5F /* HTMLImageLoader.cpp in Sources */,
-                               E3B7C0631DC34160001FB0B8 /* JSDocumentDOMJIT.cpp in Sources */,
                                A81369CD097374F600D74463 /* HTMLInputElement.cpp in Sources */,
                                93309DE5099E64920056E581 /* HTMLInterchange.cpp in Sources */,
                                A81369E5097374F600D74463 /* HTMLKeygenElement.cpp in Sources */,
                                A8EA7D320A19385500A8EF5F /* HTMLMapElement.cpp in Sources */,
                                A8EA7CAC0A192B9C00A8EF5F /* HTMLMarqueeElement.cpp in Sources */,
                                E44613A40CD6331000FADA75 /* HTMLMediaElement.cpp in Sources */,
-                               519DBC731DC10F5600329BF5 /* IDBGetAllResult.cpp in Sources */,
                                C968B2E81B1E778100EF1F81 /* HTMLMediaElementMediaSession.cpp in Sources */,
                                0779BF0D18453168000B6AE7 /* HTMLMediaElementMediaStream.cpp in Sources */,
                                A8EA79F80A1916DF00A8EF5F /* HTMLMenuElement.cpp in Sources */,
                                5148453E1BB9D07E006A72ED /* IDBError.cpp in Sources */,
                                5185FC8A1BB4C4E80012898F /* IDBEventDispatcher.cpp in Sources */,
                                5185FC8C1BB4C4E80012898F /* IDBFactory.cpp in Sources */,
+                               519DBC6E1DC011A200329BF5 /* IDBGetAllRecordsData.cpp in Sources */,
+                               519DBC731DC10F5600329BF5 /* IDBGetAllResult.cpp in Sources */,
                                5105F06B1D4BB12700FB80BC /* IDBGetRecordData.cpp in Sources */,
                                512F1A781C07EB6600908239 /* IDBGetResult.cpp in Sources */,
                                5185FC901BB4C4E80012898F /* IDBIndex.cpp in Sources */,
                                577483161DAEC32300716EF9 /* JSAesKeyGenParams.cpp in Sources */,
                                FDA15EC912B03F50003A583A /* JSAnalyserNode.cpp in Sources */,
                                31A795C61888BADC00382F90 /* JSANGLEInstancedArrays.cpp in Sources */,
-                               83C45B8C1DC2B667008871BA /* ValidationBubbleMac.mm in Sources */,
                                12A253E21C8FFF6600C22295 /* JSAnimatable.cpp in Sources */,
                                120DE3FE1C87E18800B6D4DD /* JSAnimationEffect.cpp in Sources */,
                                3198480B1A1E6CE400A13318 /* JSAnimationEvent.cpp in Sources */,
                                9BD4E9161C462872005065BC /* JSCustomElementInterface.cpp in Sources */,
                                9BE6710B1D5AEB2100345514 /* JSCustomElementRegistry.cpp in Sources */,
                                9BC5F9E01D5AAF6B002B749D /* JSCustomElementRegistryCustom.cpp in Sources */,
-                               E398FC241DC32A20003C4684 /* DOMJITHelpers.cpp in Sources */,
                                E4778B7F115A581A00B5D372 /* JSCustomEvent.cpp in Sources */,
                                DEC297611B4F2F8D005F5945 /* JSCustomEventCustom.cpp in Sources */,
                                51EC92650CE90DD400F90308 /* JSCustomSQLStatementErrorCallback.cpp in Sources */,
                                659DDC8209E198BA001BF3C6 /* JSDocument.cpp in Sources */,
                                1221E05D1C02B444006A1A00 /* JSDocumentAnimation.cpp in Sources */,
                                49C7BA8D1042F5B10009D447 /* JSDocumentCustom.cpp in Sources */,
+                               E3B7C0631DC34160001FB0B8 /* JSDocumentDOMJIT.cpp in Sources */,
                                1A494EDE0A123F4C00FDAFC1 /* JSDocumentFragment.cpp in Sources */,
                                7C33F3621B4A050400502CAF /* JSDocumentFragmentCustom.cpp in Sources */,
                                1221E05F1C02B444006A1A00 /* JSDocumentTimeline.cpp in Sources */,
                                8482B7511198CB6B00BFB005 /* JSHashChangeEvent.cpp in Sources */,
                                BC94D14E0C275C68006BC617 /* JSHistory.cpp in Sources */,
                                BCE7B1930D4E86960075A539 /* JSHistoryCustom.cpp in Sources */,
-                               5774831D1DB459DE00716EF9 /* JSHmacKeyGenParams.cpp in Sources */,
+                               57E233691DCAB24300F28D01 /* JSHmacKeyParams.cpp in Sources */,
                                BC97E412109154FA0010D361 /* JSHTMLAllCollection.cpp in Sources */,
                                BC97E42C10915B060010D361 /* JSHTMLAllCollectionCustom.cpp in Sources */,
                                1A4A2DEF0A1B852A00C807F8 /* JSHTMLAnchorElement.cpp in Sources */,
                                E44614370CD689C400FADA75 /* JSHTMLAudioElement.cpp in Sources */,
                                A80E7B120A19D606007FB8C5 /* JSHTMLBaseElement.cpp in Sources */,
                                1AE2AA220A1CDAB400B42B25 /* JSHTMLBodyElement.cpp in Sources */,
-                               837B7D201DC3F55000D051FC /* ValidationBubbleIOS.mm in Sources */,
                                1AE2AA240A1CDAB400B42B25 /* JSHTMLBRElement.cpp in Sources */,
                                A80E7EA00A1A83E3007FB8C5 /* JSHTMLButtonElement.cpp in Sources */,
                                938E666009F09B81008A48EC /* JSHTMLCanvasElement.cpp in Sources */,
                                7A0E771E10C00DB100A0276E /* JSInspectorFrontendHost.cpp in Sources */,
                                7A74ECBD101839DA00BF939E /* JSInspectorFrontendHostCustom.cpp in Sources */,
                                0F4710E51DB700C7002DCEC3 /* JSIntersectionObserver.cpp in Sources */,
+                               0F8B45751DC41DBA00443C3F /* JSIntersectionObserverCallback.cpp in Sources */,
                                0F4710E71DB700C7002DCEC3 /* JSIntersectionObserverEntry.cpp in Sources */,
+                               57E2335F1DC7D67B00F28D01 /* JSJsonWebKey.cpp in Sources */,
                                A86629D409DA2B48009633A5 /* JSKeyboardEvent.cpp in Sources */,
                                12A253E01C8FFF6600C22295 /* JSKeyframeEffect.cpp in Sources */,
                                935F45420F7C3B5F00D7C1FB /* JSLazyEventListener.cpp in Sources */,
                                BCFE2F110C1B58370020235F /* JSRect.cpp in Sources */,
                                4998AECD13F9D6C90090B1AA /* JSRequestAnimationFrameCallback.cpp in Sources */,
                                BC74DA481013F468007987AD /* JSRGBColor.cpp in Sources */,
+                               57E233731DCD46B600F28D01 /* JSRsaHashedImportParams.cpp in Sources */,
                                5768E4361DB7527400D0A4F7 /* JSRsaHashedKeyGenParams.cpp in Sources */,
                                57FEDD431DB6D76000EB96F5 /* JSRsaKeyGenParams.cpp in Sources */,
+                               57E233611DC7D6AA00F28D01 /* JSRsaOtherPrimesInfo.cpp in Sources */,
                                073794E519EE2FF200E5A045 /* JSRTCConfiguration.cpp in Sources */,
                                07969DAB17D14151007FF842 /* JSRTCDataChannel.cpp in Sources */,
                                07969DAD17D14151007FF842 /* JSRTCDataChannelEvent.cpp in Sources */,
                                1A8A64671D19FDFF00D0E00F /* PaymentRequestValidator.cpp in Sources */,
                                B27535640B053814002CE64F /* PDFDocumentImage.cpp in Sources */,
                                2D6E468417D660F500ECF8BB /* PDFDocumentImageMac.mm in Sources */,
+                               41E408391DCB748900EFCE19 /* PeerConnectionBackend.cpp in Sources */,
                                8A7CC97012076F8A001D4588 /* PendingScript.cpp in Sources */,
                                E526AF3F1727F8F200E41781 /* Performance.cpp in Sources */,
                                CB38FD4B1CCCF36600592A3F /* PerformanceEntry.cpp in Sources */,
                                BCDF317B11F8D683003C5BF8 /* UserTypingGestureIndicator.cpp in Sources */,
                                1FAFBF1815A5FA6E00083A20 /* UTIUtilities.mm in Sources */,
                                2E3BBF071162DA1100B9409A /* UUID.cpp in Sources */,
+                               837B7D201DC3F55000D051FC /* ValidationBubbleIOS.mm in Sources */,
+                               83C45B8C1DC2B667008871BA /* ValidationBubbleMac.mm in Sources */,
                                F5A154271279534D00D0B0C0 /* ValidationMessage.cpp in Sources */,
                                FD3160AE12B026F700C1A359 /* VectorMath.cpp in Sources */,
                                52D5A18F1C54592300DE34A3 /* VideoFullscreenLayerManager.mm in Sources */,
index 6a945a1..c0fa447 100644 (file)
@@ -35,7 +35,9 @@
 #include "JSCryptoKey.h"
 #include "JSCryptoKeyPair.h"
 #include "JSDOMPromise.h"
-#include "JSHmacKeyGenParams.h"
+#include "JSHmacKeyParams.h"
+#include "JSJsonWebKey.h"
+#include "JSRsaHashedImportParams.h"
 #include "JSRsaHashedKeyGenParams.h"
 #include "JSRsaKeyGenParams.h"
 #include "ScriptState.h"
@@ -47,8 +49,9 @@ using namespace JSC;
 namespace WebCore {
 
 enum class Operations {
-    GenerateKey,
     Digest,
+    GenerateKey,
+    ImportKey,
 };
 
 static std::unique_ptr<CryptoAlgorithmParameters> normalizeCryptoAlgorithmParameters(ExecState&, JSValue, Operations);
@@ -86,6 +89,20 @@ static std::unique_ptr<CryptoAlgorithmParameters> normalizeCryptoAlgorithmParame
 
         std::unique_ptr<CryptoAlgorithmParameters> result;
         switch (operation) {
+        case Operations::Digest:
+            switch (identifier) {
+            case CryptoAlgorithmIdentifier::SHA_1:
+            case CryptoAlgorithmIdentifier::SHA_224:
+            case CryptoAlgorithmIdentifier::SHA_256:
+            case CryptoAlgorithmIdentifier::SHA_384:
+            case CryptoAlgorithmIdentifier::SHA_512:
+                result = std::make_unique<CryptoAlgorithmParameters>(params);
+                break;
+            default:
+                setDOMException(&state, NOT_SUPPORTED_ERR);
+                return nullptr;
+            }
+            break;
         case Operations::GenerateKey:
             switch (identifier) {
             case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5: {
@@ -116,11 +133,11 @@ static std::unique_ptr<CryptoAlgorithmParameters> normalizeCryptoAlgorithmParame
                 break;
             }
             case CryptoAlgorithmIdentifier::HMAC: {
-                auto params = convertDictionary<CryptoAlgorithmHmacKeyGenParams>(state, value);
+                auto params = convertDictionary<CryptoAlgorithmHmacKeyParams>(state, value);
                 RETURN_IF_EXCEPTION(scope, nullptr);
                 params.hashIdentifier = toHashIdentifier(state, params.hash);
                 RETURN_IF_EXCEPTION(scope, nullptr);
-                result = std::make_unique<CryptoAlgorithmHmacKeyGenParams>(params);
+                result = std::make_unique<CryptoAlgorithmHmacKeyParams>(params);
                 break;
             }
             default:
@@ -128,15 +145,37 @@ static std::unique_ptr<CryptoAlgorithmParameters> normalizeCryptoAlgorithmParame
                 return nullptr;
             }
             break;
-        case Operations::Digest:
+        case Operations::ImportKey:
             switch (identifier) {
-            case CryptoAlgorithmIdentifier::SHA_1:
-            case CryptoAlgorithmIdentifier::SHA_224:
-            case CryptoAlgorithmIdentifier::SHA_256:
-            case CryptoAlgorithmIdentifier::SHA_384:
-            case CryptoAlgorithmIdentifier::SHA_512:
+            case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
+                result = std::make_unique<CryptoAlgorithmParameters>(params);
+                break;
+            case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
+            case CryptoAlgorithmIdentifier::RSA_PSS:
+            case CryptoAlgorithmIdentifier::RSA_OAEP: {
+                auto params = convertDictionary<CryptoAlgorithmRsaHashedImportParams>(state, value);
+                RETURN_IF_EXCEPTION(scope, nullptr);
+                params.hashIdentifier = toHashIdentifier(state, params.hash);
+                RETURN_IF_EXCEPTION(scope, nullptr);
+                result = std::make_unique<CryptoAlgorithmRsaHashedImportParams>(params);
+                break;
+            }
+            case CryptoAlgorithmIdentifier::AES_CTR:
+            case CryptoAlgorithmIdentifier::AES_CBC:
+            case CryptoAlgorithmIdentifier::AES_CMAC:
+            case CryptoAlgorithmIdentifier::AES_GCM:
+            case CryptoAlgorithmIdentifier::AES_CFB:
+            case CryptoAlgorithmIdentifier::AES_KW:
                 result = std::make_unique<CryptoAlgorithmParameters>(params);
                 break;
+            case CryptoAlgorithmIdentifier::HMAC: {
+                auto params = convertDictionary<CryptoAlgorithmHmacKeyParams>(state, value);
+                RETURN_IF_EXCEPTION(scope, nullptr);
+                params.hashIdentifier = toHashIdentifier(state, params.hash);
+                RETURN_IF_EXCEPTION(scope, nullptr);
+                result = std::make_unique<CryptoAlgorithmHmacKeyParams>(params);
+                break;
+            }
             default:
                 setDOMException(&state, NOT_SUPPORTED_ERR);
                 return nullptr;
@@ -155,6 +194,29 @@ static std::unique_ptr<CryptoAlgorithmParameters> normalizeCryptoAlgorithmParame
     return nullptr;
 }
 
+static CryptoKeyUsage cryptoKeyUsageFromString(const String& usageString)
+{
+    CryptoKeyUsage result = 0;
+    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 result;
+}
+
 static CryptoKeyUsage cryptoKeyUsagesFromJSValue(ExecState& state, JSValue iterable)
 {
     VM& vm = state.vm();
@@ -166,24 +228,12 @@ static CryptoKeyUsage cryptoKeyUsagesFromJSValue(ExecState& state, JSValue itera
 
         String usageString = nextItem.toWTFString(state);
         RETURN_IF_EXCEPTION(scope, void());
-        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;
-        else
+        CryptoKeyUsage usage = cryptoKeyUsageFromString(usageString);
+        if (!usage)
             throwTypeError(state, scope, ASCIILiteral("Invalid KeyUsages"));
+
+        // Maybe we shouldn't silently bypass duplicated usages?
+        result |= usage;
     });
     RETURN_IF_EXCEPTION(scope, 0);
     return result;
@@ -226,6 +276,46 @@ static void rejectWithException(Ref<DeferredPromise>&& passedPromise, ExceptionC
     ASSERT_NOT_REACHED();
 }
 
+static KeyData toKeyData(ExecState& state, SubtleCrypto::KeyFormat format, JSValue value)
+{
+    VM& vm = state.vm();
+    auto scope = DECLARE_THROW_SCOPE(vm);
+
+    KeyData result;
+    switch (format) {
+    case SubtleCrypto::KeyFormat::Spki:
+    case SubtleCrypto::KeyFormat::Pkcs8:
+        setDOMException(&state, NOT_SUPPORTED_ERR);
+        return result;
+    case SubtleCrypto::KeyFormat::Raw: {
+        BufferSource bufferSource = convert<IDLBufferSource>(state, value);
+        RETURN_IF_EXCEPTION(scope, result);
+        Vector<uint8_t> vector;
+        vector.append(bufferSource.data(), bufferSource.length());
+        result = WTFMove(vector);
+        return result;
+    }
+    case SubtleCrypto::KeyFormat::Jwk: {
+        result = convertDictionary<JsonWebKey>(state, value);
+        RETURN_IF_EXCEPTION(scope, result);
+        CryptoKeyUsage usages = 0;
+        if (WTF::get<JsonWebKey>(result).key_ops) {
+            for (auto usageString : WTF::get<JsonWebKey>(result).key_ops.value()) {
+                CryptoKeyUsage usage = cryptoKeyUsageFromString(usageString);
+                if (!usage)
+                    throwTypeError(&state, scope, ASCIILiteral("Invalid key_ops"));
+                // Maybe we shouldn't silently bypass duplicated usages?
+                usages |= cryptoKeyUsageFromString(usageString);
+            }
+        }
+        WTF::get<JsonWebKey>(result).usages = usages;
+        return result;
+    }
+    }
+    ASSERT_NOT_REACHED();
+    return result;
+}
+
 static void jsSubtleCryptoFunctionGenerateKeyPromise(ExecState& state, Ref<DeferredPromise>&& promise)
 {
     VM& vm = state.vm();
@@ -242,7 +332,7 @@ static void jsSubtleCryptoFunctionGenerateKeyPromise(ExecState& state, Ref<Defer
     auto extractable = state.uncheckedArgument(1).toBoolean(&state);
     RETURN_IF_EXCEPTION(scope, void());
 
-    auto keyUsages = cryptoKeyUsagesFromJSValue(state, state.argument(2));
+    auto keyUsages = cryptoKeyUsagesFromJSValue(state, state.uncheckedArgument(2));
     RETURN_IF_EXCEPTION(scope, void());
 
     auto algorithm = createAlgorithm(state, params->identifier);
@@ -275,11 +365,61 @@ static void jsSubtleCryptoFunctionGenerateKeyPromise(ExecState& state, Ref<Defer
     algorithm->generateKey(WTFMove(params), extractable, keyUsages, WTFMove(callback), WTFMove(exceptionCallback), scriptExecutionContextFromExecState(&state));
 }
 
+static void jsSubtleCryptoFunctionImportKeyPromise(ExecState& state, Ref<DeferredPromise>&& promise)
+{
+    VM& vm = state.vm();
+    auto scope = DECLARE_THROW_SCOPE(vm);
+
+    if (UNLIKELY(state.argumentCount() < 5)) {
+        promise->reject<JSValue>(createNotEnoughArgumentsError(&state));
+        return;
+    }
+
+    auto format = convertEnumeration<SubtleCrypto::KeyFormat>(state, state.uncheckedArgument(0));
+    RETURN_IF_EXCEPTION(scope, void());
+
+    auto keyData = toKeyData(state, format, state.uncheckedArgument(1));
+    RETURN_IF_EXCEPTION(scope, void());
+
+    auto params = normalizeCryptoAlgorithmParameters(state, state.uncheckedArgument(2), Operations::ImportKey);
+    RETURN_IF_EXCEPTION(scope, void());
+
+    auto extractable = state.uncheckedArgument(3).toBoolean(&state);
+    RETURN_IF_EXCEPTION(scope, void());
+
+    auto keyUsages = cryptoKeyUsagesFromJSValue(state, state.uncheckedArgument(4));
+    RETURN_IF_EXCEPTION(scope, void());
+
+    auto algorithm = createAlgorithm(state, params->identifier);
+    RETURN_IF_EXCEPTION(scope, void());
+
+    auto callback = [capturedPromise = promise.copyRef()](CryptoKey& key) mutable {
+        if ((key.type() == CryptoKeyType::Private || key.type() == CryptoKeyType::Secret) && !key.usagesBitmap()) {
+            rejectWithException(WTFMove(capturedPromise), SYNTAX_ERR);
+            return;
+        }
+        capturedPromise->resolve(key);
+    };
+    auto exceptionCallback = [capturedPromise =  promise.copyRef()](ExceptionCode ec) mutable {
+        rejectWithException(WTFMove(capturedPromise), ec);
+    };
+
+    // The spec suggests we should perform the following task asynchronously as of 11 December 2014:
+    // https://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-importKey
+    // That's simply not necessary. Therefore, we perform it synchronously.
+    algorithm->importKey(format, WTFMove(keyData), WTFMove(params), extractable, keyUsages, WTFMove(callback), WTFMove(exceptionCallback));
+}
+
 JSValue JSSubtleCrypto::generateKey(ExecState& state)
 {
     return callPromiseFunction<jsSubtleCryptoFunctionGenerateKeyPromise, PromiseExecutionScope::WindowOrWorker>(state);
 }
 
+JSValue JSSubtleCrypto::importKey(ExecState& state)
+{
+    return callPromiseFunction<jsSubtleCryptoFunctionImportKeyPromise, PromiseExecutionScope::WindowOrWorker>(state);
+}
+
 } // namespace WebCore
 
 #endif
index dd08648..016e5ff 100644 (file)
@@ -45,6 +45,11 @@ void CryptoAlgorithm::generateKey(const std::unique_ptr<CryptoAlgorithmParameter
     exceptionCallback(NOT_SUPPORTED_ERR);
 }
 
+void CryptoAlgorithm::importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool, CryptoKeyUsage, KeyCallback&&, ExceptionCallback&& exceptionCallback)
+{
+    exceptionCallback(NOT_SUPPORTED_ERR);
+}
+
 void CryptoAlgorithm::encrypt(const CryptoAlgorithmParametersDeprecated&, const CryptoKey&, const CryptoOperationData&, VectorCallback&&, VoidCallback&&, ExceptionCode& ec)
 {
     ec = NOT_SUPPORTED_ERR;
index 89ae2b4..05583ff 100644 (file)
 
 #include "CryptoAlgorithmIdentifier.h"
 #include "CryptoKeyUsage.h"
+#include "JsonWebKey.h"
+#include "SubtleCrypto.h"
 #include <wtf/Function.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/RefCounted.h>
+#include <wtf/Variant.h>
 #include <wtf/Vector.h>
 
 #if ENABLE(SUBTLE_CRYPTO)
@@ -49,6 +52,8 @@ class ScriptExecutionContext;
 // Data is mutable, so async operations should copy it first.
 typedef std::pair<const uint8_t*, size_t> CryptoOperationData;
 
+using KeyData = Variant<Vector<uint8_t>, JsonWebKey>;
+
 class CryptoAlgorithm : public RefCounted<CryptoAlgorithm> {
 public:
     virtual ~CryptoAlgorithm();
@@ -63,6 +68,7 @@ public:
     using ExceptionCallback = WTF::Function<void(ExceptionCode)>;
 
     virtual void generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsage, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext*);
+    virtual void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsage, KeyCallback&&, ExceptionCallback&&);
 
     // The following will be deprecated.
     virtual void encrypt(const CryptoAlgorithmParametersDeprecated&, const CryptoKey&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback, ExceptionCode&);
index c9d8817..10a6141 100644 (file)
@@ -38,8 +38,9 @@ public:
     enum class Class {
         None,
         AesKeyGenParams,
-        HmacKeyGenParams,
+        HmacKeyParams,
         RsaHashedKeyGenParams,
+        RsaHashedImportParams,
         RsaKeyGenParams,
     };
 
diff --git a/Source/WebCore/crypto/JsonWebKey.h b/Source/WebCore/crypto/JsonWebKey.h
new file mode 100644 (file)
index 0000000..b80998b
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2016 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 "CryptoKeyUsage.h"
+#include "RsaOtherPrimesInfo.h"
+#include <wtf/Vector.h>
+
+#if ENABLE(SUBTLE_CRYPTO)
+
+namespace WebCore {
+
+struct JsonWebKey {
+    String kty;
+    Optional<String> use;
+    // FIXME: Consider merging key_ops and usages.
+    Optional<Vector<String>> key_ops;
+    CryptoKeyUsage usages;
+    Optional<String> alg;
+
+    Optional<bool> ext;
+
+    Optional<String> crv;
+    Optional<String> x;
+    Optional<String> y;
+    Optional<String> d;
+    Optional<String> n;
+    Optional<String> e;
+    Optional<String> p;
+    Optional<String> q;
+    Optional<String> dp;
+    Optional<String> dq;
+    Optional<String> qi;
+    Optional<Vector<RsaOtherPrimesInfo>> oth;
+    Optional<String> k;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SUBTLE_CRYPTO)
diff --git a/Source/WebCore/crypto/JsonWebKey.idl b/Source/WebCore/crypto/JsonWebKey.idl
new file mode 100644 (file)
index 0000000..76e4c4b
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2016 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,
+] dictionary JsonWebKey {
+    // The following fields are defined in Section 3.1 of JSON Web Key
+    required DOMString kty;
+    DOMString use;
+    sequence<DOMString> key_ops;
+    DOMString alg;
+
+    // The following fields are defined in JSON Web Key Parameters Registration
+    boolean ext;
+
+    // The following fields are defined in Section 6 of JSON Web Algorithms
+    DOMString crv;
+    DOMString x;
+    DOMString y;
+    DOMString d;
+    DOMString n;
+    DOMString e;
+    DOMString p;
+    DOMString q;
+    DOMString dp;
+    DOMString dq;
+    DOMString qi;
+    sequence<RsaOtherPrimesInfo> oth;
+    DOMString k;
+};
diff --git a/Source/WebCore/crypto/RsaOtherPrimesInfo.h b/Source/WebCore/crypto/RsaOtherPrimesInfo.h
new file mode 100644 (file)
index 0000000..9e1f585
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2016 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 <wtf/text/WTFString.h>
+
+#if ENABLE(SUBTLE_CRYPTO)
+
+namespace WebCore {
+
+struct RsaOtherPrimesInfo {
+    String r;
+    String d;
+    String t;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SUBTLE_CRYPTO)
diff --git a/Source/WebCore/crypto/RsaOtherPrimesInfo.idl b/Source/WebCore/crypto/RsaOtherPrimesInfo.idl
new file mode 100644 (file)
index 0000000..4ea1589
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2016 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,
+] dictionary RsaOtherPrimesInfo {
+    // The following fields are defined in Section 6.3.2.7 of JSON Web Algorithms
+    required DOMString r;
+    required DOMString d;
+    required DOMString t;
+};
index 47ed8d6..fe2eccf 100644 (file)
@@ -35,6 +35,8 @@ namespace WebCore {
 
 class SubtleCrypto : public ContextDestructionObserver, public RefCounted<SubtleCrypto> {
 public:
+    enum class KeyFormat { Raw, Spki, Pkcs8, Jwk };
+
     static Ref<SubtleCrypto> create(ScriptExecutionContext& context) { return adoptRef(*new SubtleCrypto(context)); }
 
 private:
index ce0c66c..c338e03 100644 (file)
@@ -23,6 +23,8 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+enum KeyFormat { "raw", "spki", "pkcs8", "jwk" };
+
 [
     Conditional=SUBTLE_CRYPTO,
     Exposed=(Window,Worker),
@@ -31,4 +33,5 @@
 ] interface SubtleCrypto {
     // FIXME: Should this return a Promise<(CryptoKey or CryptoKeyPair)>?
     [Custom] Promise<any> generateKey(AlgorithmIdentifier algorithm, boolean extractable, sequence<KeyUsage> keyUsages);
+    [Custom] Promise<CryptoKey> importKey(KeyFormat format, (BufferSource or JsonWebKey) keyData, AlgorithmIdentifier algorithm, boolen extractable, sequence<KeyUsage> keyUsages);
 };
index c618809..58e345b 100644 (file)
@@ -39,6 +39,11 @@ namespace WebCore {
 
 const char* const CryptoAlgorithmAES_CBC::s_name = "AES-CBC";
 
+static inline bool usagesAreInvalidForCryptoAlgorithmAES_CBC(CryptoKeyUsage usages)
+{
+    return usages & (CryptoKeyUsageSign | CryptoKeyUsageVerify | CryptoKeyUsageDeriveKey | CryptoKeyUsageDeriveBits);
+}
+
 CryptoAlgorithmAES_CBC::CryptoAlgorithmAES_CBC()
 {
 }
@@ -70,7 +75,7 @@ void CryptoAlgorithmAES_CBC::generateKey(const std::unique_ptr<CryptoAlgorithmPa
 {
     const auto& aesParameters = downcast<CryptoAlgorithmAesKeyGenParams>(*parameters);
 
-    if (usages & (CryptoKeyUsageSign | CryptoKeyUsageVerify | CryptoKeyUsageDeriveKey | CryptoKeyUsageDeriveBits)) {
+    if (usagesAreInvalidForCryptoAlgorithmAES_CBC(usages)) {
         exceptionCallback(SYNTAX_ERR);
         return;
     }
@@ -84,6 +89,45 @@ void CryptoAlgorithmAES_CBC::generateKey(const std::unique_ptr<CryptoAlgorithmPa
     callback(result.get(), nullptr);
 }
 
+void CryptoAlgorithmAES_CBC::importKey(SubtleCrypto::KeyFormat format, KeyData&& data, const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsage usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
+{
+    if (usagesAreInvalidForCryptoAlgorithmAES_CBC(usages)) {
+        exceptionCallback(SYNTAX_ERR);
+        return;
+    }
+
+    RefPtr<CryptoKeyAES> result;
+    switch (format) {
+    case SubtleCrypto::KeyFormat::Raw:
+        result = CryptoKeyAES::importRaw(parameters->identifier, WTFMove(WTF::get<Vector<uint8_t>>(data)), extractable, usages);
+        break;
+    case SubtleCrypto::KeyFormat::Jwk: {
+        auto checkAlgCallback = [](size_t length, const Optional<String>& alg) -> bool {
+            switch (length) {
+            case CryptoKeyAES::s_length128:
+                return !alg || alg.value() == "A128CBC";
+            case CryptoKeyAES::s_length192:
+                return !alg || alg.value() == "A192CBC";
+            case CryptoKeyAES::s_length256:
+                return !alg || alg.value() == "A256CBC";
+            }
+            return false;
+        };
+        result = CryptoKeyAES::importJwk(parameters->identifier, WTFMove(WTF::get<JsonWebKey>(data)), extractable, usages, WTFMove(checkAlgCallback));
+        break;
+    }
+    default:
+        exceptionCallback(NOT_SUPPORTED_ERR);
+        return;
+    }
+    if (!result) {
+        exceptionCallback(DataError);
+        return;
+    }
+
+    callback(*result);
+}
+
 void CryptoAlgorithmAES_CBC::encrypt(const CryptoAlgorithmParametersDeprecated& parameters, const CryptoKey& key, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback, ExceptionCode& ec)
 {
     const CryptoAlgorithmAesCbcParamsDeprecated& aesCBCParameters = downcast<CryptoAlgorithmAesCbcParamsDeprecated>(parameters);
index 355dbea..ba4af0f 100644 (file)
@@ -45,6 +45,7 @@ public:
     CryptoAlgorithmIdentifier identifier() const override;
 
     void generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsage, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext*) final;
+    void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsage, KeyCallback&&, ExceptionCallback&&) final;
 
     // The following will be deprecated.
     void encrypt(const CryptoAlgorithmParametersDeprecated&, const CryptoKey&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback, ExceptionCode&) override;
index ed2b491..de30e3a 100644 (file)
@@ -38,6 +38,11 @@ namespace WebCore {
 
 const char* const CryptoAlgorithmAES_KW::s_name = "AES-KW";
 
+static inline bool usagesAreInvalidForCryptoAlgorithmAES_KW(CryptoKeyUsage usages)
+{
+    return usages & (CryptoKeyUsageSign | CryptoKeyUsageVerify | CryptoKeyUsageDeriveKey | CryptoKeyUsageDeriveBits | CryptoKeyUsageEncrypt | CryptoKeyUsageDecrypt);
+}
+
 CryptoAlgorithmAES_KW::CryptoAlgorithmAES_KW()
 {
 }
@@ -69,7 +74,7 @@ void CryptoAlgorithmAES_KW::generateKey(const std::unique_ptr<CryptoAlgorithmPar
 {
     const auto& aesParameters = downcast<CryptoAlgorithmAesKeyGenParams>(*parameters);
 
-    if (usages & (CryptoKeyUsageSign | CryptoKeyUsageVerify | CryptoKeyUsageDeriveKey | CryptoKeyUsageDeriveBits | CryptoKeyUsageEncrypt | CryptoKeyUsageDecrypt)) {
+    if (usagesAreInvalidForCryptoAlgorithmAES_KW(usages)) {
         exceptionCallback(SYNTAX_ERR);
         return;
     }
@@ -83,6 +88,45 @@ void CryptoAlgorithmAES_KW::generateKey(const std::unique_ptr<CryptoAlgorithmPar
     callback(result.get(), nullptr);
 }
 
+void CryptoAlgorithmAES_KW::importKey(SubtleCrypto::KeyFormat format, KeyData&& data, const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsage usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
+{
+    if (usagesAreInvalidForCryptoAlgorithmAES_KW(usages)) {
+        exceptionCallback(SYNTAX_ERR);
+        return;
+    }
+
+    RefPtr<CryptoKeyAES> result;
+    switch (format) {
+    case SubtleCrypto::KeyFormat::Raw:
+        result = CryptoKeyAES::importRaw(parameters->identifier, WTFMove(WTF::get<Vector<uint8_t>>(data)), extractable, usages);
+        break;
+    case SubtleCrypto::KeyFormat::Jwk: {
+        auto checkAlgCallback = [](size_t length, const Optional<String>& alg) -> bool {
+            switch (length) {
+            case CryptoKeyAES::s_length128:
+                return !alg || alg.value() == "A128KW";
+            case CryptoKeyAES::s_length192:
+                return !alg || alg.value() == "A192KW";
+            case CryptoKeyAES::s_length256:
+                return !alg || alg.value() == "A256KW";
+            }
+            return false;
+        };
+        result = CryptoKeyAES::importJwk(parameters->identifier, WTFMove(WTF::get<JsonWebKey>(data)), extractable, usages, WTFMove(checkAlgCallback));
+        break;
+    }
+    default:
+        exceptionCallback(NOT_SUPPORTED_ERR);
+        return;
+    }
+    if (!result) {
+        exceptionCallback(DataError);
+        return;
+    }
+
+    callback(*result);
+}
+
 void CryptoAlgorithmAES_KW::encryptForWrapKey(const CryptoAlgorithmParametersDeprecated&, const CryptoKey& key, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback, ExceptionCode& ec)
 {
     if (!keyAlgorithmMatches(key)) {
index 58d2bff..b3bb807 100644 (file)
@@ -44,6 +44,7 @@ public:
     CryptoAlgorithmIdentifier identifier() const override;
 
     void generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsage, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext*) final;
+    void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsage, KeyCallback&&, ExceptionCallback&&) final;
 
     // The following will be deprecated.
     void encryptForWrapKey(const CryptoAlgorithmParametersDeprecated&, const CryptoKey&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback, ExceptionCode&) override;
index ed186d7..225db89 100644 (file)
@@ -28,7 +28,7 @@
 
 #if ENABLE(SUBTLE_CRYPTO)
 
-#include "CryptoAlgorithmHmacKeyGenParams.h"
+#include "CryptoAlgorithmHmacKeyParams.h"
 #include "CryptoAlgorithmHmacKeyParamsDeprecated.h"
 #include "CryptoAlgorithmHmacParamsDeprecated.h"
 #include "CryptoKeyDataOctetSequence.h"
@@ -39,6 +39,11 @@ namespace WebCore {
 
 const char* const CryptoAlgorithmHMAC::s_name = "HMAC";
 
+static inline bool usagesAreInvalidForCryptoAlgorithmHMAC(CryptoKeyUsage usages)
+{
+    return usages & (CryptoKeyUsageEncrypt | CryptoKeyUsageDecrypt | CryptoKeyUsageDeriveKey | CryptoKeyUsageDeriveBits | CryptoKeyUsageWrapKey | CryptoKeyUsageUnwrapKey);
+}
+
 CryptoAlgorithmHMAC::CryptoAlgorithmHMAC()
 {
 }
@@ -70,9 +75,9 @@ bool CryptoAlgorithmHMAC::keyAlgorithmMatches(const CryptoAlgorithmHmacParamsDep
 
 void CryptoAlgorithmHMAC::generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsage usages, KeyOrKeyPairCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext*)
 {
-    const auto& hmacParameters = downcast<CryptoAlgorithmHmacKeyGenParams>(*parameters);
+    const auto& hmacParameters = downcast<CryptoAlgorithmHmacKeyParams>(*parameters);
 
-    if (usages & (CryptoKeyUsageEncrypt | CryptoKeyUsageDecrypt | CryptoKeyUsageDeriveKey | CryptoKeyUsageDeriveBits | CryptoKeyUsageWrapKey | CryptoKeyUsageUnwrapKey)) {
+    if (usagesAreInvalidForCryptoAlgorithmHMAC(usages)) {
         exceptionCallback(SYNTAX_ERR);
         return;
     }
@@ -91,6 +96,53 @@ void CryptoAlgorithmHMAC::generateKey(const std::unique_ptr<CryptoAlgorithmParam
     callback(result.get(), nullptr);
 }
 
+void CryptoAlgorithmHMAC::importKey(SubtleCrypto::KeyFormat format, KeyData&& data, const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsage usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
+{
+    const auto& hmacParameters = downcast<CryptoAlgorithmHmacKeyParams>(*parameters);
+
+    if (usagesAreInvalidForCryptoAlgorithmHMAC(usages)) {
+        exceptionCallback(SYNTAX_ERR);
+        return;
+    }
+
+    RefPtr<CryptoKeyHMAC> result;
+    switch (format) {
+    case SubtleCrypto::KeyFormat::Raw:
+        result = CryptoKeyHMAC::importRaw(hmacParameters.length.valueOr(0), hmacParameters.hashIdentifier, WTFMove(WTF::get<Vector<uint8_t>>(data)), extractable, usages);
+        break;
+    case SubtleCrypto::KeyFormat::Jwk: {
+        auto checkAlgCallback = [](CryptoAlgorithmIdentifier hash, const Optional<String>& alg) -> bool {
+            switch (hash) {
+            case CryptoAlgorithmIdentifier::SHA_1:
+                return !alg || alg.value() == "HS1";
+            case CryptoAlgorithmIdentifier::SHA_224:
+                return !alg || alg.value() == "HS224";
+            case CryptoAlgorithmIdentifier::SHA_256:
+                return !alg || alg.value() == "HS256";
+            case CryptoAlgorithmIdentifier::SHA_384:
+                return !alg || alg.value() == "HS384";
+            case CryptoAlgorithmIdentifier::SHA_512:
+                return !alg || alg.value() == "HS512";
+            default:
+                return false;
+            }
+            return false;
+        };
+        result = CryptoKeyHMAC::importJwk(hmacParameters.length.valueOr(0), hmacParameters.hashIdentifier, WTFMove(WTF::get<JsonWebKey>(data)), extractable, usages, WTFMove(checkAlgCallback));
+        break;
+    }
+    default:
+        exceptionCallback(NOT_SUPPORTED_ERR);
+        return;
+    }
+    if (!result) {
+        exceptionCallback(DataError);
+        return;
+    }
+
+    callback(*result);
+}
+
 void CryptoAlgorithmHMAC::sign(const CryptoAlgorithmParametersDeprecated& parameters, const CryptoKey& key, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback, ExceptionCode& ec)
 {
     const CryptoAlgorithmHmacParamsDeprecated& hmacParameters = downcast<CryptoAlgorithmHmacParamsDeprecated>(parameters);
index bbc9bbb..d54dcac 100644 (file)
@@ -45,6 +45,7 @@ public:
     CryptoAlgorithmIdentifier identifier() const override;
 
     void generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsage, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext*) final;
+    void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsage, KeyCallback&&, ExceptionCallback&&) final;
 
     // The following will be deprecated.
     void sign(const CryptoAlgorithmParametersDeprecated&, const CryptoKey&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback, ExceptionCode&) override;
index c9d358f..6abb35f 100644 (file)
@@ -88,6 +88,39 @@ void CryptoAlgorithmRSAES_PKCS1_v1_5::generateKey(const std::unique_ptr<CryptoAl
     CryptoKeyRSA::generatePair(CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5, CryptoAlgorithmIdentifier::SHA_1, false, rsaParameters.modulusLength, rsaParameters.publicExponentVector(), extractable, usages, WTFMove(keyPairCallback), WTFMove(failureCallback), context);
 }
 
+void CryptoAlgorithmRSAES_PKCS1_v1_5::importKey(SubtleCrypto::KeyFormat format, KeyData&& data, const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsage usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
+{
+    RefPtr<CryptoKeyRSA> result;
+    switch (format) {
+    case SubtleCrypto::KeyFormat::Jwk: {
+        JsonWebKey key = WTFMove(WTF::get<JsonWebKey>(data));
+        if ((key.d && (usages ^ CryptoKeyUsageDecrypt)) || (!key.d && (usages ^ CryptoKeyUsageEncrypt))) {
+            exceptionCallback(SYNTAX_ERR);
+            return;
+        }
+        if (usages && key.use && key.use.value() != "enc") {
+            exceptionCallback(DataError);
+            return;
+        }
+        if (key.alg && key.alg.value() != "RSA1_5") {
+            exceptionCallback(DataError);
+            return;
+        }
+        result = CryptoKeyRSA::importJwk(parameters->identifier, Nullopt, WTFMove(key), extractable, usages);
+        break;
+    }
+    default:
+        exceptionCallback(NOT_SUPPORTED_ERR);
+        return;
+    }
+    if (!result) {
+        exceptionCallback(DataError);
+        return;
+    }
+
+    callback(*result);
+}
+
 void CryptoAlgorithmRSAES_PKCS1_v1_5::encrypt(const CryptoAlgorithmParametersDeprecated&, const CryptoKey& key, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback, ExceptionCode& ec)
 {
     if (!keyAlgorithmMatches(key)) {
index 4efb6d7..24b2c6c 100644 (file)
@@ -45,6 +45,7 @@ public:
     CryptoAlgorithmIdentifier identifier() const override;
 
     void generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsage, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext*) final;
+    void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsage, KeyCallback&&, ExceptionCallback&&) final;
 
     // The following will be deprecated.
     void encrypt(const CryptoAlgorithmParametersDeprecated&, const CryptoKey&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback, ExceptionCode&) override;
index 9e616b4..f8449e1 100644 (file)
@@ -28,6 +28,7 @@
 
 #if ENABLE(SUBTLE_CRYPTO)
 
+#include "CryptoAlgorithmRsaHashedImportParams.h"
 #include "CryptoAlgorithmRsaHashedKeyGenParams.h"
 #include "CryptoAlgorithmRsaKeyGenParamsDeprecated.h"
 #include "CryptoAlgorithmRsaKeyParamsWithHashDeprecated.h"
@@ -91,6 +92,64 @@ void CryptoAlgorithmRSASSA_PKCS1_v1_5::generateKey(const std::unique_ptr<CryptoA
     CryptoKeyRSA::generatePair(CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5, rsaParameters.hashIdentifier, true, rsaParameters.modulusLength, rsaParameters.publicExponentVector(), extractable, usages, WTFMove(keyPairCallback), WTFMove(failureCallback), context);
 }
 
+void CryptoAlgorithmRSASSA_PKCS1_v1_5::importKey(SubtleCrypto::KeyFormat format, KeyData&& data, const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsage usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
+{
+    const auto& rsaParameters = downcast<CryptoAlgorithmRsaHashedImportParams>(*parameters);
+
+    RefPtr<CryptoKeyRSA> result;
+    switch (format) {
+    case SubtleCrypto::KeyFormat::Jwk: {
+        JsonWebKey key = WTFMove(WTF::get<JsonWebKey>(data));
+
+        if ((key.d && (usages ^ CryptoKeyUsageSign)) || (!key.d && (usages ^ CryptoKeyUsageVerify))) {
+            exceptionCallback(SYNTAX_ERR);
+            return;
+        }
+        if (usages && key.use && key.use.value() != "sig") {
+            exceptionCallback(DataError);
+            return;
+        }
+
+        bool isMatched = false;
+        switch (rsaParameters.hashIdentifier) {
+        case CryptoAlgorithmIdentifier::SHA_1:
+            isMatched = !key.alg || key.alg.value() == "RS1";
+            break;
+        case CryptoAlgorithmIdentifier::SHA_224:
+            isMatched = !key.alg || key.alg.value() == "RS224";
+            break;
+        case CryptoAlgorithmIdentifier::SHA_256:
+            isMatched = !key.alg || key.alg.value() == "RS256";
+            break;
+        case CryptoAlgorithmIdentifier::SHA_384:
+            isMatched = !key.alg || key.alg.value() == "RS384";
+            break;
+        case CryptoAlgorithmIdentifier::SHA_512:
+            isMatched = !key.alg || key.alg.value() == "RS512";
+            break;
+        default:
+            break;
+        }
+        if (!isMatched) {
+            exceptionCallback(DataError);
+            return;
+        }
+
+        result = CryptoKeyRSA::importJwk(rsaParameters.identifier, rsaParameters.hashIdentifier, WTFMove(key), extractable, usages);
+        break;
+    }
+    default:
+        exceptionCallback(NOT_SUPPORTED_ERR);