haikuwebkit/LayoutTests/crypto/subtle/aes-gcm-import-key-wrap-jwk...

43 lines
1.2 KiB
HTML
Raw Permalink Normal View History

WebCrypto API support for AES-GCM https://bugs.webkit.org/show_bug.cgi?id=157175 <rdar://problem/27311691> Reviewed by Brent Fulgham. LayoutTests/imported/w3c: * web-platform-tests/WebCryptoAPI/encrypt_decrypt/aes_gcm.worker-expected.txt: * web-platform-tests/WebCryptoAPI/encrypt_decrypt/test_aes_gcm-expected.txt: * web-platform-tests/WebCryptoAPI/generateKey/failures_AES-GCM.worker-expected.txt: * web-platform-tests/WebCryptoAPI/generateKey/successes_AES-GCM.worker-expected.txt: * web-platform-tests/WebCryptoAPI/generateKey/test_failures_AES-GCM-expected.txt: * web-platform-tests/WebCryptoAPI/generateKey/test_successes_AES-GCM-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 adds support for AES-GCM. Operations of AES-GCM include: encrypt, decrypt, generateKey, importKey, exportKey, wrapKey, and unwrapKey. https://www.w3.org/TR/WebCryptoAPI/#aes-gcm Tests: crypto/subtle/aes-gcm-decrypt-malformed-parameters.html crypto/subtle/aes-gcm-encrypt-malformed-parameters.html crypto/subtle/aes-gcm-generate-export-key-jwk-length-128.html crypto/subtle/aes-gcm-generate-export-key-jwk-length-192.html crypto/subtle/aes-gcm-generate-export-key-jwk-length-256.html crypto/subtle/aes-gcm-generate-export-raw-key.html crypto/subtle/aes-gcm-generate-key-encrypt-decrypt.html crypto/subtle/aes-gcm-generate-key.html crypto/subtle/aes-gcm-import-jwk-key-length-128.html crypto/subtle/aes-gcm-import-jwk-key-length-192.html crypto/subtle/aes-gcm-import-jwk-key-length-256.html crypto/subtle/aes-gcm-import-key-decrypt-additional-data-tag-length-32.html crypto/subtle/aes-gcm-import-key-decrypt-additional-data.html crypto/subtle/aes-gcm-import-key-decrypt-tagLengths.html crypto/subtle/aes-gcm-import-key-decrypt.html crypto/subtle/aes-gcm-import-key-encrypt-additional-data-tag-length-32.html crypto/subtle/aes-gcm-import-key-encrypt-additional-data.html crypto/subtle/aes-gcm-import-key-encrypt-tagLengths.html crypto/subtle/aes-gcm-import-key-encrypt.html crypto/subtle/aes-gcm-import-key-unwrap-jwk-key.html crypto/subtle/aes-gcm-import-key-unwrap-raw-key.html crypto/subtle/aes-gcm-import-key-wrap-jwk-key.html crypto/subtle/aes-gcm-import-key-wrap-raw-key.html crypto/subtle/aes-gcm-import-raw-key.html crypto/workers/subtle/aes-gcm-import-key-decrypt.html crypto/workers/subtle/aes-gcm-import-key-encrypt.html crypto/workers/subtle/aes-gcm-import-key-unwrap-key.html crypto/workers/subtle/aes-gcm-import-key-wrap-key.html * CMakeLists.txt: * DerivedSources.make: * PlatformGTK.cmake: * PlatformMac.cmake: Add CryptoAlgorithmAES_CFBMac.cpp as well. * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSSubtleCryptoCustom.cpp: (WebCore::normalizeCryptoAlgorithmParameters): Add support for AES-GCM. * crypto/CommonCryptoUtilities.h: Include SPI header for AES-GCM support. We have a mismatch SPI between different OS version. Therefore, a guardian is placed. * crypto/CryptoAlgorithmParameters.h: * crypto/algorithms/CryptoAlgorithmAES_GCM.cpp: Added. (WebCore::usagesAreInvalidForCryptoAlgorithmAES_GCM): (WebCore::tagLengthIsValid): (WebCore::CryptoAlgorithmAES_GCM::create): (WebCore::CryptoAlgorithmAES_GCM::identifier): (WebCore::CryptoAlgorithmAES_GCM::encrypt): (WebCore::CryptoAlgorithmAES_GCM::decrypt): (WebCore::CryptoAlgorithmAES_GCM::generateKey): (WebCore::CryptoAlgorithmAES_GCM::importKey): (WebCore::CryptoAlgorithmAES_GCM::exportKey): * crypto/algorithms/CryptoAlgorithmAES_GCM.h: Added. * crypto/gnutls/CryptoAlgorithmAES_GCMGnuTLS.cpp: Added. (WebCore::CryptoAlgorithmAES_GCM::platformEncrypt): (WebCore::CryptoAlgorithmAES_GCM::platformDecrypt): * crypto/mac/CryptoAlgorithmAES_GCMMac.cpp: Added. (WebCore::encryptAES_GCM): (WebCore::decyptAES_GCM): (WebCore::CryptoAlgorithmAES_GCM::platformEncrypt): (WebCore::CryptoAlgorithmAES_GCM::platformDecrypt): * crypto/mac/CryptoAlgorithmRegistryMac.cpp: (WebCore::CryptoAlgorithmRegistry::platformRegisterAlgorithms): * crypto/parameters/AesGcmParams.idl: Added. * crypto/parameters/CryptoAlgorithmAesGcmParams.h: Added. LayoutTests: This patch also adds some tests for AES-CFB. * crypto/subtle/aes-export-key-malformed-parameters-expected.txt: * crypto/subtle/aes-export-key-malformed-parameters.html: * crypto/subtle/aes-gcm-decrypt-malformed-parameters-expected.txt: Added. * crypto/subtle/aes-gcm-decrypt-malformed-parameters.html: Added. * crypto/subtle/aes-gcm-encrypt-malformed-parameters-expected.txt: Added. * crypto/subtle/aes-gcm-encrypt-malformed-parameters.html: Added. * crypto/subtle/aes-gcm-generate-export-key-jwk-length-128-expected.txt: Added. * crypto/subtle/aes-gcm-generate-export-key-jwk-length-128.html: Added. * crypto/subtle/aes-gcm-generate-export-key-jwk-length-192-expected.txt: Added. * crypto/subtle/aes-gcm-generate-export-key-jwk-length-192.html: Added. * crypto/subtle/aes-gcm-generate-export-key-jwk-length-256-expected.txt: Added. * crypto/subtle/aes-gcm-generate-export-key-jwk-length-256.html: Added. * crypto/subtle/aes-gcm-generate-export-raw-key-expected.txt: Added. * crypto/subtle/aes-gcm-generate-export-raw-key.html: Added. * crypto/subtle/aes-gcm-generate-key-encrypt-decrypt-expected.txt: Added. * crypto/subtle/aes-gcm-generate-key-encrypt-decrypt.html: Added. * crypto/subtle/aes-gcm-generate-key-expected.txt: Added. * crypto/subtle/aes-gcm-generate-key.html: Added. * crypto/subtle/aes-gcm-import-jwk-key-length-128-expected.txt: Added. * crypto/subtle/aes-gcm-import-jwk-key-length-128.html: Added. * crypto/subtle/aes-gcm-import-jwk-key-length-192-expected.txt: Added. * crypto/subtle/aes-gcm-import-jwk-key-length-192.html: Added. * crypto/subtle/aes-gcm-import-jwk-key-length-256-expected.txt: Added. * crypto/subtle/aes-gcm-import-jwk-key-length-256.html: Added. * crypto/subtle/aes-gcm-import-key-decrypt-additional-data-expected.txt: Added. * crypto/subtle/aes-gcm-import-key-decrypt-additional-data-tag-length-32-expected.txt: Added. * crypto/subtle/aes-gcm-import-key-decrypt-additional-data-tag-length-32.html: Added. * crypto/subtle/aes-gcm-import-key-decrypt-additional-data.html: Added. * crypto/subtle/aes-gcm-import-key-decrypt-expected.txt: Added. * crypto/subtle/aes-gcm-import-key-decrypt-tagLengths-expected.txt: Added. * crypto/subtle/aes-gcm-import-key-decrypt-tagLengths.html: Added. * crypto/subtle/aes-gcm-import-key-decrypt.html: Added. * crypto/subtle/aes-gcm-import-key-encrypt-additional-data-expected.txt: Added. * crypto/subtle/aes-gcm-import-key-encrypt-additional-data-tag-length-32-expected.txt: Added. * crypto/subtle/aes-gcm-import-key-encrypt-additional-data-tag-length-32.html: Added. * crypto/subtle/aes-gcm-import-key-encrypt-additional-data.html: Added. * crypto/subtle/aes-gcm-import-key-encrypt-expected.txt: Added. * crypto/subtle/aes-gcm-import-key-encrypt-tagLengths-expected.txt: Added. * crypto/subtle/aes-gcm-import-key-encrypt-tagLengths.html: Added. * crypto/subtle/aes-gcm-import-key-encrypt.html: Added. * crypto/subtle/aes-gcm-import-key-unwrap-jwk-key-expected.txt: Added. * crypto/subtle/aes-gcm-import-key-unwrap-jwk-key.html: Added. * crypto/subtle/aes-gcm-import-key-unwrap-raw-key-expected.txt: Added. * crypto/subtle/aes-gcm-import-key-unwrap-raw-key.html: Added. * crypto/subtle/aes-gcm-import-key-wrap-jwk-key-expected.txt: Added. * crypto/subtle/aes-gcm-import-key-wrap-jwk-key.html: Added. * crypto/subtle/aes-gcm-import-key-wrap-raw-key-expected.txt: Added. * crypto/subtle/aes-gcm-import-key-wrap-raw-key.html: Added. * crypto/subtle/aes-gcm-import-raw-key-expected.txt: Added. * crypto/subtle/aes-gcm-import-raw-key.html: Added. * crypto/subtle/aes-generate-key-malformed-parameters-expected.txt: * crypto/subtle/aes-generate-key-malformed-parameters.html: * crypto/subtle/aes-import-key-malformed-parameters-expected.txt: * crypto/subtle/aes-import-key-malformed-parameters.html: * crypto/workers/subtle/aes-gcm-import-key-decrypt-expected.txt: Added. * crypto/workers/subtle/aes-gcm-import-key-decrypt.html: Added. * crypto/workers/subtle/aes-gcm-import-key-encrypt-expected.txt: Added. * crypto/workers/subtle/aes-gcm-import-key-encrypt.html: Added. * crypto/workers/subtle/aes-gcm-import-key-unwrap-key-expected.txt: Added. * crypto/workers/subtle/aes-gcm-import-key-unwrap-key.html: Added. * crypto/workers/subtle/aes-gcm-import-key-wrap-key-expected.txt: Added. * crypto/workers/subtle/aes-gcm-import-key-wrap-key.html: Added. * crypto/workers/subtle/resources/aes-gcm-import-key-decrypt.js: Added. * crypto/workers/subtle/resources/aes-gcm-import-key-encrypt.js: Added. * crypto/workers/subtle/resources/aes-gcm-import-key-unwrap-key.js: Added. * crypto/workers/subtle/resources/aes-gcm-import-key-wrap-key.js: Added. Canonical link: https://commits.webkit.org/186130@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@213345 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-03 04:24:14 +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>
description("Test wrapping a JWK key with AES-GCM using an imported key");
jsTestIsAsync = true;
var extractable = true;
var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
var aesGcmParams = {
name: "aes-gcm",
iv: asciiToUint8Array("jnOw99oOZFLIEPMr"),
}
var expectWrappedKey = "cafd1c61a96285b95c291b6da304a8be03010b8f96e39fc5076d6c6d8a2a6a669fc76f425ad095b9c18eae86a3f9895998b912807840bcb8bfa9493bed2e27169bd7d61d834e38d0644543195a10c3f9d7e19703244b62e11408663ff142cf2f0c29a6c9df7555f2f77ba0";
crypto.subtle.importKey("raw", rawKey, "aes-gcm", extractable, ["wrapKey"]).then(function(result) {
wrappingKey = result;
return crypto.subtle.importKey("raw", rawKey, "aes-cbc", extractable, ["encrypt"]);
}).then(function(result) {
key = result;
return crypto.subtle.wrapKey("jwk", key, wrappingKey, aesGcmParams);
}).then(function(result) {
wrappedKey = result;
shouldBe("bytesToHexString(wrappedKey)", "expectWrappedKey");
finishJSTest();
});
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>