haikuwebkit/LayoutTests/crypto/subtle/rsa-pss-import-jwk-public-k...

48 lines
1.5 KiB
HTML
Raw Permalink Normal View History

[WebCrypto] Support RSA-PSS https://bugs.webkit.org/show_bug.cgi?id=170869 <rdar://problem/31640672> Reviewed by Brent Fulgham. Source/WebCore: This patch implements RSA-PSS according to the spec: https://www.w3.org/TR/WebCryptoAPI/#rsa-pss. Supported operations include sign, verify, generateKey, importKey and exportKey. Tests: crypto/subtle/rsa-pss-generate-export-key-jwk-sha1.html crypto/subtle/rsa-pss-generate-export-key-jwk-sha224.html crypto/subtle/rsa-pss-generate-export-key-jwk-sha256.html crypto/subtle/rsa-pss-generate-export-key-jwk-sha384.html crypto/subtle/rsa-pss-generate-export-key-jwk-sha512.html crypto/subtle/rsa-pss-generate-export-key-pkcs8.html crypto/subtle/rsa-pss-generate-export-key-spki.html crypto/subtle/rsa-pss-generate-key.html crypto/subtle/rsa-pss-import-jwk-private-key.html crypto/subtle/rsa-pss-import-jwk-public-key-empty-usages.html crypto/subtle/rsa-pss-import-jwk-public-key-sha1.html crypto/subtle/rsa-pss-import-jwk-public-key-sha224.html crypto/subtle/rsa-pss-import-jwk-public-key-sha256.html crypto/subtle/rsa-pss-import-jwk-public-key-sha384.html crypto/subtle/rsa-pss-import-jwk-public-key-sha512.html crypto/subtle/rsa-pss-import-key-sign-large-salt.html crypto/subtle/rsa-pss-import-key-sign.html crypto/subtle/rsa-pss-import-key-verify.html crypto/subtle/rsa-pss-import-pkcs8-key.html crypto/subtle/rsa-pss-import-spki-key-empty-usages.html crypto/subtle/rsa-pss-import-spki-key.html crypto/workers/subtle/rsa-pss-import-key-sign.html crypto/workers/subtle/rsa-pss-import-key-verify.html * CMakeLists.txt: * DerivedSources.make: * PlatformGTK.cmake: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSSubtleCryptoCustom.cpp: (WebCore::normalizeCryptoAlgorithmParameters): * crypto/CryptoAlgorithmParameters.h: * crypto/algorithms/CryptoAlgorithmRSA_PSS.cpp: Added. (WebCore::CryptoAlgorithmRSA_PSS::create): (WebCore::CryptoAlgorithmRSA_PSS::identifier): (WebCore::CryptoAlgorithmRSA_PSS::sign): (WebCore::CryptoAlgorithmRSA_PSS::verify): (WebCore::CryptoAlgorithmRSA_PSS::generateKey): (WebCore::CryptoAlgorithmRSA_PSS::importKey): (WebCore::CryptoAlgorithmRSA_PSS::exportKey): * crypto/algorithms/CryptoAlgorithmRSA_PSS.h: Added. * crypto/mac/CryptoAlgorithmECDSAMac.cpp: (WebCore::cryptoDigestAlgorithm): Deleted. Extract function cryptoDigestAlgorithm to a separate file. * crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp: (WebCore::cryptoDigestAlgorithm): Deleted. Extract function cryptoDigestAlgorithm to a separate file. * crypto/mac/CryptoAlgorithmRSA_PSSMac.cpp: Added. (WebCore::signRSA_PSS): (WebCore::verifyRSA_PSS): (WebCore::CryptoAlgorithmRSA_PSS::platformSign): (WebCore::CryptoAlgorithmRSA_PSS::platformVerify): * crypto/mac/CryptoAlgorithmRegistryMac.cpp: (WebCore::CryptoAlgorithmRegistry::platformRegisterAlgorithms): * crypto/mac/CryptoDigestAlgorithm.h: Added. (WebCore::cryptoDigestAlgorithm): Have cryptoDigestAlgorithm in a separate file. * crypto/parameters/CryptoAlgorithmRsaPssParams.h: Added. * crypto/parameters/RsaPssParams.idl: Added. Source/WTF: * wtf/Platform.h: Add a flag to enable RSA-PSS in the future. LayoutTests: * TestExpectations: Skip tests related to RSA-PSS for now. * crypto/subtle/rsa-generate-key-malformed-parameters-expected.txt: * crypto/subtle/rsa-generate-key-malformed-parameters.html: * crypto/subtle/rsa-import-key-malformed-parameters-expected.txt: * crypto/subtle/rsa-import-key-malformed-parameters.html: * crypto/subtle/rsa-pss-generate-export-key-jwk-sha1-expected.txt: Added. * crypto/subtle/rsa-pss-generate-export-key-jwk-sha1.html: Added. * crypto/subtle/rsa-pss-generate-export-key-jwk-sha224-expected.txt: Added. * crypto/subtle/rsa-pss-generate-export-key-jwk-sha224.html: Added. * crypto/subtle/rsa-pss-generate-export-key-jwk-sha256-expected.txt: Added. * crypto/subtle/rsa-pss-generate-export-key-jwk-sha256.html: Added. * crypto/subtle/rsa-pss-generate-export-key-jwk-sha384-expected.txt: Added. * crypto/subtle/rsa-pss-generate-export-key-jwk-sha384.html: Added. * crypto/subtle/rsa-pss-generate-export-key-jwk-sha512-expected.txt: Added. * crypto/subtle/rsa-pss-generate-export-key-jwk-sha512.html: Added. * crypto/subtle/rsa-pss-generate-export-key-pkcs8-expected.txt: Added. * crypto/subtle/rsa-pss-generate-export-key-pkcs8.html: Added. * crypto/subtle/rsa-pss-generate-export-key-spki-expected.txt: Added. * crypto/subtle/rsa-pss-generate-export-key-spki.html: Added. * crypto/subtle/rsa-pss-generate-key-expected.txt: Added. * crypto/subtle/rsa-pss-generate-key.html: Added. * crypto/subtle/rsa-pss-import-jwk-private-key-expected.txt: Added. * crypto/subtle/rsa-pss-import-jwk-private-key.html: Added. * crypto/subtle/rsa-pss-import-jwk-public-key-empty-usages-expected.txt: Added. * crypto/subtle/rsa-pss-import-jwk-public-key-empty-usages.html: Added. * crypto/subtle/rsa-pss-import-jwk-public-key-sha1-expected.txt: Added. * crypto/subtle/rsa-pss-import-jwk-public-key-sha1.html: Added. * crypto/subtle/rsa-pss-import-jwk-public-key-sha224-expected.txt: Added. * crypto/subtle/rsa-pss-import-jwk-public-key-sha224.html: Added. * crypto/subtle/rsa-pss-import-jwk-public-key-sha256-expected.txt: Added. * crypto/subtle/rsa-pss-import-jwk-public-key-sha256.html: Added. * crypto/subtle/rsa-pss-import-jwk-public-key-sha384-expected.txt: Added. * crypto/subtle/rsa-pss-import-jwk-public-key-sha384.html: Added. * crypto/subtle/rsa-pss-import-jwk-public-key-sha512-expected.txt: Added. * crypto/subtle/rsa-pss-import-jwk-public-key-sha512.html: Added. * crypto/subtle/rsa-pss-import-key-sign-expected.txt: Added. * crypto/subtle/rsa-pss-import-key-sign-large-salt-expected.txt: Added. * crypto/subtle/rsa-pss-import-key-sign-large-salt.html: Added. * crypto/subtle/rsa-pss-import-key-sign.html: Added. * crypto/subtle/rsa-pss-import-key-verify-expected.txt: Added. * crypto/subtle/rsa-pss-import-key-verify.html: Added. * crypto/subtle/rsa-pss-import-pkcs8-key-expected.txt: Added. * crypto/subtle/rsa-pss-import-pkcs8-key.html: Added. * crypto/subtle/rsa-pss-import-spki-key-empty-usages-expected.txt: Added. * crypto/subtle/rsa-pss-import-spki-key-empty-usages.html: Added. * crypto/subtle/rsa-pss-import-spki-key-expected.txt: Added. * crypto/subtle/rsa-pss-import-spki-key.html: Added. * crypto/workers/subtle/resources/rsa-pss-import-key-sign.js: Added. * crypto/workers/subtle/resources/rsa-pss-import-key-verify.js: Added. * crypto/workers/subtle/rsa-pss-import-key-sign-expected.txt: Added. * crypto/workers/subtle/rsa-pss-import-key-sign.html: Added. * crypto/workers/subtle/rsa-pss-import-key-verify-expected.txt: Added. * crypto/workers/subtle/rsa-pss-import-key-verify.html: Added. Canonical link: https://commits.webkit.org/189435@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@217315 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-05-24 00:33:23 +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 importing a JWK RSA-PSS public key with SHA-512");
jsTestIsAsync = true;
var jwkKey = {
kty: "RSA",
alg: "PS512",
use: "sig",
key_ops: ["verify"],
ext: true,
n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
e: "AQAB"
};
var extractable = true;
debug("Importing a key...");
crypto.subtle.importKey("jwk", jwkKey, {name: "RSA-PSS", hash: "SHA-512"}, extractable, ["verify"]).then(function(result) {
publicKey = result;
shouldBe("publicKey.toString()", "'[object CryptoKey]'");
shouldBe("publicKey.type", "'public'");
shouldBe("publicKey.extractable", "true");
shouldBe("publicKey.algorithm.name", "'RSA-PSS'");
shouldBe("publicKey.algorithm.modulusLength", "2048");
shouldBe("bytesToHexString(publicKey.algorithm.publicExponent)", "'010001'");
shouldBe("publicKey.algorithm.hash.name", "'SHA-512'");
shouldBe("publicKey.usages", "['verify']");
finishJSTest();
});
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>