haikuwebkit/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-ke...

48 lines
1.8 KiB
HTML
Raw Permalink Normal View History

Update SubtleCrypto::verify to match the latest spec https://bugs.webkit.org/show_bug.cgi?id=164741 <rdar://problem/29257935> Reviewed by Brent Fulgham. LayoutTests/imported/w3c: * WebCryptoAPI/idlharness-expected.txt: Source/WebCore: This patch does following few things: 1. It updates the SubtleCrypto::verify method to match the latest spec: https://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-verify. It also refers to the latest Editor's Draft to a certain degree: https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-verify. 2. It implements verify operations of the following algorithms: HMAC, and RSASSA-PKCS1-V1_5. Tests: crypto/subtle/hmac-generate-key-sign-verify.html crypto/subtle/hmac-import-key-verify-sha1.html crypto/subtle/hmac-import-key-verify-sha224.html crypto/subtle/hmac-import-key-verify-sha256.html crypto/subtle/hmac-import-key-verify-sha384.html crypto/subtle/hmac-import-key-verify-sha512.html crypto/subtle/rsassa-pkcs1-v1_5-generate-key-sign-verify.html crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha1.html crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha224.html crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha256.html crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha384.html crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha512.html crypto/subtle/verify-malformed-parameters.html crypto/workers/subtle/hmac-import-key-verify.html crypto/workers/subtle/rsassa-pkcs1-v1_5-import-key-verify.html * bindings/js/JSSubtleCryptoCustom.cpp: (WebCore::normalizeCryptoAlgorithmParameters): (WebCore::jsSubtleCryptoFunctionVerifyPromise): (WebCore::JSSubtleCrypto::verify): * crypto/CryptoAlgorithm.cpp: (WebCore::CryptoAlgorithm::verify): * crypto/CryptoAlgorithm.h: * crypto/SubtleCrypto.idl: * crypto/algorithms/CryptoAlgorithmHMAC.cpp: (WebCore::CryptoAlgorithmHMAC::verify): * crypto/algorithms/CryptoAlgorithmHMAC.h: * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp: (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::verify): * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h: * crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp: (WebCore::CryptoAlgorithmHMAC::platformVerify): * crypto/gnutls/CryptoAlgorithmHMACGnuTLS.cpp: (WebCore::CryptoAlgorithmHMAC::platformVerify): * crypto/gnutls/CryptoAlgorithmRSASSA_PKCS1_v1_5GnuTLS.cpp: (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerify): * crypto/mac/CryptoAlgorithmHMACMac.cpp: (WebCore::CryptoAlgorithmHMAC::platformVerify): * crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp: (WebCore::verifyRSASSA_PKCS1_v1_5): (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerify): LayoutTests: Besides adding tests for SubtleCrypto::verify, it also enhances *generate-key-encrypt-decrypt tests. * crypto/subtle/aes-cbc-generate-key-encrypt-decrypt-expected.txt: * crypto/subtle/aes-cbc-generate-key-encrypt-decrypt.html: * crypto/subtle/hmac-generate-key-sign-verify-expected.txt: Added. * crypto/subtle/hmac-generate-key-sign-verify.html: Added. * crypto/subtle/hmac-import-key-verify-sha1-expected.txt: Added. * crypto/subtle/hmac-import-key-verify-sha1.html: Added. * crypto/subtle/hmac-import-key-verify-sha224-expected.txt: Added. * crypto/subtle/hmac-import-key-verify-sha224.html: Added. * crypto/subtle/hmac-import-key-verify-sha256-expected.txt: Added. * crypto/subtle/hmac-import-key-verify-sha256.html: Added. * crypto/subtle/hmac-import-key-verify-sha384-expected.txt: Added. * crypto/subtle/hmac-import-key-verify-sha384.html: Added. * crypto/subtle/hmac-import-key-verify-sha512-expected.txt: Added. * crypto/subtle/hmac-import-key-verify-sha512.html: Added. * crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-expected.txt: * crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-label-expected.txt: * crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-label.html: * crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt.html: * crypto/subtle/rsaes-pkcs1-v1_5-generate-key-encrypt-decrypt-expected.txt: * crypto/subtle/rsaes-pkcs1-v1_5-generate-key-encrypt-decrypt.html: * crypto/subtle/rsassa-pkcs1-v1_5-generate-key-sign-verify-expected.txt: Added. * crypto/subtle/rsassa-pkcs1-v1_5-generate-key-sign-verify.html: Added. * crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha1-expected.txt: Added. * crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha1.html: Added. * crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha224-expected.txt: Added. * crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha224.html: Added. * crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha256-expected.txt: Added. * crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha256.html: Added. * crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha384-expected.txt: Added. * crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha384.html: Added. * crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha512-expected.txt: Added. * crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha512.html: Added. * crypto/subtle/verify-malformed-parameters-expected.txt: Added. * crypto/subtle/verify-malformed-parameters.html: Added. * crypto/workers/subtle/hmac-import-key-verify-expected.txt: Added. * crypto/workers/subtle/hmac-import-key-verify.html: Added. * crypto/workers/subtle/resources/hmac-import-key-verify.js: Added. * crypto/workers/subtle/resources/rsassa-pkcs1-v1_5-import-key-verify.js: Added. * crypto/workers/subtle/rsassa-pkcs1-v1_5-import-key-verify-expected.txt: Added. * crypto/workers/subtle/rsassa-pkcs1-v1_5-import-key-verify.html: Added. Canonical link: https://commits.webkit.org/182836@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@209150 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-11-30 21:19:20 +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 verification with RSASSA-PKCS1-v1_5 SHA-1 using an imported key");
jsTestIsAsync = true;
var extractable = false;
var text = asciiToUint8Array("Hello, World!");
var rsaImportParams = {
name: "RSASSA-PKCS1-v1_5",
hash: "SHA-1",
}
var jwkKey = {
kty: "RSA",
alg: "RS1",
use: "sig",
key_ops: ["verify"],
ext: true,
n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
e: "AQAB",
};
var signature = hexStringToUint8Array("08b83a4a58aff1db76529fe97f6dc2b58914a56f08ebc73aebf740680fc524e721c30842759acacab8acdf6e31e7cc83dbe8a48ace80b6a6558a9df892e4c2a9276c154cd605e632c8b857855a064aea68550b660a15044a0917026e494a71e4fee99fa57941268545f338c8601baa9c4f2116f0eb5432cfee5e3ed9978876fed201647921e599101930a99a2b645a9a879bce8c24592729f1f62a3b83fe21475871273cdbbe8efa7be314cabd087fbe1931ddf3fb86cbff5176a27554726b54c43208200725c6ad71d335ee5e09f3bbff7164ddf5bc857a41c5961e6f9581459db0fd0f09ee251d63b7a01bd716f6f72632b5c0f9a2c4dc2257d1e342138c13");
crypto.subtle.importKey("jwk", jwkKey, rsaImportParams, extractable, ["verify"]).then(function(key) {
return crypto.subtle.verify("RSASSA-PKCS1-v1_5", key, signature, text);
}).then(function(result) {
verified = result;
shouldBeTrue("verified");
finishJSTest();
});
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>