haikuwebkit/LayoutTests/crypto/subtle/ecdh-import-key-derive-hmac...

16 lines
428 B
Plaintext
Raw Permalink Normal View History

[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
Test deriving HMAC Keys with imported ECDH base key
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS derivedKey.type is 'secret'
PASS derivedKey.extractable is true
PASS derivedKey.algorithm.name is 'HMAC'
PASS derivedKey.algorithm.length is 128
PASS derivedKey.algorithm.hash.name is 'SHA-1'
PASS derivedKey.usages is ['sign', 'verify']
PASS successfullyParsed is true
TEST COMPLETE