haikuwebkit/LayoutTests/crypto/subtle/hmac-import-key-sign-sha384...

40 lines
1003 B
HTML
Raw Permalink Normal View History

Update SubtleCrypto::sign to match the latest spec https://bugs.webkit.org/show_bug.cgi?id=164740 <rdar://problem/29257864> Reviewed by Brent Fulgham. LayoutTests/imported/w3c: * WebCryptoAPI/idlharness-expected.txt: Source/WebCore: This patch does following few things: 1. It updates the SubtleCrypto::sign method to match the latest spec: https://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-sign. It also refers to the latest Editor's Draft to a certain degree: https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-sign. 2. It implements sign operations of the following algorithms: HMAC, and RSASSA-PKCS1-V1_5. 3. It also replaces promise.copyRef() with WTFMove(promise) for all the capture lists of exception callbacks in promise functions. Tests: crypto/subtle/hmac-import-key-sign-sha1.html crypto/subtle/hmac-import-key-sign-sha224.html crypto/subtle/hmac-import-key-sign-sha256.html crypto/subtle/hmac-import-key-sign-sha384.html crypto/subtle/hmac-import-key-sign-sha512.html crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha1.html crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha224.html crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha256.html crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha384.html crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha512.html crypto/subtle/sign-malformed-parameters.html crypto/workers/subtle/hmac-import-key-sign.html crypto/workers/subtle/rsassa-pkcs1-v1_5-import-key-sign.html * bindings/js/JSSubtleCryptoCustom.cpp: (WebCore::normalizeCryptoAlgorithmParameters): (WebCore::jsSubtleCryptoFunctionDecryptPromise): Fix a minor bug. (WebCore::jsSubtleCryptoFunctionEncryptPromise): (WebCore::jsSubtleCryptoFunctionDecryptPromise): (WebCore::jsSubtleCryptoFunctionSignPromise): (WebCore::jsSubtleCryptoFunctionGenerateKeyPromise): (WebCore::jsSubtleCryptoFunctionImportKeyPromise): (WebCore::jsSubtleCryptoFunctionExportKeyPromise): (WebCore::JSSubtleCrypto::sign): * crypto/CryptoAlgorithm.cpp: (WebCore::CryptoAlgorithm::sign): * crypto/CryptoAlgorithm.h: * crypto/SubtleCrypto.idl: * crypto/algorithms/CryptoAlgorithmHMAC.cpp: (WebCore::CryptoAlgorithmHMAC::sign): * crypto/algorithms/CryptoAlgorithmHMAC.h: * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp: (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::sign): * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h: * crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp: (WebCore::CryptoAlgorithmHMAC::platformSign): * crypto/gnutls/CryptoAlgorithmHMACGnuTLS.cpp: (WebCore::CryptoAlgorithmHMAC::platformSign): * crypto/gnutls/CryptoAlgorithmRSASSA_PKCS1_v1_5GnuTLS.cpp: (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign): * crypto/mac/CryptoAlgorithmHMACMac.cpp: (WebCore::commonCryptoHMACAlgorithm): (WebCore::calculateSignature): Remove a null guardance since the depending bug is resolved. (WebCore::CryptoAlgorithmHMAC::platformSign): (WebCore::CryptoAlgorithmHMAC::platformVerify): * crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp: (WebCore::signRSASSA_PKCS1_v1_5): (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign): LayoutTests: * crypto/subtle/hmac-import-key-sign-sha1-expected.txt: Added. * crypto/subtle/hmac-import-key-sign-sha1.html: Added. * crypto/subtle/hmac-import-key-sign-sha224-expected.txt: Added. * crypto/subtle/hmac-import-key-sign-sha224.html: Added. * crypto/subtle/hmac-import-key-sign-sha256-expected.txt: Added. * crypto/subtle/hmac-import-key-sign-sha256.html: Added. * crypto/subtle/hmac-import-key-sign-sha384-expected.txt: Added. * crypto/subtle/hmac-import-key-sign-sha384.html: Added. * crypto/subtle/hmac-import-key-sign-sha512-expected.txt: Added. * crypto/subtle/hmac-import-key-sign-sha512.html: Added. * crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha1-expected.txt: Added. * crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha1.html: Added. * crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha224-expected.txt: Added. * crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha224.html: Added. * crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha256-expected.txt: Added. * crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha256.html: Added. * crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha384-expected.txt: Added. * crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha384.html: Added. * crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha512-expected.txt: Added. * crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha512.html: Added. * crypto/subtle/sign-malformed-parameters-expected.txt: Added. * crypto/subtle/sign-malformed-parameters.html: Added. * crypto/workers/subtle/hmac-import-key-sign-expected.txt: Added. * crypto/workers/subtle/hmac-import-key-sign.html: Added. * crypto/workers/subtle/resources/hmac-import-key-sign.js: Added. * crypto/workers/subtle/resources/rsassa-pkcs1-v1_5-import-key-sign.js: Added. * crypto/workers/subtle/rsassa-pkcs1-v1_5-import-key-sign-expected.txt: Added. * crypto/workers/subtle/rsassa-pkcs1-v1_5-import-key-sign.html: Added. Canonical link: https://commits.webkit.org/182782@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@209092 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-11-29 22:52:03 +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 signing with HMAC SHA-384 using an imported key");
jsTestIsAsync = true;
var extractable = false;
var text = asciiToUint8Array("Hello, World!");
var hmacImportParams = {
name: "hmac",
hash: "sha-384",
}
var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
var expectedSignature = "5cfc6cba3135c99cb426d5d59bd33c5e212aac082f5ba57a1f70def2b3e987e3f3078be80f142221b6a8e23768dd994f";
crypto.subtle.importKey("raw", rawKey, hmacImportParams, extractable, ["sign", "verify"]).then(function(key) {
return crypto.subtle.sign("hmac", key, text);
}).then(function(result) {
signature = result;
shouldBe("bytesToHexString(signature)", "expectedSignature");
finishJSTest();
});
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>