<!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
&lt;rdar://problem/29257848&gt;

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  &lt;jiewen_tan@apple.com&gt;
+
+        Update SubtleCrypto::decrypt to match the latest spec
+        https://bugs.webkit.org/show_bug.cgi?id=164739
+        &lt;rdar://problem/29257848&gt;
+
+        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  &lt;cdumez@apple.com&gt;
</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 &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS crypto.subtle.decrypt({name: &quot;aes-cbc&quot;, iv: asciiToUint8Array(&quot;&quot;)}, key, cipherText) rejected promise  with OperationError (DOM Exception 34): The operation failed for an operation-specific reason.
+PASS crypto.subtle.decrypt({name: &quot;aes-cbc&quot;, iv: asciiToUint8Array(&quot;j&quot;)}, key, cipherText) rejected promise  with OperationError (DOM Exception 34): The operation failed for an operation-specific reason.
+PASS crypto.subtle.decrypt({name: &quot;aes-cbc&quot;, iv: asciiToUint8Array(&quot;jnOw99oOZFLIEPMrd&quot;)}, 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>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test decrypting using AES-CBC with malformed parameters&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var cipherText = hexStringToUint8Array(&quot;2ffa4618784dfd414b22c40c6330d022&quot;);
+var rawKey = asciiToUint8Array(&quot;jnOw99oOZFLIEPMr&quot;);
+
+crypto.subtle.importKey(&quot;raw&quot;, rawKey, &quot;aes-cbc&quot;, extractable, [&quot;decrypt&quot;]).then(function(result) {
+    key = result;
+    // Wrong iv length
+    shouldReject('crypto.subtle.decrypt({name: &quot;aes-cbc&quot;, iv: asciiToUint8Array(&quot;&quot;)}, key, cipherText)');
+    shouldReject('crypto.subtle.decrypt({name: &quot;aes-cbc&quot;, iv: asciiToUint8Array(&quot;j&quot;)}, key, cipherText)');
+    shouldReject('crypto.subtle.decrypt({name: &quot;aes-cbc&quot;, iv: asciiToUint8Array(&quot;jnOw99oOZFLIEPMrd&quot;)}, key, cipherText)');
+
+    finishJSTest();
+});
+
+&lt;/script&gt;
+
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</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&amp;decrypting using AES-CBC algorithm with a generated 256bit key
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+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>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test encrypting&amp;decrypting using AES-CBC algorithm with a generated 256bit key&quot;);
+
+jsTestIsAsync = true;
+var plainText = &quot;Hello, World!&quot;;
+var aesCbcParams = {
+    name: &quot;aes-cbc&quot;,
+    iv: asciiToUint8Array(&quot;jnOw99oOZFLIEPMr&quot;),
+}
+
+debug(&quot;Generating a key...&quot;);
+crypto.subtle.generateKey({name: &quot;aes-cbc&quot;, length: 256}, true, [&quot;decrypt&quot;, &quot;encrypt&quot;]).then(function(result) {
+    key = result;
+    debug(&quot;Encrypting...&quot;);
+    return crypto.subtle.encrypt(aesCbcParams, key, asciiToUint8Array(plainText));
+}).then(function(cipherText) {
+    debug(&quot;Decrypting...&quot;);
+    return crypto.subtle.decrypt(aesCbcParams, key, cipherText);
+}).then(function(result) {
+    decryptedText = result;
+
+    shouldBe(&quot;bytesToASCIIString(decryptedText)&quot;, &quot;plainText&quot;);
+
+    finishJSTest();
+});
+&lt;/script&gt;
+
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</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 &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+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>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test decrypting using AES-CBC with an imported 128bit key&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var cipherText = hexStringToUint8Array(&quot;2ffa4618784dfd414b22c40c6330d022&quot;);
+var aesCbcParams = {
+    name: &quot;aes-cbc&quot;,
+    iv: asciiToUint8Array(&quot;jnOw99oOZFLIEPMr&quot;),
+}
+var rawKey = asciiToUint8Array(&quot;jnOw99oOZFLIEPMr&quot;);
+var expectedPlainText = &quot;Hello, World!&quot;;
+
+crypto.subtle.importKey(&quot;raw&quot;, rawKey, &quot;aes-cbc&quot;, extractable, [&quot;decrypt&quot;]).then(function(key) {
+    return crypto.subtle.decrypt(aesCbcParams, key, cipherText);
+}).then(function(result) {
+    plainText = result;
+
+    shouldBe(&quot;bytesToASCIIString(plainText)&quot;, &quot;expectedPlainText&quot;);
+
+    finishJSTest();
+});
+
+&lt;/script&gt;
+
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</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 &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+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>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test decrypting with malformed parameters&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var cipherText = hexStringToUint8Array(&quot;2ffa4618784dfd414b22c40c6330d022&quot;);
+var aesCbcParams = {
+    name: &quot;aes-cbc&quot;,
+    iv: asciiToUint8Array(&quot;jnOw99oOZFLIEPMr&quot;),
+}
+var rawKey = asciiToUint8Array(&quot;jnOw99oOZFLIEPMr&quot;);
+
+// Not enough arguments.
+shouldReject('crypto.subtle.decrypt()');
+shouldReject('crypto.subtle.decrypt(1)');
+shouldReject('crypto.subtle.decrypt(1, 2)');
+
+crypto.subtle.importKey(&quot;raw&quot;, rawKey, &quot;aes-kw&quot;, extractable, [&quot;wrapKey&quot;, &quot;unwrapKey&quot;]).then(function(result) {
+    wrongKey = result;
+    // Wrong algorithm identifier.
+    shouldReject('crypto.subtle.decrypt(aesCbcParams, wrongKey, cipherText)');
+
+    return crypto.subtle.importKey(&quot;raw&quot;, rawKey, &quot;aes-cbc&quot;, extractable, [&quot;wrapKey&quot;, &quot;unwrapKey&quot;]);
+}).then(function(result) {
+    wrongKey = result;
+    // Wrong usage.
+    return shouldReject('crypto.subtle.decrypt(aesCbcParams, wrongKey, cipherText)');
+}).then(finishJSTest);
+
+&lt;/script&gt;
+
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</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 &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+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>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test decrypting using RSA-OAEP with malformed parameters&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var cipherText = hexStringToUint8Array(&quot;346dc8f3a158e494004cf82c0843ab1c1e7a612263a1c44d941309175a3d2598997be651f2d3419f89923843ca344414d45989e886aaa79573d96d4f3f777af3b2e9fcd44b51c00a8e4395bf54ac89d88559c712d49853de448e190fad886c45fa0742f2ddf18e5f6155eb7f38348217efd67c14ef141e81f3b1c1804b3bb437ef1b23a25dadb594985c500181208c74cd2068cbfdccc02db7113ed5e72d7a3543a78ec9c2070715e409ab10687762358f786c669e592e467107a13caaaadc3c341facf249baf743a3b93c49f73ea5634052f1a6ee46265e02391dd2cbcd4a523bfee8321470279fff63b87a4a53465b4736fb31ee99e9b0379761f3e630f636&quot;);
+var jwkKey = {
+    kty: &quot;RSA&quot;,
+    alg: &quot;RSA-OAEP&quot;,
+    use: &quot;enc&quot;,
+    key_ops: [&quot;decrypt&quot;, &quot;unwrapKey&quot;],
+    ext: true,
+    n: &quot;lxHN0N9VRZ0_pl0xv3-NXx70WnjkODSkQ5LjHXTFy3DOQsvkagFzD9HqYQezCmcewLjdK5PLwSesDoMdfL6tusBHcvyit1kvydYFQ3NLbENNkYsiBG5_nW4IQGL6JKbZ5iGdUop98QHKm6YZR1u4zrAtxM6bVEo05VvhjRS0M8yWoZVi-7Vdsc0LqI0Qdq_NoctX5Fu-AqiBN7Uo1HkYGcP2oC82J_J5cjw98BQiP5kDWThq9RK-X6S-EUALx_m4iG6iOYKTA3SQyf1xBqFaXXoEJjcckbOqkegecz5b-YWUh8iZPvhwnt-RZwpIbLJgKwz19ndkn9KvoEEw7YbEow&quot;,
+    e: &quot;AQAB&quot;,
+    d: &quot;cj5DkDakjM2bKduGWJREO-_zyEtuA1dD9doqKMd7IRuA0CDS7puEAS20-oXRDwfmyMXEdEUDrGGtCxh6fzDPvs_T-JA3GUK4EgHo3xZcrlXDXlKCeil6Fnr0gISZOIh5dkBrcdVL4quBJe4ZZc5mVuAC7Ld13et0TxMJ4iALGrPuqPVUOGSYIcZ9idx5zKKBWhY3tPggEdKpnHBmPfTRO4yZaf0Nw1QXrgSMZY9ejeuaurAh4Q8o4-6-r8O2LUe7ufMh_ccKkXISEh4KdOnT17EM9BQTn9UNS9GoK2ZZU0U3io5DSu_kpasr4uOVWcGlE2wczOv2nkGwG39F3sFF0Q&quot;,
+    p: &quot;x5vnco5j-TD6hTOzyN4DhkZ44m05NycxT6SUE2qTurT3-uze_L7TYutLRIRkovRMhTHZAr2pziRlasEs13PEz9Zvx1I_T68srsonrdbak-SFMecM7EjHc5C-J13gXhw9HIW28_Sx9rQ-JkGwEwE9PEdIUfuvdqpgh3SmXwPJrEs&quot;,
+    q: &quot;wb9vllg_2n-kNge0bThg_7xu1UwTzipM8vxSUkkV2IipJKIAekkU3aAB8LoPhUI0-17pSGw3ETOO27t163TI9qIPpzLbhTH9aUi7qLGbKlzPlgnqP43Z0LHxc3xKDgit-Ar29QLaX2uoJBX6VVWvhmh7BIPDHNVM5GZjwWORYgk&quot;,
+    dp: &quot;C2c8sa6wx2uk5Dcv7inAycr83PKgciYrCwG78-AC0IfGIu-lTYsZSG1ov2FQ3n5WYMWYQC_Vo5EwugiPJz_V3onBmQF53HOFefbSjXvYwNotQcyRUG5X9qIuOtGCH949H4QED6vK_u0NH-JgzLUlamwoFYbrXzwch6CCYKs2ukE&quot;,
+    dq: &quot;hbtRloDLclHwUqr2yvzDV0IFbozYjtF706x-VfXEcnXB6ls34TBYirFLJZIH7H9KeseEVkz7pY_k5555QlCV9kbebxYXl9RtiiJ-BW6yH4d4caPeYIfU9MweUQxVQWKUUkWfOHcDrCFvKZlR9Vzzjt7HKtKX9mr0bCKQcIf9baE&quot;,
+    qi: &quot;a-7hUTTnclUPKOfSgH8zEKGJ-AvdFEzxvZ5sq46Qf2MbORxVjN4dJamVvM-FoqcwN-9cuUlyr9bSFTwUBW4vXa8Xj9a8JfViuMCqzR-mL1rGIUQ5ARGhNcSsRlyKTqz5BlWlVKmXIx_p-DeVwPWiJJy4k_FqyBxrnxkzomHfrxk&quot;,
+};
+var rsaOaepParams = {
+    name: &quot;rsa-oaep&quot;,
+    // Wrong label. Correct one is &quot;WebKit.org&quot;
+    label: asciiToUint8Array(&quot;apple.com&quot;),
+}
+
+crypto.subtle.importKey(&quot;jwk&quot;, jwkKey, {name: &quot;RSA-OAEP&quot;, hash: &quot;SHA-1&quot;}, extractable, [&quot;decrypt&quot;]).then(function(result) {
+    key = result;
+
+    // Wrong label.
+    shouldReject(&quot;crypto.subtle.decrypt(rsaOaepParams, key, cipherText)&quot;).then(finishJSTest);
+});
+
+&lt;/script&gt;
+
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</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&amp;decrypting using RSA-OAEP SHA-512 algorithm with a generated key
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+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&amp;decrypting using RSA-OAEP SHA-512 algorithm with a generated key and a label
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+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>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test encrypting&amp;decrypting using RSA-OAEP SHA-512 algorithm with a generated key and a label&quot;);
+
+jsTestIsAsync = true;
+var plainText = &quot;Hello, World!&quot;;
+var algorithmKeyGen = {
+    name: &quot;RSA-OAEP&quot;,
+    // RsaKeyGenParams
+    modulusLength: 2048,
+    publicExponent: new Uint8Array([0x01, 0x00, 0x01]),  // Equivalent to 65537
+    hash: &quot;sha-512&quot;
+};
+var rsaOaepParams = {
+    name: &quot;rsa-oaep&quot;,
+    label: asciiToUint8Array(&quot;WebKit.org&quot;),
+}
+
+debug(&quot;Generating a key...&quot;);
+crypto.subtle.generateKey(algorithmKeyGen, true, [&quot;decrypt&quot;, &quot;encrypt&quot;]).then(function(result) {
+    keyPair = result;
+    debug(&quot;Encrypting...&quot;);
+    return crypto.subtle.encrypt(rsaOaepParams, keyPair.publicKey, asciiToUint8Array(plainText));
+}).then(function(cipherText) {
+    debug(&quot;Decrypting...&quot;);
+    return crypto.subtle.decrypt(rsaOaepParams, keyPair.privateKey, cipherText);
+}).then(function(result) {
+    decryptedText = result;
+
+    shouldBe(&quot;bytesToASCIIString(decryptedText)&quot;, &quot;plainText&quot;);
+
+    finishJSTest();
+});
+&lt;/script&gt;
+
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</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>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test encrypting&amp;decrypting using RSA-OAEP SHA-512 algorithm with a generated key&quot;);
+
+jsTestIsAsync = true;
+var plainText = &quot;Hello, World!&quot;;
+var algorithmKeyGen = {
+    name: &quot;RSA-OAEP&quot;,
+    // RsaKeyGenParams
+    modulusLength: 2048,
+    publicExponent: new Uint8Array([0x01, 0x00, 0x01]),  // Equivalent to 65537
+    hash: &quot;sha-512&quot;
+};
+var rsaOaepParams = {
+    name: &quot;rsa-oaep&quot;
+}
+
+debug(&quot;Generating a key...&quot;);
+crypto.subtle.generateKey(algorithmKeyGen, true, [&quot;decrypt&quot;, &quot;encrypt&quot;]).then(function(result) {
+    keyPair = result;
+    debug(&quot;Encrypting...&quot;);
+    return crypto.subtle.encrypt(rsaOaepParams, keyPair.publicKey, asciiToUint8Array(plainText));
+}).then(function(cipherText) {
+    debug(&quot;Decrypting...&quot;);
+    return crypto.subtle.decrypt(rsaOaepParams, keyPair.privateKey, cipherText);
+}).then(function(result) {
+    decryptedText = result;
+
+    shouldBe(&quot;bytesToASCIIString(decryptedText)&quot;, &quot;plainText&quot;);
+
+    finishJSTest();
+});
+&lt;/script&gt;
+
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</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 &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+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 &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+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>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test decrypting using RSA-OAEP SHA-1 with an imported key and a label&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var cipherText = hexStringToUint8Array(&quot;346dc8f3a158e494004cf82c0843ab1c1e7a612263a1c44d941309175a3d2598997be651f2d3419f89923843ca344414d45989e886aaa79573d96d4f3f777af3b2e9fcd44b51c00a8e4395bf54ac89d88559c712d49853de448e190fad886c45fa0742f2ddf18e5f6155eb7f38348217efd67c14ef141e81f3b1c1804b3bb437ef1b23a25dadb594985c500181208c74cd2068cbfdccc02db7113ed5e72d7a3543a78ec9c2070715e409ab10687762358f786c669e592e467107a13caaaadc3c341facf249baf743a3b93c49f73ea5634052f1a6ee46265e02391dd2cbcd4a523bfee8321470279fff63b87a4a53465b4736fb31ee99e9b0379761f3e630f636&quot;);
+var jwkKey = {
+    kty: &quot;RSA&quot;,
+    alg: &quot;RSA-OAEP&quot;,
+    use: &quot;enc&quot;,
+    key_ops: [&quot;decrypt&quot;, &quot;unwrapKey&quot;],
+    ext: true,
+    n: &quot;lxHN0N9VRZ0_pl0xv3-NXx70WnjkODSkQ5LjHXTFy3DOQsvkagFzD9HqYQezCmcewLjdK5PLwSesDoMdfL6tusBHcvyit1kvydYFQ3NLbENNkYsiBG5_nW4IQGL6JKbZ5iGdUop98QHKm6YZR1u4zrAtxM6bVEo05VvhjRS0M8yWoZVi-7Vdsc0LqI0Qdq_NoctX5Fu-AqiBN7Uo1HkYGcP2oC82J_J5cjw98BQiP5kDWThq9RK-X6S-EUALx_m4iG6iOYKTA3SQyf1xBqFaXXoEJjcckbOqkegecz5b-YWUh8iZPvhwnt-RZwpIbLJgKwz19ndkn9KvoEEw7YbEow&quot;,
+    e: &quot;AQAB&quot;,
+    d: &quot;cj5DkDakjM2bKduGWJREO-_zyEtuA1dD9doqKMd7IRuA0CDS7puEAS20-oXRDwfmyMXEdEUDrGGtCxh6fzDPvs_T-JA3GUK4EgHo3xZcrlXDXlKCeil6Fnr0gISZOIh5dkBrcdVL4quBJe4ZZc5mVuAC7Ld13et0TxMJ4iALGrPuqPVUOGSYIcZ9idx5zKKBWhY3tPggEdKpnHBmPfTRO4yZaf0Nw1QXrgSMZY9ejeuaurAh4Q8o4-6-r8O2LUe7ufMh_ccKkXISEh4KdOnT17EM9BQTn9UNS9GoK2ZZU0U3io5DSu_kpasr4uOVWcGlE2wczOv2nkGwG39F3sFF0Q&quot;,
+    p: &quot;x5vnco5j-TD6hTOzyN4DhkZ44m05NycxT6SUE2qTurT3-uze_L7TYutLRIRkovRMhTHZAr2pziRlasEs13PEz9Zvx1I_T68srsonrdbak-SFMecM7EjHc5C-J13gXhw9HIW28_Sx9rQ-JkGwEwE9PEdIUfuvdqpgh3SmXwPJrEs&quot;,
+    q: &quot;wb9vllg_2n-kNge0bThg_7xu1UwTzipM8vxSUkkV2IipJKIAekkU3aAB8LoPhUI0-17pSGw3ETOO27t163TI9qIPpzLbhTH9aUi7qLGbKlzPlgnqP43Z0LHxc3xKDgit-Ar29QLaX2uoJBX6VVWvhmh7BIPDHNVM5GZjwWORYgk&quot;,
+    dp: &quot;C2c8sa6wx2uk5Dcv7inAycr83PKgciYrCwG78-AC0IfGIu-lTYsZSG1ov2FQ3n5WYMWYQC_Vo5EwugiPJz_V3onBmQF53HOFefbSjXvYwNotQcyRUG5X9qIuOtGCH949H4QED6vK_u0NH-JgzLUlamwoFYbrXzwch6CCYKs2ukE&quot;,
+    dq: &quot;hbtRloDLclHwUqr2yvzDV0IFbozYjtF706x-VfXEcnXB6ls34TBYirFLJZIH7H9KeseEVkz7pY_k5555QlCV9kbebxYXl9RtiiJ-BW6yH4d4caPeYIfU9MweUQxVQWKUUkWfOHcDrCFvKZlR9Vzzjt7HKtKX9mr0bCKQcIf9baE&quot;,
+    qi: &quot;a-7hUTTnclUPKOfSgH8zEKGJ-AvdFEzxvZ5sq46Qf2MbORxVjN4dJamVvM-FoqcwN-9cuUlyr9bSFTwUBW4vXa8Xj9a8JfViuMCqzR-mL1rGIUQ5ARGhNcSsRlyKTqz5BlWlVKmXIx_p-DeVwPWiJJy4k_FqyBxrnxkzomHfrxk&quot;,
+};
+var rsaOaepParams = {
+    name: &quot;rsa-oaep&quot;,
+    label: asciiToUint8Array(&quot;WebKit.org&quot;),
+}
+var expectedPlainText = &quot;Hello, World!&quot;;
+
+crypto.subtle.importKey(&quot;jwk&quot;, jwkKey, {name: &quot;RSA-OAEP&quot;, hash: &quot;SHA-1&quot;}, extractable, [&quot;decrypt&quot;]).then(function(key) {
+    return crypto.subtle.decrypt(rsaOaepParams, key, cipherText);
+}).then(function(result) {
+    plainText = result;
+
+    shouldBe(&quot;bytesToASCIIString(plainText)&quot;, &quot;expectedPlainText&quot;);
+
+    finishJSTest();
+});
+&lt;/script&gt;
+
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</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>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test decrypting using RSA-OAEP SHA-1 with an imported key&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var cipherText = hexStringToUint8Array(&quot;64ea45b5234b05666dc21ca6f7cd6ecb0be8ce4576c0bbe9686e70c9f3ab67a9f0a4db226554f217ba7259634c7b70eb422633277d83aeb2181a001099bacbca8b5b534a77843fe611f646838999e82e681f1d1724ef0e9f65ac3020128c56ea90a0345d936e8e226b363687c7b57146eecd4ab599760661a278671b5b249051b1f1720d6e78085e321ce82867df81a67b8606e340850b189fcd08d63b1ac8ce9a97300b8c15c3c475c97f1266606b48b67a15c28937d88e0749c83212737732c74a7fdf79188405c6df72b9ee2b753f4f70ae35f2f035c5827e0c87fcceeef1c4e303c0e89ecc76773fb58e6f5a06b792ae7a1b58ee7bf09893c8fd2b93da0d&quot;);
+var jwkKey = {
+    kty: &quot;RSA&quot;,
+    alg: &quot;RSA-OAEP&quot;,
+    use: &quot;enc&quot;,
+    key_ops: [&quot;decrypt&quot;, &quot;unwrapKey&quot;],
+    ext: true,
+    n: &quot;lxHN0N9VRZ0_pl0xv3-NXx70WnjkODSkQ5LjHXTFy3DOQsvkagFzD9HqYQezCmcewLjdK5PLwSesDoMdfL6tusBHcvyit1kvydYFQ3NLbENNkYsiBG5_nW4IQGL6JKbZ5iGdUop98QHKm6YZR1u4zrAtxM6bVEo05VvhjRS0M8yWoZVi-7Vdsc0LqI0Qdq_NoctX5Fu-AqiBN7Uo1HkYGcP2oC82J_J5cjw98BQiP5kDWThq9RK-X6S-EUALx_m4iG6iOYKTA3SQyf1xBqFaXXoEJjcckbOqkegecz5b-YWUh8iZPvhwnt-RZwpIbLJgKwz19ndkn9KvoEEw7YbEow&quot;,
+    e: &quot;AQAB&quot;,
+    d: &quot;cj5DkDakjM2bKduGWJREO-_zyEtuA1dD9doqKMd7IRuA0CDS7puEAS20-oXRDwfmyMXEdEUDrGGtCxh6fzDPvs_T-JA3GUK4EgHo3xZcrlXDXlKCeil6Fnr0gISZOIh5dkBrcdVL4quBJe4ZZc5mVuAC7Ld13et0TxMJ4iALGrPuqPVUOGSYIcZ9idx5zKKBWhY3tPggEdKpnHBmPfTRO4yZaf0Nw1QXrgSMZY9ejeuaurAh4Q8o4-6-r8O2LUe7ufMh_ccKkXISEh4KdOnT17EM9BQTn9UNS9GoK2ZZU0U3io5DSu_kpasr4uOVWcGlE2wczOv2nkGwG39F3sFF0Q&quot;,
+    p: &quot;x5vnco5j-TD6hTOzyN4DhkZ44m05NycxT6SUE2qTurT3-uze_L7TYutLRIRkovRMhTHZAr2pziRlasEs13PEz9Zvx1I_T68srsonrdbak-SFMecM7EjHc5C-J13gXhw9HIW28_Sx9rQ-JkGwEwE9PEdIUfuvdqpgh3SmXwPJrEs&quot;,
+    q: &quot;wb9vllg_2n-kNge0bThg_7xu1UwTzipM8vxSUkkV2IipJKIAekkU3aAB8LoPhUI0-17pSGw3ETOO27t163TI9qIPpzLbhTH9aUi7qLGbKlzPlgnqP43Z0LHxc3xKDgit-Ar29QLaX2uoJBX6VVWvhmh7BIPDHNVM5GZjwWORYgk&quot;,
+    dp: &quot;C2c8sa6wx2uk5Dcv7inAycr83PKgciYrCwG78-AC0IfGIu-lTYsZSG1ov2FQ3n5WYMWYQC_Vo5EwugiPJz_V3onBmQF53HOFefbSjXvYwNotQcyRUG5X9qIuOtGCH949H4QED6vK_u0NH-JgzLUlamwoFYbrXzwch6CCYKs2ukE&quot;,
+    dq: &quot;hbtRloDLclHwUqr2yvzDV0IFbozYjtF706x-VfXEcnXB6ls34TBYirFLJZIH7H9KeseEVkz7pY_k5555QlCV9kbebxYXl9RtiiJ-BW6yH4d4caPeYIfU9MweUQxVQWKUUkWfOHcDrCFvKZlR9Vzzjt7HKtKX9mr0bCKQcIf9baE&quot;,
+    qi: &quot;a-7hUTTnclUPKOfSgH8zEKGJ-AvdFEzxvZ5sq46Qf2MbORxVjN4dJamVvM-FoqcwN-9cuUlyr9bSFTwUBW4vXa8Xj9a8JfViuMCqzR-mL1rGIUQ5ARGhNcSsRlyKTqz5BlWlVKmXIx_p-DeVwPWiJJy4k_FqyBxrnxkzomHfrxk&quot;,
+};
+var rsaOaepParams = {
+    name: &quot;rsa-oaep&quot;
+}
+var expectedPlainText = &quot;Hello, World!&quot;;
+
+crypto.subtle.importKey(&quot;jwk&quot;, jwkKey, {name: &quot;RSA-OAEP&quot;, hash: &quot;SHA-1&quot;}, extractable, [&quot;decrypt&quot;]).then(function(key) {
+    return crypto.subtle.decrypt(rsaOaepParams, key, cipherText);
+}).then(function(result) {
+    plainText = result;
+
+    shouldBe(&quot;bytesToASCIIString(plainText)&quot;, &quot;expectedPlainText&quot;);
+
+    finishJSTest();
+});
+
+&lt;/script&gt;
+
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</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&amp;decrypting using RSAES-PKCS1-v1_5 algorithm with a generated key
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+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>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test encrypting&amp;decrypting using RSAES-PKCS1-v1_5 algorithm with a generated key&quot;);
+
+jsTestIsAsync = true;
+var plainText = &quot;Hello, World!&quot;;
+var algorithmKeyGen = {
+    name: &quot;RSAES-PKCS1-v1_5&quot;,
+    // RsaKeyGenParams
+    modulusLength: 2048,
+    publicExponent: new Uint8Array([0x01, 0x00, 0x01]),  // Equivalent to 65537
+};
+
+debug(&quot;Generating a key...&quot;);
+crypto.subtle.generateKey(algorithmKeyGen, true, [&quot;decrypt&quot;, &quot;encrypt&quot;]).then(function(result) {
+    keyPair = result;
+    debug(&quot;Encrypting...&quot;);
+    return crypto.subtle.encrypt(&quot;RSAES-PKCS1-v1_5&quot;, keyPair.publicKey, asciiToUint8Array(plainText));
+}).then(function(cipherText) {
+    debug(&quot;Decrypting...&quot;);
+    return crypto.subtle.decrypt(&quot;RSAES-PKCS1-v1_5&quot;, keyPair.privateKey, cipherText);
+}).then(function(result) {
+    decryptedText = result;
+
+    shouldBe(&quot;bytesToASCIIString(decryptedText)&quot;, &quot;plainText&quot;);
+
+    finishJSTest();
+});
+&lt;/script&gt;
+
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</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 &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+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>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test decrypting using RSAES-PKCS1-v1_5 with an imported key&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var cipherText = hexStringToUint8Array(&quot;87ca360442614b6590ea51ba84eb081ecda83c5a19e008ed21a6b93c78a7980348f9eac9a8120a6b67326b58ff6e7a10bec113b01f6bd18a04b82d159eb3532c03d4fca597450333cd4df81456b7b864a276cc3a7551964ccc16de86e2bc7a42981f29a0855fc151692d802f6d0b6fdcc0cc01977c579acde220b60d418a480f0ccdfd370f7e045114be39f03dfd516b51bcba6af20663cb2404e4e8c5b4c239936c672c3c2de4f4f3382cdc68f277fc66ed06a0642584ead53cd676673e8cecf59fe23cbe0a59cd82c8d56187eff6cda9b9e600b9890f42c65ee9a4f16f87c1c0b53cecb6fb59a4de165cc828d6bc5b5bf152e6c3060b54fd4e11b037668e4d&quot;);
+var jwkKey = {
+    kty: &quot;RSA&quot;,
+    alg: &quot;RSA1_5&quot;,
+    use: &quot;enc&quot;,
+    key_ops: [&quot;decrypt&quot;, &quot;unwrapKey&quot;],
+    ext: true,
+    n: &quot;lxHN0N9VRZ0_pl0xv3-NXx70WnjkODSkQ5LjHXTFy3DOQsvkagFzD9HqYQezCmcewLjdK5PLwSesDoMdfL6tusBHcvyit1kvydYFQ3NLbENNkYsiBG5_nW4IQGL6JKbZ5iGdUop98QHKm6YZR1u4zrAtxM6bVEo05VvhjRS0M8yWoZVi-7Vdsc0LqI0Qdq_NoctX5Fu-AqiBN7Uo1HkYGcP2oC82J_J5cjw98BQiP5kDWThq9RK-X6S-EUALx_m4iG6iOYKTA3SQyf1xBqFaXXoEJjcckbOqkegecz5b-YWUh8iZPvhwnt-RZwpIbLJgKwz19ndkn9KvoEEw7YbEow&quot;,
+    e: &quot;AQAB&quot;,
+    d: &quot;cj5DkDakjM2bKduGWJREO-_zyEtuA1dD9doqKMd7IRuA0CDS7puEAS20-oXRDwfmyMXEdEUDrGGtCxh6fzDPvs_T-JA3GUK4EgHo3xZcrlXDXlKCeil6Fnr0gISZOIh5dkBrcdVL4quBJe4ZZc5mVuAC7Ld13et0TxMJ4iALGrPuqPVUOGSYIcZ9idx5zKKBWhY3tPggEdKpnHBmPfTRO4yZaf0Nw1QXrgSMZY9ejeuaurAh4Q8o4-6-r8O2LUe7ufMh_ccKkXISEh4KdOnT17EM9BQTn9UNS9GoK2ZZU0U3io5DSu_kpasr4uOVWcGlE2wczOv2nkGwG39F3sFF0Q&quot;,
+    p: &quot;x5vnco5j-TD6hTOzyN4DhkZ44m05NycxT6SUE2qTurT3-uze_L7TYutLRIRkovRMhTHZAr2pziRlasEs13PEz9Zvx1I_T68srsonrdbak-SFMecM7EjHc5C-J13gXhw9HIW28_Sx9rQ-JkGwEwE9PEdIUfuvdqpgh3SmXwPJrEs&quot;,
+    q: &quot;wb9vllg_2n-kNge0bThg_7xu1UwTzipM8vxSUkkV2IipJKIAekkU3aAB8LoPhUI0-17pSGw3ETOO27t163TI9qIPpzLbhTH9aUi7qLGbKlzPlgnqP43Z0LHxc3xKDgit-Ar29QLaX2uoJBX6VVWvhmh7BIPDHNVM5GZjwWORYgk&quot;,
+    dp: &quot;C2c8sa6wx2uk5Dcv7inAycr83PKgciYrCwG78-AC0IfGIu-lTYsZSG1ov2FQ3n5WYMWYQC_Vo5EwugiPJz_V3onBmQF53HOFefbSjXvYwNotQcyRUG5X9qIuOtGCH949H4QED6vK_u0NH-JgzLUlamwoFYbrXzwch6CCYKs2ukE&quot;,
+    dq: &quot;hbtRloDLclHwUqr2yvzDV0IFbozYjtF706x-VfXEcnXB6ls34TBYirFLJZIH7H9KeseEVkz7pY_k5555QlCV9kbebxYXl9RtiiJ-BW6yH4d4caPeYIfU9MweUQxVQWKUUkWfOHcDrCFvKZlR9Vzzjt7HKtKX9mr0bCKQcIf9baE&quot;,
+    qi: &quot;a-7hUTTnclUPKOfSgH8zEKGJ-AvdFEzxvZ5sq46Qf2MbORxVjN4dJamVvM-FoqcwN-9cuUlyr9bSFTwUBW4vXa8Xj9a8JfViuMCqzR-mL1rGIUQ5ARGhNcSsRlyKTqz5BlWlVKmXIx_p-DeVwPWiJJy4k_FqyBxrnxkzomHfrxk&quot;,
+};
+var expectedPlainText = &quot;Hello, World!&quot;;
+
+crypto.subtle.importKey(&quot;jwk&quot;, jwkKey, &quot;RSAES-PKCS1-v1_5&quot;, extractable, [&quot;decrypt&quot;]).then(function(key) {
+    return crypto.subtle.decrypt(&quot;RSAES-PKCS1-v1_5&quot;, key, cipherText);
+}).then(function(result) {
+    plainText = result;
+
+    shouldBe(&quot;bytesToASCIIString(plainText)&quot;, &quot;expectedPlainText&quot;);
+
+    finishJSTest();
+});
+&lt;/script&gt;
+
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</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 &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+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>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;script src=&quot;../../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;script&gt;
+        worker = startWorker('resources/aes-cbc-import-key-decrypt.js');
+    &lt;/script&gt;
+    &lt;script src=&quot;../../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</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(&quot;Test decrypting using AES-CBC with an imported 128bit key in workers&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var cipherText = hexStringToUint8Array(&quot;2ffa4618784dfd414b22c40c6330d022&quot;);
+var aesCbcParams = {
+    name: &quot;aes-cbc&quot;,
+    iv: asciiToUint8Array(&quot;jnOw99oOZFLIEPMr&quot;),
+}
+var rawKey = asciiToUint8Array(&quot;jnOw99oOZFLIEPMr&quot;);
+var expectedPlainText = &quot;Hello, World!&quot;;
+
+crypto.subtle.importKey(&quot;raw&quot;, rawKey, &quot;aes-cbc&quot;, extractable, [&quot;decrypt&quot;]).then(function(key) {
+    return crypto.subtle.decrypt(aesCbcParams, key, cipherText);
+}).then(function(result) {
+    plainText = result;
+
+    shouldBe(&quot;bytesToASCIIString(plainText)&quot;, &quot;expectedPlainText&quot;);
+
+    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(&quot;Test decrypting using RSA-OAEP SHA-1 with an imported key and a label in workers&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var cipherText = hexStringToUint8Array(&quot;346dc8f3a158e494004cf82c0843ab1c1e7a612263a1c44d941309175a3d2598997be651f2d3419f89923843ca344414d45989e886aaa79573d96d4f3f777af3b2e9fcd44b51c00a8e4395bf54ac89d88559c712d49853de448e190fad886c45fa0742f2ddf18e5f6155eb7f38348217efd67c14ef141e81f3b1c1804b3bb437ef1b23a25dadb594985c500181208c74cd2068cbfdccc02db7113ed5e72d7a3543a78ec9c2070715e409ab10687762358f786c669e592e467107a13caaaadc3c341facf249baf743a3b93c49f73ea5634052f1a6ee46265e02391dd2cbcd4a523bfee8321470279fff63b87a4a53465b4736fb31ee99e9b0379761f3e630f636&quot;);
+var jwkKey = {
+    kty: &quot;RSA&quot;,
+    alg: &quot;RSA-OAEP&quot;,
+    use: &quot;enc&quot;,
+    key_ops: [&quot;decrypt&quot;, &quot;unwrapKey&quot;],
+    ext: true,
+    n: &quot;lxHN0N9VRZ0_pl0xv3-NXx70WnjkODSkQ5LjHXTFy3DOQsvkagFzD9HqYQezCmcewLjdK5PLwSesDoMdfL6tusBHcvyit1kvydYFQ3NLbENNkYsiBG5_nW4IQGL6JKbZ5iGdUop98QHKm6YZR1u4zrAtxM6bVEo05VvhjRS0M8yWoZVi-7Vdsc0LqI0Qdq_NoctX5Fu-AqiBN7Uo1HkYGcP2oC82J_J5cjw98BQiP5kDWThq9RK-X6S-EUALx_m4iG6iOYKTA3SQyf1xBqFaXXoEJjcckbOqkegecz5b-YWUh8iZPvhwnt-RZwpIbLJgKwz19ndkn9KvoEEw7YbEow&quot;,
+    e: &quot;AQAB&quot;,
+    d: &quot;cj5DkDakjM2bKduGWJREO-_zyEtuA1dD9doqKMd7IRuA0CDS7puEAS20-oXRDwfmyMXEdEUDrGGtCxh6fzDPvs_T-JA3GUK4EgHo3xZcrlXDXlKCeil6Fnr0gISZOIh5dkBrcdVL4quBJe4ZZc5mVuAC7Ld13et0TxMJ4iALGrPuqPVUOGSYIcZ9idx5zKKBWhY3tPggEdKpnHBmPfTRO4yZaf0Nw1QXrgSMZY9ejeuaurAh4Q8o4-6-r8O2LUe7ufMh_ccKkXISEh4KdOnT17EM9BQTn9UNS9GoK2ZZU0U3io5DSu_kpasr4uOVWcGlE2wczOv2nkGwG39F3sFF0Q&quot;,
+    p: &quot;x5vnco5j-TD6hTOzyN4DhkZ44m05NycxT6SUE2qTurT3-uze_L7TYutLRIRkovRMhTHZAr2pziRlasEs13PEz9Zvx1I_T68srsonrdbak-SFMecM7EjHc5C-J13gXhw9HIW28_Sx9rQ-JkGwEwE9PEdIUfuvdqpgh3SmXwPJrEs&quot;,
+    q: &quot;wb9vllg_2n-kNge0bThg_7xu1UwTzipM8vxSUkkV2IipJKIAekkU3aAB8LoPhUI0-17pSGw3ETOO27t163TI9qIPpzLbhTH9aUi7qLGbKlzPlgnqP43Z0LHxc3xKDgit-Ar29QLaX2uoJBX6VVWvhmh7BIPDHNVM5GZjwWORYgk&quot;,
+    dp: &quot;C2c8sa6wx2uk5Dcv7inAycr83PKgciYrCwG78-AC0IfGIu-lTYsZSG1ov2FQ3n5WYMWYQC_Vo5EwugiPJz_V3onBmQF53HOFefbSjXvYwNotQcyRUG5X9qIuOtGCH949H4QED6vK_u0NH-JgzLUlamwoFYbrXzwch6CCYKs2ukE&quot;,
+    dq: &quot;hbtRloDLclHwUqr2yvzDV0IFbozYjtF706x-VfXEcnXB6ls34TBYirFLJZIH7H9KeseEVkz7pY_k5555QlCV9kbebxYXl9RtiiJ-BW6yH4d4caPeYIfU9MweUQxVQWKUUkWfOHcDrCFvKZlR9Vzzjt7HKtKX9mr0bCKQcIf9baE&quot;,
+    qi: &quot;a-7hUTTnclUPKOfSgH8zEKGJ-AvdFEzxvZ5sq46Qf2MbORxVjN4dJamVvM-FoqcwN-9cuUlyr9bSFTwUBW4vXa8Xj9a8JfViuMCqzR-mL1rGIUQ5ARGhNcSsRlyKTqz5BlWlVKmXIx_p-DeVwPWiJJy4k_FqyBxrnxkzomHfrxk&quot;,
+};
+var rsaOaepParams = {
+    name: &quot;rsa-oaep&quot;,
+    label: asciiToUint8Array(&quot;WebKit.org&quot;),
+}
+var expectedPlainText = &quot;Hello, World!&quot;;
+
+crypto.subtle.importKey(&quot;jwk&quot;, jwkKey, {name: &quot;RSA-OAEP&quot;, hash: &quot;SHA-1&quot;}, extractable, [&quot;decrypt&quot;]).then(function(key) {
+    return crypto.subtle.decrypt(rsaOaepParams, key, cipherText);
+}).then(function(result) {
+    plainText = result;
+
+    shouldBe(&quot;bytesToASCIIString(plainText)&quot;, &quot;expectedPlainText&quot;);
+
+    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(&quot;Test decrypting using RSAES-PKCS1-v1_5 with an imported key in workers&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var cipherText = hexStringToUint8Array(&quot;87ca360442614b6590ea51ba84eb081ecda83c5a19e008ed21a6b93c78a7980348f9eac9a8120a6b67326b58ff6e7a10bec113b01f6bd18a04b82d159eb3532c03d4fca597450333cd4df81456b7b864a276cc3a7551964ccc16de86e2bc7a42981f29a0855fc151692d802f6d0b6fdcc0cc01977c579acde220b60d418a480f0ccdfd370f7e045114be39f03dfd516b51bcba6af20663cb2404e4e8c5b4c239936c672c3c2de4f4f3382cdc68f277fc66ed06a0642584ead53cd676673e8cecf59fe23cbe0a59cd82c8d56187eff6cda9b9e600b9890f42c65ee9a4f16f87c1c0b53cecb6fb59a4de165cc828d6bc5b5bf152e6c3060b54fd4e11b037668e4d&quot;);
+var jwkKey = {
+    kty: &quot;RSA&quot;,
+    alg: &quot;RSA1_5&quot;,
+    use: &quot;enc&quot;,
+    key_ops: [&quot;decrypt&quot;, &quot;unwrapKey&quot;],
+    ext: true,
+    n: &quot;lxHN0N9VRZ0_pl0xv3-NXx70WnjkODSkQ5LjHXTFy3DOQsvkagFzD9HqYQezCmcewLjdK5PLwSesDoMdfL6tusBHcvyit1kvydYFQ3NLbENNkYsiBG5_nW4IQGL6JKbZ5iGdUop98QHKm6YZR1u4zrAtxM6bVEo05VvhjRS0M8yWoZVi-7Vdsc0LqI0Qdq_NoctX5Fu-AqiBN7Uo1HkYGcP2oC82J_J5cjw98BQiP5kDWThq9RK-X6S-EUALx_m4iG6iOYKTA3SQyf1xBqFaXXoEJjcckbOqkegecz5b-YWUh8iZPvhwnt-RZwpIbLJgKwz19ndkn9KvoEEw7YbEow&quot;,
+    e: &quot;AQAB&quot;,
+    d: &quot;cj5DkDakjM2bKduGWJREO-_zyEtuA1dD9doqKMd7IRuA0CDS7puEAS20-oXRDwfmyMXEdEUDrGGtCxh6fzDPvs_T-JA3GUK4EgHo3xZcrlXDXlKCeil6Fnr0gISZOIh5dkBrcdVL4quBJe4ZZc5mVuAC7Ld13et0TxMJ4iALGrPuqPVUOGSYIcZ9idx5zKKBWhY3tPggEdKpnHBmPfTRO4yZaf0Nw1QXrgSMZY9ejeuaurAh4Q8o4-6-r8O2LUe7ufMh_ccKkXISEh4KdOnT17EM9BQTn9UNS9GoK2ZZU0U3io5DSu_kpasr4uOVWcGlE2wczOv2nkGwG39F3sFF0Q&quot;,
+    p: &quot;x5vnco5j-TD6hTOzyN4DhkZ44m05NycxT6SUE2qTurT3-uze_L7TYutLRIRkovRMhTHZAr2pziRlasEs13PEz9Zvx1I_T68srsonrdbak-SFMecM7EjHc5C-J13gXhw9HIW28_Sx9rQ-JkGwEwE9PEdIUfuvdqpgh3SmXwPJrEs&quot;,
+    q: &quot;wb9vllg_2n-kNge0bThg_7xu1UwTzipM8vxSUkkV2IipJKIAekkU3aAB8LoPhUI0-17pSGw3ETOO27t163TI9qIPpzLbhTH9aUi7qLGbKlzPlgnqP43Z0LHxc3xKDgit-Ar29QLaX2uoJBX6VVWvhmh7BIPDHNVM5GZjwWORYgk&quot;,
+    dp: &quot;C2c8sa6wx2uk5Dcv7inAycr83PKgciYrCwG78-AC0IfGIu-lTYsZSG1ov2FQ3n5WYMWYQC_Vo5EwugiPJz_V3onBmQF53HOFefbSjXvYwNotQcyRUG5X9qIuOtGCH949H4QED6vK_u0NH-JgzLUlamwoFYbrXzwch6CCYKs2ukE&quot;,
+    dq: &quot;hbtRloDLclHwUqr2yvzDV0IFbozYjtF706x-VfXEcnXB6ls34TBYirFLJZIH7H9KeseEVkz7pY_k5555QlCV9kbebxYXl9RtiiJ-BW6yH4d4caPeYIfU9MweUQxVQWKUUkWfOHcDrCFvKZlR9Vzzjt7HKtKX9mr0bCKQcIf9baE&quot;,
+    qi: &quot;a-7hUTTnclUPKOfSgH8zEKGJ-AvdFEzxvZ5sq46Qf2MbORxVjN4dJamVvM-FoqcwN-9cuUlyr9bSFTwUBW4vXa8Xj9a8JfViuMCqzR-mL1rGIUQ5ARGhNcSsRlyKTqz5BlWlVKmXIx_p-DeVwPWiJJy4k_FqyBxrnxkzomHfrxk&quot;,
+};
+var expectedPlainText = &quot;Hello, World!&quot;;
+
+crypto.subtle.importKey(&quot;jwk&quot;, jwkKey, &quot;RSAES-PKCS1-v1_5&quot;, extractable, [&quot;decrypt&quot;]).then(function(key) {
+    return crypto.subtle.decrypt(&quot;RSAES-PKCS1-v1_5&quot;, key, cipherText);
+}).then(function(result) {
+    plainText = result;
+
+    shouldBe(&quot;bytesToASCIIString(plainText)&quot;, &quot;expectedPlainText&quot;);
+
+    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 &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+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>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;script src=&quot;../../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;script&gt;
+        worker = startWorker('resources/rsa-oaep-import-key-decrypt.js');
+    &lt;/script&gt;
+    &lt;script src=&quot;../../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</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 &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+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>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;script src=&quot;../../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;script&gt;
+        worker = startWorker('resources/rsaes-pkcs1-v1_5-import-key-decrypt.js');
+    &lt;/script&gt;
+    &lt;script src=&quot;../../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</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  &lt;jiewen_tan@apple.com&gt;
+
+        Update SubtleCrypto::decrypt to match the latest spec
+        https://bugs.webkit.org/show_bug.cgi?id=164739
+        &lt;rdar://problem/29257848&gt;
+
+        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  &lt;achristensen@webkit.org&gt;
</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 &quot;InvalidAccessError&quot; but got &quot;NotSupportedError&quot;
</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 &quot;InvalidAccessError&quot; but got &quot;NotSupportedError&quot;
</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 &quot;InvalidAccessError&quot; but got &quot;NotSupportedError&quot;
</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 &quot;encrypt&quot; 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 &quot;decrypt&quot; with the proper type (1) assert_inherits: property &quot;decrypt&quot; 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 &quot;decrypt&quot; not found in prototype chain
</del><ins>+PASS SubtleCrypto interface: crypto.subtle must inherit property &quot;decrypt&quot; 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 &quot;sign&quot; with the proper type (2) assert_inherits: property &quot;sign&quot; 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 &quot;sign&quot; not found in prototype chain
</span><span class="cx"> FAIL SubtleCrypto interface: crypto.subtle must inherit property &quot;verify&quot; with the proper type (3) assert_inherits: property &quot;verify&quot; 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  &lt;jiewen_tan@apple.com&gt;
+
+        Update SubtleCrypto::decrypt to match the latest spec
+        https://bugs.webkit.org/show_bug.cgi?id=164739
+        &lt;rdar://problem/29257848&gt;
+
+        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  &lt;cdumez@apple.com&gt;
</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&lt;CryptoAlgorithmParameters&gt; 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&lt;CryptoAlgorithmParameters&gt;(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&lt;CryptoKey&gt; toCryptoKey(ExecState&amp; state, JSValue value)
+{
+    VM&amp; vm = state.vm();
+    auto scope = DECLARE_THROW_SCOPE(vm);
+
+    RefPtr&lt;CryptoKey&gt; result = JSCryptoKey::toWrapped(value);
+    if (!result) {
+        throwTypeError(&amp;state, scope, ASCIILiteral(&quot;Invalid CryptoKey&quot;));
+        return nullptr;
+    }
+    return result;
+}
+
+static Vector&lt;uint8_t&gt; toVector(ExecState&amp; state, JSValue value)
+{
+    VM&amp; vm = state.vm();
+    auto scope = DECLARE_THROW_SCOPE(vm);
+
+    BufferSource data = convert&lt;IDLBufferSource&gt;(state, value);
+    RETURN_IF_EXCEPTION(scope, { });
+    Vector&lt;uint8_t&gt; dataVector;
+    dataVector.append(data.data(), data.length());
+
+    return dataVector;
+}
+
</ins><span class="cx"> static void jsSubtleCryptoFunctionEncryptPromise(ExecState&amp; state, Ref&lt;DeferredPromise&gt;&amp;&amp; promise)
</span><span class="cx"> {
</span><span class="cx">     VM&amp; 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&lt;CryptoKey&gt; key = JSCryptoKey::toWrapped(state.uncheckedArgument(1));
-    if (!key) {
-        promise-&gt;reject(TypeError, ASCIILiteral(&quot;Invalid CryptoKey&quot;));
-        return;
-    }
</del><ins>+    auto key = toCryptoKey(state, state.uncheckedArgument(1));
+    RETURN_IF_EXCEPTION(scope, void());
</ins><span class="cx"> 
</span><del>-    BufferSource data = convert&lt;IDLBufferSource&gt;(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&lt;uint8_t&gt; dataVector;
-    dataVector.append(data.data(), data.length());
</del><span class="cx"> 
</span><span class="cx">     if (params-&gt;identifier != key-&gt;algorithmIdentifier()) {
</span><span class="cx">         promise-&gt;reject(INVALID_ACCESS_ERR, ASCIILiteral(&quot;CryptoKey doesn't match AlgorithmIdentifier&quot;));
</span><span class="lines">@@ -435,9 +458,54 @@
</span><span class="cx"> 
</span><span class="cx">     JSSubtleCrypto* subtle = jsDynamicDowncast&lt;JSSubtleCrypto*&gt;(state.thisValue());
</span><span class="cx">     ASSERT(subtle);
</span><del>-    algorithm-&gt;encrypt(WTFMove(params), key.releaseNonNull(), WTFMove(dataVector), WTFMove(callback), WTFMove(exceptionCallback), *scriptExecutionContextFromExecState(&amp;state), subtle-&gt;wrapped().workQueue());
</del><ins>+    algorithm-&gt;encrypt(WTFMove(params), key.releaseNonNull(), WTFMove(data), WTFMove(callback), WTFMove(exceptionCallback), *scriptExecutionContextFromExecState(&amp;state), subtle-&gt;wrapped().workQueue());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static void jsSubtleCryptoFunctionDecryptPromise(ExecState&amp; state, Ref&lt;DeferredPromise&gt;&amp;&amp; promise)
+{
+    VM&amp; vm = state.vm();
+    auto scope = DECLARE_THROW_SCOPE(vm);
+
+    if (UNLIKELY(state.argumentCount() &lt; 3)) {
+        promise-&gt;reject&lt;JSValue&gt;(createNotEnoughArgumentsError(&amp;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-&gt;identifier != key-&gt;algorithmIdentifier()) {
+        promise-&gt;reject(INVALID_ACCESS_ERR, ASCIILiteral(&quot;CryptoKey doesn't match AlgorithmIdentifier&quot;));
+        return;
+    }
+
+    if (!key-&gt;allows(CryptoKeyUsageDecrypt)) {
+        promise-&gt;reject(INVALID_ACCESS_ERR, ASCIILiteral(&quot;CryptoKey doesn't support decryption&quot;));
+        return;
+    }
+
+    auto algorithm = createAlgorithm(state, key-&gt;algorithmIdentifier());
+    RETURN_IF_EXCEPTION(scope, void());
+
+    auto callback = [capturedPromise = promise.copyRef()](const Vector&lt;uint8_t&gt;&amp; 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&lt;JSSubtleCrypto*&gt;(state.thisValue());
+    ASSERT(subtle);
+    algorithm-&gt;decrypt(WTFMove(params), key.releaseNonNull(), WTFMove(data), WTFMove(callback), WTFMove(exceptionCallback), *scriptExecutionContextFromExecState(&amp;state), subtle-&gt;wrapped().workQueue());
+}
+
</ins><span class="cx"> static void jsSubtleCryptoFunctionGenerateKeyPromise(ExecState&amp; state, Ref&lt;DeferredPromise&gt;&amp;&amp; promise)
</span><span class="cx"> {
</span><span class="cx">     VM&amp; vm = state.vm();
</span><span class="lines">@@ -545,11 +613,8 @@
</span><span class="cx">     auto format = convertEnumeration&lt;SubtleCrypto::KeyFormat&gt;(state, state.uncheckedArgument(0));
</span><span class="cx">     RETURN_IF_EXCEPTION(scope, void());
</span><span class="cx"> 
</span><del>-    RefPtr&lt;CryptoKey&gt; key = JSCryptoKey::toWrapped(state.uncheckedArgument(1));
-    if (!key) {
-        promise-&gt;reject(TypeError, ASCIILiteral(&quot;Invalid CryptoKey&quot;));
-        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-&gt;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&lt;jsSubtleCryptoFunctionEncryptPromise, PromiseExecutionScope::WindowOrWorker&gt;(state);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+JSValue JSSubtleCrypto::decrypt(ExecState&amp; state)
+{
+    return callPromiseFunction&lt;jsSubtleCryptoFunctionDecryptPromise, PromiseExecutionScope::WindowOrWorker&gt;(state);
+}
+
</ins><span class="cx"> JSValue JSSubtleCrypto::generateKey(ExecState&amp; state)
</span><span class="cx"> {
</span><span class="cx">     return callPromiseFunction&lt;jsSubtleCryptoFunctionGenerateKeyPromise, PromiseExecutionScope::WindowOrWorker&gt;(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&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, Ref&lt;CryptoKey&gt;&amp;&amp;, Vector&lt;uint8_t&gt;&amp;&amp;, VectorCallback&amp;&amp;, ExceptionCallback&amp;&amp; exceptionCallback, ScriptExecutionContext&amp;, WorkQueue&amp;)
+{
+    exceptionCallback(NOT_SUPPORTED_ERR);
+}
+
</ins><span class="cx"> void CryptoAlgorithm::generateKey(const std::unique_ptr&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, bool, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&amp;&amp;, ExceptionCallback&amp;&amp; exceptionCallback, ScriptExecutionContext&amp;)
</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&lt;void(SubtleCrypto::KeyFormat, KeyData&amp;&amp;)&gt;;
</span><span class="cx"> 
</span><span class="cx">     virtual void encrypt(std::unique_ptr&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, Ref&lt;CryptoKey&gt;&amp;&amp;, Vector&lt;uint8_t&gt;&amp;&amp;, VectorCallback&amp;&amp;, ExceptionCallback&amp;&amp;, ScriptExecutionContext&amp;, WorkQueue&amp;);
</span><ins>+    virtual void decrypt(std::unique_ptr&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, Ref&lt;CryptoKey&gt;&amp;&amp;, Vector&lt;uint8_t&gt;&amp;&amp;, VectorCallback&amp;&amp;, ExceptionCallback&amp;&amp;, ScriptExecutionContext&amp;, WorkQueue&amp;);
</ins><span class="cx">     virtual void generateKey(const std::unique_ptr&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&amp;&amp;, ExceptionCallback&amp;&amp;, ScriptExecutionContext&amp;);
</span><span class="cx">     virtual void importKey(SubtleCrypto::KeyFormat, KeyData&amp;&amp;, const std::unique_ptr&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, bool extractable, CryptoKeyUsageBitmap, KeyCallback&amp;&amp;, ExceptionCallback&amp;&amp;);
</span><span class="cx">     virtual void exportKey(SubtleCrypto::KeyFormat, Ref&lt;CryptoKey&gt;&amp;&amp;, KeyDataCallback&amp;&amp;, ExceptionCallback&amp;&amp;);
</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&lt;any&gt; encrypt(AlgorithmIdentifier algorithm, CryptoKey key, BufferSource data);
</span><ins>+    [Custom] Promise&lt;any&gt; decrypt(AlgorithmIdentifier algorithm, CryptoKey key, BufferSource data);
</ins><span class="cx">     // FIXME: Should this return a Promise&lt;(CryptoKey or CryptoKeyPair)&gt;?
</span><span class="cx">     [Custom] Promise&lt;any&gt; generateKey(AlgorithmIdentifier algorithm, boolean extractable, sequence&lt;CryptoKeyUsage&gt; keyUsages);
</span><span class="cx">     [Custom] Promise&lt;CryptoKey&gt; importKey(KeyFormat format, (BufferSource or JsonWebKey) keyData, AlgorithmIdentifier algorithm, boolen extractable, sequence&lt;CryptoKeyUsage&gt; 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&lt;CryptoAlgorithmParameters&gt;&amp;&amp; parameters, Ref&lt;CryptoKey&gt;&amp;&amp; key, Vector&lt;uint8_t&gt;&amp;&amp; cipherText, VectorCallback&amp;&amp; callback, ExceptionCallback&amp;&amp; exceptionCallback, ScriptExecutionContext&amp; context, WorkQueue&amp; workQueue)
+{
+    ASSERT(parameters);
+    auto&amp; aesParameters = downcast&lt;CryptoAlgorithmAesCbcParams&gt;(*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&lt;CryptoAlgorithmParameters&gt;&amp;&amp; parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&amp;&amp; callback, ExceptionCallback&amp;&amp; exceptionCallback, ScriptExecutionContext&amp;)
</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&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, Ref&lt;CryptoKey&gt;&amp;&amp;, Vector&lt;uint8_t&gt;&amp;&amp;, VectorCallback&amp;&amp;, ExceptionCallback&amp;&amp;, ScriptExecutionContext&amp;, WorkQueue&amp;) final;
</span><ins>+    void decrypt(std::unique_ptr&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, Ref&lt;CryptoKey&gt;&amp;&amp;, Vector&lt;uint8_t&gt;&amp;&amp;, VectorCallback&amp;&amp;, ExceptionCallback&amp;&amp;, ScriptExecutionContext&amp;, WorkQueue&amp;) final;
</ins><span class="cx">     void generateKey(const std::unique_ptr&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&amp;&amp;, ExceptionCallback&amp;&amp;, ScriptExecutionContext&amp;) final;
</span><span class="cx">     void importKey(SubtleCrypto::KeyFormat, KeyData&amp;&amp;, const std::unique_ptr&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, bool extractable, CryptoKeyUsageBitmap, KeyCallback&amp;&amp;, ExceptionCallback&amp;&amp;) final;
</span><span class="cx">     void exportKey(SubtleCrypto::KeyFormat, Ref&lt;CryptoKey&gt;&amp;&amp;, KeyDataCallback&amp;&amp;, ExceptionCallback&amp;&amp;) final;
</span><span class="lines">@@ -56,6 +57,7 @@
</span><span class="cx"> 
</span><span class="cx">     bool keyAlgorithmMatches(const CryptoAlgorithmAesCbcParamsDeprecated&amp; algorithmParameters, const CryptoKey&amp;) const;
</span><span class="cx">     void platformEncrypt(std::unique_ptr&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, Ref&lt;CryptoKey&gt;&amp;&amp;, Vector&lt;uint8_t&gt;&amp;&amp;, VectorCallback&amp;&amp;, ExceptionCallback&amp;&amp;, ScriptExecutionContext&amp;, WorkQueue&amp;);
</span><ins>+    void platformDecrypt(std::unique_ptr&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, Ref&lt;CryptoKey&gt;&amp;&amp;, Vector&lt;uint8_t&gt;&amp;&amp;, VectorCallback&amp;&amp;, ExceptionCallback&amp;&amp;, ScriptExecutionContext&amp;, WorkQueue&amp;);
</ins><span class="cx">     ExceptionOr&lt;void&gt; platformEncrypt(const CryptoAlgorithmAesCbcParamsDeprecated&amp;, const CryptoKeyAES&amp;, const CryptoOperationData&amp;, VectorCallback&amp;&amp;, VoidCallback&amp;&amp; failureCallback);
</span><span class="cx">     ExceptionOr&lt;void&gt; platformDecrypt(const CryptoAlgorithmAesCbcParamsDeprecated&amp;, const CryptoKeyAES&amp;, const CryptoOperationData&amp;, VectorCallback&amp;&amp;, VoidCallback&amp;&amp; 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&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, Ref&lt;CryptoKey&gt;&amp;&amp; key, Vector&lt;uint8_t&gt;&amp;&amp; cipherText, VectorCallback&amp;&amp; callback, ExceptionCallback&amp;&amp; exceptionCallback, ScriptExecutionContext&amp; context, WorkQueue&amp; workQueue)
+{
+    if (key-&gt;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&lt;CryptoAlgorithmParameters&gt;&amp;&amp; parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&amp;&amp; callback, ExceptionCallback&amp;&amp; exceptionCallback, ScriptExecutionContext&amp; 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&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, Ref&lt;CryptoKey&gt;&amp;&amp;, Vector&lt;uint8_t&gt;&amp;&amp;, VectorCallback&amp;&amp;, ExceptionCallback&amp;&amp;, ScriptExecutionContext&amp;, WorkQueue&amp;) final;
</span><ins>+    void decrypt(std::unique_ptr&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, Ref&lt;CryptoKey&gt;&amp;&amp;, Vector&lt;uint8_t&gt;&amp;&amp;, VectorCallback&amp;&amp;, ExceptionCallback&amp;&amp;, ScriptExecutionContext&amp;, WorkQueue&amp;) final;
</ins><span class="cx">     void generateKey(const std::unique_ptr&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&amp;&amp;, ExceptionCallback&amp;&amp;, ScriptExecutionContext&amp;) final;
</span><span class="cx">     void importKey(SubtleCrypto::KeyFormat, KeyData&amp;&amp;, const std::unique_ptr&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, bool extractable, CryptoKeyUsageBitmap, KeyCallback&amp;&amp;, ExceptionCallback&amp;&amp;) final;
</span><span class="cx">     void exportKey(SubtleCrypto::KeyFormat, Ref&lt;CryptoKey&gt;&amp;&amp;, KeyDataCallback&amp;&amp;, ExceptionCallback&amp;&amp;) final;
</span><span class="lines">@@ -56,6 +57,7 @@
</span><span class="cx"> 
</span><span class="cx">     bool keyAlgorithmMatches(const CryptoKey&amp;) const;
</span><span class="cx">     void platformEncrypt(Ref&lt;CryptoKey&gt;&amp;&amp;, Vector&lt;uint8_t&gt;&amp;&amp;, VectorCallback&amp;&amp;, ExceptionCallback&amp;&amp;, ScriptExecutionContext&amp;, WorkQueue&amp;);
</span><ins>+    void platformDecrypt(Ref&lt;CryptoKey&gt;&amp;&amp;, Vector&lt;uint8_t&gt;&amp;&amp;, VectorCallback&amp;&amp;, ExceptionCallback&amp;&amp;, ScriptExecutionContext&amp;, WorkQueue&amp;);
</ins><span class="cx">     ExceptionOr&lt;void&gt; platformEncrypt(const CryptoKeyRSA&amp;, const CryptoOperationData&amp;, VectorCallback&amp;&amp;, VoidCallback&amp;&amp; failureCallback);
</span><span class="cx">     ExceptionOr&lt;void&gt; platformDecrypt(const CryptoKeyRSA&amp;, const CryptoOperationData&amp;, VectorCallback&amp;&amp;, VoidCallback&amp;&amp; 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&lt;CryptoAlgorithmParameters&gt;&amp;&amp; parameters, Ref&lt;CryptoKey&gt;&amp;&amp; key, Vector&lt;uint8_t&gt;&amp;&amp; cipherText, VectorCallback&amp;&amp; callback, ExceptionCallback&amp;&amp; exceptionCallback, ScriptExecutionContext&amp; context, WorkQueue&amp; workQueue)
+{
+    ASSERT(parameters);
+    if (key-&gt;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&lt;CryptoAlgorithmParameters&gt;&amp;&amp; parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&amp;&amp; callback, ExceptionCallback&amp;&amp; exceptionCallback, ScriptExecutionContext&amp; 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&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, Ref&lt;CryptoKey&gt;&amp;&amp;, Vector&lt;uint8_t&gt;&amp;&amp;, VectorCallback&amp;&amp;, ExceptionCallback&amp;&amp;, ScriptExecutionContext&amp;, WorkQueue&amp;) final;
</span><ins>+    void decrypt(std::unique_ptr&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, Ref&lt;CryptoKey&gt;&amp;&amp;, Vector&lt;uint8_t&gt;&amp;&amp;, VectorCallback&amp;&amp;, ExceptionCallback&amp;&amp;, ScriptExecutionContext&amp;, WorkQueue&amp;) final;
</ins><span class="cx">     void generateKey(const std::unique_ptr&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&amp;&amp;, ExceptionCallback&amp;&amp;, ScriptExecutionContext&amp;) final;
</span><span class="cx">     void importKey(SubtleCrypto::KeyFormat, KeyData&amp;&amp;, const std::unique_ptr&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, bool extractable, CryptoKeyUsageBitmap, KeyCallback&amp;&amp;, ExceptionCallback&amp;&amp;) final;
</span><span class="cx">     void exportKey(SubtleCrypto::KeyFormat, Ref&lt;CryptoKey&gt;&amp;&amp;, KeyDataCallback&amp;&amp;, ExceptionCallback&amp;&amp;) final;
</span><span class="lines">@@ -56,6 +57,7 @@
</span><span class="cx"> 
</span><span class="cx">     bool keyAlgorithmMatches(const CryptoAlgorithmRsaOaepParamsDeprecated&amp; algorithmParameters, const CryptoKey&amp;) const;
</span><span class="cx">     void platformEncrypt(std::unique_ptr&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, Ref&lt;CryptoKey&gt;&amp;&amp;, Vector&lt;uint8_t&gt;&amp;&amp;, VectorCallback&amp;&amp;, ExceptionCallback&amp;&amp;, ScriptExecutionContext&amp;, WorkQueue&amp;);
</span><ins>+    void platformDecrypt(std::unique_ptr&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, Ref&lt;CryptoKey&gt;&amp;&amp;, Vector&lt;uint8_t&gt;&amp;&amp;, VectorCallback&amp;&amp;, ExceptionCallback&amp;&amp;, ScriptExecutionContext&amp;, WorkQueue&amp;);
</ins><span class="cx">     ExceptionOr&lt;void&gt; platformEncrypt(const CryptoAlgorithmRsaOaepParamsDeprecated&amp;, const CryptoKeyRSA&amp;, const CryptoOperationData&amp;, VectorCallback&amp;&amp;, VoidCallback&amp;&amp; failureCallback);
</span><span class="cx">     ExceptionOr&lt;void&gt; platformDecrypt(const CryptoAlgorithmRsaOaepParamsDeprecated&amp;, const CryptoKeyRSA&amp;, const CryptoOperationData&amp;, VectorCallback&amp;&amp;, VoidCallback&amp;&amp; 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&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, Ref&lt;CryptoKey&gt;&amp;&amp;, Vector&lt;uint8_t&gt;&amp;&amp;, VectorCallback&amp;&amp;, ExceptionCallback&amp;&amp;, ScriptExecutionContext&amp;, WorkQueue&amp;)
+{
+    notImplemented();
+}
+
</ins><span class="cx"> ExceptionOr&lt;void&gt; CryptoAlgorithmAES_CBC::platformEncrypt(const CryptoAlgorithmAesCbcParamsDeprecated&amp;, const CryptoKeyAES&amp;, const CryptoOperationData&amp;, VectorCallback&amp;&amp;, VoidCallback&amp;&amp;)
</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&lt;CryptoKey&gt;&amp;&amp;, Vector&lt;uint8_t&gt;&amp;&amp;, VectorCallback&amp;&amp;, ExceptionCallback&amp;&amp;, ScriptExecutionContext&amp;, WorkQueue&amp;)
+{
+    notImplemented();
+}
+
</ins><span class="cx"> ExceptionOr&lt;void&gt; CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt(const CryptoKeyRSA&amp;, const CryptoOperationData&amp;, VectorCallback&amp;&amp;, VoidCallback&amp;&amp;)
</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&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, Ref&lt;CryptoKey&gt;&amp;&amp;, Vector&lt;uint8_t&gt;&amp;&amp;, VectorCallback&amp;&amp;, ExceptionCallback&amp;&amp;, ScriptExecutionContext&amp;, WorkQueue&amp;)
+{
+    notImplemented();
+}
+
</ins><span class="cx"> ExceptionOr&lt;void&gt; CryptoAlgorithmRSA_OAEP::platformEncrypt(const CryptoAlgorithmRsaOaepParamsDeprecated&amp;, const CryptoKeyRSA&amp;, const CryptoOperationData&amp;, VectorCallback&amp;&amp;, VoidCallback&amp;&amp;)
</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&lt;CryptoAlgorithmParameters&gt;&amp;&amp; parameters, Ref&lt;CryptoKey&gt;&amp;&amp; key, Vector&lt;uint8_t&gt;&amp;&amp; cipherText, VectorCallback&amp;&amp; callback, ExceptionCallback&amp;&amp; exceptionCallback, ScriptExecutionContext&amp; context, WorkQueue&amp; workQueue)
+{
+    context.ref();
+    workQueue.dispatch([parameters = WTFMove(parameters), key = WTFMove(key), cipherText = WTFMove(cipherText), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), &amp;context]() mutable {
+        auto&amp; aesParameters = downcast&lt;CryptoAlgorithmAesCbcParams&gt;(*parameters);
+        auto&amp; aesKey = downcast&lt;CryptoKeyAES&gt;(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&amp; context) {
+                exceptionCallback(ec);
+                context.deref();
+            });
+            return;
+        }
+        context.postTask([callback = WTFMove(callback), result = result.releaseReturnValue()](ScriptExecutionContext&amp; context) {
+            callback(result);
+            context.deref();
+        });
+    });
+}
+
</ins><span class="cx"> ExceptionOr&lt;void&gt; CryptoAlgorithmAES_CBC::platformEncrypt(const CryptoAlgorithmAesCbcParamsDeprecated&amp; parameters, const CryptoKeyAES&amp; key, const CryptoOperationData&amp; data, VectorCallback&amp;&amp; callback, VoidCallback&amp;&amp; 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&lt;uint8_t&gt; type once WebKitSubtleCrypto is deprecated.
+// https://bugs.webkit.org/show_bug.cgi?id=164939
+static ExceptionOr&lt;Vector&lt;uint8_t&gt;&gt; decryptRSAES_PKCS1_v1_5(const PlatformRSAKey key, size_t keyLength, const uint8_t* data, size_t dataLength)
+{
+    Vector&lt;uint8_t&gt; 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(), &amp;plainTextLength, 0, 0, kCCDigestNone))
+        return Exception { OperationError };
+
+    plainText.resize(plainTextLength);
+    return WTFMove(plainText);
+}
+
</ins><span class="cx"> void CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt(Ref&lt;CryptoKey&gt;&amp;&amp; key, Vector&lt;uint8_t&gt;&amp;&amp; plainText, VectorCallback&amp;&amp; callback, ExceptionCallback&amp;&amp; exceptionCallback, ScriptExecutionContext&amp; context, WorkQueue&amp; 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&lt;CryptoKey&gt;&amp;&amp; key, Vector&lt;uint8_t&gt;&amp;&amp; cipherText, VectorCallback&amp;&amp; callback, ExceptionCallback&amp;&amp; exceptionCallback, ScriptExecutionContext&amp; context, WorkQueue&amp; workQueue)
+{
+    context.ref();
+    workQueue.dispatch([key = WTFMove(key), cipherText = WTFMove(cipherText), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), &amp;context]() mutable {
+        auto&amp; rsaKey = downcast&lt;CryptoKeyRSA&gt;(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&amp; context) {
+                exceptionCallback(ec);
+                context.deref();
+            });
+            return;
+        }
+        context.postTask([callback = WTFMove(callback), result = result.releaseReturnValue()](ScriptExecutionContext&amp; context) {
+            callback(result);
+            context.deref();
+        });
+    });
+}
+
</ins><span class="cx"> ExceptionOr&lt;void&gt; CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt(const CryptoKeyRSA&amp; key, const CryptoOperationData&amp; data, VectorCallback&amp;&amp; callback, VoidCallback&amp;&amp; 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 &lt; 8192 bits
</del><span class="cx"> ExceptionOr&lt;void&gt; CryptoAlgorithmRSAES_PKCS1_v1_5::platformDecrypt(const CryptoKeyRSA&amp; key, const CryptoOperationData&amp; data, VectorCallback&amp;&amp; callback, VoidCallback&amp;&amp; failureCallback)
</span><span class="cx"> {
</span><del>-    Vector&lt;uint8_t&gt; plainText(1024);
-    size_t plainTextLength = plainText.size();
-    CCCryptorStatus status = CCRSACryptorDecrypt(key.platformKey(), ccPKCS1Padding, data.first, data.second, plainText.data(), &amp;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&lt;uint8_t&gt; type once WebKitSubtleCrypto is deprecated.
+// https://bugs.webkit.org/show_bug.cgi?id=164939
+static ExceptionOr&lt;Vector&lt;uint8_t&gt;&gt; decryptRSA_OAEP(CryptoAlgorithmIdentifier hash, const Vector&lt;uint8_t&gt;&amp; label, const PlatformRSAKey key, size_t keyLength, const uint8_t* data, size_t dataLength)
+{
+    CCDigestAlgorithm digestAlgorithm;
+    if (!getCommonCryptoDigestAlgorithm(hash, digestAlgorithm))
+        return Exception { OperationError };
+
+    Vector&lt;uint8_t&gt; 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(), &amp;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&lt;CryptoAlgorithmParameters&gt;&amp;&amp; parameters, Ref&lt;CryptoKey&gt;&amp;&amp; key, Vector&lt;uint8_t&gt;&amp;&amp; plainText, VectorCallback&amp;&amp; callback, ExceptionCallback&amp;&amp; exceptionCallback, ScriptExecutionContext&amp; context, WorkQueue&amp; 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&lt;CryptoAlgorithmParameters&gt;&amp;&amp; parameters, Ref&lt;CryptoKey&gt;&amp;&amp; key, Vector&lt;uint8_t&gt;&amp;&amp; cipherText, VectorCallback&amp;&amp; callback, ExceptionCallback&amp;&amp; exceptionCallback, ScriptExecutionContext&amp; context, WorkQueue&amp; workQueue)
+{
+    context.ref();
+    workQueue.dispatch([parameters = WTFMove(parameters), key = WTFMove(key), cipherText = WTFMove(cipherText), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), &amp;context]() mutable {
+        auto&amp; rsaParameters = downcast&lt;CryptoAlgorithmRsaOaepParams&gt;(*parameters);
+        auto&amp; rsaKey = downcast&lt;CryptoKeyRSA&gt;(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&amp; context) {
+                exceptionCallback(ec);
+                context.deref();
+            });
+            return;
+        }
+        context.postTask([callback = WTFMove(callback), result = result.releaseReturnValue()](ScriptExecutionContext&amp; context) {
+            callback(result);
+            context.deref();
+        });
+    });
+}
+
</ins><span class="cx"> ExceptionOr&lt;void&gt; CryptoAlgorithmRSA_OAEP::platformEncrypt(const CryptoAlgorithmRsaOaepParamsDeprecated&amp; parameters, const CryptoKeyRSA&amp; key, const CryptoOperationData&amp; data, VectorCallback&amp;&amp; callback, VoidCallback&amp;&amp; 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 &lt; 8192 bits
</del><span class="cx"> ExceptionOr&lt;void&gt; CryptoAlgorithmRSA_OAEP::platformDecrypt(const CryptoAlgorithmRsaOaepParamsDeprecated&amp; parameters, const CryptoKeyRSA&amp; key, const CryptoOperationData&amp; data, VectorCallback&amp;&amp; callback, VoidCallback&amp;&amp; failureCallback)
</span><span class="cx"> {
</span><del>-    CCDigestAlgorithm digestAlgorithm;
-    if (!getCommonCryptoDigestAlgorithm(parameters.hash, digestAlgorithm))
-        return Exception { NOT_SUPPORTED_ERR };
-
-    Vector&lt;uint8_t&gt; plainText(1024);
-    size_t plainTextLength = plainText.size();
-    CCCryptorStatus status = CCRSACryptorDecrypt(key.platformKey(), ccOAEPPadding, data.first, data.second, plainText.data(), &amp;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>