haikuwebkit/LayoutTests/crypto/subtle/hkdf-import-key-derive-bits...

37 lines
1.1 KiB
HTML
Raw Permalink Normal View History

[WebCrypto] Support HKDF https://bugs.webkit.org/show_bug.cgi?id=170636 <rdar://problem/23539827> Reviewed by Brent Fulgham. LayoutTests/imported/w3c: * web-platform-tests/WebCryptoAPI/derive_bits_keys/hkdf.worker-expected.txt: * web-platform-tests/WebCryptoAPI/derive_bits_keys/test_hkdf-expected.txt: * web-platform-tests/WebCryptoAPI/import_export/symmetric_importKey.worker-expected.txt: * web-platform-tests/WebCryptoAPI/import_export/test_symmetric_importKey-expected.txt: Source/WebCore: This patch implements HKDF according to the spec: https://www.w3.org/TR/WebCryptoAPI/#hkdf. Supported operations include deriveKey, deriveBits, importKey and getKeyLength. Tests: crypto/subtle/ecdh-import-key-derive-hkdf-key.html crypto/subtle/hkdf-derive-bits-malformed-parametrs.html crypto/subtle/hkdf-import-key-derive-bits.html crypto/subtle/hkdf-import-key-derive-hmac-key.html crypto/subtle/hkdf-import-key-malformed-parameters.html crypto/subtle/hkdf-import-key.html crypto/workers/subtle/hkdf-import-key-derive-bits.html crypto/workers/subtle/hkdf-import-key-derive-hmac-key.html crypto/workers/subtle/hkdf-import-key.html * CMakeLists.txt: * DerivedSources.make: * PlatformGTK.cmake: * PlatformMac.cmake: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSCryptoAlgorithmDictionary.cpp: (WebCore::JSCryptoAlgorithmDictionary::createParametersForEncrypt): (WebCore::JSCryptoAlgorithmDictionary::createParametersForDecrypt): (WebCore::JSCryptoAlgorithmDictionary::createParametersForSign): (WebCore::JSCryptoAlgorithmDictionary::createParametersForVerify): (WebCore::JSCryptoAlgorithmDictionary::createParametersForDigest): (WebCore::JSCryptoAlgorithmDictionary::createParametersForGenerateKey): (WebCore::JSCryptoAlgorithmDictionary::createParametersForDeriveKey): (WebCore::JSCryptoAlgorithmDictionary::createParametersForDeriveBits): (WebCore::JSCryptoAlgorithmDictionary::createParametersForImportKey): (WebCore::JSCryptoAlgorithmDictionary::createParametersForExportKey): Rename HKDF_CTR to HKDF. * bindings/js/JSSubtleCryptoCustom.cpp: (WebCore::normalizeCryptoAlgorithmParameters): * bindings/js/SerializedScriptValue.cpp: (WebCore::CloneSerializer::write): (WebCore::CloneDeserializer::read): Rename HKDF_CTR to HKDF. * crypto/CommonCryptoUtilities.h: * crypto/CryptoAlgorithmIdentifier.h: * crypto/CryptoAlgorithmParameters.h: * crypto/algorithms/CryptoAlgorithmHKDF.cpp: Added. (WebCore::CryptoAlgorithmHKDF::create): (WebCore::CryptoAlgorithmHKDF::identifier): (WebCore::CryptoAlgorithmHKDF::deriveBits): (WebCore::CryptoAlgorithmHKDF::importKey): (WebCore::CryptoAlgorithmHKDF::getKeyLength): * crypto/algorithms/CryptoAlgorithmHKDF.h: Added. * crypto/gcrypt/CryptoAlgorithmHKDFGCrypt.cpp: Added. (WebCore::CryptoAlgorithmHKDF::platformDeriveBits): * crypto/mac/CryptoAlgorithmHKDFMac.cpp: Added. (WebCore::CryptoAlgorithmHKDF::platformDeriveBits): * crypto/mac/CryptoAlgorithmRegistryMac.cpp: (WebCore::CryptoAlgorithmRegistry::platformRegisterAlgorithms): * crypto/parameters/CryptoAlgorithmHkdfParams.h: Added. * crypto/parameters/HkdfParams.idl: Added. LayoutTests: * TestExpectations: * crypto/subtle/ecdh-import-key-derive-hkdf-key-expected.txt: Added. * crypto/subtle/ecdh-import-key-derive-hkdf-key.html: Added. * crypto/subtle/hkdf-derive-bits-malformed-parametrs-expected.txt: Added. * crypto/subtle/hkdf-derive-bits-malformed-parametrs.html: Added. * crypto/subtle/hkdf-import-key-derive-bits-expected.txt: Added. * crypto/subtle/hkdf-import-key-derive-bits.html: Added. * crypto/subtle/hkdf-import-key-derive-hmac-key-expected.txt: Added. * crypto/subtle/hkdf-import-key-derive-hmac-key.html: Added. * crypto/subtle/hkdf-import-key-expected.txt: Added. * crypto/subtle/hkdf-import-key-malformed-parameters-expected.txt: Added. * crypto/subtle/hkdf-import-key-malformed-parameters.html: Added. * crypto/subtle/hkdf-import-key.html: Added. * crypto/workers/subtle/hkdf-import-key-derive-bits-expected.txt: Added. * crypto/workers/subtle/hkdf-import-key-derive-bits.html: Added. * crypto/workers/subtle/hkdf-import-key-derive-hmac-key-expected.txt: Added. * crypto/workers/subtle/hkdf-import-key-derive-hmac-key.html: Added. * crypto/workers/subtle/hkdf-import-key-expected.txt: Added. * crypto/workers/subtle/hkdf-import-key.html: Added. * crypto/workers/subtle/resources/hkdf-import-key-derive-bits.js: Added. * crypto/workers/subtle/resources/hkdf-import-key-derive-hmac-key.js: Added. * crypto/workers/subtle/resources/hkdf-import-key.js: Added. Canonical link: https://commits.webkit.org/187799@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215382 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-15 00:17:09 +00:00
<!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 type="text/javascript">
description("Test HKDF deriveBits operation with an imported raw key");
jsTestIsAsync = true;
var nonExtractable = false;
var rawKey = hexStringToUint8Array("0b0b0b0b0b0b0b0b0b0b0b");
var info = hexStringToUint8Array("f0f1f2f3f4f5f6f7f8f9");
var salt = hexStringToUint8Array("000102030405060708090a0b0c");
var expectedDerivedKey = "085a01ea1b10f36933068b56efa5ad81a4f14b822f5b091568a9cdd4f155fda2c22e422478d305f3f896";
crypto.subtle.importKey("raw", rawKey, "HKDF", nonExtractable, ["deriveBits"]).then(function(baseKey) {
return crypto.subtle.deriveBits({name: "HKDF", salt: salt, info: info, hash: "sha-1"}, baseKey, 336);
}).then(function(result) {
derivedKey = result;
shouldBe("bytesToHexString(derivedKey)", "expectedDerivedKey");
finishJSTest();
});
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>