haikuwebkit/LayoutTests/crypto/subtle/rsa-oaep-decrypt-malformed-...

51 lines
3.1 KiB
HTML
Raw Permalink Normal View History

Update SubtleCrypto::decrypt to match the latest spec https://bugs.webkit.org/show_bug.cgi?id=164739 <rdar://problem/29257848> Reviewed by Brent Fulgham. LayoutTests/imported/w3c: * WebCryptoAPI/encrypt_decrypt/test_aes_cbc-expected.txt: * WebCryptoAPI/idlharness-expected.txt: Source/WebCore: This patch does following few things: 1. It updates the SubtleCrypto::decrypt method to match the latest spec: https://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-decrypt. It also refers to the latest Editor's Draft to a certain degree: https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-decrypt. 2. It implements decrypt operations of the following algorithms: AES-CBC, RSAES-PKCS1-V1_5, and RSA-OAEP. Tests: crypto/subtle/aes-cbc-decrypt-malformed-parameters.html crypto/subtle/aes-cbc-generate-key-encrypt-decrypt.html crypto/subtle/aes-cbc-import-key-decrypt.html crypto/subtle/decrypt-malformed-parameters.html crypto/subtle/rsa-oaep-decrypt-malformed-parameters.html crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-label.html crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt.html crypto/subtle/rsa-oaep-import-key-decrypt-label.html crypto/subtle/rsa-oaep-import-key-decrypt.html crypto/subtle/rsaes-pkcs1-v1_5-generate-key-encrypt-decrypt.html crypto/subtle/rsaes-pkcs1-v1_5-import-key-decrypt.html crypto/workers/subtle/aes-cbc-import-key-decrypt.html crypto/workers/subtle/rsa-oaep-import-key-decrypt.html crypto/workers/subtle/rsaes-pkcs1-v1_5-import-key-decrypt.html * bindings/js/JSSubtleCryptoCustom.cpp: (WebCore::normalizeCryptoAlgorithmParameters): (WebCore::toCryptoKey): (WebCore::toVector): (WebCore::jsSubtleCryptoFunctionEncryptPromise): (WebCore::jsSubtleCryptoFunctionDecryptPromise): (WebCore::jsSubtleCryptoFunctionExportKeyPromise): (WebCore::JSSubtleCrypto::decrypt): * crypto/CryptoAlgorithm.cpp: (WebCore::CryptoAlgorithm::decrypt): * crypto/CryptoAlgorithm.h: * crypto/SubtleCrypto.idl: * crypto/algorithms/CryptoAlgorithmAES_CBC.cpp: (WebCore::CryptoAlgorithmAES_CBC::decrypt): * crypto/algorithms/CryptoAlgorithmAES_CBC.h: * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp: (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::decrypt): * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h: * crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp: (WebCore::CryptoAlgorithmRSA_OAEP::decrypt): * crypto/algorithms/CryptoAlgorithmRSA_OAEP.h: * crypto/gnutls/CryptoAlgorithmAES_CBCGnuTLS.cpp: (WebCore::CryptoAlgorithmAES_CBC::platformDecrypt): * crypto/gnutls/CryptoAlgorithmRSAES_PKCS1_v1_5GnuTLS.cpp: (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::platformDecrypt): * crypto/gnutls/CryptoAlgorithmRSA_OAEPGnuTLS.cpp: (WebCore::CryptoAlgorithmRSA_OAEP::platformDecrypt): * crypto/mac/CryptoAlgorithmAES_CBCMac.cpp: (WebCore::CryptoAlgorithmAES_CBC::platformDecrypt): * crypto/mac/CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp: (WebCore::decryptRSAES_PKCS1_v1_5): (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::platformDecrypt): * crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp: (WebCore::decryptRSA_OAEP): (WebCore::CryptoAlgorithmRSA_OAEP::platformDecrypt): LayoutTests: * crypto/subtle/aes-cbc-decrypt-malformed-parameters-expected.txt: Added. * crypto/subtle/aes-cbc-decrypt-malformed-parameters.html: Added. * crypto/subtle/aes-cbc-generate-key-encrypt-decrypt-expected.txt: Added. * crypto/subtle/aes-cbc-generate-key-encrypt-decrypt.html: Added. * crypto/subtle/aes-cbc-import-key-decrypt-expected.txt: Added. * crypto/subtle/aes-cbc-import-key-decrypt.html: Added. * crypto/subtle/decrypt-malformed-parameters-expected.txt: Added. * crypto/subtle/decrypt-malformed-parameters.html: Added. * crypto/subtle/rsa-oaep-decrypt-malformed-parameters-expected.txt: Added. * crypto/subtle/rsa-oaep-decrypt-malformed-parameters.html: Added. * crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-expected.txt: Added. * crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-label-expected.txt: Added. * crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-label.html: Added. * crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt.html: Added. * crypto/subtle/rsa-oaep-import-key-decrypt-expected.txt: Added. * crypto/subtle/rsa-oaep-import-key-decrypt-label-expected.txt: Added. * crypto/subtle/rsa-oaep-import-key-decrypt-label.html: Added. * crypto/subtle/rsa-oaep-import-key-decrypt.html: Added. * crypto/subtle/rsaes-pkcs1-v1_5-generate-key-encrypt-decrypt-expected.txt: Added. * crypto/subtle/rsaes-pkcs1-v1_5-generate-key-encrypt-decrypt.html: Added. * crypto/subtle/rsaes-pkcs1-v1_5-import-key-decrypt-expected.txt: Added. * crypto/subtle/rsaes-pkcs1-v1_5-import-key-decrypt.html: Added. * crypto/workers/subtle/aes-cbc-import-key-decrypt-expected.txt: Added. * crypto/workers/subtle/aes-cbc-import-key-decrypt.html: Added. * crypto/workers/subtle/resources/aes-cbc-import-key-decrypt.js: Added. * crypto/workers/subtle/resources/rsa-oaep-import-key-decrypt.js: Added. * crypto/workers/subtle/resources/rsaes-pkcs1-v1_5-import-key-decrypt.js: Added. * crypto/workers/subtle/rsa-oaep-import-key-decrypt-expected.txt: Added. * crypto/workers/subtle/rsa-oaep-import-key-decrypt.html: Added. * crypto/workers/subtle/rsaes-pkcs1-v1_5-import-key-decrypt-expected.txt: Added. * crypto/workers/subtle/rsaes-pkcs1-v1_5-import-key-decrypt.html: Added. Canonical link: https://commits.webkit.org/182627@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208918 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-11-19 04:38:59 +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 decrypting using RSA-OAEP with malformed parameters");
jsTestIsAsync = true;
var extractable = false;
var cipherText = hexStringToUint8Array("346dc8f3a158e494004cf82c0843ab1c1e7a612263a1c44d941309175a3d2598997be651f2d3419f89923843ca344414d45989e886aaa79573d96d4f3f777af3b2e9fcd44b51c00a8e4395bf54ac89d88559c712d49853de448e190fad886c45fa0742f2ddf18e5f6155eb7f38348217efd67c14ef141e81f3b1c1804b3bb437ef1b23a25dadb594985c500181208c74cd2068cbfdccc02db7113ed5e72d7a3543a78ec9c2070715e409ab10687762358f786c669e592e467107a13caaaadc3c341facf249baf743a3b93c49f73ea5634052f1a6ee46265e02391dd2cbcd4a523bfee8321470279fff63b87a4a53465b4736fb31ee99e9b0379761f3e630f636");
var jwkKey = {
kty: "RSA",
alg: "RSA-OAEP",
use: "enc",
key_ops: ["decrypt", "unwrapKey"],
ext: true,
n: "lxHN0N9VRZ0_pl0xv3-NXx70WnjkODSkQ5LjHXTFy3DOQsvkagFzD9HqYQezCmcewLjdK5PLwSesDoMdfL6tusBHcvyit1kvydYFQ3NLbENNkYsiBG5_nW4IQGL6JKbZ5iGdUop98QHKm6YZR1u4zrAtxM6bVEo05VvhjRS0M8yWoZVi-7Vdsc0LqI0Qdq_NoctX5Fu-AqiBN7Uo1HkYGcP2oC82J_J5cjw98BQiP5kDWThq9RK-X6S-EUALx_m4iG6iOYKTA3SQyf1xBqFaXXoEJjcckbOqkegecz5b-YWUh8iZPvhwnt-RZwpIbLJgKwz19ndkn9KvoEEw7YbEow",
e: "AQAB",
d: "cj5DkDakjM2bKduGWJREO-_zyEtuA1dD9doqKMd7IRuA0CDS7puEAS20-oXRDwfmyMXEdEUD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qzR-mL1rGIUQ5ARGhNcSsRlyKTqz5BlWlVKmXIx_p-DeVwPWiJJy4k_FqyBxrnxkzomHfrxk",
};
var rsaOaepParams = {
name: "rsa-oaep",
// Wrong label. Correct one is "WebKit.org"
label: asciiToUint8Array("apple.com"),
}
crypto.subtle.importKey("jwk", jwkKey, {name: "RSA-OAEP", hash: "SHA-1"}, extractable, ["decrypt"]).then(function(result) {
key = result;
// Wrong label.
shouldReject("crypto.subtle.decrypt(rsaOaepParams, key, cipherText)").then(finishJSTest);
});
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>