<!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>[160061] 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/160061">160061</a></dd>
<dt>Author</dt> <dd>ap@apple.com</dd>
<dt>Date</dt> <dd>2013-12-03 16:51:14 -0800 (Tue, 03 Dec 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Update WebCrypto JWK mapping to newer proposal
https://bugs.webkit.org/show_bug.cgi?id=124218

Reviewed by Anders Carlsson.

Source/WebCore: 

Tests: crypto/subtle/jwk-export-use-values.html
       crypto/subtle/jwk-import-use-values.html

1. &quot;extractable&quot; renamed to &quot;ext&quot; in JWK.
2. New values for &quot;use&quot; mapping, which can now be combined into comma separated lists,
and cover all possible WebCrypto usages.

* bindings/js/JSCryptoKeySerializationJWK.cpp:
(WebCore::JSCryptoKeySerializationJWK::reconcileUsages):
(WebCore::JSCryptoKeySerializationJWK::reconcileExtractable):
(WebCore::JSCryptoKeySerializationJWK::addJWKAlgorithmToJSON):
(WebCore::processUseValue):
(WebCore::JSCryptoKeySerializationJWK::addJWKUseToJSON):
(WebCore::JSCryptoKeySerializationJWK::serialize):

LayoutTests: 

* crypto/subtle/jwk-export-use-values-expected.txt: Added.
* crypto/subtle/jwk-export-use-values.html: Added.
* crypto/subtle/jwk-import-use-values-expected.txt: Added.
* crypto/subtle/jwk-import-use-values.html: Added.
New tests for &quot;use&quot; mapping.

* crypto/subtle/aes-cbc-import-jwk.html:
* crypto/subtle/aes-cbc-unwrap-rsa.html:
* crypto/subtle/aes-cbc-wrap-rsa-non-extractable.html:
* crypto/subtle/aes-cbc-wrap-rsa.html:
* crypto/subtle/aes-export-key-expected.txt:
* crypto/subtle/aes-export-key.html:
* crypto/subtle/hmac-export-key-expected.txt:
* crypto/subtle/hmac-export-key.html:
* crypto/subtle/hmac-import-jwk.html:
* crypto/subtle/import-jwk-expected.txt:
* crypto/subtle/import-jwk.html:
* crypto/subtle/rsa-export-key-expected.txt:
* crypto/subtle/rsa-export-key.html:
* crypto/subtle/rsa-export-private-key-expected.txt:
* crypto/subtle/rsa-export-private-key.html:
* crypto/subtle/rsa-oaep-key-manipulation-expected.txt:
* crypto/subtle/rsa-oaep-key-manipulation.html:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestscryptosubtleaescbcimportjwkhtml">trunk/LayoutTests/crypto/subtle/aes-cbc-import-jwk.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleaescbcunwraprsahtml">trunk/LayoutTests/crypto/subtle/aes-cbc-unwrap-rsa.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleaescbcwraprsanonextractablehtml">trunk/LayoutTests/crypto/subtle/aes-cbc-wrap-rsa-non-extractable.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleaescbcwraprsahtml">trunk/LayoutTests/crypto/subtle/aes-cbc-wrap-rsa.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleaesexportkeyexpectedtxt">trunk/LayoutTests/crypto/subtle/aes-export-key-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleaesexportkeyhtml">trunk/LayoutTests/crypto/subtle/aes-export-key.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacexportkeyexpectedtxt">trunk/LayoutTests/crypto/subtle/hmac-export-key-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacexportkeyhtml">trunk/LayoutTests/crypto/subtle/hmac-export-key.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacimportjwkhtml">trunk/LayoutTests/crypto/subtle/hmac-import-jwk.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleimportjwkexpectedtxt">trunk/LayoutTests/crypto/subtle/import-jwk-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleimportjwkhtml">trunk/LayoutTests/crypto/subtle/import-jwk.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaexportkeyexpectedtxt">trunk/LayoutTests/crypto/subtle/rsa-export-key-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaexportkeyhtml">trunk/LayoutTests/crypto/subtle/rsa-export-key.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaexportprivatekeyexpectedtxt">trunk/LayoutTests/crypto/subtle/rsa-export-private-key-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaexportprivatekeyhtml">trunk/LayoutTests/crypto/subtle/rsa-export-private-key.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaoaepkeymanipulationexpectedtxt">trunk/LayoutTests/crypto/subtle/rsa-oaep-key-manipulation-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaoaepkeymanipulationhtml">trunk/LayoutTests/crypto/subtle/rsa-oaep-key-manipulation.html</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSCryptoKeySerializationJWKcpp">trunk/Source/WebCore/bindings/js/JSCryptoKeySerializationJWK.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestscryptosubtlejwkexportusevaluesexpectedtxt">trunk/LayoutTests/crypto/subtle/jwk-export-use-values-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlejwkexportusevalueshtml">trunk/LayoutTests/crypto/subtle/jwk-export-use-values.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlejwkimportusevaluesexpectedtxt">trunk/LayoutTests/crypto/subtle/jwk-import-use-values-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlejwkimportusevalueshtml">trunk/LayoutTests/crypto/subtle/jwk-import-use-values.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (160060 => 160061)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2013-12-04 00:51:13 UTC (rev 160060)
+++ trunk/LayoutTests/ChangeLog        2013-12-04 00:51:14 UTC (rev 160061)
</span><span class="lines">@@ -1,5 +1,36 @@
</span><span class="cx"> 2013-12-03  Alexey Proskuryakov  &lt;ap@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Update WebCrypto JWK mapping to newer proposal
+        https://bugs.webkit.org/show_bug.cgi?id=124218
+
+        Reviewed by Anders Carlsson.
+
+        * crypto/subtle/jwk-export-use-values-expected.txt: Added.
+        * crypto/subtle/jwk-export-use-values.html: Added.
+        * crypto/subtle/jwk-import-use-values-expected.txt: Added.
+        * crypto/subtle/jwk-import-use-values.html: Added.
+        New tests for &quot;use&quot; mapping.
+
+        * crypto/subtle/aes-cbc-import-jwk.html:
+        * crypto/subtle/aes-cbc-unwrap-rsa.html:
+        * crypto/subtle/aes-cbc-wrap-rsa-non-extractable.html:
+        * crypto/subtle/aes-cbc-wrap-rsa.html:
+        * crypto/subtle/aes-export-key-expected.txt:
+        * crypto/subtle/aes-export-key.html:
+        * crypto/subtle/hmac-export-key-expected.txt:
+        * crypto/subtle/hmac-export-key.html:
+        * crypto/subtle/hmac-import-jwk.html:
+        * crypto/subtle/import-jwk-expected.txt:
+        * crypto/subtle/import-jwk.html:
+        * crypto/subtle/rsa-export-key-expected.txt:
+        * crypto/subtle/rsa-export-key.html:
+        * crypto/subtle/rsa-export-private-key-expected.txt:
+        * crypto/subtle/rsa-export-private-key.html:
+        * crypto/subtle/rsa-oaep-key-manipulation-expected.txt:
+        * crypto/subtle/rsa-oaep-key-manipulation.html:
+
+2013-12-03  Alexey Proskuryakov  &lt;ap@apple.com&gt;
+
</ins><span class="cx">         Layout Test platform/mac/accessibility/search-predicate-element-count.html is flaky
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=125195
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtleaescbcimportjwkhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/crypto/subtle/aes-cbc-import-jwk.html (160060 => 160061)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-cbc-import-jwk.html        2013-12-04 00:51:13 UTC (rev 160060)
+++ trunk/LayoutTests/crypto/subtle/aes-cbc-import-jwk.html        2013-12-04 00:51:14 UTC (rev 160061)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">     &quot;kty&quot;: &quot;oct&quot;,
</span><span class="cx">     &quot;alg&quot;: &quot;A192CBC&quot;,
</span><span class="cx">     &quot;use&quot;: &quot;enc&quot;,
</span><del>-    &quot;extractable&quot;: true,
</del><ins>+    &quot;ext&quot;: true,
</ins><span class="cx">     &quot;k&quot;: &quot;jnOw99oOZFLIEPMrgJB55WL46tJSLGt7&quot;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtleaescbcunwraprsahtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/crypto/subtle/aes-cbc-unwrap-rsa.html (160060 => 160061)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-cbc-unwrap-rsa.html        2013-12-04 00:51:13 UTC (rev 160060)
+++ trunk/LayoutTests/crypto/subtle/aes-cbc-unwrap-rsa.html        2013-12-04 00:51:14 UTC (rev 160061)
</span><span class="lines">@@ -21,12 +21,12 @@
</span><span class="cx">     alg: &quot;RS256&quot;,
</span><span class="cx">     n: &quot;rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw&quot;,
</span><span class="cx">     e: &quot;AQAB&quot;,
</span><del>-    extractable: false,
</del><ins>+    ext: false,
</ins><span class="cx">     use: &quot;sig&quot;
</span><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> var unwrappingKeyOctets = hexStringToUint8Array(&quot;2a00e0e776e94e4dc89bf947cebdebe1&quot;);
</span><del>-var wrappedKey = hexStringToUint8Array(&quot;3511f6028db04ea97e7cfad3c4cc60837bceff25cb6c88292fbcb4547570afdc32e4003fe4d65f1e7df60dc1fdb3df36c3f58ab228e33aa31005852d46d0c2ad1318435a071bbb5bbb05650ea63d551698b0c040dd95ed0d379b5e2eccb545ae5620acb8051174cd2ad647328ad99dcd462fec40748724eb1e68f209f779faa2c35b4d4d1b6604a74e62a1846249ea6192954a5af10c71ebfea79948142441ed307e9f52e797a51a8007a6f87b57c51f9e7eef54b7e4a1f818ba6ac25ee5935c23b3253d6d9d222262c79ccdb7147d9c07527c22fe7a4ab91af20479edf5930b3c053c0a0b27092cfb53203633d01dcf6e333b5be7c1933c321c953f962b934ebefd9df8cca6c0a25fcd5fb96105435c42d9902406f82bc8daa8ec12fa85d9afa65adbfe3f60828ef64adaf43ad8e3b0af104cbfafd994323732bba08f84d5cac1d157b276233dffecafe47942b83c85ead6d5886c6badf534d4a32d3f545e8032dd5e419d7bff3acde2c37a96fc34fda8747d89500bf9f7ef45873c6b3b274197c184fe91badeeddf5045f982ecc66b61e0c4d75fd496c61ffcbb36e079faf20aa0c05cd12742aefdf1f6a39c4a9c5a&quot;);
</del><ins>+var wrappedKey = hexStringToUint8Array(&quot;3511f6028db04ea97e7cfad3c4cc60837bceff25cb6c88292fbcb4547570afdc32e4003fe4d65f1e7df60dc1fdb3df36c3f58ab228e33aa31005852d46d0c2ad1318435a071bbb5bbb05650ea63d551698b0c040dd95ed0d379b5e2eccb545ae5620acb8051174cd2ad647328ad99dcd462fec40748724eb1e68f209f779faa2c35b4d4d1b6604a74e62a1846249ea6192954a5af10c71ebfea79948142441ed307e9f52e797a51a8007a6f87b57c51f9e7eef54b7e4a1f818ba6ac25ee5935c23b3253d6d9d222262c79ccdb7147d9c07527c22fe7a4ab91af20479edf5930b3c053c0a0b27092cfb53203633d01dcf6e333b5be7c1933c321c953f962b934ebefd9df8cca6c0a25fcd5fb96105435c42d9902406f82bc8daa8ec12fa85d9afa65adbfe3f60828ef64adaf43ad8e3b0af104cbfafd994323732bba08f84d5cac1d157b276233dffecafe47942b83c85ead6d5886c6badf534d4a32d3f545e8032dd5e419d7bff3acde2c37a96fc34fda8747d89500bf9f7ef45873c6b3b2741aaf74ff96a2f950028f38eb62f1be936fe0a994ebfa928021c0c96172d84584e&quot;);
</ins><span class="cx"> 
</span><span class="cx"> debug(&quot;Importing an unwrapping key...&quot;);
</span><span class="cx"> crypto.subtle.importKey(&quot;raw&quot;, unwrappingKeyOctets, &quot;AES-CBC&quot;, nonExtractable, [&quot;unwrapKey&quot;]).then(function(result) {
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtleaescbcwraprsanonextractablehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/crypto/subtle/aes-cbc-wrap-rsa-non-extractable.html (160060 => 160061)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-cbc-wrap-rsa-non-extractable.html        2013-12-04 00:51:13 UTC (rev 160060)
+++ trunk/LayoutTests/crypto/subtle/aes-cbc-wrap-rsa-non-extractable.html        2013-12-04 00:51:14 UTC (rev 160061)
</span><span class="lines">@@ -21,7 +21,7 @@
</span><span class="cx">     alg: &quot;RS256&quot;,
</span><span class="cx">     n: &quot;rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw&quot;,
</span><span class="cx">     e: &quot;AQAB&quot;,
</span><del>-    extractable: false,
</del><ins>+    ext: false,
</ins><span class="cx">     use: &quot;sig&quot;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtleaescbcwraprsahtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/crypto/subtle/aes-cbc-wrap-rsa.html (160060 => 160061)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-cbc-wrap-rsa.html        2013-12-04 00:51:13 UTC (rev 160060)
+++ trunk/LayoutTests/crypto/subtle/aes-cbc-wrap-rsa.html        2013-12-04 00:51:14 UTC (rev 160061)
</span><span class="lines">@@ -21,7 +21,7 @@
</span><span class="cx">     alg: &quot;RS256&quot;,
</span><span class="cx">     n: &quot;rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw&quot;,
</span><span class="cx">     e: &quot;AQAB&quot;,
</span><del>-    extractable: true,
</del><ins>+    ext: true,
</ins><span class="cx">     use: &quot;sig&quot;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtleaesexportkeyexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/crypto/subtle/aes-export-key-expected.txt (160060 => 160061)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-export-key-expected.txt        2013-12-04 00:51:13 UTC (rev 160060)
+++ trunk/LayoutTests/crypto/subtle/aes-export-key-expected.txt        2013-12-04 00:51:14 UTC (rev 160061)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx"> PASS exportedJWK.kty is 'oct'
</span><span class="cx"> PASS exportedJWK.k is 'jnOw99oOZFLIEPMrgJB55WL46tJSLGt7'
</span><span class="cx"> PASS exportedJWK.alg is 'A192CBC'
</span><del>-PASS exportedJWK.extractable is true
</del><ins>+PASS exportedJWK.ext is true
</ins><span class="cx"> PASS exportedJWK.use is 'enc'
</span><span class="cx"> 
</span><span class="cx"> Importing a key that's not extractable...
</span><span class="lines">@@ -31,9 +31,6 @@
</span><span class="cx"> PASS Rejected, as expected
</span><span class="cx"> Trying to export as jwk...
</span><span class="cx"> PASS Rejected, as expected
</span><del>-
-Importing a key with only encrypt+decrypt usage (this doesn't map to anything in JWK, as 'enc' also allows wrap/unwrap)...
-PASS crypto.subtle.exportKey(&quot;jwk&quot;, key) threw exception TypeError: Key usages cannot be represented in JWK. Only two variants are supported: sign+verify and encrypt+decrypt+wrapKey+unwrapKey.
</del><span class="cx"> PASS successfullyParsed is true
</span><span class="cx"> 
</span><span class="cx"> TEST COMPLETE
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtleaesexportkeyhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/crypto/subtle/aes-export-key.html (160060 => 160061)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-export-key.html        2013-12-04 00:51:13 UTC (rev 160060)
+++ trunk/LayoutTests/crypto/subtle/aes-export-key.html        2013-12-04 00:51:14 UTC (rev 160061)
</span><span class="lines">@@ -52,7 +52,7 @@
</span><span class="cx">     shouldBe(&quot;exportedJWK.kty&quot;, &quot;'oct'&quot;);
</span><span class="cx">     shouldBe(&quot;exportedJWK.k&quot;, &quot;'jnOw99oOZFLIEPMrgJB55WL46tJSLGt7'&quot;);
</span><span class="cx">     shouldBe(&quot;exportedJWK.alg&quot;, &quot;'A192CBC'&quot;);
</span><del>-    shouldBe(&quot;exportedJWK.extractable&quot;, &quot;true&quot;);
</del><ins>+    shouldBe(&quot;exportedJWK.ext&quot;, &quot;true&quot;);
</ins><span class="cx">     shouldBe(&quot;exportedJWK.use&quot;, &quot;'enc'&quot;);
</span><span class="cx"> 
</span><span class="cx">     debug(&quot;\nImporting a key that's not extractable...&quot;);
</span><span class="lines">@@ -76,16 +76,6 @@
</span><span class="cx"> }, function() {
</span><span class="cx">     testPassed(&quot;Rejected, as expected&quot;);
</span><span class="cx"> 
</span><del>-    // If this test starts to fail because a way to encode encrypt+decrypt is added to JWK, change to something that's not there.
-    // If all WebCrypto modes are added to JWK, then this test will be obsolete.
-    debug(&quot;\nImporting a key with only encrypt+decrypt usage (this doesn't map to anything in JWK, as 'enc' also allows wrap/unwrap)...&quot;);
-    return crypto.subtle.importKey(&quot;jwk&quot;, jwkKeyAsArrayBuffer, &quot;AES-CBC&quot;, extractable, ['encrypt', 'decrypt'])
-}).then(function(result) {
-    key = result;
-
-    // Maybe this should be a rejected promise, not an exception. We'll need to find a way to provide meaningful error messages with such failures.
-    shouldThrow('crypto.subtle.exportKey(&quot;jwk&quot;, key)');
-
</del><span class="cx">     finishJSTest();
</span><span class="cx"> });
</span><span class="cx"> &lt;/script&gt;
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtlehmacexportkeyexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/crypto/subtle/hmac-export-key-expected.txt (160060 => 160061)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-export-key-expected.txt        2013-12-04 00:51:13 UTC (rev 160060)
+++ trunk/LayoutTests/crypto/subtle/hmac-export-key-expected.txt        2013-12-04 00:51:14 UTC (rev 160061)
</span><span class="lines">@@ -15,7 +15,7 @@
</span><span class="cx"> PASS exportedJWK.kty is 'oct'
</span><span class="cx"> PASS exportedJWK.k is 'ahjkn-_387fgnsibf23qsvahjkn-_387fgnsibf23qs'
</span><span class="cx"> PASS exportedJWK.alg is 'HS256'
</span><del>-PASS exportedJWK.extractable is true
</del><ins>+PASS exportedJWK.ext is true
</ins><span class="cx"> PASS exportedJWK.use is 'sig'
</span><span class="cx"> 
</span><span class="cx"> Importing a key that's not extractable...
</span><span class="lines">@@ -24,9 +24,6 @@
</span><span class="cx"> PASS Rejected, as expected
</span><span class="cx"> Trying to export as jwk...
</span><span class="cx"> PASS Rejected, as expected
</span><del>-
-Importing a key with only sign usage (this doesn't map to anything in JWK, as 'sig' allows both sign and verify)...
-PASS crypto.subtle.exportKey(&quot;jwk&quot;, key) threw exception TypeError: Key usages cannot be represented in JWK. Only two variants are supported: sign+verify and encrypt+decrypt+wrapKey+unwrapKey.
</del><span class="cx"> PASS successfullyParsed is true
</span><span class="cx"> 
</span><span class="cx"> TEST COMPLETE
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtlehmacexportkeyhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/crypto/subtle/hmac-export-key.html (160060 => 160061)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-export-key.html        2013-12-04 00:51:13 UTC (rev 160060)
+++ trunk/LayoutTests/crypto/subtle/hmac-export-key.html        2013-12-04 00:51:14 UTC (rev 160061)
</span><span class="lines">@@ -46,7 +46,7 @@
</span><span class="cx">     shouldBe(&quot;exportedJWK.kty&quot;, &quot;'oct'&quot;);
</span><span class="cx">     shouldBe(&quot;exportedJWK.k&quot;, &quot;'ahjkn-_387fgnsibf23qsvahjkn-_387fgnsibf23qs'&quot;);
</span><span class="cx">     shouldBe(&quot;exportedJWK.alg&quot;, &quot;'HS256'&quot;);
</span><del>-    shouldBe(&quot;exportedJWK.extractable&quot;, &quot;true&quot;);
</del><ins>+    shouldBe(&quot;exportedJWK.ext&quot;, &quot;true&quot;);
</ins><span class="cx">     shouldBe(&quot;exportedJWK.use&quot;, &quot;'sig'&quot;);
</span><span class="cx"> 
</span><span class="cx">     debug(&quot;\nImporting a key that's not extractable...&quot;);
</span><span class="lines">@@ -70,16 +70,6 @@
</span><span class="cx"> }, function() {
</span><span class="cx">     testPassed(&quot;Rejected, as expected&quot;);
</span><span class="cx"> 
</span><del>-    // If this test starts to fail because a way to encode encrypt+decrypt is added to JWK, change to something that's not there.
-    // If all WebCrypto modes are added to JWK, then this test will be obsolete.
-    debug(&quot;\nImporting a key with only sign usage (this doesn't map to anything in JWK, as 'sig' allows both sign and verify)...&quot;);
-    return crypto.subtle.importKey(&quot;jwk&quot;, jwkKeyAsArrayBuffer, { name: &quot;HMAC&quot;, hash: &quot;SHA-256&quot; }, extractable, ['sign'])
-}).then(function(result) {
-    key = result;
-
-    // Maybe this should be a rejected promise, not an exception. We'll need to find a way to provide meaningful error messages with such failures.
-    shouldThrow('crypto.subtle.exportKey(&quot;jwk&quot;, key)');
-
</del><span class="cx">     finishJSTest();
</span><span class="cx"> });
</span><span class="cx"> &lt;/script&gt;
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtlehmacimportjwkhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/crypto/subtle/hmac-import-jwk.html (160060 => 160061)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-import-jwk.html        2013-12-04 00:51:13 UTC (rev 160060)
+++ trunk/LayoutTests/crypto/subtle/hmac-import-jwk.html        2013-12-04 00:51:14 UTC (rev 160061)
</span><span class="lines">@@ -19,7 +19,7 @@
</span><span class="cx">     &quot;kty&quot;: &quot;oct&quot;,
</span><span class="cx">     &quot;alg&quot;: &quot;HS256&quot;,
</span><span class="cx">     &quot;use&quot;: &quot;sig&quot;,
</span><del>-    &quot;extractable&quot;: false,
</del><ins>+    &quot;ext&quot;: false,
</ins><span class="cx">     &quot;k&quot;: &quot;ahjkn-_387fgnsibf23qsvahjkn-_387fgnsibf23qs&quot;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtleimportjwkexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/crypto/subtle/import-jwk-expected.txt (160060 => 160061)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/import-jwk-expected.txt        2013-12-04 00:51:13 UTC (rev 160060)
+++ trunk/LayoutTests/crypto/subtle/import-jwk-expected.txt        2013-12-04 00:51:14 UTC (rev 160061)
</span><span class="lines">@@ -11,19 +11,19 @@
</span><span class="cx"> PASS crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array('{}'), &quot;aes-cbc&quot;) threw exception TypeError: Required JWK &quot;kty&quot; member is missing.
</span><span class="cx"> PASS crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array('{ &quot;kty&quot;: &quot;foobar&quot;, &quot;alg&quot;: &quot;HS256&quot;, &quot;use&quot;: &quot;sig&quot;, &quot;k&quot;: &quot;ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs&quot; }'), null) threw exception TypeError: Unsupported JWK key type foobar.
</span><span class="cx"> PASS crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array('{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;foobar&quot;, &quot;use&quot;: &quot;sig&quot;, &quot;k&quot;: &quot;ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs&quot; }'), null) threw exception TypeError: Unsupported JWK algorithm foobar.
</span><del>-PASS crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array('{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;HS256&quot;, &quot;use&quot;: &quot;sig&quot;, &quot;extractable&quot;: false, &quot;k&quot;: &quot;ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs&quot; }'), &quot;aes-cbc&quot;) threw exception TypeError: Algorithm specified in key is not compatible with one passed to importKey as argument.
-PASS crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array('{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;HS256&quot;, &quot;use&quot;: &quot;sig&quot;, &quot;extractable&quot;: false, &quot;k&quot;: &quot;ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs&quot; }'), { name: &quot;hmac&quot;, hash: &quot;sha-1&quot; }) threw exception TypeError: Algorithm specified in key is not compatible with one passed to importKey as argument.
</del><ins>+PASS crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array('{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;HS256&quot;, &quot;use&quot;: &quot;sig&quot;, &quot;ext&quot;: false, &quot;k&quot;: &quot;ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs&quot; }'), &quot;aes-cbc&quot;) threw exception TypeError: Algorithm specified in key is not compatible with one passed to importKey as argument.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array('{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;HS256&quot;, &quot;use&quot;: &quot;sig&quot;, &quot;ext&quot;: false, &quot;k&quot;: &quot;ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs&quot; }'), { name: &quot;hmac&quot;, hash: &quot;sha-1&quot; }) threw exception TypeError: Algorithm specified in key is not compatible with one passed to importKey as argument.
</ins><span class="cx"> PASS crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array('{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;HS256&quot; }'), null) threw exception TypeError: Secret key data is not present is JWK.
</span><span class="cx"> PASS crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array('{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;A128CBC&quot; }'), null) threw exception TypeError: Secret key data is not present is JWK.
</span><del>-PASS crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array('{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;HS256&quot;, &quot;use&quot;: &quot;sig&quot;, &quot;extractable&quot;: false, &quot;k&quot;: &quot;1234&quot; }'), null) threw exception TypeError: Key size is not valid for HS256.
-PASS crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array('{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;A128CBC&quot;, &quot;use&quot;: &quot;sig&quot;, &quot;extractable&quot;: false, &quot;k&quot;: &quot;1234&quot; }'), null) threw exception TypeError: Key size is not valid for A128CBC.
-PASS crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array('{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;A128CBC&quot;, &quot;use&quot;: &quot;sig&quot;, &quot;extractable&quot;: false, &quot;k&quot;: &quot;ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs&quot; }'), null) threw exception TypeError: Key size is not valid for A128CBC.
-PASS crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array('{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;HS256&quot;, &quot;use&quot;: &quot;sig&quot;, &quot;extractable&quot;: false, &quot;k&quot;: &quot;ahjkn23387f+nsibf23qsvahjkn37387fgnsibf23qs&quot; }'), null) threw exception TypeError: Cannot decode base64url key data in JWK.
-PASS crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array('{ &quot;kty&quot;: 1, &quot;alg&quot;: &quot;HS256&quot;, &quot;use&quot;: &quot;sig&quot;, &quot;extractable&quot;: false, &quot;k&quot;: &quot;ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs&quot; }'), null) threw exception TypeError: Expected a string value for &quot;kty&quot; JSON key.
-PASS crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array('{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: 1, &quot;use&quot;: &quot;sig&quot;, &quot;extractable&quot;: false, &quot;k&quot;: &quot;ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs&quot; }'), null) threw exception TypeError: Expected a string value for &quot;alg&quot; JSON key.
-PASS crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array('{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;HS256&quot;, &quot;use&quot;: 1, &quot;extractable&quot;: false, &quot;k&quot;: &quot;ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs&quot; }'), null) threw exception TypeError: Expected a string value for &quot;use&quot; JSON key.
-PASS crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array('{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;HS256&quot;, &quot;use&quot;: &quot;sig&quot;, &quot;extractable&quot;: &quot;false&quot;, &quot;k&quot;: &quot;ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs&quot; }'), null) threw exception TypeError: Expected a boolean value for &quot;extractable&quot; JSON key.
-PASS crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array('{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;HS256&quot;, &quot;use&quot;: &quot;sig&quot;, &quot;extractable&quot;: false, &quot;k&quot;: 1 }'), null) threw exception TypeError: Expected a string value for &quot;k&quot; JSON key.
</del><ins>+PASS crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array('{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;HS256&quot;, &quot;use&quot;: &quot;sig&quot;, &quot;ext&quot;: false, &quot;k&quot;: &quot;1234&quot; }'), null) threw exception TypeError: Key size is not valid for HS256.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array('{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;A128CBC&quot;, &quot;use&quot;: &quot;sig&quot;, &quot;ext&quot;: false, &quot;k&quot;: &quot;1234&quot; }'), null) threw exception TypeError: Key size is not valid for A128CBC.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array('{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;A128CBC&quot;, &quot;use&quot;: &quot;sig&quot;, &quot;ext&quot;: false, &quot;k&quot;: &quot;ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs&quot; }'), null) threw exception TypeError: Key size is not valid for A128CBC.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array('{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;HS256&quot;, &quot;use&quot;: &quot;sig&quot;, &quot;ext&quot;: false, &quot;k&quot;: &quot;ahjkn23387f+nsibf23qsvahjkn37387fgnsibf23qs&quot; }'), null) threw exception TypeError: Cannot decode base64url key data in JWK.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array('{ &quot;kty&quot;: 1, &quot;alg&quot;: &quot;HS256&quot;, &quot;use&quot;: &quot;sig&quot;, &quot;ext&quot;: false, &quot;k&quot;: &quot;ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs&quot; }'), null) threw exception TypeError: Expected a string value for &quot;kty&quot; JSON key.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array('{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: 1, &quot;use&quot;: &quot;sig&quot;, &quot;ext&quot;: false, &quot;k&quot;: &quot;ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs&quot; }'), null) threw exception TypeError: Expected a string value for &quot;alg&quot; JSON key.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array('{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;HS256&quot;, &quot;use&quot;: 1, &quot;ext&quot;: false, &quot;k&quot;: &quot;ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs&quot; }'), null) threw exception TypeError: Expected a string value for &quot;use&quot; JSON key.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array('{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;HS256&quot;, &quot;use&quot;: &quot;sig&quot;, &quot;ext&quot;: &quot;false&quot;, &quot;k&quot;: &quot;ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs&quot; }'), null) threw exception TypeError: Expected a boolean value for &quot;ext&quot; JSON key.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array('{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;HS256&quot;, &quot;use&quot;: &quot;sig&quot;, &quot;ext&quot;: false, &quot;k&quot;: 1 }'), null) threw exception TypeError: Expected a string value for &quot;k&quot; JSON key.
</ins><span class="cx"> PASS successfullyParsed is true
</span><span class="cx"> 
</span><span class="cx"> TEST COMPLETE
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtleimportjwkhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/crypto/subtle/import-jwk.html (160060 => 160061)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/import-jwk.html        2013-12-04 00:51:13 UTC (rev 160060)
+++ trunk/LayoutTests/crypto/subtle/import-jwk.html        2013-12-04 00:51:14 UTC (rev 160061)
</span><span class="lines">@@ -23,27 +23,27 @@
</span><span class="cx"> shouldThrow('crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array(\'{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;foobar&quot;, &quot;use&quot;: &quot;sig&quot;, &quot;k&quot;: &quot;ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs&quot; }\'), null)')
</span><span class="cx"> 
</span><span class="cx"> // Algorithm mismatch.
</span><del>-shouldThrow('crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array(\'{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;HS256&quot;, &quot;use&quot;: &quot;sig&quot;, &quot;extractable&quot;: false, &quot;k&quot;: &quot;ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs&quot; }\'), &quot;aes-cbc&quot;)')
-shouldThrow('crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array(\'{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;HS256&quot;, &quot;use&quot;: &quot;sig&quot;, &quot;extractable&quot;: false, &quot;k&quot;: &quot;ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs&quot; }\'), { name: &quot;hmac&quot;, hash: &quot;sha-1&quot; })')
</del><ins>+shouldThrow('crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array(\'{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;HS256&quot;, &quot;use&quot;: &quot;sig&quot;, &quot;ext&quot;: false, &quot;k&quot;: &quot;ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs&quot; }\'), &quot;aes-cbc&quot;)')
+shouldThrow('crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array(\'{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;HS256&quot;, &quot;use&quot;: &quot;sig&quot;, &quot;ext&quot;: false, &quot;k&quot;: &quot;ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs&quot; }\'), { name: &quot;hmac&quot;, hash: &quot;sha-1&quot; })')
</ins><span class="cx"> 
</span><span class="cx"> // No key data.
</span><span class="cx"> shouldThrow('crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array(\'{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;HS256&quot; }\'), null)')
</span><span class="cx"> shouldThrow('crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array(\'{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;A128CBC&quot; }\'), null)')
</span><span class="cx"> 
</span><span class="cx"> // Key data length is incorrect, not allowed in JWK.
</span><del>-shouldThrow('crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array(\'{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;HS256&quot;, &quot;use&quot;: &quot;sig&quot;, &quot;extractable&quot;: false, &quot;k&quot;: &quot;1234&quot; }\'), null)')
-shouldThrow('crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array(\'{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;A128CBC&quot;, &quot;use&quot;: &quot;sig&quot;, &quot;extractable&quot;: false, &quot;k&quot;: &quot;1234&quot; }\'), null)')
-shouldThrow('crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array(\'{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;A128CBC&quot;, &quot;use&quot;: &quot;sig&quot;, &quot;extractable&quot;: false, &quot;k&quot;: &quot;ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs&quot; }\'), null)')
</del><ins>+shouldThrow('crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array(\'{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;HS256&quot;, &quot;use&quot;: &quot;sig&quot;, &quot;ext&quot;: false, &quot;k&quot;: &quot;1234&quot; }\'), null)')
+shouldThrow('crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array(\'{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;A128CBC&quot;, &quot;use&quot;: &quot;sig&quot;, &quot;ext&quot;: false, &quot;k&quot;: &quot;1234&quot; }\'), null)')
+shouldThrow('crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array(\'{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;A128CBC&quot;, &quot;use&quot;: &quot;sig&quot;, &quot;ext&quot;: false, &quot;k&quot;: &quot;ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs&quot; }\'), null)')
</ins><span class="cx"> 
</span><span class="cx"> // Key data is not valid base64url.
</span><del>-shouldThrow('crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array(\'{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;HS256&quot;, &quot;use&quot;: &quot;sig&quot;, &quot;extractable&quot;: false, &quot;k&quot;: &quot;ahjkn23387f+nsibf23qsvahjkn37387fgnsibf23qs&quot; }\'), null)')
</del><ins>+shouldThrow('crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array(\'{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;HS256&quot;, &quot;use&quot;: &quot;sig&quot;, &quot;ext&quot;: false, &quot;k&quot;: &quot;ahjkn23387f+nsibf23qsvahjkn37387fgnsibf23qs&quot; }\'), null)')
</ins><span class="cx"> 
</span><span class="cx"> // Incorrect data types.
</span><del>-shouldThrow('crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array(\'{ &quot;kty&quot;: 1, &quot;alg&quot;: &quot;HS256&quot;, &quot;use&quot;: &quot;sig&quot;, &quot;extractable&quot;: false, &quot;k&quot;: &quot;ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs&quot; }\'), null)')
-shouldThrow('crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array(\'{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: 1, &quot;use&quot;: &quot;sig&quot;, &quot;extractable&quot;: false, &quot;k&quot;: &quot;ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs&quot; }\'), null)')
-shouldThrow('crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array(\'{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;HS256&quot;, &quot;use&quot;: 1, &quot;extractable&quot;: false, &quot;k&quot;: &quot;ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs&quot; }\'), null)')
-shouldThrow('crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array(\'{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;HS256&quot;, &quot;use&quot;: &quot;sig&quot;, &quot;extractable&quot;: &quot;false&quot;, &quot;k&quot;: &quot;ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs&quot; }\'), null)')
-shouldThrow('crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array(\'{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;HS256&quot;, &quot;use&quot;: &quot;sig&quot;, &quot;extractable&quot;: false, &quot;k&quot;: 1 }\'), null)')
</del><ins>+shouldThrow('crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array(\'{ &quot;kty&quot;: 1, &quot;alg&quot;: &quot;HS256&quot;, &quot;use&quot;: &quot;sig&quot;, &quot;ext&quot;: false, &quot;k&quot;: &quot;ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs&quot; }\'), null)')
+shouldThrow('crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array(\'{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: 1, &quot;use&quot;: &quot;sig&quot;, &quot;ext&quot;: false, &quot;k&quot;: &quot;ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs&quot; }\'), null)')
+shouldThrow('crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array(\'{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;HS256&quot;, &quot;use&quot;: 1, &quot;ext&quot;: false, &quot;k&quot;: &quot;ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs&quot; }\'), null)')
+shouldThrow('crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array(\'{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;HS256&quot;, &quot;use&quot;: &quot;sig&quot;, &quot;ext&quot;: &quot;false&quot;, &quot;k&quot;: &quot;ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs&quot; }\'), null)')
+shouldThrow('crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array(\'{ &quot;kty&quot;: &quot;oct&quot;, &quot;alg&quot;: &quot;HS256&quot;, &quot;use&quot;: &quot;sig&quot;, &quot;ext&quot;: false, &quot;k&quot;: 1 }\'), null)')
</ins><span class="cx"> &lt;/script&gt;
</span><span class="cx"> 
</span><span class="cx"> &lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtlejwkexportusevaluesexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/jwk-export-use-values-expected.txt (0 => 160061)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/jwk-export-use-values-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/jwk-export-use-values-expected.txt        2013-12-04 00:51:14 UTC (rev 160061)
</span><span class="lines">@@ -0,0 +1,42 @@
</span><ins>+Test exporting keys with various usages to JWK.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+encrypt:
+PASS jwk.use is 'enconly'
+
+decrypt:
+PASS jwk.use is 'deconly'
+
+encrypt,decrypt:
+PASS jwk.use is 'enconly,deconly'
+
+wrapKey:
+PASS jwk.use is 'wrap'
+
+unwrapKey:
+PASS jwk.use is 'unwrap'
+
+wrapKey,unwrapKey:
+PASS jwk.use is 'wrap,unwrap'
+
+encrypt,decrypt,wrapKey:
+PASS jwk.use is 'enconly,deconly,wrap'
+
+encrypt,decrypt,wrapKey,unwrapKey:
+PASS jwk.use is 'enc'
+
+sign:
+PASS jwk.use is 'sigonly'
+
+verify:
+PASS jwk.use is 'vfyonly'
+
+sign,verify:
+PASS jwk.use is 'sig'
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins><span class="cx">Property changes on: trunk/LayoutTests/crypto/subtle/jwk-export-use-values-expected.txt
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkLayoutTestscryptosubtlejwkexportusevalueshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/jwk-export-use-values.html (0 => 160061)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/jwk-export-use-values.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/jwk-export-use-values.html        2013-12-04 00:51:14 UTC (rev 160061)
</span><span class="lines">@@ -0,0 +1,62 @@
</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 exporting keys with various usages to JWK.&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = true;
+
+var aesKeyAsArrayBuffer = Base64URL.parse(&quot;jnOw99oOZFLIEPMrgJB55WL46tJSLGt7&quot;);
+var hmacKeyAsArrayBuffer = Base64URL.parse(&quot;ahjkn-_387fgnsibf23qsvahjkn-_387fgnsibf23qs&quot;);
+
+function testWithAESCBC(usages, expectedUse)
+{
+    return crypto.subtle.importKey(&quot;raw&quot;, aesKeyAsArrayBuffer, &quot;AES-CBC&quot;, extractable, usages).then(function(result) {
+        return crypto.subtle.exportKey(&quot;jwk&quot;, result);
+    }).then(function(result) {
+        jwk = JSON.parse(bytesToASCIIString(result));
+        debug(usages + &quot;:&quot;);
+        shouldBe(&quot;jwk.use&quot;, &quot;'&quot; + expectedUse + &quot;'&quot;);
+        debug(&quot;&quot;);
+    });
+}
+
+function testWithHMAC(usages, expectedUse)
+{
+    return crypto.subtle.importKey(&quot;raw&quot;, hmacKeyAsArrayBuffer, {name: 'hmac', hash: {name: 'sha-256'}}, extractable, usages).then(function(result) {
+        return crypto.subtle.exportKey(&quot;jwk&quot;, result);
+    }).then(function(result) {
+        jwk = JSON.parse(bytesToASCIIString(result));
+        debug(usages + &quot;:&quot;);
+        shouldBe(&quot;jwk.use&quot;, &quot;'&quot; + expectedUse + &quot;'&quot;);
+        debug(&quot;&quot;);
+    });
+}
+
+Promise.all([
+    testWithAESCBC([&quot;encrypt&quot;], &quot;enconly&quot;),
+    testWithAESCBC([&quot;decrypt&quot;], &quot;deconly&quot;),
+    testWithAESCBC([&quot;encrypt&quot;, &quot;decrypt&quot;], &quot;enconly,deconly&quot;),
+    testWithAESCBC([&quot;wrapKey&quot;], &quot;wrap&quot;),
+    testWithAESCBC([&quot;unwrapKey&quot;], &quot;unwrap&quot;),
+    testWithAESCBC([&quot;wrapKey&quot;, &quot;unwrapKey&quot;], &quot;wrap,unwrap&quot;),
+    testWithAESCBC([&quot;encrypt&quot;, &quot;decrypt&quot;, &quot;wrapKey&quot;], &quot;enconly,deconly,wrap&quot;),
+    testWithAESCBC([&quot;encrypt&quot;, &quot;decrypt&quot;, &quot;wrapKey&quot;, &quot;unwrapKey&quot;], &quot;enc&quot;),
+    testWithHMAC([&quot;sign&quot;], &quot;sigonly&quot;),
+    testWithHMAC([&quot;verify&quot;], &quot;vfyonly&quot;),
+    testWithHMAC([&quot;sign&quot;, &quot;verify&quot;], &quot;sig&quot;),
+]).then(function() { 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">Property changes on: trunk/LayoutTests/crypto/subtle/jwk-export-use-values.html
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="trunkLayoutTestscryptosubtlejwkimportusevaluesexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/jwk-import-use-values-expected.txt (0 => 160061)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/jwk-import-use-values-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/jwk-import-use-values-expected.txt        2013-12-04 00:51:14 UTC (rev 160061)
</span><span class="lines">@@ -0,0 +1,57 @@
</span><ins>+Test importing keys with various uses from JWK.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+enconly:
+PASS key.usages is [&quot;encrypt&quot;]
+
+deconly:
+PASS key.usages is [&quot;decrypt&quot;]
+
+enconly,deconly:
+PASS key.usages is [&quot;encrypt&quot;,&quot;decrypt&quot;]
+
+wrap:
+PASS key.usages is [&quot;wrapKey&quot;]
+
+unwrap:
+PASS key.usages is [&quot;unwrapKey&quot;]
+
+wrap,unwrap:
+PASS key.usages is [&quot;wrapKey&quot;,&quot;unwrapKey&quot;]
+
+enconly,deconly,wrap:
+PASS key.usages is [&quot;encrypt&quot;,&quot;decrypt&quot;,&quot;wrapKey&quot;]
+
+enc:
+PASS key.usages is [&quot;encrypt&quot;,&quot;decrypt&quot;,&quot;wrapKey&quot;,&quot;unwrapKey&quot;]
+
+sigonly:
+PASS key.usages is [&quot;sign&quot;]
+
+vfyonly:
+PASS key.usages is [&quot;verify&quot;]
+
+sig:
+PASS key.usages is [&quot;sign&quot;,&quot;verify&quot;]
+
+'enconly':
+PASS key.usages is []
+
+enconly :
+PASS key.usages is []
+
+EncOnly:
+PASS key.usages is []
+
+enconly, deconly:
+PASS key.usages is [&quot;encrypt&quot;]
+
+enconly,,deconly:
+PASS key.usages is [&quot;encrypt&quot;,&quot;decrypt&quot;]
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins><span class="cx">Property changes on: trunk/LayoutTests/crypto/subtle/jwk-import-use-values-expected.txt
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkLayoutTestscryptosubtlejwkimportusevalueshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/jwk-import-use-values.html (0 => 160061)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/jwk-import-use-values.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/jwk-import-use-values.html        2013-12-04 00:51:14 UTC (rev 160061)
</span><span class="lines">@@ -0,0 +1,79 @@
</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 keys with various uses from JWK.&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = true;
+
+var aesKeyAsJSON = {
+    &quot;alg&quot;: &quot;A192CBC&quot;,
+    &quot;ext&quot;: true,
+    &quot;kty&quot;: &quot;oct&quot;,
+    &quot;k&quot;: &quot;jnOw99oOZFLIEPMrgJB55WL46tJSLGt7&quot;
+};
+
+var hmacKeyAsJSON = {
+    &quot;alg&quot;: &quot;HS256&quot;,
+    &quot;ext&quot;: true,
+    &quot;kty&quot;: &quot;oct&quot;,
+    &quot;k&quot;: &quot;ahjkn-_387fgnsibf23qsvahjkn-_387fgnsibf23qs&quot;
+};
+
+function testWithAESCBC(expectedUsages, use)
+{
+    aesKeyAsJSON.use = use;
+    return crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array(JSON.stringify(aesKeyAsJSON)), &quot;AES-CBC&quot;, extractable, [&quot;encrypt&quot;, &quot;decrypt&quot;, &quot;wrapKey&quot;, &quot;unwrapKey&quot;]).then(function(result) {
+        key = result;
+        debug(use + &quot;:&quot;);
+        shouldBe(&quot;key.usages&quot;, JSON.stringify(expectedUsages));
+        debug(&quot;&quot;);
+    });
+}
+
+function testWithHMAC(expectedUsages, use)
+{
+    hmacKeyAsJSON.use = use;
+    return crypto.subtle.importKey(&quot;jwk&quot;, asciiToUint8Array(JSON.stringify(hmacKeyAsJSON)), {name: 'hmac', hash: {name: 'sha-256'}}, extractable, [&quot;sign&quot;, &quot;verify&quot;]).then(function(result) {
+        key = result;
+        debug(use + &quot;:&quot;);
+        shouldBe(&quot;key.usages&quot;, JSON.stringify(expectedUsages));
+        debug(&quot;&quot;);
+    });
+}
+
+Promise.all([
+    testWithAESCBC([&quot;encrypt&quot;], &quot;enconly&quot;),
+    testWithAESCBC([&quot;decrypt&quot;], &quot;deconly&quot;),
+    testWithAESCBC([&quot;encrypt&quot;, &quot;decrypt&quot;], &quot;enconly,deconly&quot;),
+    testWithAESCBC([&quot;wrapKey&quot;], &quot;wrap&quot;),
+    testWithAESCBC([&quot;unwrapKey&quot;], &quot;unwrap&quot;),
+    testWithAESCBC([&quot;wrapKey&quot;, &quot;unwrapKey&quot;], &quot;wrap,unwrap&quot;),
+    testWithAESCBC([&quot;encrypt&quot;, &quot;decrypt&quot;, &quot;wrapKey&quot;], &quot;enconly,deconly,wrap&quot;),
+    testWithAESCBC([&quot;encrypt&quot;, &quot;decrypt&quot;, &quot;wrapKey&quot;, &quot;unwrapKey&quot;], &quot;enc&quot;),
+    testWithHMAC([&quot;sign&quot;], &quot;sigonly&quot;),
+    testWithHMAC([&quot;verify&quot;], &quot;vfyonly&quot;),
+    testWithHMAC([&quot;sign&quot;, &quot;verify&quot;], &quot;sig&quot;),
+
+// Incorrect use strings. There is currently no spec for what to do, but ignoring unknown uses seems right.
+    testWithAESCBC([], &quot;'enconly'&quot;),
+    testWithAESCBC([], &quot;enconly &quot;),
+    testWithAESCBC([], &quot;EncOnly&quot;),
+    testWithAESCBC([&quot;encrypt&quot;], &quot;enconly, deconly&quot;),
+    testWithAESCBC([&quot;encrypt&quot;, &quot;decrypt&quot;], &quot;enconly,,deconly&quot;),
+
+]).then(function() { 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">Property changes on: trunk/LayoutTests/crypto/subtle/jwk-import-use-values.html
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="trunkLayoutTestscryptosubtlersaexportkeyexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/crypto/subtle/rsa-export-key-expected.txt (160060 => 160061)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-export-key-expected.txt        2013-12-04 00:51:13 UTC (rev 160060)
+++ trunk/LayoutTests/crypto/subtle/rsa-export-key-expected.txt        2013-12-04 00:51:14 UTC (rev 160061)
</span><span class="lines">@@ -16,7 +16,7 @@
</span><span class="cx"> PASS exportedJWK.n is publicKeyJSON.n
</span><span class="cx"> PASS exportedJWK.e is publicKeyJSON.e
</span><span class="cx"> PASS exportedJWK.alg is 'RS256'
</span><del>-PASS exportedJWK.extractable is true
</del><ins>+PASS exportedJWK.ext is true
</ins><span class="cx"> PASS exportedJWK.use is 'sig'
</span><span class="cx"> PASS successfullyParsed is true
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaexportkeyhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/crypto/subtle/rsa-export-key.html (160060 => 160061)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-export-key.html        2013-12-04 00:51:13 UTC (rev 160060)
+++ trunk/LayoutTests/crypto/subtle/rsa-export-key.html        2013-12-04 00:51:14 UTC (rev 160061)
</span><span class="lines">@@ -44,7 +44,7 @@
</span><span class="cx">     shouldBe(&quot;exportedJWK.n&quot;, &quot;publicKeyJSON.n&quot;);
</span><span class="cx">     shouldBe(&quot;exportedJWK.e&quot;, &quot;publicKeyJSON.e&quot;);
</span><span class="cx">     shouldBe(&quot;exportedJWK.alg&quot;, &quot;'RS256'&quot;);
</span><del>-    shouldBe(&quot;exportedJWK.extractable&quot;, &quot;true&quot;);
</del><ins>+    shouldBe(&quot;exportedJWK.ext&quot;, &quot;true&quot;);
</ins><span class="cx">     shouldBe(&quot;exportedJWK.use&quot;, &quot;'sig'&quot;);
</span><span class="cx"> 
</span><span class="cx">     finishJSTest();
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaexportprivatekeyexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/crypto/subtle/rsa-export-private-key-expected.txt (160060 => 160061)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-export-private-key-expected.txt        2013-12-04 00:51:13 UTC (rev 160060)
+++ trunk/LayoutTests/crypto/subtle/rsa-export-private-key-expected.txt        2013-12-04 00:51:14 UTC (rev 160061)
</span><span class="lines">@@ -18,7 +18,7 @@
</span><span class="cx"> PASS exportedJWK.qi is privateKeyJSON.qi
</span><span class="cx"> PASS exportedJWK.oth is privateKeyJSON.oth
</span><span class="cx"> PASS exportedJWK.alg is privateKeyJSON.alg
</span><del>-PASS exportedJWK.extractable is true
</del><ins>+PASS exportedJWK.ext is true
</ins><span class="cx"> PASS exportedJWK.use is 'sig'
</span><span class="cx"> PASS successfullyParsed is true
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaexportprivatekeyhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/crypto/subtle/rsa-export-private-key.html (160060 => 160061)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-export-private-key.html        2013-12-04 00:51:13 UTC (rev 160060)
+++ trunk/LayoutTests/crypto/subtle/rsa-export-private-key.html        2013-12-04 00:51:14 UTC (rev 160061)
</span><span class="lines">@@ -52,7 +52,7 @@
</span><span class="cx">     shouldBe(&quot;exportedJWK.qi&quot;, &quot;privateKeyJSON.qi&quot;);
</span><span class="cx">     shouldBe(&quot;exportedJWK.oth&quot;, &quot;privateKeyJSON.oth&quot;);
</span><span class="cx">     shouldBe(&quot;exportedJWK.alg&quot;, &quot;privateKeyJSON.alg&quot;);
</span><del>-    shouldBe(&quot;exportedJWK.extractable&quot;, &quot;true&quot;);
</del><ins>+    shouldBe(&quot;exportedJWK.ext&quot;, &quot;true&quot;);
</ins><span class="cx">     shouldBe(&quot;exportedJWK.use&quot;, &quot;'sig'&quot;);
</span><span class="cx"> 
</span><span class="cx">     finishJSTest();
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaoaepkeymanipulationexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/crypto/subtle/rsa-oaep-key-manipulation-expected.txt (160060 => 160061)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-key-manipulation-expected.txt        2013-12-04 00:51:13 UTC (rev 160060)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-key-manipulation-expected.txt        2013-12-04 00:51:14 UTC (rev 160061)
</span><span class="lines">@@ -26,7 +26,7 @@
</span><span class="cx"> 
</span><span class="cx"> Exporting public key to JWK...
</span><span class="cx"> PASS jwkPublicKey.alg is 'RSA-OAEP'
</span><del>-PASS jwkPublicKey.extractable is true
</del><ins>+PASS jwkPublicKey.ext is true
</ins><span class="cx"> PASS jwkPublicKey.use is 'enc'
</span><span class="cx"> PASS jwkPublicKey.kty is 'RSA'
</span><span class="cx"> PASS bytesToHexString(Base64URL.parse(jwkPublicKey.e)) is '010001'
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaoaepkeymanipulationhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/crypto/subtle/rsa-oaep-key-manipulation.html (160060 => 160061)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-key-manipulation.html        2013-12-04 00:51:13 UTC (rev 160060)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-key-manipulation.html        2013-12-04 00:51:14 UTC (rev 160061)
</span><span class="lines">@@ -55,7 +55,7 @@
</span><span class="cx">     jwkPublicKeyArray = result;
</span><span class="cx">     jwkPublicKey = JSON.parse(bytesToASCIIString(jwkPublicKeyArray));
</span><span class="cx">     shouldBe(&quot;jwkPublicKey.alg&quot;, &quot;'RSA-OAEP'&quot;);
</span><del>-    shouldBe(&quot;jwkPublicKey.extractable&quot;, &quot;true&quot;);
</del><ins>+    shouldBe(&quot;jwkPublicKey.ext&quot;, &quot;true&quot;);
</ins><span class="cx">     shouldBe(&quot;jwkPublicKey.use&quot;, &quot;'enc'&quot;);
</span><span class="cx">     shouldBe(&quot;jwkPublicKey.kty&quot;, &quot;'RSA'&quot;);
</span><span class="cx">     shouldBe(&quot;bytesToHexString(Base64URL.parse(jwkPublicKey.e))&quot;, &quot;'010001'&quot;);
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (160060 => 160061)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2013-12-04 00:51:13 UTC (rev 160060)
+++ trunk/Source/WebCore/ChangeLog        2013-12-04 00:51:14 UTC (rev 160061)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2013-12-03  Alexey Proskuryakov  &lt;ap@apple.com&gt;
+
+        Update WebCrypto JWK mapping to newer proposal
+        https://bugs.webkit.org/show_bug.cgi?id=124218
+
+        Reviewed by Anders Carlsson.
+
+        Tests: crypto/subtle/jwk-export-use-values.html
+               crypto/subtle/jwk-import-use-values.html
+
+        1. &quot;extractable&quot; renamed to &quot;ext&quot; in JWK.
+        2. New values for &quot;use&quot; mapping, which can now be combined into comma separated lists,
+        and cover all possible WebCrypto usages.
+
+        * bindings/js/JSCryptoKeySerializationJWK.cpp:
+        (WebCore::JSCryptoKeySerializationJWK::reconcileUsages):
+        (WebCore::JSCryptoKeySerializationJWK::reconcileExtractable):
+        (WebCore::JSCryptoKeySerializationJWK::addJWKAlgorithmToJSON):
+        (WebCore::processUseValue):
+        (WebCore::JSCryptoKeySerializationJWK::addJWKUseToJSON):
+        (WebCore::JSCryptoKeySerializationJWK::serialize):
+
</ins><span class="cx"> 2013-12-03  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Remove some iOS-related documentScale code
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSCryptoKeySerializationJWKcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSCryptoKeySerializationJWK.cpp (160060 => 160061)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSCryptoKeySerializationJWK.cpp        2013-12-04 00:51:13 UTC (rev 160060)
+++ trunk/Source/WebCore/bindings/js/JSCryptoKeySerializationJWK.cpp        2013-12-04 00:51:14 UTC (rev 160061)
</span><span class="lines">@@ -245,7 +245,7 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void JSCryptoKeySerializationJWK::reconcileUsages(CryptoKeyUsage&amp; suggestedUsage) const
</del><ins>+void JSCryptoKeySerializationJWK::reconcileUsages(CryptoKeyUsage&amp; suggestedUsages) const
</ins><span class="cx"> {
</span><span class="cx">     String jwkUseString;
</span><span class="cx">     if (!getStringFromJSON(m_exec, m_json.get(), &quot;use&quot;, jwkUseString)) {
</span><span class="lines">@@ -253,23 +253,42 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    // FIXME: CryptoKeyUsageDeriveKey, CryptoKeyUsageDeriveBits - should these be implicitly allowed by any JWK use value?
-    // FIXME: &quot;use&quot; mapping is in flux, see &lt;https://www.w3.org/Bugs/Public/show_bug.cgi?id=23796&gt;.
-    if (jwkUseString == &quot;sig&quot;)
-        suggestedUsage = suggestedUsage &amp; (CryptoKeyUsageSign | CryptoKeyUsageVerify);
-    else if (jwkUseString == &quot;enc&quot;)
-        suggestedUsage = suggestedUsage &amp; (CryptoKeyUsageEncrypt | CryptoKeyUsageDecrypt | CryptoKeyUsageWrapKey | CryptoKeyUsageUnwrapKey);
-    else if (jwkUseString == &quot;wrap&quot;)
-        suggestedUsage = suggestedUsage &amp; (CryptoKeyUsageWrapKey | CryptoKeyUsageUnwrapKey);
-    else
-        suggestedUsage = 0; // Unknown usage, better be safe.
</del><ins>+    // Implemented according to a proposal in &lt;https://www.w3.org/Bugs/Public/show_bug.cgi?id=23796&gt;.
+    Vector&lt;String&gt; jwkUsageValues;
+    jwkUseString.split(',', jwkUsageValues);
+    CryptoKeyUsage jwkUsages = 0;
+    for (size_t i = 0, size = jwkUsageValues.size(); i &lt; size; ++i) {
+        String jwkUse = jwkUsageValues[i];
+        if (jwkUse == &quot;sig&quot;)
+            jwkUsages |= (CryptoKeyUsageSign | CryptoKeyUsageVerify);
+        else if (jwkUse == &quot;enc&quot;)
+            jwkUsages |= (CryptoKeyUsageEncrypt | CryptoKeyUsageDecrypt | CryptoKeyUsageWrapKey | CryptoKeyUsageUnwrapKey);
+        else if (jwkUse == &quot;enconly&quot;)
+            jwkUsages |= CryptoKeyUsageEncrypt;
+        else if (jwkUse == &quot;deconly&quot;)
+            jwkUsages |= CryptoKeyUsageDecrypt;
+        else if (jwkUse == &quot;sigonly&quot;)
+            jwkUsages |= CryptoKeyUsageSign;
+        else if (jwkUse == &quot;vfyonly&quot;)
+            jwkUsages |= CryptoKeyUsageVerify;
+        else if (jwkUse == &quot;drvkey&quot;)
+            jwkUsages |= CryptoKeyUsageDeriveKey;
+        else if (jwkUse == &quot;drvbits&quot;)
+            jwkUsages |= CryptoKeyUsageDeriveBits;
+        else if (jwkUse == &quot;wrap&quot;)
+            jwkUsages |= CryptoKeyUsageWrapKey;
+        else if (jwkUse == &quot;unwrap&quot;)
+            jwkUsages |= CryptoKeyUsageUnwrapKey;
+    }
+
+    suggestedUsages = suggestedUsages &amp; jwkUsages;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void JSCryptoKeySerializationJWK::reconcileExtractable(bool&amp; suggestedExtractable) const
</span><span class="cx"> {
</span><span class="cx">     bool jwkExtractable;
</span><del>-    if (!getBooleanFromJSON(m_exec, m_json.get(), &quot;extractable&quot;, jwkExtractable)) {
-        // &quot;extractable&quot; is a Netflix proposal that's not in any spec yet. It will certainly be optional once specified.
</del><ins>+    if (!getBooleanFromJSON(m_exec, m_json.get(), &quot;ext&quot;, jwkExtractable)) {
+        // &quot;ext&quot; not in JWK or WebCrypto specs yet, implemented according to a proposal in &lt;https://www.w3.org/Bugs/Public/show_bug.cgi?id=23796&gt;.
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -589,7 +608,6 @@
</span><span class="cx"> 
</span><span class="cx">     if (jwkAlgorithm.isNull()) {
</span><span class="cx">         // The spec doesn't currently tell whether export should fail, or just skip &quot;alg&quot; (which is an optional key in JWK).
</span><del>-        // Perhaps this should depend on whether the key is extractable?
</del><span class="cx">         throwTypeError(exec, &quot;Key algorithm and size do not map to any JWK algorithm identifier&quot;);
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="lines">@@ -597,19 +615,51 @@
</span><span class="cx">     addToJSON(exec, json, &quot;alg&quot;, jwkAlgorithm);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static bool processUseValue(StringBuilder&amp; builder, CryptoKeyUsage&amp; usages, const String&amp; useString, CryptoKeyUsage usagesForUseString)
+{
+    if ((usages &amp; usagesForUseString) != usagesForUseString)
+        return false;
+
+    if (!builder.isEmpty())
+        builder.append(',');
+    builder.append(useString);
+
+    usages &amp;= ~usagesForUseString;
+
+    return true;
+}
+
</ins><span class="cx"> void JSCryptoKeySerializationJWK::addJWKUseToJSON(ExecState* exec, JSObject* json, CryptoKeyUsage usages)
</span><span class="cx"> {
</span><del>-    // FIXME: &quot;use&quot; mapping is in flux, see &lt;https://www.w3.org/Bugs/Public/show_bug.cgi?id=23796&gt;.
-    switch (usages) {
-    case CryptoKeyUsageEncrypt | CryptoKeyUsageDecrypt | CryptoKeyUsageWrapKey | CryptoKeyUsageUnwrapKey:
-        addToJSON(exec, json, &quot;use&quot;, &quot;enc&quot;);
-        break;
-    case CryptoKeyUsageSign | CryptoKeyUsageVerify:
-        addToJSON(exec, json, &quot;use&quot;, &quot;sig&quot;);
-        break;
-    default:
-        throwTypeError(exec, &quot;Key usages cannot be represented in JWK. Only two variants are supported: sign+verify and encrypt+decrypt+wrapKey+unwrapKey&quot;);
</del><ins>+    // Use mapping implemented according to a proposal in &lt;https://www.w3.org/Bugs/Public/show_bug.cgi?id=23796&gt;.
+    StringBuilder useBuilder;
+    CryptoKeyUsage remainingUsages = usages;
+    while (remainingUsages) {
+        if (processUseValue(useBuilder, remainingUsages, &quot;enc&quot;, CryptoKeyUsageEncrypt | CryptoKeyUsageDecrypt | CryptoKeyUsageWrapKey | CryptoKeyUsageUnwrapKey))
+            continue;
+        if (processUseValue(useBuilder, remainingUsages, &quot;sig&quot;, CryptoKeyUsageSign | CryptoKeyUsageVerify))
+            continue;
+        if (processUseValue(useBuilder, remainingUsages, &quot;enconly&quot;, CryptoKeyUsageEncrypt))
+            continue;
+        if (processUseValue(useBuilder, remainingUsages, &quot;deconly&quot;, CryptoKeyUsageDecrypt))
+            continue;
+        if (processUseValue(useBuilder, remainingUsages, &quot;sigonly&quot;, CryptoKeyUsageSign))
+            continue;
+        if (processUseValue(useBuilder, remainingUsages, &quot;vfyonly&quot;, CryptoKeyUsageVerify))
+            continue;
+        if (processUseValue(useBuilder, remainingUsages, &quot;drvkey&quot;, CryptoKeyUsageDeriveKey))
+            continue;
+        if (processUseValue(useBuilder, remainingUsages, &quot;drvbits&quot;, CryptoKeyUsageDeriveBits))
+            continue;
+        if (processUseValue(useBuilder, remainingUsages, &quot;wrap&quot;, CryptoKeyUsageWrapKey))
+            continue;
+        if (processUseValue(useBuilder, remainingUsages, &quot;unwrap&quot;, CryptoKeyUsageUnwrapKey))
+            continue;
+        throwTypeError(exec, &quot;Key usages cannot be represented in JWK.&quot;);
+        return;
</ins><span class="cx">     }
</span><ins>+
+    addToJSON(exec, json, &quot;use&quot;, useBuilder.toString());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> String JSCryptoKeySerializationJWK::serialize(ExecState* exec, const CryptoKey&amp; key)
</span><span class="lines">@@ -627,7 +677,7 @@
</span><span class="cx">     if (exec-&gt;hadException())
</span><span class="cx">         return String();
</span><span class="cx"> 
</span><del>-    addBoolToJSON(exec, result, &quot;extractable&quot;, key.extractable());
</del><ins>+    addBoolToJSON(exec, result, &quot;ext&quot;, key.extractable());
</ins><span class="cx"> 
</span><span class="cx">     addJWKUseToJSON(exec, result, key.usagesBitmap());
</span><span class="cx">     if (exec-&gt;hadException())
</span></span></pre>
</div>
</div>

</body>
</html>