<!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>[209092] 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/209092">209092</a></dd>
<dt>Author</dt> <dd>jiewen_tan@apple.com</dd>
<dt>Date</dt> <dd>2016-11-29 14:52:03 -0800 (Tue, 29 Nov 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Update SubtleCrypto::sign to match the latest spec
https://bugs.webkit.org/show_bug.cgi?id=164740
&lt;rdar://problem/29257864&gt;

Reviewed by Brent Fulgham.

LayoutTests/imported/w3c:

* WebCryptoAPI/idlharness-expected.txt:

Source/WebCore:

This patch does following few things:
1. It updates the SubtleCrypto::sign method to match the latest spec:
   https://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-sign.
   It also refers to the latest Editor's Draft to a certain degree:
   https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-sign.
2. It implements sign operations of the following algorithms: HMAC, and
   RSASSA-PKCS1-V1_5.
3. It also replaces promise.copyRef() with WTFMove(promise) for all the
   capture lists of exception callbacks in promise functions.

Tests: crypto/subtle/hmac-import-key-sign-sha1.html
       crypto/subtle/hmac-import-key-sign-sha224.html
       crypto/subtle/hmac-import-key-sign-sha256.html
       crypto/subtle/hmac-import-key-sign-sha384.html
       crypto/subtle/hmac-import-key-sign-sha512.html
       crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha1.html
       crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha224.html
       crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha256.html
       crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha384.html
       crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha512.html
       crypto/subtle/sign-malformed-parameters.html
       crypto/workers/subtle/hmac-import-key-sign.html
       crypto/workers/subtle/rsassa-pkcs1-v1_5-import-key-sign.html

* bindings/js/JSSubtleCryptoCustom.cpp:
(WebCore::normalizeCryptoAlgorithmParameters):
(WebCore::jsSubtleCryptoFunctionDecryptPromise):
Fix a minor bug.
(WebCore::jsSubtleCryptoFunctionEncryptPromise):
(WebCore::jsSubtleCryptoFunctionDecryptPromise):
(WebCore::jsSubtleCryptoFunctionSignPromise):
(WebCore::jsSubtleCryptoFunctionGenerateKeyPromise):
(WebCore::jsSubtleCryptoFunctionImportKeyPromise):
(WebCore::jsSubtleCryptoFunctionExportKeyPromise):
(WebCore::JSSubtleCrypto::sign):
* crypto/CryptoAlgorithm.cpp:
(WebCore::CryptoAlgorithm::sign):
* crypto/CryptoAlgorithm.h:
* crypto/SubtleCrypto.idl:
* crypto/algorithms/CryptoAlgorithmHMAC.cpp:
(WebCore::CryptoAlgorithmHMAC::sign):
* crypto/algorithms/CryptoAlgorithmHMAC.h:
* crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp:
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::sign):
* crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h:
* crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp:
(WebCore::CryptoAlgorithmHMAC::platformSign):
* crypto/gnutls/CryptoAlgorithmHMACGnuTLS.cpp:
(WebCore::CryptoAlgorithmHMAC::platformSign):
* crypto/gnutls/CryptoAlgorithmRSASSA_PKCS1_v1_5GnuTLS.cpp:
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign):
* crypto/mac/CryptoAlgorithmHMACMac.cpp:
(WebCore::commonCryptoHMACAlgorithm):
(WebCore::calculateSignature):
Remove a null guardance since the depending bug is resolved.
(WebCore::CryptoAlgorithmHMAC::platformSign):
(WebCore::CryptoAlgorithmHMAC::platformVerify):
* crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp:
(WebCore::signRSASSA_PKCS1_v1_5):
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign):

LayoutTests:

* crypto/subtle/hmac-import-key-sign-sha1-expected.txt: Added.
* crypto/subtle/hmac-import-key-sign-sha1.html: Added.
* crypto/subtle/hmac-import-key-sign-sha224-expected.txt: Added.
* crypto/subtle/hmac-import-key-sign-sha224.html: Added.
* crypto/subtle/hmac-import-key-sign-sha256-expected.txt: Added.
* crypto/subtle/hmac-import-key-sign-sha256.html: Added.
* crypto/subtle/hmac-import-key-sign-sha384-expected.txt: Added.
* crypto/subtle/hmac-import-key-sign-sha384.html: Added.
* crypto/subtle/hmac-import-key-sign-sha512-expected.txt: Added.
* crypto/subtle/hmac-import-key-sign-sha512.html: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha1-expected.txt: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha1.html: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha224-expected.txt: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha224.html: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha256-expected.txt: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha256.html: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha384-expected.txt: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha384.html: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha512-expected.txt: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha512.html: Added.
* crypto/subtle/sign-malformed-parameters-expected.txt: Added.
* crypto/subtle/sign-malformed-parameters.html: Added.
* crypto/workers/subtle/hmac-import-key-sign-expected.txt: Added.
* crypto/workers/subtle/hmac-import-key-sign.html: Added.
* crypto/workers/subtle/resources/hmac-import-key-sign.js: Added.
* crypto/workers/subtle/resources/rsassa-pkcs1-v1_5-import-key-sign.js: Added.
* crypto/workers/subtle/rsassa-pkcs1-v1_5-import-key-sign-expected.txt: Added.
* crypto/workers/subtle/rsassa-pkcs1-v1_5-import-key-sign.html: Added.</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="#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="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmHMACcpp">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmHMACh">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.h</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSASSA_PKCS1_v1_5cpp">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSASSA_PKCS1_v1_5h">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h</a></li>
<li><a href="#trunkSourceWebCorecryptogcryptCryptoAlgorithmHMACGCryptcpp">trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptognutlsCryptoAlgorithmHMACGnuTLScpp">trunk/Source/WebCore/crypto/gnutls/CryptoAlgorithmHMACGnuTLS.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptognutlsCryptoAlgorithmRSASSA_PKCS1_v1_5GnuTLScpp">trunk/Source/WebCore/crypto/gnutls/CryptoAlgorithmRSASSA_PKCS1_v1_5GnuTLS.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptomacCryptoAlgorithmHMACMaccpp">trunk/Source/WebCore/crypto/mac/CryptoAlgorithmHMACMac.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptomacCryptoAlgorithmRSASSA_PKCS1_v1_5Maccpp">trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestscryptosubtlehmacimportkeysignsha1expectedtxt">trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha1-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacimportkeysignsha1html">trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha1.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacimportkeysignsha224expectedtxt">trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha224-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacimportkeysignsha224html">trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha224.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacimportkeysignsha256expectedtxt">trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha256-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacimportkeysignsha256html">trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha256.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacimportkeysignsha384expectedtxt">trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha384-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacimportkeysignsha384html">trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha384.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacimportkeysignsha512expectedtxt">trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha512-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacimportkeysignsha512html">trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha512.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeysignsha1expectedtxt">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha1-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeysignsha1html">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha1.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeysignsha224expectedtxt">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha224-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeysignsha224html">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha224.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeysignsha256expectedtxt">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha256-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeysignsha256html">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha256.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeysignsha384expectedtxt">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha384-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeysignsha384html">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha384.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeysignsha512expectedtxt">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha512-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeysignsha512html">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha512.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlesignmalformedparametersexpectedtxt">trunk/LayoutTests/crypto/subtle/sign-malformed-parameters-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlesignmalformedparametershtml">trunk/LayoutTests/crypto/subtle/sign-malformed-parameters.html</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtlehmacimportkeysignexpectedtxt">trunk/LayoutTests/crypto/workers/subtle/hmac-import-key-sign-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtlehmacimportkeysignhtml">trunk/LayoutTests/crypto/workers/subtle/hmac-import-key-sign.html</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtleresourceshmacimportkeysignjs">trunk/LayoutTests/crypto/workers/subtle/resources/hmac-import-key-sign.js</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtleresourcesrsassapkcs1v1_5importkeysignjs">trunk/LayoutTests/crypto/workers/subtle/resources/rsassa-pkcs1-v1_5-import-key-sign.js</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtlersassapkcs1v1_5importkeysignexpectedtxt">trunk/LayoutTests/crypto/workers/subtle/rsassa-pkcs1-v1_5-import-key-sign-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtlersassapkcs1v1_5importkeysignhtml">trunk/LayoutTests/crypto/workers/subtle/rsassa-pkcs1-v1_5-import-key-sign.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (209091 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-11-29 22:38:26 UTC (rev 209091)
+++ trunk/LayoutTests/ChangeLog        2016-11-29 22:52:03 UTC (rev 209092)
</span><span class="lines">@@ -1,3 +1,40 @@
</span><ins>+2016-11-22  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
+
+        Update SubtleCrypto::sign to match the latest spec
+        https://bugs.webkit.org/show_bug.cgi?id=164740
+        &lt;rdar://problem/29257864&gt;
+
+        Reviewed by Brent Fulgham.
+
+        * crypto/subtle/hmac-import-key-sign-sha1-expected.txt: Added.
+        * crypto/subtle/hmac-import-key-sign-sha1.html: Added.
+        * crypto/subtle/hmac-import-key-sign-sha224-expected.txt: Added.
+        * crypto/subtle/hmac-import-key-sign-sha224.html: Added.
+        * crypto/subtle/hmac-import-key-sign-sha256-expected.txt: Added.
+        * crypto/subtle/hmac-import-key-sign-sha256.html: Added.
+        * crypto/subtle/hmac-import-key-sign-sha384-expected.txt: Added.
+        * crypto/subtle/hmac-import-key-sign-sha384.html: Added.
+        * crypto/subtle/hmac-import-key-sign-sha512-expected.txt: Added.
+        * crypto/subtle/hmac-import-key-sign-sha512.html: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha1-expected.txt: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha1.html: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha224-expected.txt: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha224.html: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha256-expected.txt: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha256.html: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha384-expected.txt: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha384.html: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha512-expected.txt: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha512.html: Added.
+        * crypto/subtle/sign-malformed-parameters-expected.txt: Added.
+        * crypto/subtle/sign-malformed-parameters.html: Added.
+        * crypto/workers/subtle/hmac-import-key-sign-expected.txt: Added.
+        * crypto/workers/subtle/hmac-import-key-sign.html: Added.
+        * crypto/workers/subtle/resources/hmac-import-key-sign.js: Added.
+        * crypto/workers/subtle/resources/rsassa-pkcs1-v1_5-import-key-sign.js: Added.
+        * crypto/workers/subtle/rsassa-pkcs1-v1_5-import-key-sign-expected.txt: Added.
+        * crypto/workers/subtle/rsassa-pkcs1-v1_5-import-key-sign.html: Added.
+
</ins><span class="cx"> 2016-11-29  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Can't download move.simple.com direct deposit transition PDF: Non user-triggered activations of anchors that have a download attribute are ignored
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtlehmacimportkeysignsha1expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha1-expected.txt (0 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha1-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha1-expected.txt        2016-11-29 22:52:03 UTC (rev 209092)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+Test signing with HMAC SHA-1 using an imported key
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS bytesToHexString(signature) is expectedSignature
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlehmacimportkeysignsha1html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha1.html (0 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha1.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha1.html        2016-11-29 22:52:03 UTC (rev 209092)
</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 signing with HMAC SHA-1 using an imported key&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var text = asciiToUint8Array(&quot;Hello, World!&quot;);
+var hmacImportParams = {
+    name: &quot;hmac&quot;,
+    hash: &quot;sha-1&quot;,
+}
+var rawKey = asciiToUint8Array(&quot;jnOw99oOZFLIEPMr&quot;);
+var expectedSignature = &quot;6e8e66ff128606f52b8c589196ef5e0f7ca04816&quot;;
+
+crypto.subtle.importKey(&quot;raw&quot;, rawKey, hmacImportParams, extractable, [&quot;sign&quot;, &quot;verify&quot;]).then(function(key) {
+    return crypto.subtle.sign(&quot;hmac&quot;, key, text);
+}).then(function(result) {
+    signature = result;
+
+    shouldBe(&quot;bytesToHexString(signature)&quot;, &quot;expectedSignature&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="trunkLayoutTestscryptosubtlehmacimportkeysignsha224expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha224-expected.txt (0 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha224-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha224-expected.txt        2016-11-29 22:52:03 UTC (rev 209092)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+Test signing with HMAC SHA-224 using an imported key
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS bytesToHexString(signature) is expectedSignature
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlehmacimportkeysignsha224html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha224.html (0 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha224.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha224.html        2016-11-29 22:52:03 UTC (rev 209092)
</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 signing with HMAC SHA-224 using an imported key&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var text = asciiToUint8Array(&quot;Hello, World!&quot;);
+var hmacImportParams = {
+    name: &quot;hmac&quot;,
+    hash: &quot;sha-224&quot;,
+}
+var rawKey = asciiToUint8Array(&quot;jnOw99oOZFLIEPMr&quot;);
+var expectedSignature = &quot;70b638e082fabc3bf391a1935c4b6a74168401214f4fb5c31e0cebf4&quot;;
+
+crypto.subtle.importKey(&quot;raw&quot;, rawKey, hmacImportParams, extractable, [&quot;sign&quot;, &quot;verify&quot;]).then(function(key) {
+    return crypto.subtle.sign(&quot;hmac&quot;, key, text);
+}).then(function(result) {
+    signature = result;
+
+    shouldBe(&quot;bytesToHexString(signature)&quot;, &quot;expectedSignature&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="trunkLayoutTestscryptosubtlehmacimportkeysignsha256expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha256-expected.txt (0 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha256-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha256-expected.txt        2016-11-29 22:52:03 UTC (rev 209092)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+Test signing with HMAC SHA-256 using an imported key
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS bytesToHexString(signature) is expectedSignature
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlehmacimportkeysignsha256html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha256.html (0 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha256.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha256.html        2016-11-29 22:52:03 UTC (rev 209092)
</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 signing with HMAC SHA-256 using an imported key&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var text = asciiToUint8Array(&quot;Hello, World!&quot;);
+var hmacImportParams = {
+    name: &quot;hmac&quot;,
+    hash: &quot;sha-256&quot;,
+}
+var rawKey = asciiToUint8Array(&quot;jnOw99oOZFLIEPMr&quot;);
+var expectedSignature = &quot;d6b92f34723a8de7ba53dceea8c821f5d21757ddb478c27d564b356c38f583db&quot;;
+
+crypto.subtle.importKey(&quot;raw&quot;, rawKey, hmacImportParams, extractable, [&quot;sign&quot;, &quot;verify&quot;]).then(function(key) {
+    return crypto.subtle.sign(&quot;hmac&quot;, key, text);
+}).then(function(result) {
+    signature = result;
+
+    shouldBe(&quot;bytesToHexString(signature)&quot;, &quot;expectedSignature&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="trunkLayoutTestscryptosubtlehmacimportkeysignsha384expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha384-expected.txt (0 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha384-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha384-expected.txt        2016-11-29 22:52:03 UTC (rev 209092)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+Test signing with HMAC SHA-384 using an imported key
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS bytesToHexString(signature) is expectedSignature
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlehmacimportkeysignsha384html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha384.html (0 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha384.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha384.html        2016-11-29 22:52:03 UTC (rev 209092)
</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 signing with HMAC SHA-384 using an imported key&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var text = asciiToUint8Array(&quot;Hello, World!&quot;);
+var hmacImportParams = {
+    name: &quot;hmac&quot;,
+    hash: &quot;sha-384&quot;,
+}
+var rawKey = asciiToUint8Array(&quot;jnOw99oOZFLIEPMr&quot;);
+var expectedSignature = &quot;5cfc6cba3135c99cb426d5d59bd33c5e212aac082f5ba57a1f70def2b3e987e3f3078be80f142221b6a8e23768dd994f&quot;;
+
+crypto.subtle.importKey(&quot;raw&quot;, rawKey, hmacImportParams, extractable, [&quot;sign&quot;, &quot;verify&quot;]).then(function(key) {
+    return crypto.subtle.sign(&quot;hmac&quot;, key, text);
+}).then(function(result) {
+    signature = result;
+
+    shouldBe(&quot;bytesToHexString(signature)&quot;, &quot;expectedSignature&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="trunkLayoutTestscryptosubtlehmacimportkeysignsha512expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha512-expected.txt (0 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha512-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha512-expected.txt        2016-11-29 22:52:03 UTC (rev 209092)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+Test signing with HMAC SHA-512 using an imported key
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS bytesToHexString(signature) is expectedSignature
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlehmacimportkeysignsha512html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha512.html (0 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha512.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-import-key-sign-sha512.html        2016-11-29 22:52:03 UTC (rev 209092)
</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 signing with HMAC SHA-512 using an imported key&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var text = asciiToUint8Array(&quot;Hello, World!&quot;);
+var hmacImportParams = {
+    name: &quot;hmac&quot;,
+    hash: &quot;sha-512&quot;,
+}
+var rawKey = asciiToUint8Array(&quot;jnOw99oOZFLIEPMr&quot;);
+var expectedSignature = &quot;74b22e7422bd3d8562294040b8e9ff08849cf694d3f7729e02a111647b290058af5e1ca8321e5d0f512b5a55a287b39762fae85bef73611d0bddd0b3ddf252ec&quot;;
+
+crypto.subtle.importKey(&quot;raw&quot;, rawKey, hmacImportParams, extractable, [&quot;sign&quot;, &quot;verify&quot;]).then(function(key) {
+    return crypto.subtle.sign(&quot;hmac&quot;, key, text);
+}).then(function(result) {
+    signature = result;
+
+    shouldBe(&quot;bytesToHexString(signature)&quot;, &quot;expectedSignature&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="trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeysignsha1expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha1-expected.txt (0 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha1-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha1-expected.txt        2016-11-29 22:52:03 UTC (rev 209092)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+Test signing with RSASSA-PKCS1-v1_5 SHA-1 using an imported key
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS bytesToHexString(signature) is expectedSignature
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeysignsha1html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha1.html (0 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha1.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha1.html        2016-11-29 22:52:03 UTC (rev 209092)
</span><span class="lines">@@ -0,0 +1,53 @@
</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 signing with RSASSA-PKCS1-v1_5 SHA-1 using an imported key&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var text = asciiToUint8Array(&quot;Hello, World!&quot;);
+var rsaImportParams = {
+    name: &quot;RSASSA-PKCS1-v1_5&quot;,
+    hash: &quot;SHA-1&quot;,
+}
+var jwkKey = {
+    kty: &quot;RSA&quot;,
+    alg: &quot;RS1&quot;,
+    use: &quot;sig&quot;,
+    key_ops: [&quot;sign&quot;],
+    ext: true,
+    n: &quot;rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw&quot;,
+    e: &quot;AQAB&quot;,
+    d: &quot;eNLS37aCz7RXSNPD_DtLBJ6j5T8cSxdzRBCjPaI6WcGqJp16lq3UTwuoDLAqlA9oGYm238dsIWpuucP_lQtbWe-7SpxoI6_vmYGf7YVUHv1-DF9qiOmSrMmdxMnVOzYXY8RaT6thPjn_J5cfLV2xI_LwsrMtmpdSyNlgX0zTUhwtuahgAKMEChYjH2EnjHdHw6sY2-wApdcQI7ULE0oo5RzbQZpmuhcN9hiBc0L3hhF0qo50mbl02_65_GQ7DpVkXBxNgRBLzlPabmzzG2oAhfefLgYmSC1opaCkXE6vRWQNWNL45RZNZFYM3uoJghOMqGeocM0BpjdChHrPOlFvSQ&quot;,
+    p: &quot;4miTuAjKMeH5uJ5KB397QUwhbkYEgSbcA2mifmSkvE2018gb55qkBHK1eVryf1_m43LNlc6O_ak6gfzdZIZvS5NCGjPl0q09plUpu8qFOSspBwA67qGH76lFlZLn_d4yglS7wfLru4_5Ys8qLLs-DqVLviwposOnyyWqwM5AXp0&quot;,
+    q: &quot;xHYrzkivtmnz_sGchnWGc0q-pDOkKicptRpv2pMFIIXxnFX5aMeEXIZjVujXtwUy1UlFIN2GZJSvy5KJ79mu_XyNnFHMzedH-A3ee3u8h1UUrZF-vUu1_e4U_x67NN1dedzUSKynN7pFl3OkuShMBWGV-cwzOPdcVAfVuZlxUMc&quot;,
+    dp: &quot;fBzDzYDUBmBQGop7Hn0dvf_T27V6RqpctWo074CQZcFbP2atFVtKSj3viWT3xid2VHzcgiDHdfpM3nEVlEO1wwIonGCSvdjGEOZiiFVOjrZAOVxA8guOjyyFvqbXke06VwPIIVvfKeSU2zuhbP__1tt6F_fxow4Kb2xonGT0GGk&quot;,
+    dq: &quot;jmE2DiIPdhwDgLXAQpIaBqQ81bO3XfVT_LRULAwwwwlPuQV148H04zlh9TJ6Y2GZHYokV1U0eOBpJxfkb7dLYtpJpuiBjRf4yIUEoGlkkI_QlJnFSFr-YjGRdfNHqWBkxlSMZL770R9mIATndGkH7z5x-r9KwBZFC4FCG2hg_zE&quot;,
+    qi: &quot;YCX_pLwbMBA1ThVH0WcwmnytqNcrMCEwTm7ByA2eU6nWbQrULvf7m9_kzfLUcjsnpAVlBQG5JMXMy0Sq4ptwbywsa5-G8KAOOOR2L3v4hC-Eys9ftgFM_3i0o40eeQH4b3haPbntrIeMg8IzlOuVYKf9-2QuKDoWeRdd7NsdxTk&quot;,
+};
+var expectedSignature = &quot;08b83a4a58aff1db76529fe97f6dc2b58914a56f08ebc73aebf740680fc524e721c30842759acacab8acdf6e31e7cc83dbe8a48ace80b6a6558a9df892e4c2a9276c154cd605e632c8b857855a064aea68550b660a15044a0917026e494a71e4fee99fa57941268545f338c8601baa9c4f2116f0eb5432cfee5e3ed9978876fed201647921e599101930a99a2b645a9a879bce8c24592729f1f62a3b83fe21475871273cdbbe8efa7be314cabd087fbe1931ddf3fb86cbff5176a27554726b54c43208200725c6ad71d335ee5e09f3bbff7164ddf5bc857a41c5961e6f9581459db0fd0f09ee251d63b7a01bd716f6f72632b5c0f9a2c4dc2257d1e342138c13&quot;;
+
+crypto.subtle.importKey(&quot;jwk&quot;, jwkKey, rsaImportParams, extractable, [&quot;sign&quot;]).then(function(key) {
+    return crypto.subtle.sign(&quot;RSASSA-PKCS1-v1_5&quot;, key, text);
+}).then(function(result) {
+    signature = result;
+
+    shouldBe(&quot;bytesToHexString(signature)&quot;, &quot;expectedSignature&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="trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeysignsha224expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha224-expected.txt (0 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha224-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha224-expected.txt        2016-11-29 22:52:03 UTC (rev 209092)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+Test signing with RSASSA-PKCS1-v1_5 SHA-224 using an imported key
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS bytesToHexString(signature) is expectedSignature
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeysignsha224html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha224.html (0 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha224.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha224.html        2016-11-29 22:52:03 UTC (rev 209092)
</span><span class="lines">@@ -0,0 +1,53 @@
</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 signing with RSASSA-PKCS1-v1_5 SHA-224 using an imported key&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var text = asciiToUint8Array(&quot;Hello, World!&quot;);
+var rsaImportParams = {
+    name: &quot;RSASSA-PKCS1-v1_5&quot;,
+    hash: &quot;SHA-224&quot;,
+}
+var jwkKey = {
+    kty: &quot;RSA&quot;,
+    alg: &quot;RS224&quot;,
+    use: &quot;sig&quot;,
+    key_ops: [&quot;sign&quot;],
+    ext: true,
+    n: &quot;rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw&quot;,
+    e: &quot;AQAB&quot;,
+    d: &quot;eNLS37aCz7RXSNPD_DtLBJ6j5T8cSxdzRBCjPaI6WcGqJp16lq3UTwuoDLAqlA9oGYm238dsIWpuucP_lQtbWe-7SpxoI6_vmYGf7YVUHv1-DF9qiOmSrMmdxMnVOzYXY8RaT6thPjn_J5cfLV2xI_LwsrMtmpdSyNlgX0zTUhwtuahgAKMEChYjH2EnjHdHw6sY2-wApdcQI7ULE0oo5RzbQZpmuhcN9hiBc0L3hhF0qo50mbl02_65_GQ7DpVkXBxNgRBLzlPabmzzG2oAhfefLgYmSC1opaCkXE6vRWQNWNL45RZNZFYM3uoJghOMqGeocM0BpjdChHrPOlFvSQ&quot;,
+    p: &quot;4miTuAjKMeH5uJ5KB397QUwhbkYEgSbcA2mifmSkvE2018gb55qkBHK1eVryf1_m43LNlc6O_ak6gfzdZIZvS5NCGjPl0q09plUpu8qFOSspBwA67qGH76lFlZLn_d4yglS7wfLru4_5Ys8qLLs-DqVLviwposOnyyWqwM5AXp0&quot;,
+    q: &quot;xHYrzkivtmnz_sGchnWGc0q-pDOkKicptRpv2pMFIIXxnFX5aMeEXIZjVujXtwUy1UlFIN2GZJSvy5KJ79mu_XyNnFHMzedH-A3ee3u8h1UUrZF-vUu1_e4U_x67NN1dedzUSKynN7pFl3OkuShMBWGV-cwzOPdcVAfVuZlxUMc&quot;,
+    dp: &quot;fBzDzYDUBmBQGop7Hn0dvf_T27V6RqpctWo074CQZcFbP2atFVtKSj3viWT3xid2VHzcgiDHdfpM3nEVlEO1wwIonGCSvdjGEOZiiFVOjrZAOVxA8guOjyyFvqbXke06VwPIIVvfKeSU2zuhbP__1tt6F_fxow4Kb2xonGT0GGk&quot;,
+    dq: &quot;jmE2DiIPdhwDgLXAQpIaBqQ81bO3XfVT_LRULAwwwwlPuQV148H04zlh9TJ6Y2GZHYokV1U0eOBpJxfkb7dLYtpJpuiBjRf4yIUEoGlkkI_QlJnFSFr-YjGRdfNHqWBkxlSMZL770R9mIATndGkH7z5x-r9KwBZFC4FCG2hg_zE&quot;,
+    qi: &quot;YCX_pLwbMBA1ThVH0WcwmnytqNcrMCEwTm7ByA2eU6nWbQrULvf7m9_kzfLUcjsnpAVlBQG5JMXMy0Sq4ptwbywsa5-G8KAOOOR2L3v4hC-Eys9ftgFM_3i0o40eeQH4b3haPbntrIeMg8IzlOuVYKf9-2QuKDoWeRdd7NsdxTk&quot;,
+};
+var expectedSignature = &quot;3cb10634bbb4022b64e0af31d0c0533837e14c8a9a4d7b9ef8c6816133843ef58603887fb05f7215bf39e803326367d95ea8894dda321b753a62dcc3214c7e85a134bf741c883f1ee0037dde6334d62b8efe54dcb59c8510e4d733b35466ad5a064686616898d73e25138cc6fd572d52df5e80f70d3d803ae9100516b4bde58cafc068c655f0cdbd2249ae61eb1a952d49df493b3c3c4a15ffb900d4f489df797498a0e7333c58cb953c2f3b169290ae7dd51e3c53bdb0bdf4311ae3fd5d7a1c3de038f696c05190db1c60056f664c6421580385b9fe54e1b2f41eef9eb83d18c6d28745d9c0eb2c15b45f5949b78762558488ae09877f4305f8c9068576e6e5&quot;;
+
+crypto.subtle.importKey(&quot;jwk&quot;, jwkKey, rsaImportParams, extractable, [&quot;sign&quot;]).then(function(key) {
+    return crypto.subtle.sign(&quot;RSASSA-PKCS1-v1_5&quot;, key, text);
+}).then(function(result) {
+    signature = result;
+
+    shouldBe(&quot;bytesToHexString(signature)&quot;, &quot;expectedSignature&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="trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeysignsha256expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha256-expected.txt (0 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha256-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha256-expected.txt        2016-11-29 22:52:03 UTC (rev 209092)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+Test signing with RSASSA-PKCS1-v1_5 SHA-256 using an imported key
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS bytesToHexString(signature) is expectedSignature
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeysignsha256html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha256.html (0 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha256.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha256.html        2016-11-29 22:52:03 UTC (rev 209092)
</span><span class="lines">@@ -0,0 +1,53 @@
</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 signing with RSASSA-PKCS1-v1_5 SHA-256 using an imported key&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var text = asciiToUint8Array(&quot;Hello, World!&quot;);
+var rsaImportParams = {
+    name: &quot;RSASSA-PKCS1-v1_5&quot;,
+    hash: &quot;SHA-256&quot;,
+}
+var jwkKey = {
+    kty: &quot;RSA&quot;,
+    alg: &quot;RS256&quot;,
+    use: &quot;sig&quot;,
+    key_ops: [&quot;sign&quot;],
+    ext: true,
+    n: &quot;rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw&quot;,
+    e: &quot;AQAB&quot;,
+    d: &quot;eNLS37aCz7RXSNPD_DtLBJ6j5T8cSxdzRBCjPaI6WcGqJp16lq3UTwuoDLAqlA9oGYm238dsIWpuucP_lQtbWe-7SpxoI6_vmYGf7YVUHv1-DF9qiOmSrMmdxMnVOzYXY8RaT6thPjn_J5cfLV2xI_LwsrMtmpdSyNlgX0zTUhwtuahgAKMEChYjH2EnjHdHw6sY2-wApdcQI7ULE0oo5RzbQZpmuhcN9hiBc0L3hhF0qo50mbl02_65_GQ7DpVkXBxNgRBLzlPabmzzG2oAhfefLgYmSC1opaCkXE6vRWQNWNL45RZNZFYM3uoJghOMqGeocM0BpjdChHrPOlFvSQ&quot;,
+    p: &quot;4miTuAjKMeH5uJ5KB397QUwhbkYEgSbcA2mifmSkvE2018gb55qkBHK1eVryf1_m43LNlc6O_ak6gfzdZIZvS5NCGjPl0q09plUpu8qFOSspBwA67qGH76lFlZLn_d4yglS7wfLru4_5Ys8qLLs-DqVLviwposOnyyWqwM5AXp0&quot;,
+    q: &quot;xHYrzkivtmnz_sGchnWGc0q-pDOkKicptRpv2pMFIIXxnFX5aMeEXIZjVujXtwUy1UlFIN2GZJSvy5KJ79mu_XyNnFHMzedH-A3ee3u8h1UUrZF-vUu1_e4U_x67NN1dedzUSKynN7pFl3OkuShMBWGV-cwzOPdcVAfVuZlxUMc&quot;,
+    dp: &quot;fBzDzYDUBmBQGop7Hn0dvf_T27V6RqpctWo074CQZcFbP2atFVtKSj3viWT3xid2VHzcgiDHdfpM3nEVlEO1wwIonGCSvdjGEOZiiFVOjrZAOVxA8guOjyyFvqbXke06VwPIIVvfKeSU2zuhbP__1tt6F_fxow4Kb2xonGT0GGk&quot;,
+    dq: &quot;jmE2DiIPdhwDgLXAQpIaBqQ81bO3XfVT_LRULAwwwwlPuQV148H04zlh9TJ6Y2GZHYokV1U0eOBpJxfkb7dLYtpJpuiBjRf4yIUEoGlkkI_QlJnFSFr-YjGRdfNHqWBkxlSMZL770R9mIATndGkH7z5x-r9KwBZFC4FCG2hg_zE&quot;,
+    qi: &quot;YCX_pLwbMBA1ThVH0WcwmnytqNcrMCEwTm7ByA2eU6nWbQrULvf7m9_kzfLUcjsnpAVlBQG5JMXMy0Sq4ptwbywsa5-G8KAOOOR2L3v4hC-Eys9ftgFM_3i0o40eeQH4b3haPbntrIeMg8IzlOuVYKf9-2QuKDoWeRdd7NsdxTk&quot;,
+};
+var expectedSignature = &quot;6dd6df5884c84e8494794f5104559fd2966b266b7d6f3f9b8080adfb36e7c63d8f9b3b1d26084028735030749e829da0d22e3ba39454c07db7c104a19b9f509f0e4c0908c16cd604b5771bdf06507dec95d6545b896f56684016777675c16d852bb6d6ff98e1dbfc27a11d06fa028d4b8c8d2ac6790406f89283674e3f3d200aa17feb4332cbd6a6dca6b73008f5996297ac572f943037950da37b25420b24c51e76918f3e4aedeb70a0d026c75f6ae20f7fa3185f34914fc0ffd682e514d84fb73c1ce33bd1c19e4ec4b96536004af0a6206d0114196863a11d0ea575e14aedaceac6e08f1d1f9e2fab1f0cd49a0c840a8c94f9c30a2483d770cb8f9867ba6d&quot;;
+
+crypto.subtle.importKey(&quot;jwk&quot;, jwkKey, rsaImportParams, extractable, [&quot;sign&quot;]).then(function(key) {
+    return crypto.subtle.sign(&quot;RSASSA-PKCS1-v1_5&quot;, key, text);
+}).then(function(result) {
+    signature = result;
+
+    shouldBe(&quot;bytesToHexString(signature)&quot;, &quot;expectedSignature&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="trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeysignsha384expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha384-expected.txt (0 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha384-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha384-expected.txt        2016-11-29 22:52:03 UTC (rev 209092)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+Test signing with RSASSA-PKCS1-v1_5 SHA-384 using an imported key
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS bytesToHexString(signature) is expectedSignature
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeysignsha384html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha384.html (0 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha384.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha384.html        2016-11-29 22:52:03 UTC (rev 209092)
</span><span class="lines">@@ -0,0 +1,53 @@
</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 signing with RSASSA-PKCS1-v1_5 SHA-384 using an imported key&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var text = asciiToUint8Array(&quot;Hello, World!&quot;);
+var rsaImportParams = {
+    name: &quot;RSASSA-PKCS1-v1_5&quot;,
+    hash: &quot;SHA-384&quot;,
+}
+var jwkKey = {
+    kty: &quot;RSA&quot;,
+    alg: &quot;RS384&quot;,
+    use: &quot;sig&quot;,
+    key_ops: [&quot;sign&quot;],
+    ext: true,
+    n: &quot;rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw&quot;,
+    e: &quot;AQAB&quot;,
+    d: &quot;eNLS37aCz7RXSNPD_DtLBJ6j5T8cSxdzRBCjPaI6WcGqJp16lq3UTwuoDLAqlA9oGYm238dsIWpuucP_lQtbWe-7SpxoI6_vmYGf7YVUHv1-DF9qiOmSrMmdxMnVOzYXY8RaT6thPjn_J5cfLV2xI_LwsrMtmpdSyNlgX0zTUhwtuahgAKMEChYjH2EnjHdHw6sY2-wApdcQI7ULE0oo5RzbQZpmuhcN9hiBc0L3hhF0qo50mbl02_65_GQ7DpVkXBxNgRBLzlPabmzzG2oAhfefLgYmSC1opaCkXE6vRWQNWNL45RZNZFYM3uoJghOMqGeocM0BpjdChHrPOlFvSQ&quot;,
+    p: &quot;4miTuAjKMeH5uJ5KB397QUwhbkYEgSbcA2mifmSkvE2018gb55qkBHK1eVryf1_m43LNlc6O_ak6gfzdZIZvS5NCGjPl0q09plUpu8qFOSspBwA67qGH76lFlZLn_d4yglS7wfLru4_5Ys8qLLs-DqVLviwposOnyyWqwM5AXp0&quot;,
+    q: &quot;xHYrzkivtmnz_sGchnWGc0q-pDOkKicptRpv2pMFIIXxnFX5aMeEXIZjVujXtwUy1UlFIN2GZJSvy5KJ79mu_XyNnFHMzedH-A3ee3u8h1UUrZF-vUu1_e4U_x67NN1dedzUSKynN7pFl3OkuShMBWGV-cwzOPdcVAfVuZlxUMc&quot;,
+    dp: &quot;fBzDzYDUBmBQGop7Hn0dvf_T27V6RqpctWo074CQZcFbP2atFVtKSj3viWT3xid2VHzcgiDHdfpM3nEVlEO1wwIonGCSvdjGEOZiiFVOjrZAOVxA8guOjyyFvqbXke06VwPIIVvfKeSU2zuhbP__1tt6F_fxow4Kb2xonGT0GGk&quot;,
+    dq: &quot;jmE2DiIPdhwDgLXAQpIaBqQ81bO3XfVT_LRULAwwwwlPuQV148H04zlh9TJ6Y2GZHYokV1U0eOBpJxfkb7dLYtpJpuiBjRf4yIUEoGlkkI_QlJnFSFr-YjGRdfNHqWBkxlSMZL770R9mIATndGkH7z5x-r9KwBZFC4FCG2hg_zE&quot;,
+    qi: &quot;YCX_pLwbMBA1ThVH0WcwmnytqNcrMCEwTm7ByA2eU6nWbQrULvf7m9_kzfLUcjsnpAVlBQG5JMXMy0Sq4ptwbywsa5-G8KAOOOR2L3v4hC-Eys9ftgFM_3i0o40eeQH4b3haPbntrIeMg8IzlOuVYKf9-2QuKDoWeRdd7NsdxTk&quot;,
+};
+var expectedSignature = &quot;8517104ae42b39e958e01a78158f90077b7711a60634873c3ae62565900dc1c7a3e75626b30e1281fa396594bbab742a5fc3be39dee3d981b9e4e83248bf69ed3671dee86a8f03c6a9b4465bf7b3dcd1dd04c3446e77aa340f20f9bd203966dd3dec2d4d135ea1c916f218a711ccaa167332f021ed7163ba61ffed6c0c48c4097ff979eea349011febf10398c3abcec9b4540ff0767fa9a29e7b119b8fdb8eb55786d311058dc509ce58da8abf50fe0ab2f1b092a24d3f8ae2f1f533a1ef0b7e191a43bb710acb376f4f5e620ffff602d9865a93e90f5d264309559a6acd4071058abb3ce0935a06df59b6c7c273cb033bc6d6a18b32559a8d4b14da2bfa2b15&quot;;
+
+crypto.subtle.importKey(&quot;jwk&quot;, jwkKey, rsaImportParams, extractable, [&quot;sign&quot;]).then(function(key) {
+    return crypto.subtle.sign(&quot;RSASSA-PKCS1-v1_5&quot;, key, text);
+}).then(function(result) {
+    signature = result;
+
+    shouldBe(&quot;bytesToHexString(signature)&quot;, &quot;expectedSignature&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="trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeysignsha512expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha512-expected.txt (0 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha512-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha512-expected.txt        2016-11-29 22:52:03 UTC (rev 209092)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+Test signing with RSASSA-PKCS1-v1_5 SHA-512 using an imported key
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS bytesToHexString(signature) is expectedSignature
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeysignsha512html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha512.html (0 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha512.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha512.html        2016-11-29 22:52:03 UTC (rev 209092)
</span><span class="lines">@@ -0,0 +1,53 @@
</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 signing with RSASSA-PKCS1-v1_5 SHA-512 using an imported key&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var text = asciiToUint8Array(&quot;Hello, World!&quot;);
+var rsaImportParams = {
+    name: &quot;RSASSA-PKCS1-v1_5&quot;,
+    hash: &quot;SHA-512&quot;,
+}
+var jwkKey = {
+    kty: &quot;RSA&quot;,
+    alg: &quot;RS512&quot;,
+    use: &quot;sig&quot;,
+    key_ops: [&quot;sign&quot;],
+    ext: true,
+    n: &quot;rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw&quot;,
+    e: &quot;AQAB&quot;,
+    d: &quot;eNLS37aCz7RXSNPD_DtLBJ6j5T8cSxdzRBCjPaI6WcGqJp16lq3UTwuoDLAqlA9oGYm238dsIWpuucP_lQtbWe-7SpxoI6_vmYGf7YVUHv1-DF9qiOmSrMmdxMnVOzYXY8RaT6thPjn_J5cfLV2xI_LwsrMtmpdSyNlgX0zTUhwtuahgAKMEChYjH2EnjHdHw6sY2-wApdcQI7ULE0oo5RzbQZpmuhcN9hiBc0L3hhF0qo50mbl02_65_GQ7DpVkXBxNgRBLzlPabmzzG2oAhfefLgYmSC1opaCkXE6vRWQNWNL45RZNZFYM3uoJghOMqGeocM0BpjdChHrPOlFvSQ&quot;,
+    p: &quot;4miTuAjKMeH5uJ5KB397QUwhbkYEgSbcA2mifmSkvE2018gb55qkBHK1eVryf1_m43LNlc6O_ak6gfzdZIZvS5NCGjPl0q09plUpu8qFOSspBwA67qGH76lFlZLn_d4yglS7wfLru4_5Ys8qLLs-DqVLviwposOnyyWqwM5AXp0&quot;,
+    q: &quot;xHYrzkivtmnz_sGchnWGc0q-pDOkKicptRpv2pMFIIXxnFX5aMeEXIZjVujXtwUy1UlFIN2GZJSvy5KJ79mu_XyNnFHMzedH-A3ee3u8h1UUrZF-vUu1_e4U_x67NN1dedzUSKynN7pFl3OkuShMBWGV-cwzOPdcVAfVuZlxUMc&quot;,
+    dp: &quot;fBzDzYDUBmBQGop7Hn0dvf_T27V6RqpctWo074CQZcFbP2atFVtKSj3viWT3xid2VHzcgiDHdfpM3nEVlEO1wwIonGCSvdjGEOZiiFVOjrZAOVxA8guOjyyFvqbXke06VwPIIVvfKeSU2zuhbP__1tt6F_fxow4Kb2xonGT0GGk&quot;,
+    dq: &quot;jmE2DiIPdhwDgLXAQpIaBqQ81bO3XfVT_LRULAwwwwlPuQV148H04zlh9TJ6Y2GZHYokV1U0eOBpJxfkb7dLYtpJpuiBjRf4yIUEoGlkkI_QlJnFSFr-YjGRdfNHqWBkxlSMZL770R9mIATndGkH7z5x-r9KwBZFC4FCG2hg_zE&quot;,
+    qi: &quot;YCX_pLwbMBA1ThVH0WcwmnytqNcrMCEwTm7ByA2eU6nWbQrULvf7m9_kzfLUcjsnpAVlBQG5JMXMy0Sq4ptwbywsa5-G8KAOOOR2L3v4hC-Eys9ftgFM_3i0o40eeQH4b3haPbntrIeMg8IzlOuVYKf9-2QuKDoWeRdd7NsdxTk&quot;,
+};
+var expectedSignature = &quot;04dfcced9635d2208ea05c73ce76745678db57b7575a7ffa9770615a9ef9c68455bb49e9c70a99d053eb91c9dd2ecf09dba2a1334325318a2e75b78f4c4eb63c0d05a2a9418d6aefc5cb97ffbfb8cd06b39f8adaa545ea6b95e09934b0e2ef8e05734dcb1f1a72877f891637a99cd80b2f8a5ad419aebe18fa354bff95141b207f986e60ae16f192011b7f9c97137820a7af77be59d771ad35f51a895a2c5e0aafc96ba8f1f2dfcfbe5257b7b603d37e25670996c6c05f3db940c973f561bac8582659701fad4b4c84faa56af2dfeab450c40714f46bdd1bc6e24a3efc10bf3767ad452a79fb7de5fff282b2302e3f3f98bfdbb4037780e793343358b51cead1&quot;;
+
+crypto.subtle.importKey(&quot;jwk&quot;, jwkKey, rsaImportParams, extractable, [&quot;sign&quot;]).then(function(key) {
+    return crypto.subtle.sign(&quot;RSASSA-PKCS1-v1_5&quot;, key, text);
+}).then(function(result) {
+    signature = result;
+
+    shouldBe(&quot;bytesToHexString(signature)&quot;, &quot;expectedSignature&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="trunkLayoutTestscryptosubtlesignmalformedparametersexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/sign-malformed-parameters-expected.txt (0 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/sign-malformed-parameters-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/sign-malformed-parameters-expected.txt        2016-11-29 22:52:03 UTC (rev 209092)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+Test signing with malformed parameters
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS crypto.subtle.sign() rejected promise  with TypeError: Not enough arguments.
+PASS crypto.subtle.sign(1) rejected promise  with TypeError: Not enough arguments.
+PASS crypto.subtle.sign(1, 2) rejected promise  with TypeError: Not enough arguments.
+PASS crypto.subtle.sign(&quot;rsassa-pkcs1-v1_5&quot;, wrongKey, text) rejected promise  with InvalidAccessError (DOM Exception 15): CryptoKey doesn't match AlgorithmIdentifier.
+PASS crypto.subtle.sign(&quot;hmac&quot;, wrongKey, text) rejected promise  with InvalidAccessError (DOM Exception 15): CryptoKey doesn't support signing.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlesignmalformedparametershtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/sign-malformed-parameters.html (0 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/sign-malformed-parameters.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/sign-malformed-parameters.html        2016-11-29 22:52:03 UTC (rev 209092)
</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 signing with malformed parameters&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var text = asciiToUint8Array(&quot;Hello, World!&quot;);
+var hmacImportParams = {
+    name: &quot;hmac&quot;,
+    hash: &quot;sha-1&quot;,
+}
+var rawKey = asciiToUint8Array(&quot;jnOw99oOZFLIEPMr&quot;);
+
+// Not enough arguments.
+shouldReject('crypto.subtle.sign()');
+shouldReject('crypto.subtle.sign(1)');
+shouldReject('crypto.subtle.sign(1, 2)');
+
+crypto.subtle.importKey(&quot;raw&quot;, rawKey, hmacImportParams, extractable, [&quot;sign&quot;, &quot;verify&quot;]).then(function(result) {
+    wrongKey = result;
+    // Wrong algorithm identifier.
+    shouldReject('crypto.subtle.sign(&quot;rsassa-pkcs1-v1_5&quot;, wrongKey, text)');
+
+    return crypto.subtle.importKey(&quot;raw&quot;, rawKey, hmacImportParams, extractable, [&quot;verify&quot;]);
+}).then(function(result) {
+    wrongKey = result;
+    // Wrong usage.
+    return shouldReject('crypto.subtle.sign(&quot;hmac&quot;, wrongKey, text)');
+}).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="trunkLayoutTestscryptoworkerssubtlehmacimportkeysignexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/hmac-import-key-sign-expected.txt (0 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/hmac-import-key-sign-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/hmac-import-key-sign-expected.txt        2016-11-29 22:52:03 UTC (rev 209092)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+[Worker] Test signing with HMAC SHA-1 using 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/hmac-import-key-sign.js
+PASS [Worker] bytesToHexString(signature) is expectedSignature
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtlehmacimportkeysignhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/hmac-import-key-sign.html (0 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/hmac-import-key-sign.html                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/hmac-import-key-sign.html        2016-11-29 22:52:03 UTC (rev 209092)
</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/hmac-import-key-sign.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="trunkLayoutTestscryptoworkerssubtleresourceshmacimportkeysignjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/resources/hmac-import-key-sign.js (0 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/resources/hmac-import-key-sign.js                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/resources/hmac-import-key-sign.js        2016-11-29 22:52:03 UTC (rev 209092)
</span><span class="lines">@@ -0,0 +1,25 @@
</span><ins>+importScripts('../../../../resources/js-test-pre.js');
+importScripts('../../../resources/common.js');
+
+description(&quot;Test signing with HMAC SHA-1 using an imported key in workers&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var text = asciiToUint8Array(&quot;Hello, World!&quot;);
+var hmacImportParams = {
+    name: &quot;hmac&quot;,
+    hash: &quot;sha-1&quot;,
+}
+var rawKey = asciiToUint8Array(&quot;jnOw99oOZFLIEPMr&quot;);
+var expectedSignature = &quot;6e8e66ff128606f52b8c589196ef5e0f7ca04816&quot;;
+
+crypto.subtle.importKey(&quot;raw&quot;, rawKey, hmacImportParams, extractable, [&quot;sign&quot;, &quot;verify&quot;]).then(function(key) {
+    return crypto.subtle.sign(&quot;hmac&quot;, key, text);
+}).then(function(result) {
+    signature = result;
+
+    shouldBe(&quot;bytesToHexString(signature)&quot;, &quot;expectedSignature&quot;);
+
+    finishJSTest();
+});
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtleresourcesrsassapkcs1v1_5importkeysignjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/resources/rsassa-pkcs1-v1_5-import-key-sign.js (0 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/resources/rsassa-pkcs1-v1_5-import-key-sign.js                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/resources/rsassa-pkcs1-v1_5-import-key-sign.js        2016-11-29 22:52:03 UTC (rev 209092)
</span><span class="lines">@@ -0,0 +1,39 @@
</span><ins>+importScripts('../../../../resources/js-test-pre.js');
+importScripts('../../../resources/common.js');
+
+description(&quot;Test signing with RSASSA-PKCS1-v1_5 SHA-1 using an imported key in workers&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var text = asciiToUint8Array(&quot;Hello, World!&quot;);
+var rsaImportParams = {
+    name: &quot;RSASSA-PKCS1-v1_5&quot;,
+    hash: &quot;SHA-1&quot;,
+}
+var jwkKey = {
+    kty: &quot;RSA&quot;,
+    alg: &quot;RS1&quot;,
+    use: &quot;sig&quot;,
+    key_ops: [&quot;sign&quot;],
+    ext: true,
+    n: &quot;rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw&quot;,
+    e: &quot;AQAB&quot;,
+    d: &quot;eNLS37aCz7RXSNPD_DtLBJ6j5T8cSxdzRBCjPaI6WcGqJp16lq3UTwuoDLAqlA9oGYm238dsIWpuucP_lQtbWe-7SpxoI6_vmYGf7YVUHv1-DF9qiOmSrMmdxMnVOzYXY8RaT6thPjn_J5cfLV2xI_LwsrMtmpdSyNlgX0zTUhwtuahgAKMEChYjH2EnjHdHw6sY2-wApdcQI7ULE0oo5RzbQZpmuhcN9hiBc0L3hhF0qo50mbl02_65_GQ7DpVkXBxNgRBLzlPabmzzG2oAhfefLgYmSC1opaCkXE6vRWQNWNL45RZNZFYM3uoJghOMqGeocM0BpjdChHrPOlFvSQ&quot;,
+    p: &quot;4miTuAjKMeH5uJ5KB397QUwhbkYEgSbcA2mifmSkvE2018gb55qkBHK1eVryf1_m43LNlc6O_ak6gfzdZIZvS5NCGjPl0q09plUpu8qFOSspBwA67qGH76lFlZLn_d4yglS7wfLru4_5Ys8qLLs-DqVLviwposOnyyWqwM5AXp0&quot;,
+    q: &quot;xHYrzkivtmnz_sGchnWGc0q-pDOkKicptRpv2pMFIIXxnFX5aMeEXIZjVujXtwUy1UlFIN2GZJSvy5KJ79mu_XyNnFHMzedH-A3ee3u8h1UUrZF-vUu1_e4U_x67NN1dedzUSKynN7pFl3OkuShMBWGV-cwzOPdcVAfVuZlxUMc&quot;,
+    dp: &quot;fBzDzYDUBmBQGop7Hn0dvf_T27V6RqpctWo074CQZcFbP2atFVtKSj3viWT3xid2VHzcgiDHdfpM3nEVlEO1wwIonGCSvdjGEOZiiFVOjrZAOVxA8guOjyyFvqbXke06VwPIIVvfKeSU2zuhbP__1tt6F_fxow4Kb2xonGT0GGk&quot;,
+    dq: &quot;jmE2DiIPdhwDgLXAQpIaBqQ81bO3XfVT_LRULAwwwwlPuQV148H04zlh9TJ6Y2GZHYokV1U0eOBpJxfkb7dLYtpJpuiBjRf4yIUEoGlkkI_QlJnFSFr-YjGRdfNHqWBkxlSMZL770R9mIATndGkH7z5x-r9KwBZFC4FCG2hg_zE&quot;,
+    qi: &quot;YCX_pLwbMBA1ThVH0WcwmnytqNcrMCEwTm7ByA2eU6nWbQrULvf7m9_kzfLUcjsnpAVlBQG5JMXMy0Sq4ptwbywsa5-G8KAOOOR2L3v4hC-Eys9ftgFM_3i0o40eeQH4b3haPbntrIeMg8IzlOuVYKf9-2QuKDoWeRdd7NsdxTk&quot;,
+};
+var expectedSignature = &quot;08b83a4a58aff1db76529fe97f6dc2b58914a56f08ebc73aebf740680fc524e721c30842759acacab8acdf6e31e7cc83dbe8a48ace80b6a6558a9df892e4c2a9276c154cd605e632c8b857855a064aea68550b660a15044a0917026e494a71e4fee99fa57941268545f338c8601baa9c4f2116f0eb5432cfee5e3ed9978876fed201647921e599101930a99a2b645a9a879bce8c24592729f1f62a3b83fe21475871273cdbbe8efa7be314cabd087fbe1931ddf3fb86cbff5176a27554726b54c43208200725c6ad71d335ee5e09f3bbff7164ddf5bc857a41c5961e6f9581459db0fd0f09ee251d63b7a01bd716f6f72632b5c0f9a2c4dc2257d1e342138c13&quot;;
+
+crypto.subtle.importKey(&quot;jwk&quot;, jwkKey, rsaImportParams, extractable, [&quot;sign&quot;]).then(function(key) {
+    return crypto.subtle.sign(&quot;RSASSA-PKCS1-v1_5&quot;, key, text);
+}).then(function(result) {
+    signature = result;
+
+    shouldBe(&quot;bytesToHexString(signature)&quot;, &quot;expectedSignature&quot;);
+
+    finishJSTest();
+});
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtlersassapkcs1v1_5importkeysignexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/rsassa-pkcs1-v1_5-import-key-sign-expected.txt (0 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/rsassa-pkcs1-v1_5-import-key-sign-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/rsassa-pkcs1-v1_5-import-key-sign-expected.txt        2016-11-29 22:52:03 UTC (rev 209092)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+[Worker] Test signing with RSASSA-PKCS1-v1_5 SHA-1 using 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/rsassa-pkcs1-v1_5-import-key-sign.js
+PASS [Worker] bytesToHexString(signature) is expectedSignature
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtlersassapkcs1v1_5importkeysignhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/rsassa-pkcs1-v1_5-import-key-sign.html (0 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/rsassa-pkcs1-v1_5-import-key-sign.html                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/rsassa-pkcs1-v1_5-import-key-sign.html        2016-11-29 22:52:03 UTC (rev 209092)
</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/rsassa-pkcs1-v1_5-import-key-sign.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 (209091 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog        2016-11-29 22:38:26 UTC (rev 209091)
+++ trunk/LayoutTests/imported/w3c/ChangeLog        2016-11-29 22:52:03 UTC (rev 209092)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2016-11-22  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
+
+        Update SubtleCrypto::sign to match the latest spec
+        https://bugs.webkit.org/show_bug.cgi?id=164740
+        &lt;rdar://problem/29257864&gt;
+
+        Reviewed by Brent Fulgham.
+
+        * WebCryptoAPI/idlharness-expected.txt:
+
</ins><span class="cx"> 2016-11-18  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Update SubtleCrypto::decrypt to match the latest spec
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cWebCryptoAPIidlharnessexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/WebCryptoAPI/idlharness-expected.txt (209091 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/WebCryptoAPI/idlharness-expected.txt        2016-11-29 22:38:26 UTC (rev 209091)
+++ trunk/LayoutTests/imported/w3c/WebCryptoAPI/idlharness-expected.txt        2016-11-29 22:52:03 UTC (rev 209092)
</span><span class="lines">@@ -47,8 +47,8 @@
</span><span class="cx"> PASS SubtleCrypto interface: calling encrypt(AlgorithmIdentifier,CryptoKey,BufferSource) on crypto.subtle with too few arguments must throw TypeError 
</span><span class="cx"> PASS SubtleCrypto interface: crypto.subtle must inherit property &quot;decrypt&quot; with the proper type (1) 
</span><span class="cx"> PASS SubtleCrypto interface: calling decrypt(AlgorithmIdentifier,CryptoKey,BufferSource) on crypto.subtle with too few arguments must throw TypeError 
</span><del>-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
-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
</del><ins>+PASS SubtleCrypto interface: crypto.subtle must inherit property &quot;sign&quot; with the proper type (2) 
+PASS SubtleCrypto interface: calling sign(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;verify&quot; with the proper type (3) assert_inherits: property &quot;verify&quot; not found in prototype chain
</span><span class="cx"> FAIL SubtleCrypto interface: calling verify(AlgorithmIdentifier,CryptoKey,BufferSource,BufferSource) on crypto.subtle with too few arguments must throw TypeError assert_inherits: property &quot;verify&quot; not found in prototype chain
</span><span class="cx"> FAIL SubtleCrypto interface: crypto.subtle must inherit property &quot;digest&quot; with the proper type (4) assert_inherits: property &quot;digest&quot; not found in prototype chain
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (209091 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-11-29 22:38:26 UTC (rev 209091)
+++ trunk/Source/WebCore/ChangeLog        2016-11-29 22:52:03 UTC (rev 209092)
</span><span class="lines">@@ -1,3 +1,72 @@
</span><ins>+2016-11-22  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
+
+        Update SubtleCrypto::sign to match the latest spec
+        https://bugs.webkit.org/show_bug.cgi?id=164740
+        &lt;rdar://problem/29257864&gt;
+
+        Reviewed by Brent Fulgham.
+
+        This patch does following few things:
+        1. It updates the SubtleCrypto::sign method to match the latest spec:
+           https://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-sign.
+           It also refers to the latest Editor's Draft to a certain degree:
+           https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-sign.
+        2. It implements sign operations of the following algorithms: HMAC, and
+           RSASSA-PKCS1-V1_5.
+        3. It also replaces promise.copyRef() with WTFMove(promise) for all the
+           capture lists of exception callbacks in promise functions.
+
+        Tests: crypto/subtle/hmac-import-key-sign-sha1.html
+               crypto/subtle/hmac-import-key-sign-sha224.html
+               crypto/subtle/hmac-import-key-sign-sha256.html
+               crypto/subtle/hmac-import-key-sign-sha384.html
+               crypto/subtle/hmac-import-key-sign-sha512.html
+               crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha1.html
+               crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha224.html
+               crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha256.html
+               crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha384.html
+               crypto/subtle/rsassa-pkcs1-v1_5-import-key-sign-sha512.html
+               crypto/subtle/sign-malformed-parameters.html
+               crypto/workers/subtle/hmac-import-key-sign.html
+               crypto/workers/subtle/rsassa-pkcs1-v1_5-import-key-sign.html
+
+        * bindings/js/JSSubtleCryptoCustom.cpp:
+        (WebCore::normalizeCryptoAlgorithmParameters):
+        (WebCore::jsSubtleCryptoFunctionDecryptPromise):
+        Fix a minor bug.
+        (WebCore::jsSubtleCryptoFunctionEncryptPromise):
+        (WebCore::jsSubtleCryptoFunctionDecryptPromise):
+        (WebCore::jsSubtleCryptoFunctionSignPromise):
+        (WebCore::jsSubtleCryptoFunctionGenerateKeyPromise):
+        (WebCore::jsSubtleCryptoFunctionImportKeyPromise):
+        (WebCore::jsSubtleCryptoFunctionExportKeyPromise):
+        (WebCore::JSSubtleCrypto::sign):
+        * crypto/CryptoAlgorithm.cpp:
+        (WebCore::CryptoAlgorithm::sign):
+        * crypto/CryptoAlgorithm.h:
+        * crypto/SubtleCrypto.idl:
+        * crypto/algorithms/CryptoAlgorithmHMAC.cpp:
+        (WebCore::CryptoAlgorithmHMAC::sign):
+        * crypto/algorithms/CryptoAlgorithmHMAC.h:
+        * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp:
+        (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::sign):
+        * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h:
+        * crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp:
+        (WebCore::CryptoAlgorithmHMAC::platformSign):
+        * crypto/gnutls/CryptoAlgorithmHMACGnuTLS.cpp:
+        (WebCore::CryptoAlgorithmHMAC::platformSign):
+        * crypto/gnutls/CryptoAlgorithmRSASSA_PKCS1_v1_5GnuTLS.cpp:
+        (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign):
+        * crypto/mac/CryptoAlgorithmHMACMac.cpp:
+        (WebCore::commonCryptoHMACAlgorithm):
+        (WebCore::calculateSignature):
+        Remove a null guardance since the depending bug is resolved.
+        (WebCore::CryptoAlgorithmHMAC::platformSign):
+        (WebCore::CryptoAlgorithmHMAC::platformVerify):
+        * crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp:
+        (WebCore::signRSASSA_PKCS1_v1_5):
+        (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign):
+
</ins><span class="cx"> 2016-11-29  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Can't download move.simple.com direct deposit transition PDF: Non user-triggered activations of anchors that have a download attribute are ignored
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSSubtleCryptoCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp (209091 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp        2016-11-29 22:38:26 UTC (rev 209091)
+++ trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp        2016-11-29 22:52:03 UTC (rev 209092)
</span><span class="lines">@@ -54,6 +54,7 @@
</span><span class="cx"> enum class Operations {
</span><span class="cx">     Encrypt,
</span><span class="cx">     Decrypt,
</span><ins>+    Sign,
</ins><span class="cx">     Digest,
</span><span class="cx">     GenerateKey,
</span><span class="cx">     ImportKey,
</span><span class="lines">@@ -117,6 +118,17 @@
</span><span class="cx">                 return nullptr;
</span><span class="cx">             }
</span><span class="cx">             break;
</span><ins>+        case Operations::Sign:
+            switch (*identifier) {
+            case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
+            case CryptoAlgorithmIdentifier::HMAC:
+                result = std::make_unique&lt;CryptoAlgorithmParameters&gt;(params);
+                break;
+            default:
+                setDOMException(&amp;state, NOT_SUPPORTED_ERR);
+                return nullptr;
+            }
+            break;
</ins><span class="cx">         case Operations::Digest:
</span><span class="cx">             switch (*identifier) {
</span><span class="cx">             case CryptoAlgorithmIdentifier::SHA_1:
</span><span class="lines">@@ -452,7 +464,7 @@
</span><span class="cx">         fulfillPromiseWithArrayBuffer(WTFMove(capturedPromise), cipherText.data(), cipherText.size());
</span><span class="cx">         return;
</span><span class="cx">     };
</span><del>-    auto exceptionCallback = [capturedPromise = promise.copyRef()](ExceptionCode ec) mutable {
</del><ins>+    auto exceptionCallback = [capturedPromise = WTFMove(promise)](ExceptionCode ec) mutable {
</ins><span class="cx">         rejectWithException(WTFMove(capturedPromise), ec);
</span><span class="cx">     };
</span><span class="cx"> 
</span><span class="lines">@@ -493,11 +505,11 @@
</span><span class="cx">     auto algorithm = createAlgorithm(state, key-&gt;algorithmIdentifier());
</span><span class="cx">     RETURN_IF_EXCEPTION(scope, void());
</span><span class="cx"> 
</span><del>-    auto callback = [capturedPromise = promise.copyRef()](const Vector&lt;uint8_t&gt;&amp; cipherText) mutable {
-        fulfillPromiseWithArrayBuffer(WTFMove(capturedPromise), cipherText.data(), cipherText.size());
</del><ins>+    auto callback = [capturedPromise = promise.copyRef()](const Vector&lt;uint8_t&gt;&amp; plainText) mutable {
+        fulfillPromiseWithArrayBuffer(WTFMove(capturedPromise), plainText.data(), plainText.size());
</ins><span class="cx">         return;
</span><span class="cx">     };
</span><del>-    auto exceptionCallback = [capturedPromise = promise.copyRef()](ExceptionCode ec) mutable {
</del><ins>+    auto exceptionCallback = [capturedPromise = WTFMove(promise)](ExceptionCode ec) mutable {
</ins><span class="cx">         rejectWithException(WTFMove(capturedPromise), ec);
</span><span class="cx">     };
</span><span class="cx"> 
</span><span class="lines">@@ -506,6 +518,51 @@
</span><span class="cx">     algorithm-&gt;decrypt(WTFMove(params), key.releaseNonNull(), WTFMove(data), WTFMove(callback), WTFMove(exceptionCallback), *scriptExecutionContextFromExecState(&amp;state), subtle-&gt;wrapped().workQueue());
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static void jsSubtleCryptoFunctionSignPromise(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::Sign);
+    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(CryptoKeyUsageSign)) {
+        promise-&gt;reject(INVALID_ACCESS_ERR, ASCIILiteral(&quot;CryptoKey doesn't support signing&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; signature) mutable {
+        fulfillPromiseWithArrayBuffer(WTFMove(capturedPromise), signature.data(), signature.size());
+        return;
+    };
+    auto exceptionCallback = [capturedPromise = WTFMove(promise)](ExceptionCode ec) mutable {
+        rejectWithException(WTFMove(capturedPromise), ec);
+    };
+
+    JSSubtleCrypto* subtle = jsDynamicDowncast&lt;JSSubtleCrypto*&gt;(state.thisValue());
+    ASSERT(subtle);
+    algorithm-&gt;sign(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,7 +602,7 @@
</span><span class="cx">             capturedPromise-&gt;resolve(keyPair);
</span><span class="cx">         }
</span><span class="cx">     };
</span><del>-    auto exceptionCallback = [capturedPromise =  promise.copyRef()](ExceptionCode ec) mutable {
</del><ins>+    auto exceptionCallback = [capturedPromise = WTFMove(promise)](ExceptionCode ec) mutable {
</ins><span class="cx">         rejectWithException(WTFMove(capturedPromise), ec);
</span><span class="cx">     };
</span><span class="cx"> 
</span><span class="lines">@@ -590,7 +647,7 @@
</span><span class="cx">         }
</span><span class="cx">         capturedPromise-&gt;resolve(key);
</span><span class="cx">     };
</span><del>-    auto exceptionCallback = [capturedPromise =  promise.copyRef()](ExceptionCode ec) mutable {
</del><ins>+    auto exceptionCallback = [capturedPromise = WTFMove(promise)](ExceptionCode ec) mutable {
</ins><span class="cx">         rejectWithException(WTFMove(capturedPromise), ec);
</span><span class="cx">     };
</span><span class="cx"> 
</span><span class="lines">@@ -657,7 +714,7 @@
</span><span class="cx">         }
</span><span class="cx">         ASSERT_NOT_REACHED();
</span><span class="cx">     };
</span><del>-    auto exceptionCallback = [capturedPromise =  promise.copyRef()](ExceptionCode ec) mutable {
</del><ins>+    auto exceptionCallback = [capturedPromise = WTFMove(promise)](ExceptionCode ec) mutable {
</ins><span class="cx">         rejectWithException(WTFMove(capturedPromise), ec);
</span><span class="cx">     };
</span><span class="cx"> 
</span><span class="lines">@@ -677,6 +734,11 @@
</span><span class="cx">     return callPromiseFunction&lt;jsSubtleCryptoFunctionDecryptPromise, PromiseExecutionScope::WindowOrWorker&gt;(state);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+JSValue JSSubtleCrypto::sign(ExecState&amp; state)
+{
+    return callPromiseFunction&lt;jsSubtleCryptoFunctionSignPromise, 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 (209091 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/CryptoAlgorithm.cpp        2016-11-29 22:38:26 UTC (rev 209091)
+++ trunk/Source/WebCore/crypto/CryptoAlgorithm.cpp        2016-11-29 22:52:03 UTC (rev 209092)
</span><span class="lines">@@ -42,6 +42,11 @@
</span><span class="cx">     exceptionCallback(NOT_SUPPORTED_ERR);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void CryptoAlgorithm::sign(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 CryptoAlgorithmParameters&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 (209091 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/CryptoAlgorithm.h        2016-11-29 22:38:26 UTC (rev 209091)
+++ trunk/Source/WebCore/crypto/CryptoAlgorithm.h        2016-11-29 22:52:03 UTC (rev 209092)
</span><span class="lines">@@ -66,6 +66,7 @@
</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><span class="cx">     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;);
</span><ins>+    virtual void sign(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 CryptoAlgorithmParameters&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 (209091 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/SubtleCrypto.idl        2016-11-29 22:38:26 UTC (rev 209091)
+++ trunk/Source/WebCore/crypto/SubtleCrypto.idl        2016-11-29 22:52:03 UTC (rev 209092)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> ] interface SubtleCrypto {
</span><span class="cx">     [Custom] Promise&lt;any&gt; encrypt(AlgorithmIdentifier algorithm, CryptoKey key, BufferSource data);
</span><span class="cx">     [Custom] Promise&lt;any&gt; decrypt(AlgorithmIdentifier algorithm, CryptoKey key, BufferSource data);
</span><ins>+    [Custom] Promise&lt;any&gt; sign(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="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmHMACcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp (209091 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp        2016-11-29 22:38:26 UTC (rev 209091)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp        2016-11-29 22:52:03 UTC (rev 209092)
</span><span class="lines">@@ -69,6 +69,11 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void CryptoAlgorithmHMAC::sign(Ref&lt;CryptoKey&gt;&amp;&amp; key, Vector&lt;uint8_t&gt;&amp;&amp; data, VectorCallback&amp;&amp; callback, ExceptionCallback&amp;&amp; exceptionCallback, ScriptExecutionContext&amp; context, WorkQueue&amp; workQueue)
+{
+    platformSign(WTFMove(key), WTFMove(data), WTFMove(callback), WTFMove(exceptionCallback), context, workQueue);
+}
+
</ins><span class="cx"> void CryptoAlgorithmHMAC::generateKey(const CryptoAlgorithmParameters&amp; parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&amp;&amp; callback, ExceptionCallback&amp;&amp; exceptionCallback, ScriptExecutionContext&amp;)
</span><span class="cx"> {
</span><span class="cx">     const auto&amp; hmacParameters = downcast&lt;CryptoAlgorithmHmacKeyParams&gt;(parameters);
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmHMACh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.h (209091 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.h        2016-11-29 22:38:26 UTC (rev 209091)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.h        2016-11-29 22:52:03 UTC (rev 209092)
</span><span class="lines">@@ -44,6 +44,7 @@
</span><span class="cx">     CryptoAlgorithmHMAC() = default;
</span><span class="cx">     CryptoAlgorithmIdentifier identifier() const final;
</span><span class="cx"> 
</span><ins>+    void sign(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 CryptoAlgorithmParameters&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">@@ -55,6 +56,7 @@
</span><span class="cx">     ExceptionOr&lt;void&gt; importKey(const CryptoAlgorithmParametersDeprecated&amp;, const CryptoKeyData&amp;, bool extractable, CryptoKeyUsageBitmap, KeyCallback&amp;&amp;, VoidCallback&amp;&amp; failureCallback) final;
</span><span class="cx"> 
</span><span class="cx">     bool keyAlgorithmMatches(const CryptoAlgorithmHmacParamsDeprecated&amp; algorithmParameters, const CryptoKey&amp;) const;
</span><ins>+    void platformSign(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; platformSign(const CryptoAlgorithmHmacParamsDeprecated&amp;, const CryptoKeyHMAC&amp;, const CryptoOperationData&amp;, VectorCallback&amp;&amp;, VoidCallback&amp;&amp; failureCallback);
</span><span class="cx">     ExceptionOr&lt;void&gt; platformVerify(const CryptoAlgorithmHmacParamsDeprecated&amp;, const CryptoKeyHMAC&amp;, const CryptoOperationData&amp; signature, const CryptoOperationData&amp;, BoolCallback&amp;&amp;, VoidCallback&amp;&amp; failureCallback);
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSASSA_PKCS1_v1_5cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp (209091 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp        2016-11-29 22:38:26 UTC (rev 209091)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp        2016-11-29 22:52:03 UTC (rev 209092)
</span><span class="lines">@@ -68,6 +68,15 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void CryptoAlgorithmRSASSA_PKCS1_v1_5::sign(Ref&lt;CryptoKey&gt;&amp;&amp; key, Vector&lt;uint8_t&gt;&amp;&amp; data, 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;
+    }
+    platformSign(WTFMove(key), WTFMove(data), WTFMove(callback), WTFMove(exceptionCallback), context, workQueue);
+}
+
</ins><span class="cx"> void CryptoAlgorithmRSASSA_PKCS1_v1_5::generateKey(const CryptoAlgorithmParameters&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">     const auto&amp; rsaParameters = downcast&lt;CryptoAlgorithmRsaHashedKeyGenParams&gt;(parameters);
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSASSA_PKCS1_v1_5h"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h (209091 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h        2016-11-29 22:38:26 UTC (rev 209091)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h        2016-11-29 22:52:03 UTC (rev 209092)
</span><span class="lines">@@ -44,6 +44,7 @@
</span><span class="cx">     CryptoAlgorithmRSASSA_PKCS1_v1_5() = default;
</span><span class="cx">     CryptoAlgorithmIdentifier identifier() const final;
</span><span class="cx"> 
</span><ins>+    void sign(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 CryptoAlgorithmParameters&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">@@ -54,6 +55,7 @@
</span><span class="cx">     ExceptionOr&lt;void&gt; importKey(const CryptoAlgorithmParametersDeprecated&amp;, const CryptoKeyData&amp;, bool extractable, CryptoKeyUsageBitmap, KeyCallback&amp;&amp;, VoidCallback&amp;&amp; failureCallback) final;
</span><span class="cx"> 
</span><span class="cx">     bool keyAlgorithmMatches(const CryptoAlgorithmRsaSsaParamsDeprecated&amp; algorithmParameters, const CryptoKey&amp;) const;
</span><ins>+    void platformSign(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; platformSign(const CryptoAlgorithmRsaSsaParamsDeprecated&amp;, const CryptoKeyRSA&amp;, const CryptoOperationData&amp;, VectorCallback&amp;&amp;, VoidCallback&amp;&amp; failureCallback);
</span><span class="cx">     ExceptionOr&lt;void&gt; platformVerify(const CryptoAlgorithmRsaSsaParamsDeprecated&amp;, const CryptoKeyRSA&amp;, const CryptoOperationData&amp; signature, const CryptoOperationData&amp;, BoolCallback&amp;&amp;, VoidCallback&amp;&amp; failureCallback);
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCorecryptogcryptCryptoAlgorithmHMACGCryptcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp (209091 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp        2016-11-29 22:38:26 UTC (rev 209091)
+++ trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp        2016-11-29 22:52:03 UTC (rev 209092)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> #include &quot;CryptoAlgorithmHmacParamsDeprecated.h&quot;
</span><span class="cx"> #include &quot;CryptoKeyHMAC.h&quot;
</span><span class="cx"> #include &quot;ExceptionCode.h&quot;
</span><ins>+#include &quot;NotImplemented.h&quot;
</ins><span class="cx"> #include &lt;gcrypt.h&gt;
</span><span class="cx"> #include &lt;wtf/CryptographicUtilities.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -96,6 +97,11 @@
</span><span class="cx">     return WTFMove(signature);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void CryptoAlgorithmHMAC::platformSign(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; CryptoAlgorithmHMAC::platformSign(const CryptoAlgorithmHmacParamsDeprecated&amp; parameters, const CryptoKeyHMAC&amp; key, const CryptoOperationData&amp; data, VectorCallback&amp;&amp; callback, VoidCallback&amp;&amp; failureCallback)
</span><span class="cx"> {
</span><span class="cx">     int algorithm = getGCryptDigestAlgorithm(parameters.hash);
</span></span></pre></div>
<a id="trunkSourceWebCorecryptognutlsCryptoAlgorithmHMACGnuTLScpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/gnutls/CryptoAlgorithmHMACGnuTLS.cpp (209091 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/gnutls/CryptoAlgorithmHMACGnuTLS.cpp        2016-11-29 22:38:26 UTC (rev 209091)
+++ trunk/Source/WebCore/crypto/gnutls/CryptoAlgorithmHMACGnuTLS.cpp        2016-11-29 22:52:03 UTC (rev 209092)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> #include &quot;CryptoAlgorithmHmacParamsDeprecated.h&quot;
</span><span class="cx"> #include &quot;CryptoKeyHMAC.h&quot;
</span><span class="cx"> #include &quot;ExceptionCode.h&quot;
</span><ins>+#include &quot;NotImplemented.h&quot;
</ins><span class="cx"> #include &lt;gnutls/gnutls.h&gt;
</span><span class="cx"> #include &lt;gnutls/crypto.h&gt;
</span><span class="cx"> #include &lt;wtf/CryptographicUtilities.h&gt;
</span><span class="lines">@@ -68,6 +69,11 @@
</span><span class="cx">     return result;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void CryptoAlgorithmHMAC::platformSign(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; CryptoAlgorithmHMAC::platformSign(const CryptoAlgorithmHmacParamsDeprecated&amp; parameters, const CryptoKeyHMAC&amp; key, const CryptoOperationData&amp; data, VectorCallback&amp;&amp; callback, VoidCallback&amp;&amp;)
</span><span class="cx"> {
</span><span class="cx">     gnutls_mac_algorithm_t algorithm = getGnutlsDigestAlgorithm(parameters.hash);
</span></span></pre></div>
<a id="trunkSourceWebCorecryptognutlsCryptoAlgorithmRSASSA_PKCS1_v1_5GnuTLScpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/gnutls/CryptoAlgorithmRSASSA_PKCS1_v1_5GnuTLS.cpp (209091 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/gnutls/CryptoAlgorithmRSASSA_PKCS1_v1_5GnuTLS.cpp        2016-11-29 22:38:26 UTC (rev 209091)
+++ trunk/Source/WebCore/crypto/gnutls/CryptoAlgorithmRSASSA_PKCS1_v1_5GnuTLS.cpp        2016-11-29 22:52:03 UTC (rev 209092)
</span><span class="lines">@@ -35,6 +35,11 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+void CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign(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; CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign(const CryptoAlgorithmRsaSsaParamsDeprecated&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="trunkSourceWebCorecryptomacCryptoAlgorithmHMACMaccpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/mac/CryptoAlgorithmHMACMac.cpp (209091 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/mac/CryptoAlgorithmHMACMac.cpp        2016-11-29 22:38:26 UTC (rev 209091)
+++ trunk/Source/WebCore/crypto/mac/CryptoAlgorithmHMACMac.cpp        2016-11-29 22:52:03 UTC (rev 209092)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> #include &quot;CryptoAlgorithmHmacParamsDeprecated.h&quot;
</span><span class="cx"> #include &quot;CryptoKeyHMAC.h&quot;
</span><span class="cx"> #include &quot;ExceptionCode.h&quot;
</span><ins>+#include &quot;ScriptExecutionContext.h&quot;
</ins><span class="cx"> #include &lt;CommonCrypto/CommonHMAC.h&gt;
</span><span class="cx"> #include &lt;wtf/CryptographicUtilities.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -54,7 +55,9 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static Vector&lt;uint8_t&gt; calculateSignature(CCHmacAlgorithm algorithm, const Vector&lt;uint8_t&gt;&amp; key, const CryptoOperationData&amp; data)
</del><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 Vector&lt;uint8_t&gt; calculateSignature(CCHmacAlgorithm algorithm, const Vector&lt;uint8_t&gt;&amp; key, const uint8_t* data, size_t dataLength)
</ins><span class="cx"> {
</span><span class="cx">     size_t digestLength;
</span><span class="cx">     switch (algorithm) {
</span><span class="lines">@@ -79,17 +82,40 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     Vector&lt;uint8_t&gt; result(digestLength);
</span><del>-    const void* keyData = key.data() ? key.data() : reinterpret_cast&lt;const uint8_t*&gt;(&quot;&quot;); // &lt;rdar://problem/15467425&gt; HMAC crashes when key pointer is null.
-    CCHmac(algorithm, keyData, key.size(), data.first, data.second, result.data());
</del><ins>+    CCHmac(algorithm, key.data(), key.size(), data, dataLength, result.data());
</ins><span class="cx">     return result;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void CryptoAlgorithmHMAC::platformSign(Ref&lt;CryptoKey&gt;&amp;&amp; key, Vector&lt;uint8_t&gt;&amp;&amp; data, VectorCallback&amp;&amp; callback, ExceptionCallback&amp;&amp; exceptionCallback, ScriptExecutionContext&amp; context, WorkQueue&amp; workQueue)
+{
+    context.ref();
+    workQueue.dispatch([key = WTFMove(key), data = WTFMove(data), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), &amp;context]() mutable {
+        auto&amp; hmacKey = downcast&lt;CryptoKeyHMAC&gt;(key.get());
+        auto algorithm = commonCryptoHMACAlgorithm(hmacKey.hashAlgorithmIdentifier());
+        if (!algorithm) {
+            // We should only dereference callbacks after being back to the Document/Worker threads.
+            context.postTask([exceptionCallback = WTFMove(exceptionCallback), callback = WTFMove(callback)](ScriptExecutionContext&amp; context) {
+                exceptionCallback(OperationError);
+                context.deref();
+            });
+            return;
+        }
+        auto result = calculateSignature(*algorithm, hmacKey.key(), data.data(), data.size());
+        // We should only dereference callbacks after being back to the Document/Worker threads.
+        context.postTask([callback = WTFMove(callback), result = WTFMove(result), exceptionCallback = WTFMove(exceptionCallback)](ScriptExecutionContext&amp; context) {
+            callback(result);
+            context.deref();
+        });
+    });
+
+}
+
</ins><span class="cx"> ExceptionOr&lt;void&gt; CryptoAlgorithmHMAC::platformSign(const CryptoAlgorithmHmacParamsDeprecated&amp; parameters, const CryptoKeyHMAC&amp; key, const CryptoOperationData&amp; data, VectorCallback&amp;&amp; callback, VoidCallback&amp;&amp;)
</span><span class="cx"> {
</span><span class="cx">     auto algorithm = commonCryptoHMACAlgorithm(parameters.hash);
</span><span class="cx">     if (!algorithm)
</span><span class="cx">         return Exception { NOT_SUPPORTED_ERR };
</span><del>-    callback(calculateSignature(*algorithm, key.key(), data));
</del><ins>+    callback(calculateSignature(*algorithm, key.key(), data.first, data.second));
</ins><span class="cx">     return { };
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -99,7 +125,7 @@
</span><span class="cx">     if (!algorithm)
</span><span class="cx">         return Exception { NOT_SUPPORTED_ERR };
</span><span class="cx"> 
</span><del>-    auto signature = calculateSignature(*algorithm, key.key(), data);
</del><ins>+    auto signature = calculateSignature(*algorithm, key.key(), data.first, data.second);
</ins><span class="cx"> 
</span><span class="cx">     // Using a constant time comparison to prevent timing attacks.
</span><span class="cx">     bool result = signature.size() == expectedSignature.second &amp;&amp; !constantTimeMemcmp(signature.data(), expectedSignature.first, signature.size());
</span></span></pre></div>
<a id="trunkSourceWebCorecryptomacCryptoAlgorithmRSASSA_PKCS1_v1_5Maccpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp (209091 => 209092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp        2016-11-29 22:38:26 UTC (rev 209091)
+++ trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp        2016-11-29 22:52:03 UTC (rev 209092)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> #include &quot;CryptoDigest.h&quot;
</span><span class="cx"> #include &quot;CryptoKeyRSA.h&quot;
</span><span class="cx"> #include &quot;ExceptionCode.h&quot;
</span><ins>+#include &quot;ScriptExecutionContext.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -54,35 +55,63 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-ExceptionOr&lt;void&gt; CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign(const CryptoAlgorithmRsaSsaParamsDeprecated&amp; parameters, const CryptoKeyRSA&amp; key, const CryptoOperationData&amp; data, VectorCallback&amp;&amp; callback, VoidCallback&amp;&amp; failureCallback)
</del><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; signRSASSA_PKCS1_v1_5(CryptoAlgorithmIdentifier hash, const PlatformRSAKey key, size_t keyLength, const uint8_t* data, size_t dataLength)
</ins><span class="cx"> {
</span><span class="cx">     CCDigestAlgorithm digestAlgorithm;
</span><del>-    if (!getCommonCryptoDigestAlgorithm(parameters.hash, digestAlgorithm))
-        return Exception { NOT_SUPPORTED_ERR };
</del><ins>+    if (!getCommonCryptoDigestAlgorithm(hash, digestAlgorithm))
+        return Exception { OperationError };
</ins><span class="cx"> 
</span><del>-    auto cryptoDigestAlgorithm = WebCore::cryptoDigestAlgorithm(parameters.hash);
</del><ins>+    auto cryptoDigestAlgorithm = WebCore::cryptoDigestAlgorithm(hash);
</ins><span class="cx">     if (!cryptoDigestAlgorithm)
</span><del>-        return Exception { NOT_SUPPORTED_ERR };
-
</del><ins>+        return Exception { OperationError };
</ins><span class="cx">     auto digest = CryptoDigest::create(*cryptoDigestAlgorithm);
</span><span class="cx">     if (!digest)
</span><del>-        return Exception { NOT_SUPPORTED_ERR };
-
-    digest-&gt;addBytes(data.first, data.second);
-
</del><ins>+        return Exception { OperationError };
+    digest-&gt;addBytes(data, dataLength);
</ins><span class="cx">     auto digestData = digest-&gt;computeHash();
</span><span class="cx"> 
</span><del>-    Vector&lt;uint8_t&gt; signature(512);
</del><ins>+    Vector&lt;uint8_t&gt; signature(keyLength / 8); // Per https://tools.ietf.org/html/rfc3447#section-8.2.1
</ins><span class="cx">     size_t signatureSize = signature.size();
</span><span class="cx"> 
</span><del>-    CCCryptorStatus status = CCRSACryptorSign(key.platformKey(), ccPKCS1Padding, digestData.data(), digestData.size(), digestAlgorithm, 0, signature.data(), &amp;signatureSize);
-    if (status) {
</del><ins>+    CCCryptorStatus status = CCRSACryptorSign(key, ccPKCS1Padding, digestData.data(), digestData.size(), digestAlgorithm, 0, signature.data(), &amp;signatureSize);
+    if (status)
+        return Exception { OperationError };
+
+    return WTFMove(signature);
+}
+
+void CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign(Ref&lt;CryptoKey&gt;&amp;&amp; key, Vector&lt;uint8_t&gt;&amp;&amp; data, VectorCallback&amp;&amp; callback, ExceptionCallback&amp;&amp; exceptionCallback, ScriptExecutionContext&amp; context, WorkQueue&amp; workQueue)
+{
+    context.ref();
+    workQueue.dispatch([key = WTFMove(key), data = WTFMove(data), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), &amp;context]() mutable {
+        auto&amp; rsaKey = downcast&lt;CryptoKeyRSA&gt;(key.get());
+        auto result = signRSASSA_PKCS1_v1_5(rsaKey.hashAlgorithmIdentifier(), rsaKey.platformKey(), rsaKey.keySizeInBits(), data.data(), data.size());
+        if (result.hasException()) {
+            // We should only dereference callbacks after being back to the Document/Worker threads.
+            context.postTask([exceptionCallback = WTFMove(exceptionCallback), ec = result.releaseException().code(), callback = WTFMove(callback)](ScriptExecutionContext&amp; context) {
+                exceptionCallback(ec);
+                context.deref();
+            });
+            return;
+        }
+        // We should only dereference callbacks after being back to the Document/Worker threads.
+        context.postTask([callback = WTFMove(callback), result = result.releaseReturnValue(), exceptionCallback = WTFMove(exceptionCallback)](ScriptExecutionContext&amp; context) {
+            callback(result);
+            context.deref();
+        });
+    });
+}
+
+ExceptionOr&lt;void&gt; CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign(const CryptoAlgorithmRsaSsaParamsDeprecated&amp; parameters, const CryptoKeyRSA&amp; key, const CryptoOperationData&amp; data, VectorCallback&amp;&amp; callback, VoidCallback&amp;&amp; failureCallback)
+{
+    auto result = signRSASSA_PKCS1_v1_5(parameters.hash, 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>-
-    signature.resize(signatureSize);
-    callback(signature);
</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>