haikuwebkit/LayoutTests/crypto/subtle/rsa-pss-generate-export-key...

43 lines
1001 B
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 exporting a RSA-PSS public key with SPKI format.");
jsTestIsAsync = true;
var algorithmKeyGen = {
name: "RSA-PSS",
// RsaKeyGenParams
modulusLength: 2048,
publicExponent: new Uint8Array([0x01, 0x00, 0x01]), // Equivalent to 65537
hash: "sha-1",
};
var extractable = true;
var keyPair;
debug("Generating a key pair...");
crypto.subtle.generateKey(algorithmKeyGen, extractable, ["sign", "verify"]).then(function(result) {
keyPair = result;
debug("Exporting the public key...");
return crypto.subtle.exportKey("spki", keyPair.publicKey);
}).then(function(result) {
publicKey = result;
shouldBe("publicKey.byteLength", "294");
finishJSTest();
});
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>