<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[208918] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/208918">208918</a></dd>
<dt>Author</dt> <dd>jiewen_tan@apple.com</dd>
<dt>Date</dt> <dd>2016-11-18 20:38:59 -0800 (Fri, 18 Nov 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>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.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cWebCryptoAPIencrypt_decrypttest_aes_cbcexpectedtxt">trunk/LayoutTests/imported/w3c/WebCryptoAPI/encrypt_decrypt/test_aes_cbc-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cWebCryptoAPIidlharnessexpectedtxt">trunk/LayoutTests/imported/w3c/WebCryptoAPI/idlharness-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSSubtleCryptoCustomcpp">trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoCryptoAlgorithmcpp">trunk/Source/WebCore/crypto/CryptoAlgorithm.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoCryptoAlgorithmh">trunk/Source/WebCore/crypto/CryptoAlgorithm.h</a></li>
<li><a href="#trunkSourceWebCorecryptoSubtleCryptoidl">trunk/Source/WebCore/crypto/SubtleCrypto.idl</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmAES_CBCcpp">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmAES_CBCh">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.h</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSAES_PKCS1_v1_5cpp">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSAES_PKCS1_v1_5h">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSA_OAEPcpp">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSA_OAEPh">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.h</a></li>
<li><a href="#trunkSourceWebCorecryptognutlsCryptoAlgorithmAES_CBCGnuTLScpp">trunk/Source/WebCore/crypto/gnutls/CryptoAlgorithmAES_CBCGnuTLS.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptognutlsCryptoAlgorithmRSAES_PKCS1_v1_5GnuTLScpp">trunk/Source/WebCore/crypto/gnutls/CryptoAlgorithmRSAES_PKCS1_v1_5GnuTLS.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptognutlsCryptoAlgorithmRSA_OAEPGnuTLScpp">trunk/Source/WebCore/crypto/gnutls/CryptoAlgorithmRSA_OAEPGnuTLS.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptomacCryptoAlgorithmAES_CBCMaccpp">trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_CBCMac.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptomacCryptoAlgorithmRSAES_PKCS1_v1_5Maccpp">trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptomacCryptoAlgorithmRSA_OAEPMaccpp">trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestscryptosubtleaescbcdecryptmalformedparametersexpectedtxt">trunk/LayoutTests/crypto/subtle/aes-cbc-decrypt-malformed-parameters-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleaescbcdecryptmalformedparametershtml">trunk/LayoutTests/crypto/subtle/aes-cbc-decrypt-malformed-parameters.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleaescbcgeneratekeyencryptdecryptexpectedtxt">trunk/LayoutTests/crypto/subtle/aes-cbc-generate-key-encrypt-decrypt-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleaescbcgeneratekeyencryptdecrypthtml">trunk/LayoutTests/crypto/subtle/aes-cbc-generate-key-encrypt-decrypt.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleaescbcimportkeydecryptexpectedtxt">trunk/LayoutTests/crypto/subtle/aes-cbc-import-key-decrypt-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleaescbcimportkeydecrypthtml">trunk/LayoutTests/crypto/subtle/aes-cbc-import-key-decrypt.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtledecryptmalformedparametersexpectedtxt">trunk/LayoutTests/crypto/subtle/decrypt-malformed-parameters-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtledecryptmalformedparametershtml">trunk/LayoutTests/crypto/subtle/decrypt-malformed-parameters.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaoaepdecryptmalformedparametersexpectedtxt">trunk/LayoutTests/crypto/subtle/rsa-oaep-decrypt-malformed-parameters-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaoaepdecryptmalformedparametershtml">trunk/LayoutTests/crypto/subtle/rsa-oaep-decrypt-malformed-parameters.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaoaepgeneratekeyencryptdecryptexpectedtxt">trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaoaepgeneratekeyencryptdecryptlabelexpectedtxt">trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-label-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaoaepgeneratekeyencryptdecryptlabelhtml">trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-label.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaoaepgeneratekeyencryptdecrypthtml">trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaoaepimportkeydecryptexpectedtxt">trunk/LayoutTests/crypto/subtle/rsa-oaep-import-key-decrypt-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaoaepimportkeydecryptlabelexpectedtxt">trunk/LayoutTests/crypto/subtle/rsa-oaep-import-key-decrypt-label-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaoaepimportkeydecryptlabelhtml">trunk/LayoutTests/crypto/subtle/rsa-oaep-import-key-decrypt-label.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaoaepimportkeydecrypthtml">trunk/LayoutTests/crypto/subtle/rsa-oaep-import-key-decrypt.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaespkcs1v1_5generatekeyencryptdecryptexpectedtxt">trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-generate-key-encrypt-decrypt-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaespkcs1v1_5generatekeyencryptdecrypthtml">trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-generate-key-encrypt-decrypt.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaespkcs1v1_5importkeydecryptexpectedtxt">trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-key-decrypt-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaespkcs1v1_5importkeydecrypthtml">trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-key-decrypt.html</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtleaescbcimportkeydecryptexpectedtxt">trunk/LayoutTests/crypto/workers/subtle/aes-cbc-import-key-decrypt-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtleaescbcimportkeydecrypthtml">trunk/LayoutTests/crypto/workers/subtle/aes-cbc-import-key-decrypt.html</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtleresourcesaescbcimportkeydecryptjs">trunk/LayoutTests/crypto/workers/subtle/resources/aes-cbc-import-key-decrypt.js</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtleresourcesrsaoaepimportkeydecryptjs">trunk/LayoutTests/crypto/workers/subtle/resources/rsa-oaep-import-key-decrypt.js</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtleresourcesrsaespkcs1v1_5importkeydecryptjs">trunk/LayoutTests/crypto/workers/subtle/resources/rsaes-pkcs1-v1_5-import-key-decrypt.js</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtlersaoaepimportkeydecryptexpectedtxt">trunk/LayoutTests/crypto/workers/subtle/rsa-oaep-import-key-decrypt-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtlersaoaepimportkeydecrypthtml">trunk/LayoutTests/crypto/workers/subtle/rsa-oaep-import-key-decrypt.html</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtlersaespkcs1v1_5importkeydecryptexpectedtxt">trunk/LayoutTests/crypto/workers/subtle/rsaes-pkcs1-v1_5-import-key-decrypt-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtlersaespkcs1v1_5importkeydecrypthtml">trunk/LayoutTests/crypto/workers/subtle/rsaes-pkcs1-v1_5-import-key-decrypt.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (208917 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-11-19 04:25:38 UTC (rev 208917)
+++ trunk/LayoutTests/ChangeLog        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -1,3 +1,43 @@
</span><ins>+2016-11-18 Jiewen Tan <jiewen_tan@apple.com>
+
+ Update SubtleCrypto::decrypt to match the latest spec
+ https://bugs.webkit.org/show_bug.cgi?id=164739
+ <rdar://problem/29257848>
+
+ Reviewed by Brent Fulgham.
+
+ * 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.
+
</ins><span class="cx"> 2016-11-18 Chris Dumez <cdumez@apple.com>
</span><span class="cx">
</span><span class="cx"> Unreviewed, rolling out r208837.
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtleaescbcdecryptmalformedparametersexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/aes-cbc-decrypt-malformed-parameters-expected.txt (0 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-cbc-decrypt-malformed-parameters-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/aes-cbc-decrypt-malformed-parameters-expected.txt        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+Test decrypting using AES-CBC with malformed parameters
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS crypto.subtle.decrypt({name: "aes-cbc", iv: asciiToUint8Array("")}, key, cipherText) rejected promise with OperationError (DOM Exception 34): The operation failed for an operation-specific reason.
+PASS crypto.subtle.decrypt({name: "aes-cbc", iv: asciiToUint8Array("j")}, key, cipherText) rejected promise with OperationError (DOM Exception 34): The operation failed for an operation-specific reason.
+PASS crypto.subtle.decrypt({name: "aes-cbc", iv: asciiToUint8Array("jnOw99oOZFLIEPMrd")}, key, cipherText) rejected promise with OperationError (DOM Exception 34): The operation failed for an operation-specific reason.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleaescbcdecryptmalformedparametershtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/aes-cbc-decrypt-malformed-parameters.html (0 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-cbc-decrypt-malformed-parameters.html         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/aes-cbc-decrypt-malformed-parameters.html        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -0,0 +1,34 @@
</span><ins>+<!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 AES-CBC with malformed parameters");
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var cipherText = hexStringToUint8Array("2ffa4618784dfd414b22c40c6330d022");
+var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
+
+crypto.subtle.importKey("raw", rawKey, "aes-cbc", extractable, ["decrypt"]).then(function(result) {
+ key = result;
+ // Wrong iv length
+ shouldReject('crypto.subtle.decrypt({name: "aes-cbc", iv: asciiToUint8Array("")}, key, cipherText)');
+ shouldReject('crypto.subtle.decrypt({name: "aes-cbc", iv: asciiToUint8Array("j")}, key, cipherText)');
+ shouldReject('crypto.subtle.decrypt({name: "aes-cbc", iv: asciiToUint8Array("jnOw99oOZFLIEPMrd")}, key, cipherText)');
+
+ finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleaescbcgeneratekeyencryptdecryptexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/aes-cbc-generate-key-encrypt-decrypt-expected.txt (0 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-cbc-generate-key-encrypt-decrypt-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/aes-cbc-generate-key-encrypt-decrypt-expected.txt        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -0,0 +1,13 @@
</span><ins>+Test encrypting&decrypting using AES-CBC algorithm with a generated 256bit key
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Generating a key...
+Encrypting...
+Decrypting...
+PASS bytesToASCIIString(decryptedText) is plainText
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleaescbcgeneratekeyencryptdecrypthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/aes-cbc-generate-key-encrypt-decrypt.html (0 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-cbc-generate-key-encrypt-decrypt.html         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/aes-cbc-generate-key-encrypt-decrypt.html        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -0,0 +1,40 @@
</span><ins>+<!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 encrypting&decrypting using AES-CBC algorithm with a generated 256bit key");
+
+jsTestIsAsync = true;
+var plainText = "Hello, World!";
+var aesCbcParams = {
+ name: "aes-cbc",
+ iv: asciiToUint8Array("jnOw99oOZFLIEPMr"),
+}
+
+debug("Generating a key...");
+crypto.subtle.generateKey({name: "aes-cbc", length: 256}, true, ["decrypt", "encrypt"]).then(function(result) {
+ key = result;
+ debug("Encrypting...");
+ return crypto.subtle.encrypt(aesCbcParams, key, asciiToUint8Array(plainText));
+}).then(function(cipherText) {
+ debug("Decrypting...");
+ return crypto.subtle.decrypt(aesCbcParams, key, cipherText);
+}).then(function(result) {
+ decryptedText = result;
+
+ shouldBe("bytesToASCIIString(decryptedText)", "plainText");
+
+ finishJSTest();
+});
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleaescbcimportkeydecryptexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/aes-cbc-import-key-decrypt-expected.txt (0 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-cbc-import-key-decrypt-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/aes-cbc-import-key-decrypt-expected.txt        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+Test decrypting using AES-CBC with an imported 128bit key
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS bytesToASCIIString(plainText) is expectedPlainText
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleaescbcimportkeydecrypthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/aes-cbc-import-key-decrypt.html (0 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-cbc-import-key-decrypt.html         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/aes-cbc-import-key-decrypt.html        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -0,0 +1,39 @@
</span><ins>+<!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 AES-CBC with an imported 128bit key");
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var cipherText = hexStringToUint8Array("2ffa4618784dfd414b22c40c6330d022");
+var aesCbcParams = {
+ name: "aes-cbc",
+ iv: asciiToUint8Array("jnOw99oOZFLIEPMr"),
+}
+var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
+var expectedPlainText = "Hello, World!";
+
+crypto.subtle.importKey("raw", rawKey, "aes-cbc", extractable, ["decrypt"]).then(function(key) {
+ return crypto.subtle.decrypt(aesCbcParams, key, cipherText);
+}).then(function(result) {
+ plainText = result;
+
+ shouldBe("bytesToASCIIString(plainText)", "expectedPlainText");
+
+ finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtledecryptmalformedparametersexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/decrypt-malformed-parameters-expected.txt (0 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/decrypt-malformed-parameters-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/decrypt-malformed-parameters-expected.txt        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+Test decrypting with malformed parameters
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS crypto.subtle.decrypt() rejected promise with TypeError: Not enough arguments.
+PASS crypto.subtle.decrypt(1) rejected promise with TypeError: Not enough arguments.
+PASS crypto.subtle.decrypt(1, 2) rejected promise with TypeError: Not enough arguments.
+PASS crypto.subtle.decrypt(aesCbcParams, wrongKey, cipherText) rejected promise with InvalidAccessError (DOM Exception 15): CryptoKey doesn't match AlgorithmIdentifier.
+PASS crypto.subtle.decrypt(aesCbcParams, wrongKey, cipherText) rejected promise with InvalidAccessError (DOM Exception 15): CryptoKey doesn't support decryption.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtledecryptmalformedparametershtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/decrypt-malformed-parameters.html (0 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/decrypt-malformed-parameters.html         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/decrypt-malformed-parameters.html        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -0,0 +1,45 @@
</span><ins>+<!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 with malformed parameters");
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var cipherText = hexStringToUint8Array("2ffa4618784dfd414b22c40c6330d022");
+var aesCbcParams = {
+ name: "aes-cbc",
+ iv: asciiToUint8Array("jnOw99oOZFLIEPMr"),
+}
+var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
+
+// Not enough arguments.
+shouldReject('crypto.subtle.decrypt()');
+shouldReject('crypto.subtle.decrypt(1)');
+shouldReject('crypto.subtle.decrypt(1, 2)');
+
+crypto.subtle.importKey("raw", rawKey, "aes-kw", extractable, ["wrapKey", "unwrapKey"]).then(function(result) {
+ wrongKey = result;
+ // Wrong algorithm identifier.
+ shouldReject('crypto.subtle.decrypt(aesCbcParams, wrongKey, cipherText)');
+
+ return crypto.subtle.importKey("raw", rawKey, "aes-cbc", extractable, ["wrapKey", "unwrapKey"]);
+}).then(function(result) {
+ wrongKey = result;
+ // Wrong usage.
+ return shouldReject('crypto.subtle.decrypt(aesCbcParams, wrongKey, cipherText)');
+}).then(finishJSTest);
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaoaepdecryptmalformedparametersexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-oaep-decrypt-malformed-parameters-expected.txt (0 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-decrypt-malformed-parameters-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-decrypt-malformed-parameters-expected.txt        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+Test decrypting using RSA-OAEP with malformed parameters
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS crypto.subtle.decrypt(rsaOaepParams, key, cipherText) rejected promise with OperationError (DOM Exception 34): The operation failed for an operation-specific reason.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaoaepdecryptmalformedparametershtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-oaep-decrypt-malformed-parameters.html (0 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-decrypt-malformed-parameters.html         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-decrypt-malformed-parameters.html        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -0,0 +1,50 @@
</span><ins>+<!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-oXRDwfmyMXEdEUDrGGtCxh6fzDPvs_T-JA3GUK4EgHo3xZcrlXDXlKCeil6Fnr0gISZOIh5dkBrcdVL4quBJe4ZZc5mVuAC7Ld13et0TxMJ4iALGrPuqPVUOGSYIcZ9idx5zKKBWhY3tPggEdKpnHBmPfTRO4yZaf0Nw1QXrgSMZY9ejeuaurAh4Q8o4-6-r8O2LUe7ufMh_ccKkXISEh4KdOnT17EM9BQTn9UNS9GoK2ZZU0U3io5DSu_kpasr4uOVWcGlE2wczOv2nkGwG39F3sFF0Q",
+ p: "x5vnco5j-TD6hTOzyN4DhkZ44m05NycxT6SUE2qTurT3-uze_L7TYutLRIRkovRMhTHZAr2pziRlasEs13PEz9Zvx1I_T68srsonrdbak-SFMecM7EjHc5C-J13gXhw9HIW28_Sx9rQ-JkGwEwE9PEdIUfuvdqpgh3SmXwPJrEs",
+ q: "wb9vllg_2n-kNge0bThg_7xu1UwTzipM8vxSUkkV2IipJKIAekkU3aAB8LoPhUI0-17pSGw3ETOO27t163TI9qIPpzLbhTH9aUi7qLGbKlzPlgnqP43Z0LHxc3xKDgit-Ar29QLaX2uoJBX6VVWvhmh7BIPDHNVM5GZjwWORYgk",
+ dp: "C2c8sa6wx2uk5Dcv7inAycr83PKgciYrCwG78-AC0IfGIu-lTYsZSG1ov2FQ3n5WYMWYQC_Vo5EwugiPJz_V3onBmQF53HOFefbSjXvYwNotQcyRUG5X9qIuOtGCH949H4QED6vK_u0NH-JgzLUlamwoFYbrXzwch6CCYKs2ukE",
+ dq: "hbtRloDLclHwUqr2yvzDV0IFbozYjtF706x-VfXEcnXB6ls34TBYirFLJZIH7H9KeseEVkz7pY_k5555QlCV9kbebxYXl9RtiiJ-BW6yH4d4caPeYIfU9MweUQxVQWKUUkWfOHcDrCFvKZlR9Vzzjt7HKtKX9mr0bCKQcIf9baE",
+ qi: "a-7hUTTnclUPKOfSgH8zEKGJ-AvdFEzxvZ5sq46Qf2MbORxVjN4dJamVvM-FoqcwN-9cuUlyr9bSFTwUBW4vXa8Xj9a8JfViuMCqzR-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>
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaoaepgeneratekeyencryptdecryptexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-expected.txt (0 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-expected.txt        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -0,0 +1,13 @@
</span><ins>+Test encrypting&decrypting using RSA-OAEP SHA-512 algorithm with a generated key
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Generating a key...
+Encrypting...
+Decrypting...
+PASS bytesToASCIIString(decryptedText) is plainText
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaoaepgeneratekeyencryptdecryptlabelexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-label-expected.txt (0 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-label-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-label-expected.txt        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -0,0 +1,13 @@
</span><ins>+Test encrypting&decrypting using RSA-OAEP SHA-512 algorithm with a generated key and a label
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Generating a key...
+Encrypting...
+Decrypting...
+PASS bytesToASCIIString(decryptedText) is plainText
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaoaepgeneratekeyencryptdecryptlabelhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-label.html (0 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-label.html         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-label.html        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -0,0 +1,47 @@
</span><ins>+<!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 encrypting&decrypting using RSA-OAEP SHA-512 algorithm with a generated key and a label");
+
+jsTestIsAsync = true;
+var plainText = "Hello, World!";
+var algorithmKeyGen = {
+ name: "RSA-OAEP",
+ // RsaKeyGenParams
+ modulusLength: 2048,
+ publicExponent: new Uint8Array([0x01, 0x00, 0x01]), // Equivalent to 65537
+ hash: "sha-512"
+};
+var rsaOaepParams = {
+ name: "rsa-oaep",
+ label: asciiToUint8Array("WebKit.org"),
+}
+
+debug("Generating a key...");
+crypto.subtle.generateKey(algorithmKeyGen, true, ["decrypt", "encrypt"]).then(function(result) {
+ keyPair = result;
+ debug("Encrypting...");
+ return crypto.subtle.encrypt(rsaOaepParams, keyPair.publicKey, asciiToUint8Array(plainText));
+}).then(function(cipherText) {
+ debug("Decrypting...");
+ return crypto.subtle.decrypt(rsaOaepParams, keyPair.privateKey, cipherText);
+}).then(function(result) {
+ decryptedText = result;
+
+ shouldBe("bytesToASCIIString(decryptedText)", "plainText");
+
+ finishJSTest();
+});
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaoaepgeneratekeyencryptdecrypthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt.html (0 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt.html         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt.html        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -0,0 +1,46 @@
</span><ins>+<!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 encrypting&decrypting using RSA-OAEP SHA-512 algorithm with a generated key");
+
+jsTestIsAsync = true;
+var plainText = "Hello, World!";
+var algorithmKeyGen = {
+ name: "RSA-OAEP",
+ // RsaKeyGenParams
+ modulusLength: 2048,
+ publicExponent: new Uint8Array([0x01, 0x00, 0x01]), // Equivalent to 65537
+ hash: "sha-512"
+};
+var rsaOaepParams = {
+ name: "rsa-oaep"
+}
+
+debug("Generating a key...");
+crypto.subtle.generateKey(algorithmKeyGen, true, ["decrypt", "encrypt"]).then(function(result) {
+ keyPair = result;
+ debug("Encrypting...");
+ return crypto.subtle.encrypt(rsaOaepParams, keyPair.publicKey, asciiToUint8Array(plainText));
+}).then(function(cipherText) {
+ debug("Decrypting...");
+ return crypto.subtle.decrypt(rsaOaepParams, keyPair.privateKey, cipherText);
+}).then(function(result) {
+ decryptedText = result;
+
+ shouldBe("bytesToASCIIString(decryptedText)", "plainText");
+
+ finishJSTest();
+});
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaoaepimportkeydecryptexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-oaep-import-key-decrypt-expected.txt (0 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-import-key-decrypt-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-import-key-decrypt-expected.txt        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+Test decrypting using RSA-OAEP SHA-1 with an imported key
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS bytesToASCIIString(plainText) is expectedPlainText
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaoaepimportkeydecryptlabelexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-oaep-import-key-decrypt-label-expected.txt (0 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-import-key-decrypt-label-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-import-key-decrypt-label-expected.txt        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+Test decrypting using RSA-OAEP SHA-1 with an imported key and a label
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS bytesToASCIIString(plainText) is expectedPlainText
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaoaepimportkeydecryptlabelhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-oaep-import-key-decrypt-label.html (0 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-import-key-decrypt-label.html         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-import-key-decrypt-label.html        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -0,0 +1,52 @@
</span><ins>+<!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 SHA-1 with an imported key and a label");
+
+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-oXRDwfmyMXEdEUDrGGtCxh6fzDPvs_T-JA3GUK4EgHo3xZcrlXDXlKCeil6Fnr0gISZOIh5dkBrcdVL4quBJe4ZZc5mVuAC7Ld13et0TxMJ4iALGrPuqPVUOGSYIcZ9idx5zKKBWhY3tPggEdKpnHBmPfTRO4yZaf0Nw1QXrgSMZY9ejeuaurAh4Q8o4-6-r8O2LUe7ufMh_ccKkXISEh4KdOnT17EM9BQTn9UNS9GoK2ZZU0U3io5DSu_kpasr4uOVWcGlE2wczOv2nkGwG39F3sFF0Q",
+ p: "x5vnco5j-TD6hTOzyN4DhkZ44m05NycxT6SUE2qTurT3-uze_L7TYutLRIRkovRMhTHZAr2pziRlasEs13PEz9Zvx1I_T68srsonrdbak-SFMecM7EjHc5C-J13gXhw9HIW28_Sx9rQ-JkGwEwE9PEdIUfuvdqpgh3SmXwPJrEs",
+ q: "wb9vllg_2n-kNge0bThg_7xu1UwTzipM8vxSUkkV2IipJKIAekkU3aAB8LoPhUI0-17pSGw3ETOO27t163TI9qIPpzLbhTH9aUi7qLGbKlzPlgnqP43Z0LHxc3xKDgit-Ar29QLaX2uoJBX6VVWvhmh7BIPDHNVM5GZjwWORYgk",
+ dp: "C2c8sa6wx2uk5Dcv7inAycr83PKgciYrCwG78-AC0IfGIu-lTYsZSG1ov2FQ3n5WYMWYQC_Vo5EwugiPJz_V3onBmQF53HOFefbSjXvYwNotQcyRUG5X9qIuOtGCH949H4QED6vK_u0NH-JgzLUlamwoFYbrXzwch6CCYKs2ukE",
+ dq: "hbtRloDLclHwUqr2yvzDV0IFbozYjtF706x-VfXEcnXB6ls34TBYirFLJZIH7H9KeseEVkz7pY_k5555QlCV9kbebxYXl9RtiiJ-BW6yH4d4caPeYIfU9MweUQxVQWKUUkWfOHcDrCFvKZlR9Vzzjt7HKtKX9mr0bCKQcIf9baE",
+ qi: "a-7hUTTnclUPKOfSgH8zEKGJ-AvdFEzxvZ5sq46Qf2MbORxVjN4dJamVvM-FoqcwN-9cuUlyr9bSFTwUBW4vXa8Xj9a8JfViuMCqzR-mL1rGIUQ5ARGhNcSsRlyKTqz5BlWlVKmXIx_p-DeVwPWiJJy4k_FqyBxrnxkzomHfrxk",
+};
+var rsaOaepParams = {
+ name: "rsa-oaep",
+ label: asciiToUint8Array("WebKit.org"),
+}
+var expectedPlainText = "Hello, World!";
+
+crypto.subtle.importKey("jwk", jwkKey, {name: "RSA-OAEP", hash: "SHA-1"}, extractable, ["decrypt"]).then(function(key) {
+ return crypto.subtle.decrypt(rsaOaepParams, key, cipherText);
+}).then(function(result) {
+ plainText = result;
+
+ shouldBe("bytesToASCIIString(plainText)", "expectedPlainText");
+
+ finishJSTest();
+});
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaoaepimportkeydecrypthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-oaep-import-key-decrypt.html (0 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-import-key-decrypt.html         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-import-key-decrypt.html        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -0,0 +1,52 @@
</span><ins>+<!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 SHA-1 with an imported key");
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var cipherText = hexStringToUint8Array("64ea45b5234b05666dc21ca6f7cd6ecb0be8ce4576c0bbe9686e70c9f3ab67a9f0a4db226554f217ba7259634c7b70eb422633277d83aeb2181a001099bacbca8b5b534a77843fe611f646838999e82e681f1d1724ef0e9f65ac3020128c56ea90a0345d936e8e226b363687c7b57146eecd4ab599760661a278671b5b249051b1f1720d6e78085e321ce82867df81a67b8606e340850b189fcd08d63b1ac8ce9a97300b8c15c3c475c97f1266606b48b67a15c28937d88e0749c83212737732c74a7fdf79188405c6df72b9ee2b753f4f70ae35f2f035c5827e0c87fcceeef1c4e303c0e89ecc76773fb58e6f5a06b792ae7a1b58ee7bf09893c8fd2b93da0d");
+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-oXRDwfmyMXEdEUDrGGtCxh6fzDPvs_T-JA3GUK4EgHo3xZcrlXDXlKCeil6Fnr0gISZOIh5dkBrcdVL4quBJe4ZZc5mVuAC7Ld13et0TxMJ4iALGrPuqPVUOGSYIcZ9idx5zKKBWhY3tPggEdKpnHBmPfTRO4yZaf0Nw1QXrgSMZY9ejeuaurAh4Q8o4-6-r8O2LUe7ufMh_ccKkXISEh4KdOnT17EM9BQTn9UNS9GoK2ZZU0U3io5DSu_kpasr4uOVWcGlE2wczOv2nkGwG39F3sFF0Q",
+ p: "x5vnco5j-TD6hTOzyN4DhkZ44m05NycxT6SUE2qTurT3-uze_L7TYutLRIRkovRMhTHZAr2pziRlasEs13PEz9Zvx1I_T68srsonrdbak-SFMecM7EjHc5C-J13gXhw9HIW28_Sx9rQ-JkGwEwE9PEdIUfuvdqpgh3SmXwPJrEs",
+ q: "wb9vllg_2n-kNge0bThg_7xu1UwTzipM8vxSUkkV2IipJKIAekkU3aAB8LoPhUI0-17pSGw3ETOO27t163TI9qIPpzLbhTH9aUi7qLGbKlzPlgnqP43Z0LHxc3xKDgit-Ar29QLaX2uoJBX6VVWvhmh7BIPDHNVM5GZjwWORYgk",
+ dp: "C2c8sa6wx2uk5Dcv7inAycr83PKgciYrCwG78-AC0IfGIu-lTYsZSG1ov2FQ3n5WYMWYQC_Vo5EwugiPJz_V3onBmQF53HOFefbSjXvYwNotQcyRUG5X9qIuOtGCH949H4QED6vK_u0NH-JgzLUlamwoFYbrXzwch6CCYKs2ukE",
+ dq: "hbtRloDLclHwUqr2yvzDV0IFbozYjtF706x-VfXEcnXB6ls34TBYirFLJZIH7H9KeseEVkz7pY_k5555QlCV9kbebxYXl9RtiiJ-BW6yH4d4caPeYIfU9MweUQxVQWKUUkWfOHcDrCFvKZlR9Vzzjt7HKtKX9mr0bCKQcIf9baE",
+ qi: "a-7hUTTnclUPKOfSgH8zEKGJ-AvdFEzxvZ5sq46Qf2MbORxVjN4dJamVvM-FoqcwN-9cuUlyr9bSFTwUBW4vXa8Xj9a8JfViuMCqzR-mL1rGIUQ5ARGhNcSsRlyKTqz5BlWlVKmXIx_p-DeVwPWiJJy4k_FqyBxrnxkzomHfrxk",
+};
+var rsaOaepParams = {
+ name: "rsa-oaep"
+}
+var expectedPlainText = "Hello, World!";
+
+crypto.subtle.importKey("jwk", jwkKey, {name: "RSA-OAEP", hash: "SHA-1"}, extractable, ["decrypt"]).then(function(key) {
+ return crypto.subtle.decrypt(rsaOaepParams, key, cipherText);
+}).then(function(result) {
+ plainText = result;
+
+ shouldBe("bytesToASCIIString(plainText)", "expectedPlainText");
+
+ finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaespkcs1v1_5generatekeyencryptdecryptexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-generate-key-encrypt-decrypt-expected.txt (0 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-generate-key-encrypt-decrypt-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-generate-key-encrypt-decrypt-expected.txt        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -0,0 +1,13 @@
</span><ins>+Test encrypting&decrypting using RSAES-PKCS1-v1_5 algorithm with a generated key
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Generating a key...
+Encrypting...
+Decrypting...
+PASS bytesToASCIIString(decryptedText) is plainText
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaespkcs1v1_5generatekeyencryptdecrypthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-generate-key-encrypt-decrypt.html (0 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-generate-key-encrypt-decrypt.html         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-generate-key-encrypt-decrypt.html        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -0,0 +1,42 @@
</span><ins>+<!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 encrypting&decrypting using RSAES-PKCS1-v1_5 algorithm with a generated key");
+
+jsTestIsAsync = true;
+var plainText = "Hello, World!";
+var algorithmKeyGen = {
+ name: "RSAES-PKCS1-v1_5",
+ // RsaKeyGenParams
+ modulusLength: 2048,
+ publicExponent: new Uint8Array([0x01, 0x00, 0x01]), // Equivalent to 65537
+};
+
+debug("Generating a key...");
+crypto.subtle.generateKey(algorithmKeyGen, true, ["decrypt", "encrypt"]).then(function(result) {
+ keyPair = result;
+ debug("Encrypting...");
+ return crypto.subtle.encrypt("RSAES-PKCS1-v1_5", keyPair.publicKey, asciiToUint8Array(plainText));
+}).then(function(cipherText) {
+ debug("Decrypting...");
+ return crypto.subtle.decrypt("RSAES-PKCS1-v1_5", keyPair.privateKey, cipherText);
+}).then(function(result) {
+ decryptedText = result;
+
+ shouldBe("bytesToASCIIString(decryptedText)", "plainText");
+
+ finishJSTest();
+});
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaespkcs1v1_5importkeydecryptexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-key-decrypt-expected.txt (0 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-key-decrypt-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-key-decrypt-expected.txt        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+Test decrypting using RSAES-PKCS1-v1_5 with an imported key
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS bytesToASCIIString(plainText) is expectedPlainText
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaespkcs1v1_5importkeydecrypthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-key-decrypt.html (0 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-key-decrypt.html         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-key-decrypt.html        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -0,0 +1,48 @@
</span><ins>+<!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 RSAES-PKCS1-v1_5 with an imported key");
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var cipherText = hexStringToUint8Array("87ca360442614b6590ea51ba84eb081ecda83c5a19e008ed21a6b93c78a7980348f9eac9a8120a6b67326b58ff6e7a10bec113b01f6bd18a04b82d159eb3532c03d4fca597450333cd4df81456b7b864a276cc3a7551964ccc16de86e2bc7a42981f29a0855fc151692d802f6d0b6fdcc0cc01977c579acde220b60d418a480f0ccdfd370f7e045114be39f03dfd516b51bcba6af20663cb2404e4e8c5b4c239936c672c3c2de4f4f3382cdc68f277fc66ed06a0642584ead53cd676673e8cecf59fe23cbe0a59cd82c8d56187eff6cda9b9e600b9890f42c65ee9a4f16f87c1c0b53cecb6fb59a4de165cc828d6bc5b5bf152e6c3060b54fd4e11b037668e4d");
+var jwkKey = {
+ kty: "RSA",
+ alg: "RSA1_5",
+ 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-oXRDwfmyMXEdEUDrGGtCxh6fzDPvs_T-JA3GUK4EgHo3xZcrlXDXlKCeil6Fnr0gISZOIh5dkBrcdVL4quBJe4ZZc5mVuAC7Ld13et0TxMJ4iALGrPuqPVUOGSYIcZ9idx5zKKBWhY3tPggEdKpnHBmPfTRO4yZaf0Nw1QXrgSMZY9ejeuaurAh4Q8o4-6-r8O2LUe7ufMh_ccKkXISEh4KdOnT17EM9BQTn9UNS9GoK2ZZU0U3io5DSu_kpasr4uOVWcGlE2wczOv2nkGwG39F3sFF0Q",
+ p: "x5vnco5j-TD6hTOzyN4DhkZ44m05NycxT6SUE2qTurT3-uze_L7TYutLRIRkovRMhTHZAr2pziRlasEs13PEz9Zvx1I_T68srsonrdbak-SFMecM7EjHc5C-J13gXhw9HIW28_Sx9rQ-JkGwEwE9PEdIUfuvdqpgh3SmXwPJrEs",
+ q: "wb9vllg_2n-kNge0bThg_7xu1UwTzipM8vxSUkkV2IipJKIAekkU3aAB8LoPhUI0-17pSGw3ETOO27t163TI9qIPpzLbhTH9aUi7qLGbKlzPlgnqP43Z0LHxc3xKDgit-Ar29QLaX2uoJBX6VVWvhmh7BIPDHNVM5GZjwWORYgk",
+ dp: "C2c8sa6wx2uk5Dcv7inAycr83PKgciYrCwG78-AC0IfGIu-lTYsZSG1ov2FQ3n5WYMWYQC_Vo5EwugiPJz_V3onBmQF53HOFefbSjXvYwNotQcyRUG5X9qIuOtGCH949H4QED6vK_u0NH-JgzLUlamwoFYbrXzwch6CCYKs2ukE",
+ dq: "hbtRloDLclHwUqr2yvzDV0IFbozYjtF706x-VfXEcnXB6ls34TBYirFLJZIH7H9KeseEVkz7pY_k5555QlCV9kbebxYXl9RtiiJ-BW6yH4d4caPeYIfU9MweUQxVQWKUUkWfOHcDrCFvKZlR9Vzzjt7HKtKX9mr0bCKQcIf9baE",
+ qi: "a-7hUTTnclUPKOfSgH8zEKGJ-AvdFEzxvZ5sq46Qf2MbORxVjN4dJamVvM-FoqcwN-9cuUlyr9bSFTwUBW4vXa8Xj9a8JfViuMCqzR-mL1rGIUQ5ARGhNcSsRlyKTqz5BlWlVKmXIx_p-DeVwPWiJJy4k_FqyBxrnxkzomHfrxk",
+};
+var expectedPlainText = "Hello, World!";
+
+crypto.subtle.importKey("jwk", jwkKey, "RSAES-PKCS1-v1_5", extractable, ["decrypt"]).then(function(key) {
+ return crypto.subtle.decrypt("RSAES-PKCS1-v1_5", key, cipherText);
+}).then(function(result) {
+ plainText = result;
+
+ shouldBe("bytesToASCIIString(plainText)", "expectedPlainText");
+
+ finishJSTest();
+});
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtleaescbcimportkeydecryptexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/aes-cbc-import-key-decrypt-expected.txt (0 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/aes-cbc-import-key-decrypt-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/aes-cbc-import-key-decrypt-expected.txt        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+[Worker] Test decrypting using AES-CBC with an imported 128bit key in workers
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Starting worker: resources/aes-cbc-import-key-decrypt.js
+PASS [Worker] bytesToASCIIString(plainText) is expectedPlainText
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtleaescbcimportkeydecrypthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/aes-cbc-import-key-decrypt.html (0 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/aes-cbc-import-key-decrypt.html         (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/aes-cbc-import-key-decrypt.html        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+ <script src="../../../resources/js-test-pre.js"></script>
+</head>
+<body>
+ <script>
+ worker = startWorker('resources/aes-cbc-import-key-decrypt.js');
+ </script>
+ <script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtleresourcesaescbcimportkeydecryptjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/resources/aes-cbc-import-key-decrypt.js (0 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/resources/aes-cbc-import-key-decrypt.js         (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/resources/aes-cbc-import-key-decrypt.js        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -0,0 +1,25 @@
</span><ins>+importScripts('../../../../resources/js-test-pre.js');
+importScripts('../../../resources/common.js');
+
+description("Test decrypting using AES-CBC with an imported 128bit key in workers");
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var cipherText = hexStringToUint8Array("2ffa4618784dfd414b22c40c6330d022");
+var aesCbcParams = {
+ name: "aes-cbc",
+ iv: asciiToUint8Array("jnOw99oOZFLIEPMr"),
+}
+var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
+var expectedPlainText = "Hello, World!";
+
+crypto.subtle.importKey("raw", rawKey, "aes-cbc", extractable, ["decrypt"]).then(function(key) {
+ return crypto.subtle.decrypt(aesCbcParams, key, cipherText);
+}).then(function(result) {
+ plainText = result;
+
+ shouldBe("bytesToASCIIString(plainText)", "expectedPlainText");
+
+ finishJSTest();
+});
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtleresourcesrsaoaepimportkeydecryptjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/resources/rsa-oaep-import-key-decrypt.js (0 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/resources/rsa-oaep-import-key-decrypt.js         (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/resources/rsa-oaep-import-key-decrypt.js        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -0,0 +1,39 @@
</span><ins>+importScripts('../../../../resources/js-test-pre.js');
+importScripts('../../../resources/common.js');
+
+description("Test decrypting using RSA-OAEP SHA-1 with an imported key and a label in workers");
+
+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-oXRDwfmyMXEdEUDrGGtCxh6fzDPvs_T-JA3GUK4EgHo3xZcrlXDXlKCeil6Fnr0gISZOIh5dkBrcdVL4quBJe4ZZc5mVuAC7Ld13et0TxMJ4iALGrPuqPVUOGSYIcZ9idx5zKKBWhY3tPggEdKpnHBmPfTRO4yZaf0Nw1QXrgSMZY9ejeuaurAh4Q8o4-6-r8O2LUe7ufMh_ccKkXISEh4KdOnT17EM9BQTn9UNS9GoK2ZZU0U3io5DSu_kpasr4uOVWcGlE2wczOv2nkGwG39F3sFF0Q",
+ p: "x5vnco5j-TD6hTOzyN4DhkZ44m05NycxT6SUE2qTurT3-uze_L7TYutLRIRkovRMhTHZAr2pziRlasEs13PEz9Zvx1I_T68srsonrdbak-SFMecM7EjHc5C-J13gXhw9HIW28_Sx9rQ-JkGwEwE9PEdIUfuvdqpgh3SmXwPJrEs",
+ q: "wb9vllg_2n-kNge0bThg_7xu1UwTzipM8vxSUkkV2IipJKIAekkU3aAB8LoPhUI0-17pSGw3ETOO27t163TI9qIPpzLbhTH9aUi7qLGbKlzPlgnqP43Z0LHxc3xKDgit-Ar29QLaX2uoJBX6VVWvhmh7BIPDHNVM5GZjwWORYgk",
+ dp: "C2c8sa6wx2uk5Dcv7inAycr83PKgciYrCwG78-AC0IfGIu-lTYsZSG1ov2FQ3n5WYMWYQC_Vo5EwugiPJz_V3onBmQF53HOFefbSjXvYwNotQcyRUG5X9qIuOtGCH949H4QED6vK_u0NH-JgzLUlamwoFYbrXzwch6CCYKs2ukE",
+ dq: "hbtRloDLclHwUqr2yvzDV0IFbozYjtF706x-VfXEcnXB6ls34TBYirFLJZIH7H9KeseEVkz7pY_k5555QlCV9kbebxYXl9RtiiJ-BW6yH4d4caPeYIfU9MweUQxVQWKUUkWfOHcDrCFvKZlR9Vzzjt7HKtKX9mr0bCKQcIf9baE",
+ qi: "a-7hUTTnclUPKOfSgH8zEKGJ-AvdFEzxvZ5sq46Qf2MbORxVjN4dJamVvM-FoqcwN-9cuUlyr9bSFTwUBW4vXa8Xj9a8JfViuMCqzR-mL1rGIUQ5ARGhNcSsRlyKTqz5BlWlVKmXIx_p-DeVwPWiJJy4k_FqyBxrnxkzomHfrxk",
+};
+var rsaOaepParams = {
+ name: "rsa-oaep",
+ label: asciiToUint8Array("WebKit.org"),
+}
+var expectedPlainText = "Hello, World!";
+
+crypto.subtle.importKey("jwk", jwkKey, {name: "RSA-OAEP", hash: "SHA-1"}, extractable, ["decrypt"]).then(function(key) {
+ return crypto.subtle.decrypt(rsaOaepParams, key, cipherText);
+}).then(function(result) {
+ plainText = result;
+
+ shouldBe("bytesToASCIIString(plainText)", "expectedPlainText");
+
+ finishJSTest();
+});
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtleresourcesrsaespkcs1v1_5importkeydecryptjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/resources/rsaes-pkcs1-v1_5-import-key-decrypt.js (0 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/resources/rsaes-pkcs1-v1_5-import-key-decrypt.js         (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/resources/rsaes-pkcs1-v1_5-import-key-decrypt.js        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -0,0 +1,35 @@
</span><ins>+importScripts('../../../../resources/js-test-pre.js');
+importScripts('../../../resources/common.js');
+
+description("Test decrypting using RSAES-PKCS1-v1_5 with an imported key in workers");
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var cipherText = hexStringToUint8Array("87ca360442614b6590ea51ba84eb081ecda83c5a19e008ed21a6b93c78a7980348f9eac9a8120a6b67326b58ff6e7a10bec113b01f6bd18a04b82d159eb3532c03d4fca597450333cd4df81456b7b864a276cc3a7551964ccc16de86e2bc7a42981f29a0855fc151692d802f6d0b6fdcc0cc01977c579acde220b60d418a480f0ccdfd370f7e045114be39f03dfd516b51bcba6af20663cb2404e4e8c5b4c239936c672c3c2de4f4f3382cdc68f277fc66ed06a0642584ead53cd676673e8cecf59fe23cbe0a59cd82c8d56187eff6cda9b9e600b9890f42c65ee9a4f16f87c1c0b53cecb6fb59a4de165cc828d6bc5b5bf152e6c3060b54fd4e11b037668e4d");
+var jwkKey = {
+ kty: "RSA",
+ alg: "RSA1_5",
+ 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-oXRDwfmyMXEdEUDrGGtCxh6fzDPvs_T-JA3GUK4EgHo3xZcrlXDXlKCeil6Fnr0gISZOIh5dkBrcdVL4quBJe4ZZc5mVuAC7Ld13et0TxMJ4iALGrPuqPVUOGSYIcZ9idx5zKKBWhY3tPggEdKpnHBmPfTRO4yZaf0Nw1QXrgSMZY9ejeuaurAh4Q8o4-6-r8O2LUe7ufMh_ccKkXISEh4KdOnT17EM9BQTn9UNS9GoK2ZZU0U3io5DSu_kpasr4uOVWcGlE2wczOv2nkGwG39F3sFF0Q",
+ p: "x5vnco5j-TD6hTOzyN4DhkZ44m05NycxT6SUE2qTurT3-uze_L7TYutLRIRkovRMhTHZAr2pziRlasEs13PEz9Zvx1I_T68srsonrdbak-SFMecM7EjHc5C-J13gXhw9HIW28_Sx9rQ-JkGwEwE9PEdIUfuvdqpgh3SmXwPJrEs",
+ q: "wb9vllg_2n-kNge0bThg_7xu1UwTzipM8vxSUkkV2IipJKIAekkU3aAB8LoPhUI0-17pSGw3ETOO27t163TI9qIPpzLbhTH9aUi7qLGbKlzPlgnqP43Z0LHxc3xKDgit-Ar29QLaX2uoJBX6VVWvhmh7BIPDHNVM5GZjwWORYgk",
+ dp: "C2c8sa6wx2uk5Dcv7inAycr83PKgciYrCwG78-AC0IfGIu-lTYsZSG1ov2FQ3n5WYMWYQC_Vo5EwugiPJz_V3onBmQF53HOFefbSjXvYwNotQcyRUG5X9qIuOtGCH949H4QED6vK_u0NH-JgzLUlamwoFYbrXzwch6CCYKs2ukE",
+ dq: "hbtRloDLclHwUqr2yvzDV0IFbozYjtF706x-VfXEcnXB6ls34TBYirFLJZIH7H9KeseEVkz7pY_k5555QlCV9kbebxYXl9RtiiJ-BW6yH4d4caPeYIfU9MweUQxVQWKUUkWfOHcDrCFvKZlR9Vzzjt7HKtKX9mr0bCKQcIf9baE",
+ qi: "a-7hUTTnclUPKOfSgH8zEKGJ-AvdFEzxvZ5sq46Qf2MbORxVjN4dJamVvM-FoqcwN-9cuUlyr9bSFTwUBW4vXa8Xj9a8JfViuMCqzR-mL1rGIUQ5ARGhNcSsRlyKTqz5BlWlVKmXIx_p-DeVwPWiJJy4k_FqyBxrnxkzomHfrxk",
+};
+var expectedPlainText = "Hello, World!";
+
+crypto.subtle.importKey("jwk", jwkKey, "RSAES-PKCS1-v1_5", extractable, ["decrypt"]).then(function(key) {
+ return crypto.subtle.decrypt("RSAES-PKCS1-v1_5", key, cipherText);
+}).then(function(result) {
+ plainText = result;
+
+ shouldBe("bytesToASCIIString(plainText)", "expectedPlainText");
+
+ finishJSTest();
+});
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtlersaoaepimportkeydecryptexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/rsa-oaep-import-key-decrypt-expected.txt (0 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/rsa-oaep-import-key-decrypt-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/rsa-oaep-import-key-decrypt-expected.txt        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+[Worker] Test decrypting using RSA-OAEP SHA-1 with an imported key and a label in workers
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Starting worker: resources/rsa-oaep-import-key-decrypt.js
+PASS [Worker] bytesToASCIIString(plainText) is expectedPlainText
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtlersaoaepimportkeydecrypthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/rsa-oaep-import-key-decrypt.html (0 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/rsa-oaep-import-key-decrypt.html         (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/rsa-oaep-import-key-decrypt.html        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+ <script src="../../../resources/js-test-pre.js"></script>
+</head>
+<body>
+ <script>
+ worker = startWorker('resources/rsa-oaep-import-key-decrypt.js');
+ </script>
+ <script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtlersaespkcs1v1_5importkeydecryptexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/rsaes-pkcs1-v1_5-import-key-decrypt-expected.txt (0 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/rsaes-pkcs1-v1_5-import-key-decrypt-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/rsaes-pkcs1-v1_5-import-key-decrypt-expected.txt        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+[Worker] Test decrypting using RSAES-PKCS1-v1_5 with an imported key in workers
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Starting worker: resources/rsaes-pkcs1-v1_5-import-key-decrypt.js
+PASS [Worker] bytesToASCIIString(plainText) is expectedPlainText
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtlersaespkcs1v1_5importkeydecrypthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/rsaes-pkcs1-v1_5-import-key-decrypt.html (0 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/rsaes-pkcs1-v1_5-import-key-decrypt.html         (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/rsaes-pkcs1-v1_5-import-key-decrypt.html        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+ <script src="../../../resources/js-test-pre.js"></script>
+</head>
+<body>
+ <script>
+ worker = startWorker('resources/rsaes-pkcs1-v1_5-import-key-decrypt.js');
+ </script>
+ <script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (208917 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog        2016-11-19 04:25:38 UTC (rev 208917)
+++ trunk/LayoutTests/imported/w3c/ChangeLog        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2016-11-18 Jiewen Tan <jiewen_tan@apple.com>
+
+ Update SubtleCrypto::decrypt to match the latest spec
+ https://bugs.webkit.org/show_bug.cgi?id=164739
+ <rdar://problem/29257848>
+
+ Reviewed by Brent Fulgham.
+
+ * WebCryptoAPI/encrypt_decrypt/test_aes_cbc-expected.txt:
+ * WebCryptoAPI/idlharness-expected.txt:
+
</ins><span class="cx"> 2016-11-18 Alex Christensen <achristensen@webkit.org>
</span><span class="cx">
</span><span class="cx"> TextDecoder constructor should not accept replacement encodings
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cWebCryptoAPIencrypt_decrypttest_aes_cbcexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/WebCryptoAPI/encrypt_decrypt/test_aes_cbc-expected.txt (208917 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/WebCryptoAPI/encrypt_decrypt/test_aes_cbc-expected.txt        2016-11-19 04:25:38 UTC (rev 208917)
+++ trunk/LayoutTests/imported/w3c/WebCryptoAPI/encrypt_decrypt/test_aes_cbc-expected.txt        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -7,12 +7,12 @@
</span><span class="cx"> PASS AES-CBC 128-bit key with altered plaintext
</span><span class="cx"> PASS AES-CBC 192-bit key with altered plaintext
</span><span class="cx"> PASS AES-CBC 256-bit key with altered plaintext
</span><del>-FAIL AES-CBC 128-bit key decryption subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
-FAIL AES-CBC 192-bit key decryption subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
-FAIL AES-CBC 256-bit key decryption subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
-FAIL AES-CBC 128-bit key decryption with altered ciphertext subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, ciphertext)', 'subtle.decrypt' is undefined)
-FAIL AES-CBC 192-bit key decryption with altered ciphertext subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, ciphertext)', 'subtle.decrypt' is undefined)
-FAIL AES-CBC 256-bit key decryption with altered ciphertext subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, ciphertext)', 'subtle.decrypt' is undefined)
</del><ins>+PASS AES-CBC 128-bit key decryption
+PASS AES-CBC 192-bit key decryption
+PASS AES-CBC 256-bit key decryption
+PASS AES-CBC 128-bit key decryption with altered ciphertext
+PASS AES-CBC 192-bit key decryption with altered ciphertext
+PASS AES-CBC 256-bit key decryption with altered ciphertext
</ins><span class="cx"> PASS AES-CBC 128-bit key without encrypt usage
</span><span class="cx"> PASS AES-CBC 192-bit key without encrypt usage
</span><span class="cx"> PASS AES-CBC 256-bit key without encrypt usage
</span><span class="lines">@@ -19,9 +19,9 @@
</span><span class="cx"> FAIL AES-CBC 128-bit key with mismatched key and algorithm assert_equals: Mismatch should cause InvalidAccessError instead of The operation is not supported. expected "InvalidAccessError" but got "NotSupportedError"
</span><span class="cx"> FAIL AES-CBC 192-bit key with mismatched key and algorithm assert_equals: Mismatch should cause InvalidAccessError instead of The operation is not supported. expected "InvalidAccessError" but got "NotSupportedError"
</span><span class="cx"> FAIL AES-CBC 256-bit key with mismatched key and algorithm assert_equals: Mismatch should cause InvalidAccessError instead of The operation is not supported. expected "InvalidAccessError" but got "NotSupportedError"
</span><del>-FAIL AES-CBC 128-bit key without decrypt usage subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
-FAIL AES-CBC 192-bit key without decrypt usage subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
-FAIL AES-CBC 256-bit key without decrypt usage subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
</del><ins>+PASS AES-CBC 128-bit key without decrypt usage
+PASS AES-CBC 192-bit key without decrypt usage
+PASS AES-CBC 256-bit key without decrypt usage
</ins><span class="cx"> PASS AES-CBC 128-bit key, 64-bit IV
</span><span class="cx"> PASS AES-CBC 128-bit key, 192-bit IV
</span><span class="cx"> PASS AES-CBC 192-bit key, 64-bit IV
</span><span class="lines">@@ -28,19 +28,19 @@
</span><span class="cx"> PASS AES-CBC 192-bit key, 192-bit IV
</span><span class="cx"> PASS AES-CBC 256-bit key, 64-bit IV
</span><span class="cx"> PASS AES-CBC 256-bit key, 192-bit IV
</span><del>-FAIL AES-CBC 128-bit key, 64-bit IV decryption subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
-FAIL AES-CBC 128-bit key, 192-bit IV decryption subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
-FAIL AES-CBC 192-bit key, 64-bit IV decryption subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
-FAIL AES-CBC 192-bit key, 192-bit IV decryption subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
-FAIL AES-CBC 256-bit key, 64-bit IV decryption subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
-FAIL AES-CBC 256-bit key, 192-bit IV decryption subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
-FAIL AES-CBC 128-bit key, zeroPadChar subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
-FAIL AES-CBC 128-bit key, bigPadChar subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
-FAIL AES-CBC 128-bit key, inconsistentPadChars subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
-FAIL AES-CBC 192-bit key, zeroPadChar subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
-FAIL AES-CBC 192-bit key, bigPadChar subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
-FAIL AES-CBC 192-bit key, inconsistentPadChars subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
-FAIL AES-CBC 256-bit key, zeroPadChar subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
-FAIL AES-CBC 256-bit key, bigPadChar subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
-FAIL AES-CBC 256-bit key, inconsistentPadChars subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
</del><ins>+PASS AES-CBC 128-bit key, 64-bit IV decryption
+PASS AES-CBC 128-bit key, 192-bit IV decryption
+PASS AES-CBC 192-bit key, 64-bit IV decryption
+PASS AES-CBC 192-bit key, 192-bit IV decryption
+PASS AES-CBC 256-bit key, 64-bit IV decryption
+PASS AES-CBC 256-bit key, 192-bit IV decryption
+FAIL AES-CBC 128-bit key, zeroPadChar assert_unreached: should have thrown exception for test AES-CBC 128-bit key, zeroPadChar Reached unreachable code
+FAIL AES-CBC 128-bit key, bigPadChar assert_unreached: should have thrown exception for test AES-CBC 128-bit key, bigPadChar Reached unreachable code
+FAIL AES-CBC 128-bit key, inconsistentPadChars assert_unreached: should have thrown exception for test AES-CBC 128-bit key, inconsistentPadChars Reached unreachable code
+FAIL AES-CBC 192-bit key, zeroPadChar assert_unreached: should have thrown exception for test AES-CBC 192-bit key, zeroPadChar Reached unreachable code
+FAIL AES-CBC 192-bit key, bigPadChar assert_unreached: should have thrown exception for test AES-CBC 192-bit key, bigPadChar Reached unreachable code
+FAIL AES-CBC 192-bit key, inconsistentPadChars assert_unreached: should have thrown exception for test AES-CBC 192-bit key, inconsistentPadChars Reached unreachable code
+FAIL AES-CBC 256-bit key, zeroPadChar assert_unreached: should have thrown exception for test AES-CBC 256-bit key, zeroPadChar Reached unreachable code
+FAIL AES-CBC 256-bit key, bigPadChar assert_unreached: should have thrown exception for test AES-CBC 256-bit key, bigPadChar Reached unreachable code
+FAIL AES-CBC 256-bit key, inconsistentPadChars assert_unreached: should have thrown exception for test AES-CBC 256-bit key, inconsistentPadChars Reached unreachable code
</ins><span class="cx">
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cWebCryptoAPIidlharnessexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/WebCryptoAPI/idlharness-expected.txt (208917 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/WebCryptoAPI/idlharness-expected.txt        2016-11-19 04:25:38 UTC (rev 208917)
+++ trunk/LayoutTests/imported/w3c/WebCryptoAPI/idlharness-expected.txt        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -45,8 +45,8 @@
</span><span class="cx"> PASS Stringification of crypto.subtle
</span><span class="cx"> PASS SubtleCrypto interface: crypto.subtle must inherit property "encrypt" with the proper type (0)
</span><span class="cx"> PASS SubtleCrypto interface: calling encrypt(AlgorithmIdentifier,CryptoKey,BufferSource) on crypto.subtle with too few arguments must throw TypeError
</span><del>-FAIL SubtleCrypto interface: crypto.subtle must inherit property "decrypt" with the proper type (1) assert_inherits: property "decrypt" not found in prototype chain
-FAIL SubtleCrypto interface: calling decrypt(AlgorithmIdentifier,CryptoKey,BufferSource) on crypto.subtle with too few arguments must throw TypeError assert_inherits: property "decrypt" not found in prototype chain
</del><ins>+PASS SubtleCrypto interface: crypto.subtle must inherit property "decrypt" with the proper type (1)
+PASS SubtleCrypto interface: calling decrypt(AlgorithmIdentifier,CryptoKey,BufferSource) on crypto.subtle with too few arguments must throw TypeError
</ins><span class="cx"> FAIL SubtleCrypto interface: crypto.subtle must inherit property "sign" with the proper type (2) assert_inherits: property "sign" not found in prototype chain
</span><span class="cx"> FAIL SubtleCrypto interface: calling sign(AlgorithmIdentifier,CryptoKey,BufferSource) on crypto.subtle with too few arguments must throw TypeError assert_inherits: property "sign" not found in prototype chain
</span><span class="cx"> FAIL SubtleCrypto interface: crypto.subtle must inherit property "verify" with the proper type (3) assert_inherits: property "verify" not found in prototype chain
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (208917 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-11-19 04:25:38 UTC (rev 208917)
+++ trunk/Source/WebCore/ChangeLog        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -1,3 +1,70 @@
</span><ins>+2016-11-18 Jiewen Tan <jiewen_tan@apple.com>
+
+ Update SubtleCrypto::decrypt to match the latest spec
+ https://bugs.webkit.org/show_bug.cgi?id=164739
+ <rdar://problem/29257848>
+
+ Reviewed by Brent Fulgham.
+
+ 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):
+
</ins><span class="cx"> 2016-11-18 Chris Dumez <cdumez@apple.com>
</span><span class="cx">
</span><span class="cx"> Unreviewed, rolling out r208837.
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSSubtleCryptoCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp (208917 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp        2016-11-19 04:25:38 UTC (rev 208917)
+++ trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -53,6 +53,7 @@
</span><span class="cx">
</span><span class="cx"> enum class Operations {
</span><span class="cx"> Encrypt,
</span><ins>+ Decrypt,
</ins><span class="cx"> Digest,
</span><span class="cx"> GenerateKey,
</span><span class="cx"> ImportKey,
</span><span class="lines">@@ -94,6 +95,7 @@
</span><span class="cx"> std::unique_ptr<CryptoAlgorithmParameters> result;
</span><span class="cx"> switch (operation) {
</span><span class="cx"> case Operations::Encrypt:
</span><ins>+ case Operations::Decrypt:
</ins><span class="cx"> switch (*identifier) {
</span><span class="cx"> case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
</span><span class="cx"> result = std::make_unique<CryptoAlgorithmParameters>(params);
</span><span class="lines">@@ -388,6 +390,32 @@
</span><span class="cx"> return result;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static RefPtr<CryptoKey> toCryptoKey(ExecState& state, JSValue value)
+{
+ VM& vm = state.vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ RefPtr<CryptoKey> result = JSCryptoKey::toWrapped(value);
+ if (!result) {
+ throwTypeError(&state, scope, ASCIILiteral("Invalid CryptoKey"));
+ return nullptr;
+ }
+ return result;
+}
+
+static Vector<uint8_t> toVector(ExecState& state, JSValue value)
+{
+ VM& vm = state.vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ BufferSource data = convert<IDLBufferSource>(state, value);
+ RETURN_IF_EXCEPTION(scope, { });
+ Vector<uint8_t> dataVector;
+ dataVector.append(data.data(), data.length());
+
+ return dataVector;
+}
+
</ins><span class="cx"> static void jsSubtleCryptoFunctionEncryptPromise(ExecState& state, Ref<DeferredPromise>&& promise)
</span><span class="cx"> {
</span><span class="cx"> VM& vm = state.vm();
</span><span class="lines">@@ -401,16 +429,11 @@
</span><span class="cx"> auto params = normalizeCryptoAlgorithmParameters(state, state.uncheckedArgument(0), Operations::Encrypt);
</span><span class="cx"> RETURN_IF_EXCEPTION(scope, void());
</span><span class="cx">
</span><del>- RefPtr<CryptoKey> key = JSCryptoKey::toWrapped(state.uncheckedArgument(1));
- if (!key) {
- promise->reject(TypeError, ASCIILiteral("Invalid CryptoKey"));
- return;
- }
</del><ins>+ auto key = toCryptoKey(state, state.uncheckedArgument(1));
+ RETURN_IF_EXCEPTION(scope, void());
</ins><span class="cx">
</span><del>- BufferSource data = convert<IDLBufferSource>(state, state.uncheckedArgument(2));
</del><ins>+ auto data = toVector(state, state.uncheckedArgument(2));
</ins><span class="cx"> RETURN_IF_EXCEPTION(scope, void());
</span><del>- Vector<uint8_t> dataVector;
- dataVector.append(data.data(), data.length());
</del><span class="cx">
</span><span class="cx"> if (params->identifier != key->algorithmIdentifier()) {
</span><span class="cx"> promise->reject(INVALID_ACCESS_ERR, ASCIILiteral("CryptoKey doesn't match AlgorithmIdentifier"));
</span><span class="lines">@@ -435,9 +458,54 @@
</span><span class="cx">
</span><span class="cx"> JSSubtleCrypto* subtle = jsDynamicDowncast<JSSubtleCrypto*>(state.thisValue());
</span><span class="cx"> ASSERT(subtle);
</span><del>- algorithm->encrypt(WTFMove(params), key.releaseNonNull(), WTFMove(dataVector), WTFMove(callback), WTFMove(exceptionCallback), *scriptExecutionContextFromExecState(&state), subtle->wrapped().workQueue());
</del><ins>+ algorithm->encrypt(WTFMove(params), key.releaseNonNull(), WTFMove(data), WTFMove(callback), WTFMove(exceptionCallback), *scriptExecutionContextFromExecState(&state), subtle->wrapped().workQueue());
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+static void jsSubtleCryptoFunctionDecryptPromise(ExecState& state, Ref<DeferredPromise>&& promise)
+{
+ VM& vm = state.vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ if (UNLIKELY(state.argumentCount() < 3)) {
+ promise->reject<JSValue>(createNotEnoughArgumentsError(&state));
+ return;
+ }
+
+ auto params = normalizeCryptoAlgorithmParameters(state, state.uncheckedArgument(0), Operations::Decrypt);
+ RETURN_IF_EXCEPTION(scope, void());
+
+ auto key = toCryptoKey(state, state.uncheckedArgument(1));
+ RETURN_IF_EXCEPTION(scope, void());
+
+ auto data = toVector(state, state.uncheckedArgument(2));
+ RETURN_IF_EXCEPTION(scope, void());
+
+ if (params->identifier != key->algorithmIdentifier()) {
+ promise->reject(INVALID_ACCESS_ERR, ASCIILiteral("CryptoKey doesn't match AlgorithmIdentifier"));
+ return;
+ }
+
+ if (!key->allows(CryptoKeyUsageDecrypt)) {
+ promise->reject(INVALID_ACCESS_ERR, ASCIILiteral("CryptoKey doesn't support decryption"));
+ return;
+ }
+
+ auto algorithm = createAlgorithm(state, key->algorithmIdentifier());
+ RETURN_IF_EXCEPTION(scope, void());
+
+ auto callback = [capturedPromise = promise.copyRef()](const Vector<uint8_t>& cipherText) mutable {
+ fulfillPromiseWithArrayBuffer(WTFMove(capturedPromise), cipherText.data(), cipherText.size());
+ return;
+ };
+ auto exceptionCallback = [capturedPromise = promise.copyRef()](ExceptionCode ec) mutable {
+ rejectWithException(WTFMove(capturedPromise), ec);
+ };
+
+ JSSubtleCrypto* subtle = jsDynamicDowncast<JSSubtleCrypto*>(state.thisValue());
+ ASSERT(subtle);
+ algorithm->decrypt(WTFMove(params), key.releaseNonNull(), WTFMove(data), WTFMove(callback), WTFMove(exceptionCallback), *scriptExecutionContextFromExecState(&state), subtle->wrapped().workQueue());
+}
+
</ins><span class="cx"> static void jsSubtleCryptoFunctionGenerateKeyPromise(ExecState& state, Ref<DeferredPromise>&& promise)
</span><span class="cx"> {
</span><span class="cx"> VM& vm = state.vm();
</span><span class="lines">@@ -545,11 +613,8 @@
</span><span class="cx"> auto format = convertEnumeration<SubtleCrypto::KeyFormat>(state, state.uncheckedArgument(0));
</span><span class="cx"> RETURN_IF_EXCEPTION(scope, void());
</span><span class="cx">
</span><del>- RefPtr<CryptoKey> key = JSCryptoKey::toWrapped(state.uncheckedArgument(1));
- if (!key) {
- promise->reject(TypeError, ASCIILiteral("Invalid CryptoKey"));
- return;
- }
</del><ins>+ auto key = toCryptoKey(state, state.uncheckedArgument(1));
+ RETURN_IF_EXCEPTION(scope, void());
</ins><span class="cx">
</span><span class="cx"> switch (key->algorithmIdentifier()) {
</span><span class="cx"> case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
</span><span class="lines">@@ -607,6 +672,11 @@
</span><span class="cx"> return callPromiseFunction<jsSubtleCryptoFunctionEncryptPromise, PromiseExecutionScope::WindowOrWorker>(state);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+JSValue JSSubtleCrypto::decrypt(ExecState& state)
+{
+ return callPromiseFunction<jsSubtleCryptoFunctionDecryptPromise, PromiseExecutionScope::WindowOrWorker>(state);
+}
+
</ins><span class="cx"> JSValue JSSubtleCrypto::generateKey(ExecState& state)
</span><span class="cx"> {
</span><span class="cx"> return callPromiseFunction<jsSubtleCryptoFunctionGenerateKeyPromise, PromiseExecutionScope::WindowOrWorker>(state);
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoCryptoAlgorithmcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/CryptoAlgorithm.cpp (208917 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/CryptoAlgorithm.cpp        2016-11-19 04:25:38 UTC (rev 208917)
+++ trunk/Source/WebCore/crypto/CryptoAlgorithm.cpp        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -37,6 +37,11 @@
</span><span class="cx"> exceptionCallback(NOT_SUPPORTED_ERR);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void CryptoAlgorithm::decrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&, WorkQueue&)
+{
+ exceptionCallback(NOT_SUPPORTED_ERR);
+}
+
</ins><span class="cx"> void CryptoAlgorithm::generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&&, bool, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&)
</span><span class="cx"> {
</span><span class="cx"> exceptionCallback(NOT_SUPPORTED_ERR);
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoCryptoAlgorithmh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/CryptoAlgorithm.h (208917 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/CryptoAlgorithm.h        2016-11-19 04:25:38 UTC (rev 208917)
+++ trunk/Source/WebCore/crypto/CryptoAlgorithm.h        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -65,6 +65,7 @@
</span><span class="cx"> using KeyDataCallback = WTF::Function<void(SubtleCrypto::KeyFormat, KeyData&&)>;
</span><span class="cx">
</span><span class="cx"> virtual void encrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
</span><ins>+ virtual void decrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
</ins><span class="cx"> virtual void generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&);
</span><span class="cx"> virtual void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&);
</span><span class="cx"> virtual void exportKey(SubtleCrypto::KeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&);
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoSubtleCryptoidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/SubtleCrypto.idl (208917 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/SubtleCrypto.idl        2016-11-19 04:25:38 UTC (rev 208917)
+++ trunk/Source/WebCore/crypto/SubtleCrypto.idl        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> NoInterfaceObject,
</span><span class="cx"> ] interface SubtleCrypto {
</span><span class="cx"> [Custom] Promise<any> encrypt(AlgorithmIdentifier algorithm, CryptoKey key, BufferSource data);
</span><ins>+ [Custom] Promise<any> decrypt(AlgorithmIdentifier algorithm, CryptoKey key, BufferSource data);
</ins><span class="cx"> // FIXME: Should this return a Promise<(CryptoKey or CryptoKeyPair)>?
</span><span class="cx"> [Custom] Promise<any> generateKey(AlgorithmIdentifier algorithm, boolean extractable, sequence<CryptoKeyUsage> keyUsages);
</span><span class="cx"> [Custom] Promise<CryptoKey> importKey(KeyFormat format, (BufferSource or JsonWebKey) keyData, AlgorithmIdentifier algorithm, boolen extractable, sequence<CryptoKeyUsage> keyUsages);
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmAES_CBCcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.cpp (208917 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.cpp        2016-11-19 04:25:38 UTC (rev 208917)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.cpp        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -77,6 +77,17 @@
</span><span class="cx"> platformEncrypt(WTFMove(parameters), WTFMove(key), WTFMove(plainText), WTFMove(callback), WTFMove(exceptionCallback), context, workQueue);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void CryptoAlgorithmAES_CBC::decrypt(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& cipherText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
+{
+ ASSERT(parameters);
+ auto& aesParameters = downcast<CryptoAlgorithmAesCbcParams>(*parameters);
+ if (aesParameters.ivVector().size() != IVSIZE) {
+ exceptionCallback(OperationError);
+ return;
+ }
+ platformDecrypt(WTFMove(parameters), WTFMove(key), WTFMove(cipherText), WTFMove(callback), WTFMove(exceptionCallback), context, workQueue);
+}
+
</ins><span class="cx"> void CryptoAlgorithmAES_CBC::generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&)
</span><span class="cx"> {
</span><span class="cx"> ASSERT(parameters);
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmAES_CBCh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.h (208917 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.h        2016-11-19 04:25:38 UTC (rev 208917)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.h        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -45,6 +45,7 @@
</span><span class="cx"> CryptoAlgorithmIdentifier identifier() const final;
</span><span class="cx">
</span><span class="cx"> void encrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
</span><ins>+ void decrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
</ins><span class="cx"> void generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final;
</span><span class="cx"> void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
</span><span class="cx"> void exportKey(SubtleCrypto::KeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
</span><span class="lines">@@ -56,6 +57,7 @@
</span><span class="cx">
</span><span class="cx"> bool keyAlgorithmMatches(const CryptoAlgorithmAesCbcParamsDeprecated& algorithmParameters, const CryptoKey&) const;
</span><span class="cx"> void platformEncrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
</span><ins>+ void platformDecrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
</ins><span class="cx"> ExceptionOr<void> platformEncrypt(const CryptoAlgorithmAesCbcParamsDeprecated&, const CryptoKeyAES&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback);
</span><span class="cx"> ExceptionOr<void> platformDecrypt(const CryptoAlgorithmAesCbcParamsDeprecated&, const CryptoKeyAES&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback);
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSAES_PKCS1_v1_5cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp (208917 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp        2016-11-19 04:25:38 UTC (rev 208917)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -68,6 +68,15 @@
</span><span class="cx"> platformEncrypt(WTFMove(key), WTFMove(plainText), WTFMove(callback), WTFMove(exceptionCallback), context, workQueue);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void CryptoAlgorithmRSAES_PKCS1_v1_5::decrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&& key, Vector<uint8_t>&& cipherText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
+{
+ if (key->type() != CryptoKeyType::Private) {
+ exceptionCallback(INVALID_ACCESS_ERR);
+ return;
+ }
+ platformDecrypt(WTFMove(key), WTFMove(cipherText), WTFMove(callback), WTFMove(exceptionCallback), context, workQueue);
+}
+
</ins><span class="cx"> void CryptoAlgorithmRSAES_PKCS1_v1_5::generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context)
</span><span class="cx"> {
</span><span class="cx"> ASSERT(parameters);
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSAES_PKCS1_v1_5h"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h (208917 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h        2016-11-19 04:25:38 UTC (rev 208917)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -45,6 +45,7 @@
</span><span class="cx"> CryptoAlgorithmIdentifier identifier() const final;
</span><span class="cx">
</span><span class="cx"> void encrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
</span><ins>+ void decrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
</ins><span class="cx"> void generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final;
</span><span class="cx"> void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
</span><span class="cx"> void exportKey(SubtleCrypto::KeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
</span><span class="lines">@@ -56,6 +57,7 @@
</span><span class="cx">
</span><span class="cx"> bool keyAlgorithmMatches(const CryptoKey&) const;
</span><span class="cx"> void platformEncrypt(Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
</span><ins>+ void platformDecrypt(Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
</ins><span class="cx"> ExceptionOr<void> platformEncrypt(const CryptoKeyRSA&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback);
</span><span class="cx"> ExceptionOr<void> platformDecrypt(const CryptoKeyRSA&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback);
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSA_OAEPcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp (208917 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp        2016-11-19 04:25:38 UTC (rev 208917)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -78,6 +78,15 @@
</span><span class="cx"> platformEncrypt(WTFMove(parameters), WTFMove(key), WTFMove(plainText), WTFMove(callback), WTFMove(exceptionCallback), context, workQueue);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void CryptoAlgorithmRSA_OAEP::decrypt(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& cipherText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
+{
+ ASSERT(parameters);
+ if (key->type() != CryptoKeyType::Private) {
+ exceptionCallback(INVALID_ACCESS_ERR);
+ return;
+ }
+ platformDecrypt(WTFMove(parameters), WTFMove(key), WTFMove(cipherText), WTFMove(callback), WTFMove(exceptionCallback), context, workQueue);
+}
</ins><span class="cx">
</span><span class="cx"> void CryptoAlgorithmRSA_OAEP::generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSA_OAEPh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.h (208917 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.h        2016-11-19 04:25:38 UTC (rev 208917)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.h        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -45,6 +45,7 @@
</span><span class="cx"> CryptoAlgorithmIdentifier identifier() const final;
</span><span class="cx">
</span><span class="cx"> void encrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
</span><ins>+ void decrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
</ins><span class="cx"> void generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final;
</span><span class="cx"> void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
</span><span class="cx"> void exportKey(SubtleCrypto::KeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
</span><span class="lines">@@ -56,6 +57,7 @@
</span><span class="cx">
</span><span class="cx"> bool keyAlgorithmMatches(const CryptoAlgorithmRsaOaepParamsDeprecated& algorithmParameters, const CryptoKey&) const;
</span><span class="cx"> void platformEncrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
</span><ins>+ void platformDecrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
</ins><span class="cx"> ExceptionOr<void> platformEncrypt(const CryptoAlgorithmRsaOaepParamsDeprecated&, const CryptoKeyRSA&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback);
</span><span class="cx"> ExceptionOr<void> platformDecrypt(const CryptoAlgorithmRsaOaepParamsDeprecated&, const CryptoKeyRSA&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback);
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCorecryptognutlsCryptoAlgorithmAES_CBCGnuTLScpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/gnutls/CryptoAlgorithmAES_CBCGnuTLS.cpp (208917 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/gnutls/CryptoAlgorithmAES_CBCGnuTLS.cpp        2016-11-19 04:25:38 UTC (rev 208917)
+++ trunk/Source/WebCore/crypto/gnutls/CryptoAlgorithmAES_CBCGnuTLS.cpp        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -38,6 +38,11 @@
</span><span class="cx"> notImplemented();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void CryptoAlgorithmAES_CBC::platformDecrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&)
+{
+ notImplemented();
+}
+
</ins><span class="cx"> ExceptionOr<void> CryptoAlgorithmAES_CBC::platformEncrypt(const CryptoAlgorithmAesCbcParamsDeprecated&, const CryptoKeyAES&, const CryptoOperationData&, VectorCallback&&, VoidCallback&&)
</span><span class="cx"> {
</span><span class="cx"> notImplemented();
</span></span></pre></div>
<a id="trunkSourceWebCorecryptognutlsCryptoAlgorithmRSAES_PKCS1_v1_5GnuTLScpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/gnutls/CryptoAlgorithmRSAES_PKCS1_v1_5GnuTLS.cpp (208917 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/gnutls/CryptoAlgorithmRSAES_PKCS1_v1_5GnuTLS.cpp        2016-11-19 04:25:38 UTC (rev 208917)
+++ trunk/Source/WebCore/crypto/gnutls/CryptoAlgorithmRSAES_PKCS1_v1_5GnuTLS.cpp        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -39,6 +39,11 @@
</span><span class="cx"> notImplemented();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void CryptoAlgorithmRSAES_PKCS1_v1_5::platformDecrypt(Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&)
+{
+ notImplemented();
+}
+
</ins><span class="cx"> ExceptionOr<void> CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt(const CryptoKeyRSA&, const CryptoOperationData&, VectorCallback&&, VoidCallback&&)
</span><span class="cx"> {
</span><span class="cx"> notImplemented();
</span></span></pre></div>
<a id="trunkSourceWebCorecryptognutlsCryptoAlgorithmRSA_OAEPGnuTLScpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/gnutls/CryptoAlgorithmRSA_OAEPGnuTLS.cpp (208917 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/gnutls/CryptoAlgorithmRSA_OAEPGnuTLS.cpp        2016-11-19 04:25:38 UTC (rev 208917)
+++ trunk/Source/WebCore/crypto/gnutls/CryptoAlgorithmRSA_OAEPGnuTLS.cpp        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -38,6 +38,11 @@
</span><span class="cx"> notImplemented();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void CryptoAlgorithmRSA_OAEP::platformDecrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&)
+{
+ notImplemented();
+}
+
</ins><span class="cx"> ExceptionOr<void> CryptoAlgorithmRSA_OAEP::platformEncrypt(const CryptoAlgorithmRsaOaepParamsDeprecated&, const CryptoKeyRSA&, const CryptoOperationData&, VectorCallback&&, VoidCallback&&)
</span><span class="cx"> {
</span><span class="cx"> notImplemented();
</span></span></pre></div>
<a id="trunkSourceWebCorecryptomacCryptoAlgorithmAES_CBCMaccpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_CBCMac.cpp (208917 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_CBCMac.cpp        2016-11-19 04:25:38 UTC (rev 208917)
+++ trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_CBCMac.cpp        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -95,6 +95,28 @@
</span><span class="cx"> });
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void CryptoAlgorithmAES_CBC::platformDecrypt(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& cipherText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
+{
+ context.ref();
+ workQueue.dispatch([parameters = WTFMove(parameters), key = WTFMove(key), cipherText = WTFMove(cipherText), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), &context]() mutable {
+ auto& aesParameters = downcast<CryptoAlgorithmAesCbcParams>(*parameters);
+ auto& aesKey = downcast<CryptoKeyAES>(key.get());
+ assert(aesParameters.ivVector().size() == kCCBlockSizeAES128);
+ auto result = transformAES_CBC(kCCDecrypt, aesParameters.ivVector().data(), aesKey.key(), cipherText.data(), cipherText.size());
+ if (result.hasException()) {
+ context.postTask([exceptionCallback = WTFMove(exceptionCallback), ec = result.releaseException().code()](ScriptExecutionContext& context) {
+ exceptionCallback(ec);
+ context.deref();
+ });
+ return;
+ }
+ context.postTask([callback = WTFMove(callback), result = result.releaseReturnValue()](ScriptExecutionContext& context) {
+ callback(result);
+ context.deref();
+ });
+ });
+}
+
</ins><span class="cx"> ExceptionOr<void> CryptoAlgorithmAES_CBC::platformEncrypt(const CryptoAlgorithmAesCbcParamsDeprecated& parameters, const CryptoKeyAES& key, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback)
</span><span class="cx"> {
</span><span class="cx"> ASSERT(sizeof(parameters.iv) == kCCBlockSizeAES128);
</span></span></pre></div>
<a id="trunkSourceWebCorecryptomacCryptoAlgorithmRSAES_PKCS1_v1_5Maccpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp (208917 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp        2016-11-19 04:25:38 UTC (rev 208917)
+++ trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -47,6 +47,19 @@
</span><span class="cx"> return WTFMove(cipherText);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+// FIXME: We should change data to Vector<uint8_t> type once WebKitSubtleCrypto is deprecated.
+// https://bugs.webkit.org/show_bug.cgi?id=164939
+static ExceptionOr<Vector<uint8_t>> decryptRSAES_PKCS1_v1_5(const PlatformRSAKey key, size_t keyLength, const uint8_t* data, size_t dataLength)
+{
+ Vector<uint8_t> plainText(keyLength / 8); // Per Step 1 of https://tools.ietf.org/html/rfc3447#section-7.2.1
+ size_t plainTextLength = plainText.size();
+ if (CCRSACryptorDecrypt(key, ccPKCS1Padding, data, dataLength, plainText.data(), &plainTextLength, 0, 0, kCCDigestNone))
+ return Exception { OperationError };
+
+ plainText.resize(plainTextLength);
+ return WTFMove(plainText);
+}
+
</ins><span class="cx"> void CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt(Ref<CryptoKey>&& key, Vector<uint8_t>&& plainText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
</span><span class="cx"> {
</span><span class="cx"> context.ref();
</span><span class="lines">@@ -67,6 +80,26 @@
</span><span class="cx"> });
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void CryptoAlgorithmRSAES_PKCS1_v1_5::platformDecrypt(Ref<CryptoKey>&& key, Vector<uint8_t>&& cipherText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
+{
+ context.ref();
+ workQueue.dispatch([key = WTFMove(key), cipherText = WTFMove(cipherText), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), &context]() mutable {
+ auto& rsaKey = downcast<CryptoKeyRSA>(key.get());
+ auto result = decryptRSAES_PKCS1_v1_5(rsaKey.platformKey(), rsaKey.keySizeInBits(), cipherText.data(), cipherText.size());
+ if (result.hasException()) {
+ context.postTask([exceptionCallback = WTFMove(exceptionCallback), ec = result.releaseException().code()](ScriptExecutionContext& context) {
+ exceptionCallback(ec);
+ context.deref();
+ });
+ return;
+ }
+ context.postTask([callback = WTFMove(callback), result = result.releaseReturnValue()](ScriptExecutionContext& context) {
+ callback(result);
+ context.deref();
+ });
+ });
+}
+
</ins><span class="cx"> ExceptionOr<void> CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt(const CryptoKeyRSA& key, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback)
</span><span class="cx"> {
</span><span class="cx"> auto result = encryptRSAES_PKCS1_v1_5(key.platformKey(), key.keySizeInBits(), data.first, data.second);
</span><span class="lines">@@ -78,19 +111,14 @@
</span><span class="cx"> return { };
</span><span class="cx"> }
</span><span class="cx">
</span><del>-// FIXME: We should get rid of the magic number 1024. It only makes sense when key length < 8192 bits
</del><span class="cx"> ExceptionOr<void> CryptoAlgorithmRSAES_PKCS1_v1_5::platformDecrypt(const CryptoKeyRSA& key, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback)
</span><span class="cx"> {
</span><del>- Vector<uint8_t> plainText(1024);
- size_t plainTextLength = plainText.size();
- CCCryptorStatus status = CCRSACryptorDecrypt(key.platformKey(), ccPKCS1Padding, data.first, data.second, plainText.data(), &plainTextLength, 0, 0, kCCDigestNone);
- if (status) {
</del><ins>+ auto result = decryptRSAES_PKCS1_v1_5(key.platformKey(), key.keySizeInBits(), data.first, data.second);
+ if (result.hasException()) {
</ins><span class="cx"> failureCallback();
</span><span class="cx"> return { };
</span><span class="cx"> }
</span><del>-
- plainText.resize(plainTextLength);
- callback(plainText);
</del><ins>+ callback(result.releaseReturnValue());
</ins><span class="cx"> return { };
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorecryptomacCryptoAlgorithmRSA_OAEPMaccpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp (208917 => 208918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp        2016-11-19 04:25:38 UTC (rev 208917)
+++ trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp        2016-11-19 04:38:59 UTC (rev 208918)
</span><span class="lines">@@ -53,6 +53,23 @@
</span><span class="cx"> return WTFMove(cipherText);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+// FIXME: We should change data to Vector<uint8_t> type once WebKitSubtleCrypto is deprecated.
+// https://bugs.webkit.org/show_bug.cgi?id=164939
+static ExceptionOr<Vector<uint8_t>> decryptRSA_OAEP(CryptoAlgorithmIdentifier hash, const Vector<uint8_t>& label, const PlatformRSAKey key, size_t keyLength, const uint8_t* data, size_t dataLength)
+{
+ CCDigestAlgorithm digestAlgorithm;
+ if (!getCommonCryptoDigestAlgorithm(hash, digestAlgorithm))
+ return Exception { OperationError };
+
+ Vector<uint8_t> plainText(keyLength / 8); // Per Step 1.b of https://tools.ietf.org/html/rfc3447#section-7.1.1
+ size_t plainTextLength = plainText.size();
+ if (CCRSACryptorDecrypt(key, ccOAEPPadding, data, dataLength, plainText.data(), &plainTextLength, label.data(), label.size(), digestAlgorithm))
+ return Exception { OperationError };
+
+ plainText.resize(plainTextLength);
+ return WTFMove(plainText);
+}
+
</ins><span class="cx"> void CryptoAlgorithmRSA_OAEP::platformEncrypt(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& plainText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
</span><span class="cx"> {
</span><span class="cx"> context.ref();
</span><span class="lines">@@ -74,6 +91,27 @@
</span><span class="cx"> });
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void CryptoAlgorithmRSA_OAEP::platformDecrypt(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& cipherText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
+{
+ context.ref();
+ workQueue.dispatch([parameters = WTFMove(parameters), key = WTFMove(key), cipherText = WTFMove(cipherText), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), &context]() mutable {
+ auto& rsaParameters = downcast<CryptoAlgorithmRsaOaepParams>(*parameters);
+ auto& rsaKey = downcast<CryptoKeyRSA>(key.get());
+ auto result = decryptRSA_OAEP(rsaKey.hashAlgorithmIdentifier(), rsaParameters.labelVector(), rsaKey.platformKey(), rsaKey.keySizeInBits(), cipherText.data(), cipherText.size());
+ if (result.hasException()) {
+ context.postTask([exceptionCallback = WTFMove(exceptionCallback), ec = result.releaseException().code()](ScriptExecutionContext& context) {
+ exceptionCallback(ec);
+ context.deref();
+ });
+ return;
+ }
+ context.postTask([callback = WTFMove(callback), result = result.releaseReturnValue()](ScriptExecutionContext& context) {
+ callback(result);
+ context.deref();
+ });
+ });
+}
+
</ins><span class="cx"> ExceptionOr<void> CryptoAlgorithmRSA_OAEP::platformEncrypt(const CryptoAlgorithmRsaOaepParamsDeprecated& parameters, const CryptoKeyRSA& key, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback)
</span><span class="cx"> {
</span><span class="cx"> ASSERT(parameters.hasLabel || parameters.label.isEmpty());
</span><span class="lines">@@ -86,23 +124,15 @@
</span><span class="cx"> return { };
</span><span class="cx"> }
</span><span class="cx">
</span><del>-// FIXME: We should get rid of the magic number 1024. It only makes sense when key length < 8192 bits
</del><span class="cx"> ExceptionOr<void> CryptoAlgorithmRSA_OAEP::platformDecrypt(const CryptoAlgorithmRsaOaepParamsDeprecated& parameters, const CryptoKeyRSA& key, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback)
</span><span class="cx"> {
</span><del>- CCDigestAlgorithm digestAlgorithm;
- if (!getCommonCryptoDigestAlgorithm(parameters.hash, digestAlgorithm))
- return Exception { NOT_SUPPORTED_ERR };
-
- Vector<uint8_t> plainText(1024);
- size_t plainTextLength = plainText.size();
- CCCryptorStatus status = CCRSACryptorDecrypt(key.platformKey(), ccOAEPPadding, data.first, data.second, plainText.data(), &plainTextLength, parameters.label.data(), parameters.label.size(), digestAlgorithm);
- if (status) {
</del><ins>+ ASSERT(parameters.hasLabel || parameters.label.isEmpty());
+ auto result = decryptRSA_OAEP(parameters.hash, parameters.label, key.platformKey(), key.keySizeInBits(), data.first, data.second);
+ if (result.hasException()) {
</ins><span class="cx"> failureCallback();
</span><span class="cx"> return { };
</span><span class="cx"> }
</span><del>-
- plainText.resize(plainTextLength);
- callback(plainText);
</del><ins>+ callback(result.releaseReturnValue());
</ins><span class="cx"> return { };
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>