haikuwebkit/LayoutTests/crypto/subtle/aes-cbc-generate-key-length...

16 lines
413 B
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 length 192 using AES-CBC algorithm.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Generating 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