haikuwebkit/LayoutTests/crypto/subtle/aes-generate-key-malformed-...

42 lines
5.8 KiB
Plaintext
Raw Permalink Normal View History

Update SubtleCrypto::generateKey to match the latest spec https://bugs.webkit.org/show_bug.cgi?id=163718 <rdar://problem/28864380> Reviewed by Chris Dumez. LayoutTests/imported/w3c: * WebCryptoAPI/generateKey/test_aes-cbc-expected.txt: * WebCryptoAPI/generateKey/test_aes-cbc.html: * WebCryptoAPI/generateKey/test_aes-ctr-expected.txt: * WebCryptoAPI/generateKey/test_aes-ctr.html: * WebCryptoAPI/generateKey/test_failures-expected.txt: * WebCryptoAPI/generateKey/test_failures.html: * WebCryptoAPI/generateKey/test_failures_AES-CBC-expected.txt: * WebCryptoAPI/generateKey/test_failures_AES-CBC.html: * WebCryptoAPI/generateKey/test_failures_AES-CTR-expected.txt: * WebCryptoAPI/generateKey/test_failures_AES-CTR.html: * WebCryptoAPI/generateKey/test_failures_AES-GCM-expected.txt: * WebCryptoAPI/generateKey/test_failures_AES-GCM.html: * WebCryptoAPI/generateKey/test_failures_AES-KW-expected.txt: * WebCryptoAPI/generateKey/test_failures_AES-KW.html: * WebCryptoAPI/generateKey/test_failures_ECDH-expected.txt: * WebCryptoAPI/generateKey/test_failures_ECDH.html: * WebCryptoAPI/generateKey/test_failures_ECDSA-expected.txt: * WebCryptoAPI/generateKey/test_failures_ECDSA.html: * WebCryptoAPI/generateKey/test_failures_HMAC-expected.txt: * WebCryptoAPI/generateKey/test_failures_HMAC.html: * WebCryptoAPI/generateKey/test_failures_RSA-OAEP-expected.txt: * WebCryptoAPI/generateKey/test_failures_RSA-OAEP.html: * WebCryptoAPI/generateKey/test_failures_RSA-PSS-expected.txt: * WebCryptoAPI/generateKey/test_failures_RSA-PSS.html: * WebCryptoAPI/generateKey/test_failures_RSASSA-PKCS1-v1_5-expected.txt: * WebCryptoAPI/generateKey/test_failures_RSASSA-PKCS1-v1_5.html: * WebCryptoAPI/generateKey/test_successes-expected.txt: * WebCryptoAPI/generateKey/test_successes.html: * WebCryptoAPI/generateKey/test_successes_AES-CBC-expected.txt: * WebCryptoAPI/generateKey/test_successes_AES-CBC.html: * WebCryptoAPI/generateKey/test_successes_AES-CTR-expected.txt: * WebCryptoAPI/generateKey/test_successes_AES-CTR.html: * WebCryptoAPI/generateKey/test_successes_AES-GCM-expected.txt: * WebCryptoAPI/generateKey/test_successes_AES-GCM.html: * WebCryptoAPI/generateKey/test_successes_AES-KW-expected.txt: * WebCryptoAPI/generateKey/test_successes_AES-KW.html: * WebCryptoAPI/generateKey/test_successes_ECDH-expected.txt: * WebCryptoAPI/generateKey/test_successes_ECDH.html: * WebCryptoAPI/generateKey/test_successes_ECDSA-expected.txt: * WebCryptoAPI/generateKey/test_successes_ECDSA.html: * WebCryptoAPI/generateKey/test_successes_HMAC-expected.txt: * WebCryptoAPI/generateKey/test_successes_HMAC.html: * WebCryptoAPI/generateKey/test_successes_RSA-OAEP-expected.txt: * WebCryptoAPI/generateKey/test_successes_RSA-OAEP.html: * WebCryptoAPI/generateKey/test_successes_RSA-PSS-expected.txt: * WebCryptoAPI/generateKey/test_successes_RSA-PSS.html: * WebCryptoAPI/generateKey/test_successes_RSASSA-PKCS1-v1_5-expected.txt: * WebCryptoAPI/generateKey/test_successes_RSASSA-PKCS1-v1_5.html: * WebCryptoAPI/idlharness-expected.txt: Source/WebCore: This patch does following few things: 1. It updates the SubtleCrypto::generateKey method to match the latest spec: https://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-generateKey. It also refers to the latest Editor's Draft at a certain degree: https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-generateKey. 2. It implements generateKey operations of following algorithms: AES-CBC, AES-KW, HMAC, RSAES-PKCS1-V1_5, RSASSA-PKCS1-V1_5, and RSA-OAEP. 3. It replaces SPECIALIZE_TYPE_TRAITS_CRYPTO_ALGORITHM_PARAMETERS with SPECIALIZE_TYPE_TRAITS_CRYPTO_ALGORITHM_PARAMETERS_DEPRECATED for deprecated params. 4. It fixes https://bugs.webkit.org/show_bug.cgi?id=129750 as well. Tests: crypto/subtle/aes-cbc-generate-key-length-128.html crypto/subtle/aes-cbc-generate-key-length-192.html crypto/subtle/aes-cbc-generate-key-length-256.html crypto/subtle/aes-generate-key-malformed-parameters.html crypto/subtle/aes-kw-generate-key.html crypto/subtle/generate-key-malformed-paramters.html crypto/subtle/hmac-generate-key-customized-length.html crypto/subtle/hmac-generate-key-hash-object.html crypto/subtle/hmac-generate-key-malformed-parameters.html crypto/subtle/hmac-generate-key-sha1.html crypto/subtle/hmac-generate-key-sha224.html crypto/subtle/hmac-generate-key-sha256.html crypto/subtle/hmac-generate-key-sha384.html crypto/subtle/hmac-generate-key-sha512.html crypto/subtle/rsa-generate-key-malformed-parameters.html crypto/subtle/rsa-oaep-generate-key.html crypto/subtle/rsaes-pkcs1-v1_5-generate-key-extractable.html crypto/subtle/rsaes-pkcs1-v1_5-generate-key.html crypto/subtle/rsassa-pkcs1-v1_5-generate-key.html crypto/webkitSubtle/hmac-generate-key.html: crypto/workers/subtle/aes-generate-key.html crypto/workers/subtle/hmac-generate-key.html crypto/workers/subtle/rsa-generate-key.html * CMakeLists.txt: * DerivedSources.make: * Modules/encryptedmedia/CDMSessionClearKey.cpp: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSSubtleCryptoCustom.cpp: Added. (WebCore::toHashIdentifier): (WebCore::normalizeCryptoAlgorithmParameters): (WebCore::cryptoKeyUsagesFromJSValue): (WebCore::createAlgorithm): (WebCore::rejectWithException): (WebCore::jsSubtleCryptoFunctionGenerateKeyPromise): (WebCore::JSSubtleCrypto::generateKey): * bindings/js/JSWebKitSubtleCryptoCustom.cpp: (WebCore::JSWebKitSubtleCrypto::generateKey): * crypto/CryptoAlgorithm.cpp: (WebCore::CryptoAlgorithm::generateKey): * crypto/CryptoAlgorithm.h: * crypto/CryptoAlgorithmParameters.h: Added. (WebCore::CryptoAlgorithmParameters::CryptoAlgorithmParameters): (WebCore::CryptoAlgorithmParameters::~CryptoAlgorithmParameters): (WebCore::CryptoAlgorithmParameters::parametersClass): * crypto/CryptoAlgorithmParameters.idl: Added. * crypto/CryptoAlgorithmParametersDeprecated.h: * crypto/CryptoKey.cpp: (WebCore::CryptoKey::setUsagesBitmap): * crypto/CryptoKey.h: * crypto/CryptoKeyPair.idl: * crypto/SubtleCrypto.idl: * crypto/algorithms/CryptoAlgorithmAES_CBC.cpp: (WebCore::CryptoAlgorithmAES_CBC::generateKey): * crypto/algorithms/CryptoAlgorithmAES_CBC.h: * crypto/algorithms/CryptoAlgorithmAES_KW.cpp: (WebCore::CryptoAlgorithmAES_KW::generateKey): * crypto/algorithms/CryptoAlgorithmAES_KW.h: * crypto/algorithms/CryptoAlgorithmHMAC.cpp: (WebCore::CryptoAlgorithmHMAC::generateKey): * crypto/algorithms/CryptoAlgorithmHMAC.h: * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp: (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::generateKey): * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h: * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp: (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::generateKey): * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h: * crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp: (WebCore::CryptoAlgorithmRSA_OAEP::generateKey): * crypto/algorithms/CryptoAlgorithmRSA_OAEP.h: * crypto/gnutls/CryptoKeyRSAGnuTLS.cpp: (WebCore::CryptoKeyRSA::generatePair): * crypto/keys/CryptoKeyAES.cpp: (WebCore::CryptoKeyAES::generate): * crypto/keys/CryptoKeyHMAC.cpp: (WebCore::CryptoKeyHMAC::generate): * crypto/keys/CryptoKeyRSA.h: * crypto/mac/CryptoKeyRSAMac.cpp: (WebCore::CryptoKeyRSA::generatePair): * crypto/parameters/AesKeyGenParams.idl: Added. * crypto/parameters/CryptoAlgorithmAesCbcParamsDeprecated.h: * crypto/parameters/CryptoAlgorithmAesKeyGenParams.h: Added. * crypto/parameters/CryptoAlgorithmAesKeyGenParamsDeprecated.h: * crypto/parameters/CryptoAlgorithmHmacKeyGenParams.h: Added. * crypto/parameters/CryptoAlgorithmHmacKeyParamsDeprecated.h: * crypto/parameters/CryptoAlgorithmHmacParamsDeprecated.h: * crypto/parameters/CryptoAlgorithmRsaHashedKeyGenParams.h: Added. * crypto/parameters/CryptoAlgorithmRsaKeyGenParams.h: Added. (WebCore::CryptoAlgorithmRsaKeyGenParams::arrayToVector): * crypto/parameters/CryptoAlgorithmRsaKeyGenParamsDeprecated.h: * crypto/parameters/CryptoAlgorithmRsaKeyParamsWithHashDeprecated.h: * crypto/parameters/CryptoAlgorithmRsaOaepParamsDeprecated.h: * crypto/parameters/CryptoAlgorithmRsaSsaParamsDeprecated.h: * crypto/parameters/HmacKeyGenParams.idl: Added. * crypto/parameters/RsaHashedKeyGenParams.idl: Added. * crypto/parameters/RsaKeyGenParams.idl: Added. LayoutTests: Besides adding tests for SubtleCrypto::generateKey related stuff and fixing HMAC. This patch also add shouldReject(_a, _rejectCallback, _resolveCallback, _message) in js-test-pre.js. * TestExpectations: * crypto/subtle/aes-cbc-generate-key-length-128-expected.txt: Added. * crypto/subtle/aes-cbc-generate-key-length-128.html: Added. * crypto/subtle/aes-cbc-generate-key-length-192-expected.txt: Added. * crypto/subtle/aes-cbc-generate-key-length-192.html: Added. * crypto/subtle/aes-cbc-generate-key-length-256-expected.txt: Added. * crypto/subtle/aes-cbc-generate-key-length-256.html: Added. * crypto/subtle/aes-generate-key-malformed-parameters-expected.txt: Added. * crypto/subtle/aes-generate-key-malformed-parameters.html: Added. * crypto/subtle/aes-kw-generate-key-expected.txt: Added. * crypto/subtle/aes-kw-generate-key.html: Added. * crypto/subtle/generate-key-malformed-paramters-expected.txt: Added. * crypto/subtle/generate-key-malformed-paramters.html: Added. * crypto/subtle/hmac-generate-key-customized-length-expected.txt: Added. * crypto/subtle/hmac-generate-key-customized-length.html: Added. * crypto/subtle/hmac-generate-key-hash-object-expected.txt: Added. * crypto/subtle/hmac-generate-key-hash-object.html: Added. * crypto/subtle/hmac-generate-key-malformed-parameters-expected.txt: Added. * crypto/subtle/hmac-generate-key-malformed-parameters.html: Added. * crypto/subtle/hmac-generate-key-sha1-expected.txt: Added. * crypto/subtle/hmac-generate-key-sha1.html: Added. * crypto/subtle/hmac-generate-key-sha224-expected.txt: Added. * crypto/subtle/hmac-generate-key-sha224.html: Added. * crypto/subtle/hmac-generate-key-sha256-expected.txt: Added. * crypto/subtle/hmac-generate-key-sha256.html: Added. * crypto/subtle/hmac-generate-key-sha384-expected.txt: Added. * crypto/subtle/hmac-generate-key-sha384.html: Added. * crypto/subtle/hmac-generate-key-sha512-expected.txt: Added. * crypto/subtle/hmac-generate-key-sha512.html: Added. * crypto/subtle/rsa-generate-key-malformed-parameters-expected.txt: Added. * crypto/subtle/rsa-generate-key-malformed-parameters.html: Added. * crypto/subtle/rsa-oaep-generate-key-expected.txt: Added. * crypto/subtle/rsa-oaep-generate-key.html: Added. * crypto/subtle/rsaes-pkcs1-v1_5-generate-key-expected.txt: Added. * crypto/subtle/rsaes-pkcs1-v1_5-generate-key-extractable-expected.txt: Added. * crypto/subtle/rsaes-pkcs1-v1_5-generate-key-extractable.html: Added. * crypto/subtle/rsaes-pkcs1-v1_5-generate-key.html: Added. * crypto/subtle/rsassa-pkcs1-v1_5-generate-key-expected.txt: Added. * crypto/subtle/rsassa-pkcs1-v1_5-generate-key.html: Added. * crypto/webkitSubtle/hmac-generate-key-expected.txt: * crypto/webkitSubtle/hmac-generate-key.html: * crypto/workers/subtle/aes-generate-key-expected.txt: Added. * crypto/workers/subtle/aes-generate-key.html: Added. * crypto/workers/subtle/hmac-generate-key-expected.txt: Added. * crypto/workers/subtle/hmac-generate-key.html: Added. * crypto/workers/subtle/resources/aes-generate-key.js: Added. * crypto/workers/subtle/resources/hmac-generate-key.js: Added. * crypto/workers/subtle/resources/rsa-generate-key.js: Added. * crypto/workers/subtle/rsa-generate-key-expected.txt: Added. * crypto/workers/subtle/rsa-generate-key.html: Added. * resources/js-test-pre.js: Canonical link: https://commits.webkit.org/181666@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207809 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-25 06:07:04 +00:00
Test generating an AES key with malformed-paramters.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
[WebCrypto] Implement SubtleCrypto::DeriveKey method https://bugs.webkit.org/show_bug.cgi?id=169386 <rdar://problem/23789585> Reviewed by Brent Fulgham. Source/WebCore: This patch does following few things: 1. It implements SubtleCrypto::DeriveKey method according to the spec: https://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-deriveKey. 2. It implements getKeyLength operations for AES-CBC, AES-KW, AES-CFB, AES-GCM, and HMAC, which is needed by the SubtleCrypto::DeriveKey method. 3. It enables ECDH DeriveKey operation. 4. It replaces unigned long with size_t in all the crypto codes. Tests: crypto/subtle/derive-key-malformed-parameters.html crypto/subtle/ecdh-import-key-derive-aes-key.html crypto/subtle/ecdh-import-key-derive-hmac-key-custom-length.html crypto/subtle/unwrap-key-malformed-parameters.html crypto/subtle/wrap-key-malformed-parameters.html crypto/workers/subtle/ecdh-import-key-derive-key.html * CMakeLists.txt: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSSubtleCryptoCustom.cpp: (WebCore::normalizeCryptoAlgorithmParameters): (WebCore::jsSubtleCryptoFunctionEncryptPromise): (WebCore::jsSubtleCryptoFunctionDecryptPromise): (WebCore::jsSubtleCryptoFunctionSignPromise): (WebCore::jsSubtleCryptoFunctionVerifyPromise): (WebCore::jsSubtleCryptoFunctionDigestPromise): (WebCore::jsSubtleCryptoFunctionDeriveKeyPromise): (WebCore::jsSubtleCryptoFunctionDeriveBitsPromise): Remove unnecessary return statement from callbacks. * crypto/CryptoAlgorithm.cpp: (WebCore::CryptoAlgorithm::deriveBits): (WebCore::CryptoAlgorithm::getKeyLength): * crypto/CryptoAlgorithm.h: * crypto/CryptoAlgorithmParameters.h: * crypto/algorithms/CryptoAlgorithmAES_CBC.cpp: (WebCore::CryptoAlgorithmAES_CBC::generateKey): (WebCore::CryptoAlgorithmAES_CBC::getKeyLength): * crypto/algorithms/CryptoAlgorithmAES_CBC.h: * crypto/algorithms/CryptoAlgorithmAES_CFB.cpp: (WebCore::CryptoAlgorithmAES_CFB::generateKey): (WebCore::CryptoAlgorithmAES_CFB::getKeyLength): * crypto/algorithms/CryptoAlgorithmAES_CFB.h: * crypto/algorithms/CryptoAlgorithmAES_GCM.cpp: (WebCore::CryptoAlgorithmAES_GCM::generateKey): (WebCore::CryptoAlgorithmAES_GCM::getKeyLength): * crypto/algorithms/CryptoAlgorithmAES_GCM.h: * crypto/algorithms/CryptoAlgorithmAES_KW.cpp: (WebCore::CryptoAlgorithmAES_KW::generateKey): (WebCore::CryptoAlgorithmAES_KW::getKeyLength): * crypto/algorithms/CryptoAlgorithmAES_KW.h: * crypto/algorithms/CryptoAlgorithmECDH.cpp: (WebCore::CryptoAlgorithmECDH::deriveBits): * crypto/algorithms/CryptoAlgorithmECDH.h: * crypto/algorithms/CryptoAlgorithmHMAC.cpp: (WebCore::CryptoAlgorithmHMAC::getKeyLength): * crypto/algorithms/CryptoAlgorithmHMAC.h: * crypto/keys/CryptoKeyAES.cpp: (WebCore::CryptoKeyAES::getKeyLength): * crypto/keys/CryptoKeyAES.h: * crypto/keys/CryptoKeyHMAC.cpp: (WebCore::getKeyLengthFromHash): (WebCore::CryptoKeyHMAC::generate): (WebCore::CryptoKeyHMAC::getKeyLength): * crypto/keys/CryptoKeyHMAC.h: * crypto/mac/CryptoAlgorithmECDHMac.cpp: (WebCore::CryptoAlgorithmECDH::platformDeriveBits): * crypto/parameters/AesKeyParams.idl: Renamed from Source/WebCore/crypto/parameters/AesKeyGenParams.idl. * crypto/parameters/CryptoAlgorithmAesKeyParams.h: Renamed from Source/WebCore/crypto/parameters/CryptoAlgorithmAesKeyGenParams.h. Rename AesKeyGenParams to AesKeyParams to represent a unified dictionary for AesKeyGenParams and AesDerivedKeyParams. * crypto/parameters/CryptoAlgorithmHmacKeyParams.h: * crypto/parameters/CryptoAlgorithmRsaKeyGenParams.h: LayoutTests: * crypto/subtle/aes-generate-key-malformed-parameters-expected.txt: * crypto/subtle/derive-key-malformed-parameters-expected.txt: Added. * crypto/subtle/derive-key-malformed-parameters.html: Added. * crypto/subtle/deriveKey-malformed-parameters-expected.txt: Removed. * crypto/subtle/deriveKey-malformed-parameters.html: Removed. * crypto/subtle/ecdh-import-key-derive-aes-key-expected.txt: Added. * crypto/subtle/ecdh-import-key-derive-aes-key.html: Added. * crypto/subtle/ecdh-import-key-derive-hmac-key-custom-length-expected.txt: Added. * crypto/subtle/ecdh-import-key-derive-hmac-key-custom-length.html: Added. * crypto/subtle/unwrap-key-malformed-parameters-expected.txt: Renamed from LayoutTests/crypto/subtle/unwrapKey-malformed-parameters-expected.txt. * crypto/subtle/unwrap-key-malformed-parameters.html: Renamed from LayoutTests/crypto/subtle/unwrapKey-malformed-parameters.html. * crypto/subtle/wrap-key-malformed-parameters-expected.txt: Renamed from LayoutTests/crypto/subtle/wrapKey-malformed-parameters-expected.txt. * crypto/subtle/wrap-key-malformed-parameters.html: Renamed from LayoutTests/crypto/subtle/wrapKey-malformed-parameters.html. A bit renaming. * crypto/workers/subtle/ecdh-import-key-derive-key-expected.txt: Added. * crypto/workers/subtle/ecdh-import-key-derive-key.html: Added. * crypto/workers/subtle/resources/ecdh-import-key-derive-key.js: Added. Canonical link: https://commits.webkit.org/186385@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@213628 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-09 05:50:31 +00:00
PASS crypto.subtle.generateKey("aes-cbc", extractable, ["encrypt", "decrypt"]) rejected promise with TypeError: Member AesKeyParams.length is required and must be an instance of unsigned short.
PASS crypto.subtle.generateKey({name: "aes-cbc"}, extractable, ["encrypt", "decrypt"]) rejected promise with TypeError: Member AesKeyParams.length is required and must be an instance of unsigned short.
PASS crypto.subtle.generateKey({name: "aes-cbc", length: true}, extractable, ["encrypt", "decrypt"]) rejected promise with OperationError: The operation failed for an operation-specific reason.
PASS crypto.subtle.generateKey({name: "aes-cbc", length: null}, extractable, ["encrypt", "decrypt"]) rejected promise with OperationError: The operation failed for an operation-specific reason.
[WebCrypto] Implement SubtleCrypto::DeriveKey method https://bugs.webkit.org/show_bug.cgi?id=169386 <rdar://problem/23789585> Reviewed by Brent Fulgham. Source/WebCore: This patch does following few things: 1. It implements SubtleCrypto::DeriveKey method according to the spec: https://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-deriveKey. 2. It implements getKeyLength operations for AES-CBC, AES-KW, AES-CFB, AES-GCM, and HMAC, which is needed by the SubtleCrypto::DeriveKey method. 3. It enables ECDH DeriveKey operation. 4. It replaces unigned long with size_t in all the crypto codes. Tests: crypto/subtle/derive-key-malformed-parameters.html crypto/subtle/ecdh-import-key-derive-aes-key.html crypto/subtle/ecdh-import-key-derive-hmac-key-custom-length.html crypto/subtle/unwrap-key-malformed-parameters.html crypto/subtle/wrap-key-malformed-parameters.html crypto/workers/subtle/ecdh-import-key-derive-key.html * CMakeLists.txt: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSSubtleCryptoCustom.cpp: (WebCore::normalizeCryptoAlgorithmParameters): (WebCore::jsSubtleCryptoFunctionEncryptPromise): (WebCore::jsSubtleCryptoFunctionDecryptPromise): (WebCore::jsSubtleCryptoFunctionSignPromise): (WebCore::jsSubtleCryptoFunctionVerifyPromise): (WebCore::jsSubtleCryptoFunctionDigestPromise): (WebCore::jsSubtleCryptoFunctionDeriveKeyPromise): (WebCore::jsSubtleCryptoFunctionDeriveBitsPromise): Remove unnecessary return statement from callbacks. * crypto/CryptoAlgorithm.cpp: (WebCore::CryptoAlgorithm::deriveBits): (WebCore::CryptoAlgorithm::getKeyLength): * crypto/CryptoAlgorithm.h: * crypto/CryptoAlgorithmParameters.h: * crypto/algorithms/CryptoAlgorithmAES_CBC.cpp: (WebCore::CryptoAlgorithmAES_CBC::generateKey): (WebCore::CryptoAlgorithmAES_CBC::getKeyLength): * crypto/algorithms/CryptoAlgorithmAES_CBC.h: * crypto/algorithms/CryptoAlgorithmAES_CFB.cpp: (WebCore::CryptoAlgorithmAES_CFB::generateKey): (WebCore::CryptoAlgorithmAES_CFB::getKeyLength): * crypto/algorithms/CryptoAlgorithmAES_CFB.h: * crypto/algorithms/CryptoAlgorithmAES_GCM.cpp: (WebCore::CryptoAlgorithmAES_GCM::generateKey): (WebCore::CryptoAlgorithmAES_GCM::getKeyLength): * crypto/algorithms/CryptoAlgorithmAES_GCM.h: * crypto/algorithms/CryptoAlgorithmAES_KW.cpp: (WebCore::CryptoAlgorithmAES_KW::generateKey): (WebCore::CryptoAlgorithmAES_KW::getKeyLength): * crypto/algorithms/CryptoAlgorithmAES_KW.h: * crypto/algorithms/CryptoAlgorithmECDH.cpp: (WebCore::CryptoAlgorithmECDH::deriveBits): * crypto/algorithms/CryptoAlgorithmECDH.h: * crypto/algorithms/CryptoAlgorithmHMAC.cpp: (WebCore::CryptoAlgorithmHMAC::getKeyLength): * crypto/algorithms/CryptoAlgorithmHMAC.h: * crypto/keys/CryptoKeyAES.cpp: (WebCore::CryptoKeyAES::getKeyLength): * crypto/keys/CryptoKeyAES.h: * crypto/keys/CryptoKeyHMAC.cpp: (WebCore::getKeyLengthFromHash): (WebCore::CryptoKeyHMAC::generate): (WebCore::CryptoKeyHMAC::getKeyLength): * crypto/keys/CryptoKeyHMAC.h: * crypto/mac/CryptoAlgorithmECDHMac.cpp: (WebCore::CryptoAlgorithmECDH::platformDeriveBits): * crypto/parameters/AesKeyParams.idl: Renamed from Source/WebCore/crypto/parameters/AesKeyGenParams.idl. * crypto/parameters/CryptoAlgorithmAesKeyParams.h: Renamed from Source/WebCore/crypto/parameters/CryptoAlgorithmAesKeyGenParams.h. Rename AesKeyGenParams to AesKeyParams to represent a unified dictionary for AesKeyGenParams and AesDerivedKeyParams. * crypto/parameters/CryptoAlgorithmHmacKeyParams.h: * crypto/parameters/CryptoAlgorithmRsaKeyGenParams.h: LayoutTests: * crypto/subtle/aes-generate-key-malformed-parameters-expected.txt: * crypto/subtle/derive-key-malformed-parameters-expected.txt: Added. * crypto/subtle/derive-key-malformed-parameters.html: Added. * crypto/subtle/deriveKey-malformed-parameters-expected.txt: Removed. * crypto/subtle/deriveKey-malformed-parameters.html: Removed. * crypto/subtle/ecdh-import-key-derive-aes-key-expected.txt: Added. * crypto/subtle/ecdh-import-key-derive-aes-key.html: Added. * crypto/subtle/ecdh-import-key-derive-hmac-key-custom-length-expected.txt: Added. * crypto/subtle/ecdh-import-key-derive-hmac-key-custom-length.html: Added. * crypto/subtle/unwrap-key-malformed-parameters-expected.txt: Renamed from LayoutTests/crypto/subtle/unwrapKey-malformed-parameters-expected.txt. * crypto/subtle/unwrap-key-malformed-parameters.html: Renamed from LayoutTests/crypto/subtle/unwrapKey-malformed-parameters.html. * crypto/subtle/wrap-key-malformed-parameters-expected.txt: Renamed from LayoutTests/crypto/subtle/wrapKey-malformed-parameters-expected.txt. * crypto/subtle/wrap-key-malformed-parameters.html: Renamed from LayoutTests/crypto/subtle/wrapKey-malformed-parameters.html. A bit renaming. * crypto/workers/subtle/ecdh-import-key-derive-key-expected.txt: Added. * crypto/workers/subtle/ecdh-import-key-derive-key.html: Added. * crypto/workers/subtle/resources/ecdh-import-key-derive-key.js: Added. Canonical link: https://commits.webkit.org/186385@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@213628 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-09 05:50:31 +00:00
PASS crypto.subtle.generateKey({name: "aes-cbc", length: undefined}, extractable, ["encrypt", "decrypt"]) rejected promise with TypeError: Member AesKeyParams.length is required and must be an instance of unsigned short.
Update SubtleCrypto::generateKey to match the latest spec https://bugs.webkit.org/show_bug.cgi?id=163718 <rdar://problem/28864380> Reviewed by Chris Dumez. LayoutTests/imported/w3c: * WebCryptoAPI/generateKey/test_aes-cbc-expected.txt: * WebCryptoAPI/generateKey/test_aes-cbc.html: * WebCryptoAPI/generateKey/test_aes-ctr-expected.txt: * WebCryptoAPI/generateKey/test_aes-ctr.html: * WebCryptoAPI/generateKey/test_failures-expected.txt: * WebCryptoAPI/generateKey/test_failures.html: * WebCryptoAPI/generateKey/test_failures_AES-CBC-expected.txt: * WebCryptoAPI/generateKey/test_failures_AES-CBC.html: * WebCryptoAPI/generateKey/test_failures_AES-CTR-expected.txt: * WebCryptoAPI/generateKey/test_failures_AES-CTR.html: * WebCryptoAPI/generateKey/test_failures_AES-GCM-expected.txt: * WebCryptoAPI/generateKey/test_failures_AES-GCM.html: * WebCryptoAPI/generateKey/test_failures_AES-KW-expected.txt: * WebCryptoAPI/generateKey/test_failures_AES-KW.html: * WebCryptoAPI/generateKey/test_failures_ECDH-expected.txt: * WebCryptoAPI/generateKey/test_failures_ECDH.html: * WebCryptoAPI/generateKey/test_failures_ECDSA-expected.txt: * WebCryptoAPI/generateKey/test_failures_ECDSA.html: * WebCryptoAPI/generateKey/test_failures_HMAC-expected.txt: * WebCryptoAPI/generateKey/test_failures_HMAC.html: * WebCryptoAPI/generateKey/test_failures_RSA-OAEP-expected.txt: * WebCryptoAPI/generateKey/test_failures_RSA-OAEP.html: * WebCryptoAPI/generateKey/test_failures_RSA-PSS-expected.txt: * WebCryptoAPI/generateKey/test_failures_RSA-PSS.html: * WebCryptoAPI/generateKey/test_failures_RSASSA-PKCS1-v1_5-expected.txt: * WebCryptoAPI/generateKey/test_failures_RSASSA-PKCS1-v1_5.html: * WebCryptoAPI/generateKey/test_successes-expected.txt: * WebCryptoAPI/generateKey/test_successes.html: * WebCryptoAPI/generateKey/test_successes_AES-CBC-expected.txt: * WebCryptoAPI/generateKey/test_successes_AES-CBC.html: * WebCryptoAPI/generateKey/test_successes_AES-CTR-expected.txt: * WebCryptoAPI/generateKey/test_successes_AES-CTR.html: * WebCryptoAPI/generateKey/test_successes_AES-GCM-expected.txt: * WebCryptoAPI/generateKey/test_successes_AES-GCM.html: * WebCryptoAPI/generateKey/test_successes_AES-KW-expected.txt: * WebCryptoAPI/generateKey/test_successes_AES-KW.html: * WebCryptoAPI/generateKey/test_successes_ECDH-expected.txt: * WebCryptoAPI/generateKey/test_successes_ECDH.html: * WebCryptoAPI/generateKey/test_successes_ECDSA-expected.txt: * WebCryptoAPI/generateKey/test_successes_ECDSA.html: * WebCryptoAPI/generateKey/test_successes_HMAC-expected.txt: * WebCryptoAPI/generateKey/test_successes_HMAC.html: * WebCryptoAPI/generateKey/test_successes_RSA-OAEP-expected.txt: * WebCryptoAPI/generateKey/test_successes_RSA-OAEP.html: * WebCryptoAPI/generateKey/test_successes_RSA-PSS-expected.txt: * WebCryptoAPI/generateKey/test_successes_RSA-PSS.html: * WebCryptoAPI/generateKey/test_successes_RSASSA-PKCS1-v1_5-expected.txt: * WebCryptoAPI/generateKey/test_successes_RSASSA-PKCS1-v1_5.html: * WebCryptoAPI/idlharness-expected.txt: Source/WebCore: This patch does following few things: 1. It updates the SubtleCrypto::generateKey method to match the latest spec: https://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-generateKey. It also refers to the latest Editor's Draft at a certain degree: https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-generateKey. 2. It implements generateKey operations of following algorithms: AES-CBC, AES-KW, HMAC, RSAES-PKCS1-V1_5, RSASSA-PKCS1-V1_5, and RSA-OAEP. 3. It replaces SPECIALIZE_TYPE_TRAITS_CRYPTO_ALGORITHM_PARAMETERS with SPECIALIZE_TYPE_TRAITS_CRYPTO_ALGORITHM_PARAMETERS_DEPRECATED for deprecated params. 4. It fixes https://bugs.webkit.org/show_bug.cgi?id=129750 as well. Tests: crypto/subtle/aes-cbc-generate-key-length-128.html crypto/subtle/aes-cbc-generate-key-length-192.html crypto/subtle/aes-cbc-generate-key-length-256.html crypto/subtle/aes-generate-key-malformed-parameters.html crypto/subtle/aes-kw-generate-key.html crypto/subtle/generate-key-malformed-paramters.html crypto/subtle/hmac-generate-key-customized-length.html crypto/subtle/hmac-generate-key-hash-object.html crypto/subtle/hmac-generate-key-malformed-parameters.html crypto/subtle/hmac-generate-key-sha1.html crypto/subtle/hmac-generate-key-sha224.html crypto/subtle/hmac-generate-key-sha256.html crypto/subtle/hmac-generate-key-sha384.html crypto/subtle/hmac-generate-key-sha512.html crypto/subtle/rsa-generate-key-malformed-parameters.html crypto/subtle/rsa-oaep-generate-key.html crypto/subtle/rsaes-pkcs1-v1_5-generate-key-extractable.html crypto/subtle/rsaes-pkcs1-v1_5-generate-key.html crypto/subtle/rsassa-pkcs1-v1_5-generate-key.html crypto/webkitSubtle/hmac-generate-key.html: crypto/workers/subtle/aes-generate-key.html crypto/workers/subtle/hmac-generate-key.html crypto/workers/subtle/rsa-generate-key.html * CMakeLists.txt: * DerivedSources.make: * Modules/encryptedmedia/CDMSessionClearKey.cpp: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSSubtleCryptoCustom.cpp: Added. (WebCore::toHashIdentifier): (WebCore::normalizeCryptoAlgorithmParameters): (WebCore::cryptoKeyUsagesFromJSValue): (WebCore::createAlgorithm): (WebCore::rejectWithException): (WebCore::jsSubtleCryptoFunctionGenerateKeyPromise): (WebCore::JSSubtleCrypto::generateKey): * bindings/js/JSWebKitSubtleCryptoCustom.cpp: (WebCore::JSWebKitSubtleCrypto::generateKey): * crypto/CryptoAlgorithm.cpp: (WebCore::CryptoAlgorithm::generateKey): * crypto/CryptoAlgorithm.h: * crypto/CryptoAlgorithmParameters.h: Added. (WebCore::CryptoAlgorithmParameters::CryptoAlgorithmParameters): (WebCore::CryptoAlgorithmParameters::~CryptoAlgorithmParameters): (WebCore::CryptoAlgorithmParameters::parametersClass): * crypto/CryptoAlgorithmParameters.idl: Added. * crypto/CryptoAlgorithmParametersDeprecated.h: * crypto/CryptoKey.cpp: (WebCore::CryptoKey::setUsagesBitmap): * crypto/CryptoKey.h: * crypto/CryptoKeyPair.idl: * crypto/SubtleCrypto.idl: * crypto/algorithms/CryptoAlgorithmAES_CBC.cpp: (WebCore::CryptoAlgorithmAES_CBC::generateKey): * crypto/algorithms/CryptoAlgorithmAES_CBC.h: * crypto/algorithms/CryptoAlgorithmAES_KW.cpp: (WebCore::CryptoAlgorithmAES_KW::generateKey): * crypto/algorithms/CryptoAlgorithmAES_KW.h: * crypto/algorithms/CryptoAlgorithmHMAC.cpp: (WebCore::CryptoAlgorithmHMAC::generateKey): * crypto/algorithms/CryptoAlgorithmHMAC.h: * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp: (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::generateKey): * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h: * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp: (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::generateKey): * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h: * crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp: (WebCore::CryptoAlgorithmRSA_OAEP::generateKey): * crypto/algorithms/CryptoAlgorithmRSA_OAEP.h: * crypto/gnutls/CryptoKeyRSAGnuTLS.cpp: (WebCore::CryptoKeyRSA::generatePair): * crypto/keys/CryptoKeyAES.cpp: (WebCore::CryptoKeyAES::generate): * crypto/keys/CryptoKeyHMAC.cpp: (WebCore::CryptoKeyHMAC::generate): * crypto/keys/CryptoKeyRSA.h: * crypto/mac/CryptoKeyRSAMac.cpp: (WebCore::CryptoKeyRSA::generatePair): * crypto/parameters/AesKeyGenParams.idl: Added. * crypto/parameters/CryptoAlgorithmAesCbcParamsDeprecated.h: * crypto/parameters/CryptoAlgorithmAesKeyGenParams.h: Added. * crypto/parameters/CryptoAlgorithmAesKeyGenParamsDeprecated.h: * crypto/parameters/CryptoAlgorithmHmacKeyGenParams.h: Added. * crypto/parameters/CryptoAlgorithmHmacKeyParamsDeprecated.h: * crypto/parameters/CryptoAlgorithmHmacParamsDeprecated.h: * crypto/parameters/CryptoAlgorithmRsaHashedKeyGenParams.h: Added. * crypto/parameters/CryptoAlgorithmRsaKeyGenParams.h: Added. (WebCore::CryptoAlgorithmRsaKeyGenParams::arrayToVector): * crypto/parameters/CryptoAlgorithmRsaKeyGenParamsDeprecated.h: * crypto/parameters/CryptoAlgorithmRsaKeyParamsWithHashDeprecated.h: * crypto/parameters/CryptoAlgorithmRsaOaepParamsDeprecated.h: * crypto/parameters/CryptoAlgorithmRsaSsaParamsDeprecated.h: * crypto/parameters/HmacKeyGenParams.idl: Added. * crypto/parameters/RsaHashedKeyGenParams.idl: Added. * crypto/parameters/RsaKeyGenParams.idl: Added. LayoutTests: Besides adding tests for SubtleCrypto::generateKey related stuff and fixing HMAC. This patch also add shouldReject(_a, _rejectCallback, _resolveCallback, _message) in js-test-pre.js. * TestExpectations: * crypto/subtle/aes-cbc-generate-key-length-128-expected.txt: Added. * crypto/subtle/aes-cbc-generate-key-length-128.html: Added. * crypto/subtle/aes-cbc-generate-key-length-192-expected.txt: Added. * crypto/subtle/aes-cbc-generate-key-length-192.html: Added. * crypto/subtle/aes-cbc-generate-key-length-256-expected.txt: Added. * crypto/subtle/aes-cbc-generate-key-length-256.html: Added. * crypto/subtle/aes-generate-key-malformed-parameters-expected.txt: Added. * crypto/subtle/aes-generate-key-malformed-parameters.html: Added. * crypto/subtle/aes-kw-generate-key-expected.txt: Added. * crypto/subtle/aes-kw-generate-key.html: Added. * crypto/subtle/generate-key-malformed-paramters-expected.txt: Added. * crypto/subtle/generate-key-malformed-paramters.html: Added. * crypto/subtle/hmac-generate-key-customized-length-expected.txt: Added. * crypto/subtle/hmac-generate-key-customized-length.html: Added. * crypto/subtle/hmac-generate-key-hash-object-expected.txt: Added. * crypto/subtle/hmac-generate-key-hash-object.html: Added. * crypto/subtle/hmac-generate-key-malformed-parameters-expected.txt: Added. * crypto/subtle/hmac-generate-key-malformed-parameters.html: Added. * crypto/subtle/hmac-generate-key-sha1-expected.txt: Added. * crypto/subtle/hmac-generate-key-sha1.html: Added. * crypto/subtle/hmac-generate-key-sha224-expected.txt: Added. * crypto/subtle/hmac-generate-key-sha224.html: Added. * crypto/subtle/hmac-generate-key-sha256-expected.txt: Added. * crypto/subtle/hmac-generate-key-sha256.html: Added. * crypto/subtle/hmac-generate-key-sha384-expected.txt: Added. * crypto/subtle/hmac-generate-key-sha384.html: Added. * crypto/subtle/hmac-generate-key-sha512-expected.txt: Added. * crypto/subtle/hmac-generate-key-sha512.html: Added. * crypto/subtle/rsa-generate-key-malformed-parameters-expected.txt: Added. * crypto/subtle/rsa-generate-key-malformed-parameters.html: Added. * crypto/subtle/rsa-oaep-generate-key-expected.txt: Added. * crypto/subtle/rsa-oaep-generate-key.html: Added. * crypto/subtle/rsaes-pkcs1-v1_5-generate-key-expected.txt: Added. * crypto/subtle/rsaes-pkcs1-v1_5-generate-key-extractable-expected.txt: Added. * crypto/subtle/rsaes-pkcs1-v1_5-generate-key-extractable.html: Added. * crypto/subtle/rsaes-pkcs1-v1_5-generate-key.html: Added. * crypto/subtle/rsassa-pkcs1-v1_5-generate-key-expected.txt: Added. * crypto/subtle/rsassa-pkcs1-v1_5-generate-key.html: Added. * crypto/webkitSubtle/hmac-generate-key-expected.txt: * crypto/webkitSubtle/hmac-generate-key.html: * crypto/workers/subtle/aes-generate-key-expected.txt: Added. * crypto/workers/subtle/aes-generate-key.html: Added. * crypto/workers/subtle/hmac-generate-key-expected.txt: Added. * crypto/workers/subtle/hmac-generate-key.html: Added. * crypto/workers/subtle/resources/aes-generate-key.js: Added. * crypto/workers/subtle/resources/hmac-generate-key.js: Added. * crypto/workers/subtle/resources/rsa-generate-key.js: Added. * crypto/workers/subtle/rsa-generate-key-expected.txt: Added. * crypto/workers/subtle/rsa-generate-key.html: Added. * resources/js-test-pre.js: Canonical link: https://commits.webkit.org/181666@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207809 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-25 06:07:04 +00:00
PASS crypto.subtle.generateKey({name: "aes-cbc", length: Symbol()}, extractable, ["encrypt", "decrypt"]) rejected promise with TypeError: Cannot convert a symbol to a number.
Add support for ImplementedAs, Clamp, EnforceRange, TreatNullAs for dictionary members https://bugs.webkit.org/show_bug.cgi?id=169731 Reviewed by Alex Christensen. LayoutTests/imported/w3c: Rebaseline tests. The results seem to show a problem in the original tests. * web-platform-tests/WebCryptoAPI/encrypt_decrypt/aes_gcm.worker-expected.txt: * web-platform-tests/WebCryptoAPI/encrypt_decrypt/test_aes_gcm-expected.txt: Source/WebCore: * bindings/scripts/CodeGeneratorJS.pm: (GenerateDictionaryImplementationContent): Create a new $implementationAsKey. Look for ImplementedAs, and if it exists, override the value with the alias. Set the parameters of convert<>() using JSValueToNative. (IsValidContextForJSValueToNative): Update to include IDLDictionaryMembers. (JSValueToNative): Bypass parseEnumeration serialization for enums if the context is an IDLDictionaryMember. Dictionary members need convert<IDLEnumeration> which throw a TypeError or return the enum (and utilizes parseEnumeration). parseEnumeration, in contrast, returns an optional. * bindings/scripts/test/TestObj.idl: Add test cases in TestDictionary. Update test results. * bindings/scripts/test/JS/JSTestEventConstructor.cpp: * bindings/scripts/test/JS/JSTestObj.cpp: * bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp: LayoutTests: Rebaseline. The enhancement progressed the results of these tests. * crypto/subtle/aes-gcm-encrypt-malformed-parameters-expected.txt: * crypto/subtle/aes-generate-key-malformed-parameters-expected.txt: * crypto/subtle/hmac-generate-key-malformed-parameters-expected.txt: Canonical link: https://commits.webkit.org/186799@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@214139 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-18 20:22:18 +00:00
PASS crypto.subtle.generateKey({name: "aes-cbc", length: { }}, extractable, ["encrypt", "decrypt"]) rejected promise with TypeError: Value NaN is outside the range [0, 65535].
PASS crypto.subtle.generateKey({name: "aes-cbc", length: "foo"}, extractable, ["encrypt", "decrypt"]) rejected promise with TypeError: Value NaN is outside the range [0, 65535].
PASS crypto.subtle.generateKey({name: "aes-cbc", length: 128}, extractable, ["sign"]) rejected promise with SyntaxError: A required parameter was missing or out-of-range.
PASS crypto.subtle.generateKey({name: "aes-cbc", length: 128}, extractable, ["verify"]) rejected promise with SyntaxError: A required parameter was missing or out-of-range.
PASS crypto.subtle.generateKey({name: "aes-cbc", length: 128}, extractable, ["deriveKey"]) rejected promise with SyntaxError: A required parameter was missing or out-of-range.
PASS crypto.subtle.generateKey({name: "aes-cbc", length: 128}, extractable, ["deriveBits"]) rejected promise with SyntaxError: A required parameter was missing or out-of-range.
PASS crypto.subtle.generateKey({name: "aes-kw", length: 128}, extractable, ["encrypt"]) rejected promise with SyntaxError: A required parameter was missing or out-of-range.
PASS crypto.subtle.generateKey({name: "aes-kw", length: 128}, extractable, ["decrypt"]) rejected promise with SyntaxError: A required parameter was missing or out-of-range.
PASS crypto.subtle.generateKey({name: "aes-kw", length: 128}, extractable, ["sign"]) rejected promise with SyntaxError: A required parameter was missing or out-of-range.
PASS crypto.subtle.generateKey({name: "aes-kw", length: 128}, extractable, ["verify"]) rejected promise with SyntaxError: A required parameter was missing or out-of-range.
PASS crypto.subtle.generateKey({name: "aes-kw", length: 128}, extractable, ["deriveKey"]) rejected promise with SyntaxError: A required parameter was missing or out-of-range.
PASS crypto.subtle.generateKey({name: "aes-kw", length: 128}, extractable, ["deriveBits"]) rejected promise with SyntaxError: A required parameter was missing or out-of-range.
PASS crypto.subtle.generateKey({name: "aes-cfb-8", length: 128}, extractable, ["sign"]) rejected promise with SyntaxError: A required parameter was missing or out-of-range.
PASS crypto.subtle.generateKey({name: "aes-cfb-8", length: 128}, extractable, ["verify"]) rejected promise with SyntaxError: A required parameter was missing or out-of-range.
PASS crypto.subtle.generateKey({name: "aes-cfb-8", length: 128}, extractable, ["deriveKey"]) rejected promise with SyntaxError: A required parameter was missing or out-of-range.
PASS crypto.subtle.generateKey({name: "aes-cfb-8", length: 128}, extractable, ["deriveBits"]) rejected promise with SyntaxError: A required parameter was missing or out-of-range.
PASS crypto.subtle.generateKey({name: "aes-gcm", length: 128}, extractable, ["sign"]) rejected promise with SyntaxError: A required parameter was missing or out-of-range.
PASS crypto.subtle.generateKey({name: "aes-gcm", length: 128}, extractable, ["verify"]) rejected promise with SyntaxError: A required parameter was missing or out-of-range.
PASS crypto.subtle.generateKey({name: "aes-gcm", length: 128}, extractable, ["deriveKey"]) rejected promise with SyntaxError: A required parameter was missing or out-of-range.
PASS crypto.subtle.generateKey({name: "aes-gcm", length: 128}, extractable, ["deriveBits"]) rejected promise with SyntaxError: A required parameter was missing or out-of-range.
PASS crypto.subtle.generateKey({name: "aes-ctr", length: 128}, extractable, ["sign"]) rejected promise with SyntaxError: A required parameter was missing or out-of-range.
PASS crypto.subtle.generateKey({name: "aes-ctr", length: 128}, extractable, ["verify"]) rejected promise with SyntaxError: A required parameter was missing or out-of-range.
PASS crypto.subtle.generateKey({name: "aes-ctr", length: 128}, extractable, ["deriveKey"]) rejected promise with SyntaxError: A required parameter was missing or out-of-range.
PASS crypto.subtle.generateKey({name: "aes-ctr", length: 128}, extractable, ["deriveBits"]) rejected promise with SyntaxError: A required parameter was missing or out-of-range.
PASS crypto.subtle.generateKey({name: "aes-cbc", length: 111}, extractable, ["encrypt"]) rejected promise with OperationError: The operation failed for an operation-specific reason.
PASS crypto.subtle.generateKey({name: "aes-kw", length: 111}, extractable, ["wrapKey"]) rejected promise with OperationError: The operation failed for an operation-specific reason.
Update SubtleCrypto::generateKey to match the latest spec https://bugs.webkit.org/show_bug.cgi?id=163718 <rdar://problem/28864380> Reviewed by Chris Dumez. LayoutTests/imported/w3c: * WebCryptoAPI/generateKey/test_aes-cbc-expected.txt: * WebCryptoAPI/generateKey/test_aes-cbc.html: * WebCryptoAPI/generateKey/test_aes-ctr-expected.txt: * WebCryptoAPI/generateKey/test_aes-ctr.html: * WebCryptoAPI/generateKey/test_failures-expected.txt: * WebCryptoAPI/generateKey/test_failures.html: * WebCryptoAPI/generateKey/test_failures_AES-CBC-expected.txt: * WebCryptoAPI/generateKey/test_failures_AES-CBC.html: * WebCryptoAPI/generateKey/test_failures_AES-CTR-expected.txt: * WebCryptoAPI/generateKey/test_failures_AES-CTR.html: * WebCryptoAPI/generateKey/test_failures_AES-GCM-expected.txt: * WebCryptoAPI/generateKey/test_failures_AES-GCM.html: * WebCryptoAPI/generateKey/test_failures_AES-KW-expected.txt: * WebCryptoAPI/generateKey/test_failures_AES-KW.html: * WebCryptoAPI/generateKey/test_failures_ECDH-expected.txt: * WebCryptoAPI/generateKey/test_failures_ECDH.html: * WebCryptoAPI/generateKey/test_failures_ECDSA-expected.txt: * WebCryptoAPI/generateKey/test_failures_ECDSA.html: * WebCryptoAPI/generateKey/test_failures_HMAC-expected.txt: * WebCryptoAPI/generateKey/test_failures_HMAC.html: * WebCryptoAPI/generateKey/test_failures_RSA-OAEP-expected.txt: * WebCryptoAPI/generateKey/test_failures_RSA-OAEP.html: * WebCryptoAPI/generateKey/test_failures_RSA-PSS-expected.txt: * WebCryptoAPI/generateKey/test_failures_RSA-PSS.html: * WebCryptoAPI/generateKey/test_failures_RSASSA-PKCS1-v1_5-expected.txt: * WebCryptoAPI/generateKey/test_failures_RSASSA-PKCS1-v1_5.html: * WebCryptoAPI/generateKey/test_successes-expected.txt: * WebCryptoAPI/generateKey/test_successes.html: * WebCryptoAPI/generateKey/test_successes_AES-CBC-expected.txt: * WebCryptoAPI/generateKey/test_successes_AES-CBC.html: * WebCryptoAPI/generateKey/test_successes_AES-CTR-expected.txt: * WebCryptoAPI/generateKey/test_successes_AES-CTR.html: * WebCryptoAPI/generateKey/test_successes_AES-GCM-expected.txt: * WebCryptoAPI/generateKey/test_successes_AES-GCM.html: * WebCryptoAPI/generateKey/test_successes_AES-KW-expected.txt: * WebCryptoAPI/generateKey/test_successes_AES-KW.html: * WebCryptoAPI/generateKey/test_successes_ECDH-expected.txt: * WebCryptoAPI/generateKey/test_successes_ECDH.html: * WebCryptoAPI/generateKey/test_successes_ECDSA-expected.txt: * WebCryptoAPI/generateKey/test_successes_ECDSA.html: * WebCryptoAPI/generateKey/test_successes_HMAC-expected.txt: * WebCryptoAPI/generateKey/test_successes_HMAC.html: * WebCryptoAPI/generateKey/test_successes_RSA-OAEP-expected.txt: * WebCryptoAPI/generateKey/test_successes_RSA-OAEP.html: * WebCryptoAPI/generateKey/test_successes_RSA-PSS-expected.txt: * WebCryptoAPI/generateKey/test_successes_RSA-PSS.html: * WebCryptoAPI/generateKey/test_successes_RSASSA-PKCS1-v1_5-expected.txt: * WebCryptoAPI/generateKey/test_successes_RSASSA-PKCS1-v1_5.html: * WebCryptoAPI/idlharness-expected.txt: Source/WebCore: This patch does following few things: 1. It updates the SubtleCrypto::generateKey method to match the latest spec: https://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-generateKey. It also refers to the latest Editor's Draft at a certain degree: https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-generateKey. 2. It implements generateKey operations of following algorithms: AES-CBC, AES-KW, HMAC, RSAES-PKCS1-V1_5, RSASSA-PKCS1-V1_5, and RSA-OAEP. 3. It replaces SPECIALIZE_TYPE_TRAITS_CRYPTO_ALGORITHM_PARAMETERS with SPECIALIZE_TYPE_TRAITS_CRYPTO_ALGORITHM_PARAMETERS_DEPRECATED for deprecated params. 4. It fixes https://bugs.webkit.org/show_bug.cgi?id=129750 as well. Tests: crypto/subtle/aes-cbc-generate-key-length-128.html crypto/subtle/aes-cbc-generate-key-length-192.html crypto/subtle/aes-cbc-generate-key-length-256.html crypto/subtle/aes-generate-key-malformed-parameters.html crypto/subtle/aes-kw-generate-key.html crypto/subtle/generate-key-malformed-paramters.html crypto/subtle/hmac-generate-key-customized-length.html crypto/subtle/hmac-generate-key-hash-object.html crypto/subtle/hmac-generate-key-malformed-parameters.html crypto/subtle/hmac-generate-key-sha1.html crypto/subtle/hmac-generate-key-sha224.html crypto/subtle/hmac-generate-key-sha256.html crypto/subtle/hmac-generate-key-sha384.html crypto/subtle/hmac-generate-key-sha512.html crypto/subtle/rsa-generate-key-malformed-parameters.html crypto/subtle/rsa-oaep-generate-key.html crypto/subtle/rsaes-pkcs1-v1_5-generate-key-extractable.html crypto/subtle/rsaes-pkcs1-v1_5-generate-key.html crypto/subtle/rsassa-pkcs1-v1_5-generate-key.html crypto/webkitSubtle/hmac-generate-key.html: crypto/workers/subtle/aes-generate-key.html crypto/workers/subtle/hmac-generate-key.html crypto/workers/subtle/rsa-generate-key.html * CMakeLists.txt: * DerivedSources.make: * Modules/encryptedmedia/CDMSessionClearKey.cpp: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSSubtleCryptoCustom.cpp: Added. (WebCore::toHashIdentifier): (WebCore::normalizeCryptoAlgorithmParameters): (WebCore::cryptoKeyUsagesFromJSValue): (WebCore::createAlgorithm): (WebCore::rejectWithException): (WebCore::jsSubtleCryptoFunctionGenerateKeyPromise): (WebCore::JSSubtleCrypto::generateKey): * bindings/js/JSWebKitSubtleCryptoCustom.cpp: (WebCore::JSWebKitSubtleCrypto::generateKey): * crypto/CryptoAlgorithm.cpp: (WebCore::CryptoAlgorithm::generateKey): * crypto/CryptoAlgorithm.h: * crypto/CryptoAlgorithmParameters.h: Added. (WebCore::CryptoAlgorithmParameters::CryptoAlgorithmParameters): (WebCore::CryptoAlgorithmParameters::~CryptoAlgorithmParameters): (WebCore::CryptoAlgorithmParameters::parametersClass): * crypto/CryptoAlgorithmParameters.idl: Added. * crypto/CryptoAlgorithmParametersDeprecated.h: * crypto/CryptoKey.cpp: (WebCore::CryptoKey::setUsagesBitmap): * crypto/CryptoKey.h: * crypto/CryptoKeyPair.idl: * crypto/SubtleCrypto.idl: * crypto/algorithms/CryptoAlgorithmAES_CBC.cpp: (WebCore::CryptoAlgorithmAES_CBC::generateKey): * crypto/algorithms/CryptoAlgorithmAES_CBC.h: * crypto/algorithms/CryptoAlgorithmAES_KW.cpp: (WebCore::CryptoAlgorithmAES_KW::generateKey): * crypto/algorithms/CryptoAlgorithmAES_KW.h: * crypto/algorithms/CryptoAlgorithmHMAC.cpp: (WebCore::CryptoAlgorithmHMAC::generateKey): * crypto/algorithms/CryptoAlgorithmHMAC.h: * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp: (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::generateKey): * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h: * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp: (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::generateKey): * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h: * crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp: (WebCore::CryptoAlgorithmRSA_OAEP::generateKey): * crypto/algorithms/CryptoAlgorithmRSA_OAEP.h: * crypto/gnutls/CryptoKeyRSAGnuTLS.cpp: (WebCore::CryptoKeyRSA::generatePair): * crypto/keys/CryptoKeyAES.cpp: (WebCore::CryptoKeyAES::generate): * crypto/keys/CryptoKeyHMAC.cpp: (WebCore::CryptoKeyHMAC::generate): * crypto/keys/CryptoKeyRSA.h: * crypto/mac/CryptoKeyRSAMac.cpp: (WebCore::CryptoKeyRSA::generatePair): * crypto/parameters/AesKeyGenParams.idl: Added. * crypto/parameters/CryptoAlgorithmAesCbcParamsDeprecated.h: * crypto/parameters/CryptoAlgorithmAesKeyGenParams.h: Added. * crypto/parameters/CryptoAlgorithmAesKeyGenParamsDeprecated.h: * crypto/parameters/CryptoAlgorithmHmacKeyGenParams.h: Added. * crypto/parameters/CryptoAlgorithmHmacKeyParamsDeprecated.h: * crypto/parameters/CryptoAlgorithmHmacParamsDeprecated.h: * crypto/parameters/CryptoAlgorithmRsaHashedKeyGenParams.h: Added. * crypto/parameters/CryptoAlgorithmRsaKeyGenParams.h: Added. (WebCore::CryptoAlgorithmRsaKeyGenParams::arrayToVector): * crypto/parameters/CryptoAlgorithmRsaKeyGenParamsDeprecated.h: * crypto/parameters/CryptoAlgorithmRsaKeyParamsWithHashDeprecated.h: * crypto/parameters/CryptoAlgorithmRsaOaepParamsDeprecated.h: * crypto/parameters/CryptoAlgorithmRsaSsaParamsDeprecated.h: * crypto/parameters/HmacKeyGenParams.idl: Added. * crypto/parameters/RsaHashedKeyGenParams.idl: Added. * crypto/parameters/RsaKeyGenParams.idl: Added. LayoutTests: Besides adding tests for SubtleCrypto::generateKey related stuff and fixing HMAC. This patch also add shouldReject(_a, _rejectCallback, _resolveCallback, _message) in js-test-pre.js. * TestExpectations: * crypto/subtle/aes-cbc-generate-key-length-128-expected.txt: Added. * crypto/subtle/aes-cbc-generate-key-length-128.html: Added. * crypto/subtle/aes-cbc-generate-key-length-192-expected.txt: Added. * crypto/subtle/aes-cbc-generate-key-length-192.html: Added. * crypto/subtle/aes-cbc-generate-key-length-256-expected.txt: Added. * crypto/subtle/aes-cbc-generate-key-length-256.html: Added. * crypto/subtle/aes-generate-key-malformed-parameters-expected.txt: Added. * crypto/subtle/aes-generate-key-malformed-parameters.html: Added. * crypto/subtle/aes-kw-generate-key-expected.txt: Added. * crypto/subtle/aes-kw-generate-key.html: Added. * crypto/subtle/generate-key-malformed-paramters-expected.txt: Added. * crypto/subtle/generate-key-malformed-paramters.html: Added. * crypto/subtle/hmac-generate-key-customized-length-expected.txt: Added. * crypto/subtle/hmac-generate-key-customized-length.html: Added. * crypto/subtle/hmac-generate-key-hash-object-expected.txt: Added. * crypto/subtle/hmac-generate-key-hash-object.html: Added. * crypto/subtle/hmac-generate-key-malformed-parameters-expected.txt: Added. * crypto/subtle/hmac-generate-key-malformed-parameters.html: Added. * crypto/subtle/hmac-generate-key-sha1-expected.txt: Added. * crypto/subtle/hmac-generate-key-sha1.html: Added. * crypto/subtle/hmac-generate-key-sha224-expected.txt: Added. * crypto/subtle/hmac-generate-key-sha224.html: Added. * crypto/subtle/hmac-generate-key-sha256-expected.txt: Added. * crypto/subtle/hmac-generate-key-sha256.html: Added. * crypto/subtle/hmac-generate-key-sha384-expected.txt: Added. * crypto/subtle/hmac-generate-key-sha384.html: Added. * crypto/subtle/hmac-generate-key-sha512-expected.txt: Added. * crypto/subtle/hmac-generate-key-sha512.html: Added. * crypto/subtle/rsa-generate-key-malformed-parameters-expected.txt: Added. * crypto/subtle/rsa-generate-key-malformed-parameters.html: Added. * crypto/subtle/rsa-oaep-generate-key-expected.txt: Added. * crypto/subtle/rsa-oaep-generate-key.html: Added. * crypto/subtle/rsaes-pkcs1-v1_5-generate-key-expected.txt: Added. * crypto/subtle/rsaes-pkcs1-v1_5-generate-key-extractable-expected.txt: Added. * crypto/subtle/rsaes-pkcs1-v1_5-generate-key-extractable.html: Added. * crypto/subtle/rsaes-pkcs1-v1_5-generate-key.html: Added. * crypto/subtle/rsassa-pkcs1-v1_5-generate-key-expected.txt: Added. * crypto/subtle/rsassa-pkcs1-v1_5-generate-key.html: Added. * crypto/webkitSubtle/hmac-generate-key-expected.txt: * crypto/webkitSubtle/hmac-generate-key.html: * crypto/workers/subtle/aes-generate-key-expected.txt: Added. * crypto/workers/subtle/aes-generate-key.html: Added. * crypto/workers/subtle/hmac-generate-key-expected.txt: Added. * crypto/workers/subtle/hmac-generate-key.html: Added. * crypto/workers/subtle/resources/aes-generate-key.js: Added. * crypto/workers/subtle/resources/hmac-generate-key.js: Added. * crypto/workers/subtle/resources/rsa-generate-key.js: Added. * crypto/workers/subtle/rsa-generate-key-expected.txt: Added. * crypto/workers/subtle/rsa-generate-key.html: Added. * resources/js-test-pre.js: Canonical link: https://commits.webkit.org/181666@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207809 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-25 06:07:04 +00:00
PASS successfullyParsed is true
TEST COMPLETE