<!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>[208801] 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/208801">208801</a></dd>
<dt>Author</dt> <dd>jiewen_tan@apple.com</dd>
<dt>Date</dt> <dd>2016-11-16 12:18:45 -0800 (Wed, 16 Nov 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add more tests for SubtleCrypto::importKey and SubtleCrypto::exportKey
https://bugs.webkit.org/show_bug.cgi?id=164815
&lt;rdar://problem/29281660&gt;

Reviewed by Brent Fulgham.

Source/WebCore:

Tests: crypto/subtle/aes-import-jwk-key-export-jwk-key.html
       crypto/subtle/aes-import-jwk-key-export-raw-key.html
       crypto/subtle/aes-import-raw-key-export-jwk-key.html
       crypto/subtle/aes-import-raw-key-export-raw-key.html
       crypto/subtle/hmac-import-jwk-key-export-jwk-key.html
       crypto/subtle/hmac-import-jwk-key-export-raw-key.html
       crypto/subtle/hmac-import-raw-key-export-jwk-key.html
       crypto/subtle/hmac-import-raw-key-export-raw-key.html
       crypto/subtle/rsa-import-jwk-key-export-jwk-key-private.html
       crypto/subtle/rsa-import-jwk-key-export-jwk-key-public.html

* crypto/mac/CryptoKeyRSAMac.cpp:
(WebCore::CryptoKeyRSA::create):
Add a comment.

LayoutTests:

* crypto/subtle/aes-import-jwk-key-export-jwk-key.html: Added.
* crypto/subtle/aes-import-jwk-key-export-raw-key.html: Added.
* crypto/subtle/aes-import-raw-key-export-jwk-key.html: Added.
* crypto/subtle/aes-import-raw-key-export-raw-key.html: Added.
* crypto/subtle/hmac-import-jwk-key-export-jwk-key.html: Added.
* crypto/subtle/hmac-import-jwk-key-export-raw-key.html: Added.
* crypto/subtle/hmac-import-raw-key-export-jwk-key.html: Added.
* crypto/subtle/hmac-import-raw-key-export-raw-key.html: Added.
* crypto/subtle/rsa-import-jwk-key-export-jwk-key-private.html: Added.
* crypto/subtle/rsa-import-jwk-key-export-jwk-key-public.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorecryptomacCryptoKeyRSAMaccpp">trunk/Source/WebCore/crypto/mac/CryptoKeyRSAMac.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestscryptosubtleaesimportjwkkeyexportjwkkeyexpectedtxt">trunk/LayoutTests/crypto/subtle/aes-import-jwk-key-export-jwk-key-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleaesimportjwkkeyexportjwkkeyhtml">trunk/LayoutTests/crypto/subtle/aes-import-jwk-key-export-jwk-key.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleaesimportjwkkeyexportrawkeyexpectedtxt">trunk/LayoutTests/crypto/subtle/aes-import-jwk-key-export-raw-key-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleaesimportjwkkeyexportrawkeyhtml">trunk/LayoutTests/crypto/subtle/aes-import-jwk-key-export-raw-key.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleaesimportrawkeyexportjwkkeyexpectedtxt">trunk/LayoutTests/crypto/subtle/aes-import-raw-key-export-jwk-key-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleaesimportrawkeyexportjwkkeyhtml">trunk/LayoutTests/crypto/subtle/aes-import-raw-key-export-jwk-key.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleaesimportrawkeyexportrawkeyexpectedtxt">trunk/LayoutTests/crypto/subtle/aes-import-raw-key-export-raw-key-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleaesimportrawkeyexportrawkeyhtml">trunk/LayoutTests/crypto/subtle/aes-import-raw-key-export-raw-key.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacimportjwkkeyexportjwkkeyexpectedtxt">trunk/LayoutTests/crypto/subtle/hmac-import-jwk-key-export-jwk-key-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacimportjwkkeyexportjwkkeyhtml">trunk/LayoutTests/crypto/subtle/hmac-import-jwk-key-export-jwk-key.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacimportjwkkeyexportrawkeyexpectedtxt">trunk/LayoutTests/crypto/subtle/hmac-import-jwk-key-export-raw-key-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacimportjwkkeyexportrawkeyhtml">trunk/LayoutTests/crypto/subtle/hmac-import-jwk-key-export-raw-key.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacimportrawkeyexportjwkkeyexpectedtxt">trunk/LayoutTests/crypto/subtle/hmac-import-raw-key-export-jwk-key-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacimportrawkeyexportjwkkeyhtml">trunk/LayoutTests/crypto/subtle/hmac-import-raw-key-export-jwk-key.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacimportrawkeyexportrawkeyexpectedtxt">trunk/LayoutTests/crypto/subtle/hmac-import-raw-key-export-raw-key-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacimportrawkeyexportrawkeyhtml">trunk/LayoutTests/crypto/subtle/hmac-import-raw-key-export-raw-key.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaimportjwkkeyexportjwkkeyprivateexpectedtxt">trunk/LayoutTests/crypto/subtle/rsa-import-jwk-key-export-jwk-key-private-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaimportjwkkeyexportjwkkeyprivatehtml">trunk/LayoutTests/crypto/subtle/rsa-import-jwk-key-export-jwk-key-private.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaimportjwkkeyexportjwkkeypublicexpectedtxt">trunk/LayoutTests/crypto/subtle/rsa-import-jwk-key-export-jwk-key-public-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaimportjwkkeyexportjwkkeypublichtml">trunk/LayoutTests/crypto/subtle/rsa-import-jwk-key-export-jwk-key-public.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (208800 => 208801)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-11-16 20:09:16 UTC (rev 208800)
+++ trunk/LayoutTests/ChangeLog        2016-11-16 20:18:45 UTC (rev 208801)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2016-11-16  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
+
+        Add more tests for SubtleCrypto::importKey and SubtleCrypto::exportKey
+        https://bugs.webkit.org/show_bug.cgi?id=164815
+        &lt;rdar://problem/29281660&gt;
+
+        Reviewed by Brent Fulgham.
+
+        * crypto/subtle/aes-import-jwk-key-export-jwk-key.html: Added.
+        * crypto/subtle/aes-import-jwk-key-export-raw-key.html: Added.
+        * crypto/subtle/aes-import-raw-key-export-jwk-key.html: Added.
+        * crypto/subtle/aes-import-raw-key-export-raw-key.html: Added.
+        * crypto/subtle/hmac-import-jwk-key-export-jwk-key.html: Added.
+        * crypto/subtle/hmac-import-jwk-key-export-raw-key.html: Added.
+        * crypto/subtle/hmac-import-raw-key-export-jwk-key.html: Added.
+        * crypto/subtle/hmac-import-raw-key-export-raw-key.html: Added.
+        * crypto/subtle/rsa-import-jwk-key-export-jwk-key-private.html: Added.
+        * crypto/subtle/rsa-import-jwk-key-export-jwk-key-public.html: Added.
+
</ins><span class="cx"> 2016-11-16  Ryan Haddad  &lt;ryanhaddad@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Updating TestExpectations for two http/tests/security/module-crossorigin tests.
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtleaesimportjwkkeyexportjwkkeyexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/aes-import-jwk-key-export-jwk-key-expected.txt (0 => 208801)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-import-jwk-key-export-jwk-key-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/aes-import-jwk-key-export-jwk-key-expected.txt        2016-11-16 20:18:45 UTC (rev 208801)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+Test importing a JWK AES-CBC key with legnth 128 and then export it in JWK format
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Importing a key...
+Exporting a key...
+PASS exportedJwkKey.kty is jwkKey.kty
+PASS exportedJwkKey.k is jwkKey.k
+PASS exportedJwkKey.alg is jwkKey.alg
+PASS exportedJwkKey.key_ops is jwkKey.key_ops
+PASS exportedJwkKey.ext is jwkKey.ext
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleaesimportjwkkeyexportjwkkeyhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/aes-import-jwk-key-export-jwk-key.html (0 => 208801)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-import-jwk-key-export-jwk-key.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/aes-import-jwk-key-export-jwk-key.html        2016-11-16 20:18:45 UTC (rev 208801)
</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 importing a JWK AES-CBC key with legnth 128 and then export it in JWK format&quot;);
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: &quot;oct&quot;,
+    k: &quot;KbXExKw7lIKkvDHi4ud3lg&quot;,
+    alg: &quot;A128CBC&quot;,
+    key_ops: [&quot;decrypt&quot;, &quot;encrypt&quot;, &quot;unwrapKey&quot;, &quot;wrapKey&quot;],
+    ext: true,
+};
+var extractable = true;
+
+debug(&quot;Importing a key...&quot;);
+crypto.subtle.importKey(&quot;jwk&quot;, jwkKey, &quot;aes-cbc&quot;, extractable, [&quot;encrypt&quot;, &quot;decrypt&quot;, &quot;wrapKey&quot;, &quot;unwrapKey&quot;]).then(function(cryptoKey) {
+    debug(&quot;Exporting a key...&quot;);
+    return crypto.subtle.exportKey(&quot;jwk&quot;, cryptoKey);
+}).then(function(result) {
+    exportedJwkKey = result;
+
+    shouldBe(&quot;exportedJwkKey.kty&quot;, &quot;jwkKey.kty&quot;);
+    shouldBe(&quot;exportedJwkKey.k&quot;, &quot;jwkKey.k&quot;);
+    shouldBe(&quot;exportedJwkKey.alg&quot;, &quot;jwkKey.alg&quot;);
+    shouldBe(&quot;exportedJwkKey.key_ops&quot;, &quot;jwkKey.key_ops&quot;);
+    shouldBe(&quot;exportedJwkKey.ext&quot;, &quot;jwkKey.ext&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="trunkLayoutTestscryptosubtleaesimportjwkkeyexportrawkeyexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/aes-import-jwk-key-export-raw-key-expected.txt (0 => 208801)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-import-jwk-key-export-raw-key-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/aes-import-jwk-key-export-raw-key-expected.txt        2016-11-16 20:18:45 UTC (rev 208801)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+Test importing a JWK AES-CBC key with legnth 128 and then export it in raw format
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Importing a key...
+Exporting a key...
+PASS Base64URL.stringify(exportedRawKey) is jwkKey.k
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleaesimportjwkkeyexportrawkeyhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/aes-import-jwk-key-export-raw-key.html (0 => 208801)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-import-jwk-key-export-raw-key.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/aes-import-jwk-key-export-raw-key.html        2016-11-16 20:18:45 UTC (rev 208801)
</span><span class="lines">@@ -0,0 +1,41 @@
</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 importing a JWK AES-CBC key with legnth 128 and then export it in raw format&quot;);
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: &quot;oct&quot;,
+    k: &quot;KbXExKw7lIKkvDHi4ud3lg&quot;,
+    alg: &quot;A128CBC&quot;,
+    key_ops: [&quot;decrypt&quot;, &quot;encrypt&quot;, &quot;unwrapKey&quot;, &quot;wrapKey&quot;],
+    ext: true,
+};
+var extractable = true;
+
+debug(&quot;Importing a key...&quot;);
+crypto.subtle.importKey(&quot;jwk&quot;, jwkKey, &quot;aes-cbc&quot;, extractable, [&quot;encrypt&quot;, &quot;decrypt&quot;, &quot;wrapKey&quot;, &quot;unwrapKey&quot;]).then(function(cryptoKey) {
+    debug(&quot;Exporting a key...&quot;);
+    return crypto.subtle.exportKey(&quot;raw&quot;, cryptoKey);
+}).then(function(result) {
+    exportedRawKey = new Uint8Array(result);
+
+    shouldBe(&quot;Base64URL.stringify(exportedRawKey)&quot;, &quot;jwkKey.k&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="trunkLayoutTestscryptosubtleaesimportrawkeyexportjwkkeyexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/aes-import-raw-key-export-jwk-key-expected.txt (0 => 208801)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-import-raw-key-export-jwk-key-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/aes-import-raw-key-export-jwk-key-expected.txt        2016-11-16 20:18:45 UTC (rev 208801)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+Test importing a raw AES-CBC key with legnth 128 and then export it in JWK format
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Importing a key...
+Exporting a key...
+PASS Base64URL.parse(exportedJwkKey.k) is rawKey
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleaesimportrawkeyexportjwkkeyhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/aes-import-raw-key-export-jwk-key.html (0 => 208801)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-import-raw-key-export-jwk-key.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/aes-import-raw-key-export-jwk-key.html        2016-11-16 20:18:45 UTC (rev 208801)
</span><span class="lines">@@ -0,0 +1,35 @@
</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 importing a raw AES-CBC key with legnth 128 and then export it in JWK format&quot;);
+
+jsTestIsAsync = true;
+
+var rawKey = hexStringToUint8Array(&quot;909152300357f94c2f64321c2d395370&quot;);
+var extractable = true;
+
+debug(&quot;Importing a key...&quot;);
+crypto.subtle.importKey(&quot;raw&quot;, rawKey, &quot;aes-cbc&quot;, extractable, [&quot;encrypt&quot;, &quot;decrypt&quot;, &quot;wrapKey&quot;, &quot;unwrapKey&quot;]).then(function(cryptoKey) {
+    debug(&quot;Exporting a key...&quot;);
+    return crypto.subtle.exportKey(&quot;jwk&quot;, cryptoKey);
+}).then(function(result) {
+    exportedJwkKey = result;
+
+    shouldBe(&quot;Base64URL.parse(exportedJwkKey.k)&quot;, &quot;rawKey&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 class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtleaesimportrawkeyexportrawkeyexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/aes-import-raw-key-export-raw-key-expected.txt (0 => 208801)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-import-raw-key-export-raw-key-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/aes-import-raw-key-export-raw-key-expected.txt        2016-11-16 20:18:45 UTC (rev 208801)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+Test importing a raw AES-CBC key with legnth 128 and then export it in raw format
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Importing a key...
+Exporting a key...
+PASS exportedRawKey is rawKey
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleaesimportrawkeyexportrawkeyhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/aes-import-raw-key-export-raw-key.html (0 => 208801)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-import-raw-key-export-raw-key.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/aes-import-raw-key-export-raw-key.html        2016-11-16 20:18:45 UTC (rev 208801)
</span><span class="lines">@@ -0,0 +1,35 @@
</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 importing a raw AES-CBC key with legnth 128 and then export it in raw format&quot;);
+
+jsTestIsAsync = true;
+
+var rawKey = hexStringToUint8Array(&quot;909152300357f94c2f64321c2d395370&quot;);
+var extractable = true;
+
+debug(&quot;Importing a key...&quot;);
+crypto.subtle.importKey(&quot;raw&quot;, rawKey, &quot;aes-cbc&quot;, extractable, [&quot;encrypt&quot;, &quot;decrypt&quot;, &quot;wrapKey&quot;, &quot;unwrapKey&quot;]).then(function(cryptoKey) {
+    debug(&quot;Exporting a key...&quot;);
+    return crypto.subtle.exportKey(&quot;raw&quot;, cryptoKey);
+}).then(function(result) {
+    exportedRawKey = new Uint8Array(result);
+
+    shouldBe(&quot;exportedRawKey&quot;, &quot;rawKey&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 class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtlehmacimportjwkkeyexportjwkkeyexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-import-jwk-key-export-jwk-key-expected.txt (0 => 208801)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-import-jwk-key-export-jwk-key-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-import-jwk-key-export-jwk-key-expected.txt        2016-11-16 20:18:45 UTC (rev 208801)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+Test importing a JWK HMAC key with SHA-1 and then export it in JWK format
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Importing a key...
+Exporting a key...
+PASS exportedJwkKey.kty is jwkKey.kty
+PASS exportedJwkKey.k is jwkKey.k
+PASS exportedJwkKey.alg is jwkKey.alg
+PASS exportedJwkKey.key_ops is jwkKey.key_ops
+PASS exportedJwkKey.ext is jwkKey.ext
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlehmacimportjwkkeyexportjwkkeyhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-import-jwk-key-export-jwk-key.html (0 => 208801)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-import-jwk-key-export-jwk-key.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-import-jwk-key-export-jwk-key.html        2016-11-16 20:18:45 UTC (rev 208801)
</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 importing a JWK HMAC key with SHA-1 and then export it in JWK format&quot;);
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: &quot;oct&quot;,
+    k: &quot;vgJ5AXWT3Fm2w_zZCRF4UVwo53rIhwqLm6b9Tq4m1c53dr94eqPlxt99yb9RCjCFDa2C56K448xe4V964xFucg&quot;,
+    alg: &quot;HS1&quot;,
+    key_ops: [&quot;sign&quot;, &quot;verify&quot;],
+    ext: true,
+};
+var extractable = true;
+
+debug(&quot;Importing a key...&quot;);
+crypto.subtle.importKey(&quot;jwk&quot;, jwkKey, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]).then(function(cryptoKey) {
+    debug(&quot;Exporting a key...&quot;);
+    return crypto.subtle.exportKey(&quot;jwk&quot;, cryptoKey);
+}).then(function(result) {
+    exportedJwkKey = result;
+
+    shouldBe(&quot;exportedJwkKey.kty&quot;, &quot;jwkKey.kty&quot;);
+    shouldBe(&quot;exportedJwkKey.k&quot;, &quot;jwkKey.k&quot;);
+    shouldBe(&quot;exportedJwkKey.alg&quot;, &quot;jwkKey.alg&quot;);
+    shouldBe(&quot;exportedJwkKey.key_ops&quot;, &quot;jwkKey.key_ops&quot;);
+    shouldBe(&quot;exportedJwkKey.ext&quot;, &quot;jwkKey.ext&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="trunkLayoutTestscryptosubtlehmacimportjwkkeyexportrawkeyexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-import-jwk-key-export-raw-key-expected.txt (0 => 208801)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-import-jwk-key-export-raw-key-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-import-jwk-key-export-raw-key-expected.txt        2016-11-16 20:18:45 UTC (rev 208801)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+Test importing a JWK HMAC key with SHA-1 and then export it in raw format
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Importing a key...
+Exporting a key...
+PASS Base64URL.stringify(exportedRawKey) is jwkKey.k
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlehmacimportjwkkeyexportrawkeyhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-import-jwk-key-export-raw-key.html (0 => 208801)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-import-jwk-key-export-raw-key.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-import-jwk-key-export-raw-key.html        2016-11-16 20:18:45 UTC (rev 208801)
</span><span class="lines">@@ -0,0 +1,41 @@
</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 importing a JWK HMAC key with SHA-1 and then export it in raw format&quot;);
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: &quot;oct&quot;,
+    k: &quot;vgJ5AXWT3Fm2w_zZCRF4UVwo53rIhwqLm6b9Tq4m1c53dr94eqPlxt99yb9RCjCFDa2C56K448xe4V964xFucg&quot;,
+    alg: &quot;HS1&quot;,
+    key_ops: [&quot;sign&quot;, &quot;verify&quot;],
+    ext: true,
+};
+var extractable = true;
+
+debug(&quot;Importing a key...&quot;);
+crypto.subtle.importKey(&quot;jwk&quot;, jwkKey, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]).then(function(cryptoKey) {
+    debug(&quot;Exporting a key...&quot;);
+    return crypto.subtle.exportKey(&quot;raw&quot;, cryptoKey);
+}).then(function(result) {
+    exportedRawKey = new Uint8Array(result);
+
+    shouldBe(&quot;Base64URL.stringify(exportedRawKey)&quot;, &quot;jwkKey.k&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="trunkLayoutTestscryptosubtlehmacimportrawkeyexportjwkkeyexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-import-raw-key-export-jwk-key-expected.txt (0 => 208801)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-import-raw-key-export-jwk-key-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-import-raw-key-export-jwk-key-expected.txt        2016-11-16 20:18:45 UTC (rev 208801)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+Test importing a raw HMAC key with SHA-1 and then export it in JWK format
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Importing a key...
+Exporting a key...
+PASS Base64URL.parse(exportedJwkKey.k) is rawKey
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlehmacimportrawkeyexportjwkkeyhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-import-raw-key-export-jwk-key.html (0 => 208801)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-import-raw-key-export-jwk-key.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-import-raw-key-export-jwk-key.html        2016-11-16 20:18:45 UTC (rev 208801)
</span><span class="lines">@@ -0,0 +1,35 @@
</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 importing a raw HMAC key with SHA-1 and then export it in JWK format&quot;);
+
+jsTestIsAsync = true;
+
+var rawKey = hexStringToUint8Array(&quot;192ff1e96a1399322db620760a738793ab6dfaf26bd2b3889bd81fc9d82ea25d11bb1b4763c0a9259512298e162dab2e6f505c9fc376fda1179a2a4055dd67f6&quot;);
+var extractable = true;
+
+debug(&quot;Importing a key...&quot;);
+crypto.subtle.importKey(&quot;raw&quot;, rawKey, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]).then(function(cryptoKey) {
+    debug(&quot;Exporting a key...&quot;);
+    return crypto.subtle.exportKey(&quot;jwk&quot;, cryptoKey);
+}).then(function(result) {
+    exportedJwkKey = result;
+
+    shouldBe(&quot;Base64URL.parse(exportedJwkKey.k)&quot;, &quot;rawKey&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 class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtlehmacimportrawkeyexportrawkeyexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-import-raw-key-export-raw-key-expected.txt (0 => 208801)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-import-raw-key-export-raw-key-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-import-raw-key-export-raw-key-expected.txt        2016-11-16 20:18:45 UTC (rev 208801)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+Test importing a raw HMAC key with SHA-1 and then export it in raw format
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Importing a key...
+Exporting a key...
+PASS exportedRawKey is rawKey
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlehmacimportrawkeyexportrawkeyhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-import-raw-key-export-raw-key.html (0 => 208801)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-import-raw-key-export-raw-key.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-import-raw-key-export-raw-key.html        2016-11-16 20:18:45 UTC (rev 208801)
</span><span class="lines">@@ -0,0 +1,35 @@
</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 importing a raw HMAC key with SHA-1 and then export it in raw format&quot;);
+
+jsTestIsAsync = true;
+
+var rawKey = hexStringToUint8Array(&quot;192ff1e96a1399322db620760a738793ab6dfaf26bd2b3889bd81fc9d82ea25d11bb1b4763c0a9259512298e162dab2e6f505c9fc376fda1179a2a4055dd67f6&quot;);
+var extractable = true;
+
+debug(&quot;Importing a key...&quot;);
+crypto.subtle.importKey(&quot;raw&quot;, rawKey, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]).then(function(cryptoKey) {
+    debug(&quot;Exporting a key...&quot;);
+    return crypto.subtle.exportKey(&quot;raw&quot;, cryptoKey);
+}).then(function(result) {
+    exportedRawKey = new Uint8Array(result);
+
+    shouldBe(&quot;exportedRawKey&quot;, &quot;rawKey&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 class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaimportjwkkeyexportjwkkeyprivateexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-import-jwk-key-export-jwk-key-private-expected.txt (0 => 208801)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-import-jwk-key-export-jwk-key-private-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-import-jwk-key-export-jwk-key-private-expected.txt        2016-11-16 20:18:45 UTC (rev 208801)
</span><span class="lines">@@ -0,0 +1,22 @@
</span><ins>+Test importing a JWK RSA-OAEP public key with SHA-1 and then export it in JWK format
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Importing a key...
+Exporting a key...
+PASS exportedJwkKey.kty is jwkKey.kty
+PASS exportedJwkKey.alg is jwkKey.alg
+PASS exportedJwkKey.key_ops is jwkKey.key_ops
+PASS exportedJwkKey.ext is jwkKey.ext
+PASS exportedJwkKey.n is jwkKey.n
+PASS exportedJwkKey.e is jwkKey.e
+PASS exportedJwkKey.p is jwkKey.p
+PASS exportedJwkKey.q is jwkKey.q
+PASS exportedJwkKey.dp is jwkKey.dp
+PASS exportedJwkKey.dq is jwkKey.dq
+PASS exportedJwkKey.qi is jwkKey.qi
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaimportjwkkeyexportjwkkeyprivatehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-import-jwk-key-export-jwk-key-private.html (0 => 208801)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-import-jwk-key-export-jwk-key-private.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-import-jwk-key-export-jwk-key-private.html        2016-11-16 20:18:45 UTC (rev 208801)
</span><span class="lines">@@ -0,0 +1,61 @@
</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 importing a JWK RSA-OAEP public key with SHA-1 and then export it in JWK format&quot;);
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: &quot;RSA&quot;,
+    alg: &quot;RSA-OAEP&quot;,
+    key_ops: [&quot;decrypt&quot;, &quot;unwrapKey&quot;],
+    ext: true,
+    n: &quot;v_dgJnIz-_l4noBUwEkMAc-TkUXOBXUb4homc5oLYbVKYee51acuc3m26xK-vPD7VMCwEt17ylKW6jiEIEG50cZxzvCnGn2AiaqzVeqmm79htT93aX74yD6lginrtSSky5pasjxLlIzvEEGCC3zuupFyxXmCztY3AXbfcTscgWgSiNrgNzuuxtG6tbigc9gEPQj8XgSecr8XXKTqVbwQwh8rOao2rHfe_IjiXwElsTaL2sl3IHIrHx6NVbj54_0HCuo5AZ4ZyJ_bkLVBFe4gO9pIlhVuAHr6adlM83-moDeowYKqU4me_2GR_JspZ3Kif-WEwSY6jJuIn7qXtD5jUw&quot;,
+    e: &quot;AQAB&quot;,
+    d: &quot;DxvDH4OBf-VkjuT-xpt5LHNP4_Egg-FxrlvshtCq8Ke6EPaR87TSvRfpQ5sYE_rLbSI1OWbhJU1Wv1xvWbKSk2YQ8v6RyE30XeFnd-2d60gmwoMaPN1Xazsy_4mZGYqmxbeCR-Di-fAVqKvfNlRA3cIwzEYB-5F0htL6Rwkl9zE8th1DTuBvqBLoTxYZKLnoCN8YdfTUr-CQOghMafCwi3ltAkZqxNNqP9RRSqfkNCqAKK_23jhXS9yZSes3QEO1LBxDNpdumIk4smpO_iFhxd5I68s8JCDogfNQulmErrYbAk6cAUXNMvpua9ipH-uIw8qgakzKfD6lIQmeFoM7MQ&quot;,
+    p: &quot;7uKCNGo6nH5Kk6zz6H6n3LAkKr45IQb1CfyLi6Po-6lxHt2a5bi5CkRH7PNUz3QRYWAkYmlpfvoAqzXhOYIUewvcbzyzTUxpv-F1Xbw9KV6nc1LFe8W8733AzLtHBgjimwU9VYgsmV7DJDP7djODjskSGPC9O9rcq7jK_1atFy8&quot;,
+    q: &quot;zbhQdf5AX_ssgZALSFhMmvR39c2XJXBLFuAF_c1EBRtch3X-_DgHiZ1srZrdIbnI7yjx7smJPg1Met1pHTgrk9jdlGwkzxFQWgo5XbhergrB7njOtWmkTUlpd01zidk0Nh138KTCchVe7h4JKy7wIomw9256B3ozh0DuP7eIrR0&quot;,
+    dp: &quot;C5HAyJUUfZvINNq9fVcU_iUxuzg3QBg8Kd2nTH4FvJp6Ngp5hAKsQ4kHCrzGML3oUZT8bh-40kN9YM1dORHJuCPc6y4_aND4lihvLLj_JU_GQFmT4uiyu86VVdUEHZC0mNlqHQhZUJw8SzaRSSo5huLKE5clMw7ofRCYFEG4ZFU&quot;,
+    dq: &quot;axFbpx2N6aZzUndit-Nk81z7Nk4rNUwNeLldxOtZVIMaFFKARErw-Vman3wzTQNBpd-ckxgHOul2_ZdQxuleHNPI9x-VxMORG1uo4bM8a76jkncDtn1mCueDYZlI4dzPBL8vlmpZ3UBsKOgvA2-pgYBCP3UbQ9sBCIrttPHTy60&quot;,
+    qi: &quot;o3RcFTK_WfBFceq7ZG3u3imgQkIfRWZorEAKBffBNw0ggh7XjKKNx_dAinTmCE_UlNih-kO9UPTPEI3QyB3i_BIxcm122Ldzot-9Q7H-hsQ6p7AODSlc3xfYNQEG5PjEsDBBG_GlybmDeblhr67s2hDPEmMgAuoXNHxf4QMvmqM&quot;,
+};
+var extractable = true;
+
+debug(&quot;Importing a key...&quot;);
+crypto.subtle.importKey(&quot;jwk&quot;, jwkKey, {name: &quot;RSA-OAEP&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;decrypt&quot;, &quot;unwrapKey&quot;]).then(function(cryptoKey) {
+    debug(&quot;Exporting a key...&quot;);
+    return crypto.subtle.exportKey(&quot;jwk&quot;, cryptoKey);
+}).then(function(result) {
+    exportedJwkKey = result;
+
+    shouldBe(&quot;exportedJwkKey.kty&quot;, &quot;jwkKey.kty&quot;);
+    shouldBe(&quot;exportedJwkKey.alg&quot;, &quot;jwkKey.alg&quot;);
+    shouldBe(&quot;exportedJwkKey.key_ops&quot;, &quot;jwkKey.key_ops&quot;);
+    shouldBe(&quot;exportedJwkKey.ext&quot;, &quot;jwkKey.ext&quot;);
+    shouldBe(&quot;exportedJwkKey.n&quot;, &quot;jwkKey.n&quot;);
+    shouldBe(&quot;exportedJwkKey.e&quot;, &quot;jwkKey.e&quot;);
+    // FIXME: Since we actually recaculate the private exponent based on modulus, public exponent, first prime factor, and second prime factor,
+    // this exported private exponent may not match the imported one.
+    // shouldBe(&quot;exportedJwkKey.d&quot;, &quot;jwkKey.d&quot;);
+    shouldBe(&quot;exportedJwkKey.p&quot;, &quot;jwkKey.p&quot;);
+    shouldBe(&quot;exportedJwkKey.q&quot;, &quot;jwkKey.q&quot;);
+    shouldBe(&quot;exportedJwkKey.dp&quot;, &quot;jwkKey.dp&quot;);
+    shouldBe(&quot;exportedJwkKey.dq&quot;, &quot;jwkKey.dq&quot;);
+    shouldBe(&quot;exportedJwkKey.qi&quot;, &quot;jwkKey.qi&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="trunkLayoutTestscryptosubtlersaimportjwkkeyexportjwkkeypublicexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-import-jwk-key-export-jwk-key-public-expected.txt (0 => 208801)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-import-jwk-key-export-jwk-key-public-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-import-jwk-key-export-jwk-key-public-expected.txt        2016-11-16 20:18:45 UTC (rev 208801)
</span><span class="lines">@@ -0,0 +1,17 @@
</span><ins>+Test importing a JWK RSA-OAEP public key with SHA-1 and then export it in JWK format
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Importing a key...
+Exporting a key...
+PASS exportedJwkKey.kty is jwkKey.kty
+PASS exportedJwkKey.alg is jwkKey.alg
+PASS exportedJwkKey.key_ops is jwkKey.key_ops
+PASS exportedJwkKey.ext is jwkKey.ext
+PASS exportedJwkKey.n is jwkKey.n
+PASS exportedJwkKey.e is jwkKey.e
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaimportjwkkeyexportjwkkeypublichtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-import-jwk-key-export-jwk-key-public.html (0 => 208801)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-import-jwk-key-export-jwk-key-public.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-import-jwk-key-export-jwk-key-public.html        2016-11-16 20:18:45 UTC (rev 208801)
</span><span class="lines">@@ -0,0 +1,47 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test importing a JWK RSA-OAEP public key with SHA-1 and then export it in JWK format&quot;);
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: &quot;RSA&quot;,
+    alg: &quot;RSA-OAEP&quot;,
+    key_ops: [&quot;encrypt&quot;, &quot;wrapKey&quot;],
+    ext: true,
+    n: &quot;p55Xl-DyqKL06TE8GCuXd_e-ruTqVB19iDH6DwTIknTyM0fl8EY6qsyOBNTxjpLDsOldEJ8QblG78WY7xYTZtNn-fimz5eG80bwSZ6FUO10z3ikeKzPPC7K4AA196rMoiEu2G4mSfqeg5zz6_iqHf8u_md_n8yk_iPaXJ9RVT-W4zEQQ6WSlsOtYa7blSSAlq0JYDJciNeE0RGqUU-UjcxUWIEnT2ODHGRzSfKHgc8O3fGt4dpVm0op1yItBcSAY-0_f1p_YrVDo8bsyq2uodyDGYhcuQgYJ0NjMgT_rb8rUPpR3bUitd-IZJd_NO9i_NmvbnQfgl6kfnxe_2kM4Tw&quot;,
+    e: &quot;AQAB&quot;
+};
+var extractable = true;
+
+debug(&quot;Importing a key...&quot;);
+crypto.subtle.importKey(&quot;jwk&quot;, jwkKey, {name: &quot;RSA-OAEP&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;encrypt&quot;, &quot;wrapKey&quot;]).then(function(cryptoKey) {
+    debug(&quot;Exporting a key...&quot;);
+    return crypto.subtle.exportKey(&quot;jwk&quot;, cryptoKey);
+}).then(function(result) {
+    exportedJwkKey = result;
+
+    shouldBe(&quot;exportedJwkKey.kty&quot;, &quot;jwkKey.kty&quot;);
+    shouldBe(&quot;exportedJwkKey.alg&quot;, &quot;jwkKey.alg&quot;);
+    shouldBe(&quot;exportedJwkKey.key_ops&quot;, &quot;jwkKey.key_ops&quot;);
+    shouldBe(&quot;exportedJwkKey.ext&quot;, &quot;jwkKey.ext&quot;);
+    shouldBe(&quot;exportedJwkKey.n&quot;, &quot;jwkKey.n&quot;);
+    shouldBe(&quot;exportedJwkKey.e&quot;, &quot;jwkKey.e&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="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (208800 => 208801)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-11-16 20:09:16 UTC (rev 208800)
+++ trunk/Source/WebCore/ChangeLog        2016-11-16 20:18:45 UTC (rev 208801)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2016-11-16  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
+
+        Add more tests for SubtleCrypto::importKey and SubtleCrypto::exportKey
+        https://bugs.webkit.org/show_bug.cgi?id=164815
+        &lt;rdar://problem/29281660&gt;
+
+        Reviewed by Brent Fulgham.
+
+        Tests: crypto/subtle/aes-import-jwk-key-export-jwk-key.html
+               crypto/subtle/aes-import-jwk-key-export-raw-key.html
+               crypto/subtle/aes-import-raw-key-export-jwk-key.html
+               crypto/subtle/aes-import-raw-key-export-raw-key.html
+               crypto/subtle/hmac-import-jwk-key-export-jwk-key.html
+               crypto/subtle/hmac-import-jwk-key-export-raw-key.html
+               crypto/subtle/hmac-import-raw-key-export-jwk-key.html
+               crypto/subtle/hmac-import-raw-key-export-raw-key.html
+               crypto/subtle/rsa-import-jwk-key-export-jwk-key-private.html
+               crypto/subtle/rsa-import-jwk-key-export-jwk-key-public.html
+
+        * crypto/mac/CryptoKeyRSAMac.cpp:
+        (WebCore::CryptoKeyRSA::create):
+        Add a comment.
+
</ins><span class="cx"> 2016-11-16  Antti Koivisto  &lt;antti@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Remove getMutableCachedPseudoStyle
</span></span></pre></div>
<a id="trunkSourceWebCorecryptomacCryptoKeyRSAMaccpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/mac/CryptoKeyRSAMac.cpp (208800 => 208801)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/mac/CryptoKeyRSAMac.cpp        2016-11-16 20:09:16 UTC (rev 208800)
+++ trunk/Source/WebCore/crypto/mac/CryptoKeyRSAMac.cpp        2016-11-16 20:18:45 UTC (rev 208801)
</span><span class="lines">@@ -117,6 +117,9 @@
</span><span class="cx">         return nullptr;
</span><span class="cx">     }
</span><span class="cx">     CCRSACryptorRef cryptor;
</span><ins>+    // FIXME: It is so weired that we recaculate the private exponent from first prime factor and second prime factor,
+    // given the fact that we have already had it. Also, the re-caculated private exponent may not match the given one.
+    // See &lt;rdar://problem/15452324&gt;.
</ins><span class="cx">     CCCryptorStatus status = CCRSACryptorCreateFromData(
</span><span class="cx">         keyData.type() == CryptoKeyDataRSAComponents::Type::Public ? ccRSAKeyPublic : ccRSAKeyPrivate,
</span><span class="cx">         (uint8_t*)keyData.modulus().data(), keyData.modulus().size(),
</span></span></pre>
</div>
</div>

</body>
</html>