<!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>[209657] 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/209657">209657</a></dd>
<dt>Author</dt> <dd>jiewen_tan@apple.com</dd>
<dt>Date</dt> <dd>2016-12-10 00:57:42 -0800 (Sat, 10 Dec 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>[WebCrypto] RSA algorithms should allow importing keys without usages
https://bugs.webkit.org/show_bug.cgi?id=165680
&lt;rdar://problem/29601354&gt;

Reviewed by Brent Fulgham.

LayoutTests/imported/w3c:

* WebCryptoAPI/encrypt_decrypt/test_rsa_oaep-expected.txt:

Source/WebCore:

Tests: crypto/subtle/rsa-oaep-import-jwk-public-key-empty-usages.html
       crypto/subtle/rsa-oaep-import-spki-key-empty-usages.html
       crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-empty-usages.html
       crypto/subtle/rsaes-pkcs1-v1_5-import-spki-key-empty-usages.html
       crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-empty-usages.html
       crypto/subtle/rsassa-pkcs1-v1_5-import-spki-key-empty-usages.html

* crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp:
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::importKey):
* crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp:
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::importKey):
* crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp:
(WebCore::CryptoAlgorithmRSA_OAEP::importKey):

LayoutTests:

* crypto/subtle/rsa-oaep-import-jwk-public-key-empty-usages-expected.txt: Added.
* crypto/subtle/rsa-oaep-import-jwk-public-key-empty-usages.html: Added.
* crypto/subtle/rsa-oaep-import-spki-key-empty-usages-expected.txt: Added.
* crypto/subtle/rsa-oaep-import-spki-key-empty-usages.html: Added.
* crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-empty-usages-expected.txt: Added.
* crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-empty-usages.html: Added.
* crypto/subtle/rsaes-pkcs1-v1_5-import-spki-key-empty-usages-expected.txt: Added.
* crypto/subtle/rsaes-pkcs1-v1_5-import-spki-key-empty-usages.html: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-empty-usages-expected.txt: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-empty-usages.html: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-spki-key-empty-usages-expected.txt: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-spki-key-empty-usages.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cWebCryptoAPIencrypt_decrypttest_rsa_oaepexpectedtxt">trunk/LayoutTests/imported/w3c/WebCryptoAPI/encrypt_decrypt/test_rsa_oaep-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSAES_PKCS1_v1_5cpp">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSASSA_PKCS1_v1_5cpp">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSA_OAEPcpp">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestscryptosubtlersaoaepimportjwkpublickeyemptyusagesexpectedtxt">trunk/LayoutTests/crypto/subtle/rsa-oaep-import-jwk-public-key-empty-usages-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaoaepimportjwkpublickeyemptyusageshtml">trunk/LayoutTests/crypto/subtle/rsa-oaep-import-jwk-public-key-empty-usages.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaoaepimportspkikeyemptyusagesexpectedtxt">trunk/LayoutTests/crypto/subtle/rsa-oaep-import-spki-key-empty-usages-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaoaepimportspkikeyemptyusageshtml">trunk/LayoutTests/crypto/subtle/rsa-oaep-import-spki-key-empty-usages.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaespkcs1v1_5importjwkpublickeyemptyusagesexpectedtxt">trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-empty-usages-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaespkcs1v1_5importjwkpublickeyemptyusageshtml">trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-empty-usages.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaespkcs1v1_5importspkikeyemptyusagesexpectedtxt">trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-spki-key-empty-usages-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaespkcs1v1_5importspkikeyemptyusageshtml">trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-spki-key-empty-usages.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5importjwkpublickeyemptyusagesexpectedtxt">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-empty-usages-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5importjwkpublickeyemptyusageshtml">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-empty-usages.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5importspkikeyemptyusagesexpectedtxt">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-spki-key-empty-usages-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5importspkikeyemptyusageshtml">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-spki-key-empty-usages.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (209656 => 209657)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-12-10 08:43:46 UTC (rev 209656)
+++ trunk/LayoutTests/ChangeLog        2016-12-10 08:57:42 UTC (rev 209657)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2016-12-10  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
+
+        [WebCrypto] RSA algorithms should allow importing keys without usages
+        https://bugs.webkit.org/show_bug.cgi?id=165680
+        &lt;rdar://problem/29601354&gt;
+
+        Reviewed by Brent Fulgham.
+
+        * crypto/subtle/rsa-oaep-import-jwk-public-key-empty-usages-expected.txt: Added.
+        * crypto/subtle/rsa-oaep-import-jwk-public-key-empty-usages.html: Added.
+        * crypto/subtle/rsa-oaep-import-spki-key-empty-usages-expected.txt: Added.
+        * crypto/subtle/rsa-oaep-import-spki-key-empty-usages.html: Added.
+        * crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-empty-usages-expected.txt: Added.
+        * crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-empty-usages.html: Added.
+        * crypto/subtle/rsaes-pkcs1-v1_5-import-spki-key-empty-usages-expected.txt: Added.
+        * crypto/subtle/rsaes-pkcs1-v1_5-import-spki-key-empty-usages.html: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-empty-usages-expected.txt: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-empty-usages.html: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-import-spki-key-empty-usages-expected.txt: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-import-spki-key-empty-usages.html: Added.
+
</ins><span class="cx"> 2016-12-09  Romain Bellessort  &lt;romain.bellessort@crf.canon.fr&gt;
</span><span class="cx"> 
</span><span class="cx">         [Readable Streams API] Implement ReadableByteStreamController desiredSize
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaoaepimportjwkpublickeyemptyusagesexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-oaep-import-jwk-public-key-empty-usages-expected.txt (0 => 209657)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-import-jwk-public-key-empty-usages-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-import-jwk-public-key-empty-usages-expected.txt        2016-12-10 08:57:42 UTC (rev 209657)
</span><span class="lines">@@ -0,0 +1,18 @@
</span><ins>+Test importing a JWK RSA-OAEP public key with SHA-1 and empty usages
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Importing a key...
+PASS publicKey.toString() is '[object CryptoKey]'
+PASS publicKey.type is 'public'
+PASS publicKey.extractable is true
+PASS publicKey.algorithm.name is 'RSA-OAEP'
+PASS publicKey.algorithm.modulusLength is 2048
+PASS bytesToHexString(publicKey.algorithm.publicExponent) is '010001'
+PASS publicKey.algorithm.hash.name is 'SHA-1'
+PASS publicKey.usages is [ ]
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaoaepimportjwkpublickeyemptyusageshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-oaep-import-jwk-public-key-empty-usages.html (0 => 209657)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-import-jwk-public-key-empty-usages.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-import-jwk-public-key-empty-usages.html        2016-12-10 08:57:42 UTC (rev 209657)
</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 empty usages&quot;);
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: &quot;RSA&quot;,
+    alg: &quot;RSA-OAEP&quot;,
+    use: &quot;enc&quot;,
+    key_ops: [&quot;encrypt&quot;, &quot;wrapKey&quot;],
+    ext: true,
+    n: &quot;rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw&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, [ ]).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;publicKey.toString()&quot;, &quot;'[object CryptoKey]'&quot;);
+    shouldBe(&quot;publicKey.type&quot;, &quot;'public'&quot;);
+    shouldBe(&quot;publicKey.extractable&quot;, &quot;true&quot;);
+    shouldBe(&quot;publicKey.algorithm.name&quot;, &quot;'RSA-OAEP'&quot;);
+    shouldBe(&quot;publicKey.algorithm.modulusLength&quot;, &quot;2048&quot;);
+    shouldBe(&quot;bytesToHexString(publicKey.algorithm.publicExponent)&quot;, &quot;'010001'&quot;);
+    shouldBe(&quot;publicKey.algorithm.hash.name&quot;, &quot;'SHA-1'&quot;);
+    shouldBe(&quot;publicKey.usages&quot;, &quot;[ ]&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="trunkLayoutTestscryptosubtlersaoaepimportspkikeyemptyusagesexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-oaep-import-spki-key-empty-usages-expected.txt (0 => 209657)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-import-spki-key-empty-usages-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-import-spki-key-empty-usages-expected.txt        2016-12-10 08:57:42 UTC (rev 209657)
</span><span class="lines">@@ -0,0 +1,18 @@
</span><ins>+Test importing a SPKI RSA-OAEP key with empty usages
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Importing a key...
+PASS publicKey.toString() is '[object CryptoKey]'
+PASS publicKey.type is 'public'
+PASS publicKey.extractable is true
+PASS publicKey.algorithm.name is 'RSA-OAEP'
+PASS publicKey.algorithm.modulusLength is 2048
+PASS bytesToHexString(publicKey.algorithm.publicExponent) is '010001'
+PASS publicKey.algorithm.hash.name is 'SHA-1'
+PASS publicKey.usages is [ ]
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaoaepimportspkikeyemptyusageshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-oaep-import-spki-key-empty-usages.html (0 => 209657)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-import-spki-key-empty-usages.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-import-spki-key-empty-usages.html        2016-12-10 08:57:42 UTC (rev 209657)
</span><span class="lines">@@ -0,0 +1,40 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test importing a SPKI RSA-OAEP key with empty usages&quot;);
+
+jsTestIsAsync = true;
+
+// Generated from OpenSSL
+var spkiKey = Base64URL.parse(&quot;MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwCjRCtFwvSNYMZ07u5SxARxglJl75T7bUZXFsDVxHkMhpNC2RaN4jWE5bwYUDMeD2fVmxhpaUQn/6AbFLh6gHxtwrCfc7rIo/SfDdGd3GkRlXK5xXwGuM6MvP9nuZHaarIyArRFh2U2UZxFlVsKI0pSHo6n58W1fPZ1syOoVEZ/WYE6gLhMMwfpeAm97mro7mekRdMULOV/mR5Ul3CHm9Zt93Dc8GpnPA8bhLiB0VNyGTEMa06nJul4gj1sjxLDoUvZY2EWq7oUUnfLBUYMfiqK0kQcW94wvBrIq2DQUApLyTTbaAOY46TLwX6c8LtubJriYKTC5a9Bb0/7ovTWB0wIDAQAB&quot;);
+var extractable = true;
+
+debug(&quot;Importing a key...&quot;);
+crypto.subtle.importKey(&quot;spki&quot;, spkiKey, {name: &quot;RSA-OAEP&quot;, hash: &quot;sha-1&quot;}, extractable, [ ]).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;publicKey.toString()&quot;, &quot;'[object CryptoKey]'&quot;);
+    shouldBe(&quot;publicKey.type&quot;, &quot;'public'&quot;);
+    shouldBe(&quot;publicKey.extractable&quot;, &quot;true&quot;);
+    shouldBe(&quot;publicKey.algorithm.name&quot;, &quot;'RSA-OAEP'&quot;);
+    shouldBe(&quot;publicKey.algorithm.modulusLength&quot;, &quot;2048&quot;);
+    shouldBe(&quot;bytesToHexString(publicKey.algorithm.publicExponent)&quot;, &quot;'010001'&quot;);
+    shouldBe(&quot;publicKey.algorithm.hash.name&quot;, &quot;'SHA-1'&quot;);
+    shouldBe(&quot;publicKey.usages&quot;, &quot;[ ]&quot;);
+
+    finishJSTest();
+});
+
+&lt;/script&gt;
+
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaespkcs1v1_5importjwkpublickeyemptyusagesexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-empty-usages-expected.txt (0 => 209657)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-empty-usages-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-empty-usages-expected.txt        2016-12-10 08:57:42 UTC (rev 209657)
</span><span class="lines">@@ -0,0 +1,18 @@
</span><ins>+Test importing a JWK RSAES-PKCS1-v1_5 public key with empty usages
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Importing a key...
+PASS publicKey.toString() is '[object CryptoKey]'
+PASS publicKey.type is 'public'
+PASS publicKey.extractable is true
+PASS publicKey.algorithm.name is 'RSAES-PKCS1-v1_5'
+PASS publicKey.algorithm.modulusLength is 2048
+PASS bytesToHexString(publicKey.algorithm.publicExponent) is '010001'
+PASS publicKey.algorithm.hash is undefined.
+PASS publicKey.usages is [ ]
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaespkcs1v1_5importjwkpublickeyemptyusageshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-empty-usages.html (0 => 209657)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-empty-usages.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-empty-usages.html        2016-12-10 08:57:42 UTC (rev 209657)
</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 RSAES-PKCS1-v1_5 public key with empty usages&quot;);
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: &quot;RSA&quot;,
+    alg: &quot;RSA1_5&quot;,
+    use: &quot;enc&quot;,
+    key_ops: [&quot;encrypt&quot;],
+    ext: true,
+    n: &quot;rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw&quot;,
+    e: &quot;AQAB&quot;
+};
+var extractable = true;
+
+debug(&quot;Importing a key...&quot;);
+crypto.subtle.importKey(&quot;jwk&quot;, jwkKey, &quot;RSAES-PKCS1-v1_5&quot;, extractable, [ ]).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;publicKey.toString()&quot;, &quot;'[object CryptoKey]'&quot;);
+    shouldBe(&quot;publicKey.type&quot;, &quot;'public'&quot;);
+    shouldBe(&quot;publicKey.extractable&quot;, &quot;true&quot;);
+    shouldBe(&quot;publicKey.algorithm.name&quot;, &quot;'RSAES-PKCS1-v1_5'&quot;);
+    shouldBe(&quot;publicKey.algorithm.modulusLength&quot;, &quot;2048&quot;);
+    shouldBe(&quot;bytesToHexString(publicKey.algorithm.publicExponent)&quot;, &quot;'010001'&quot;);
+    shouldBeUndefined(&quot;publicKey.algorithm.hash&quot;);
+    shouldBe(&quot;publicKey.usages&quot;, &quot;[ ]&quot;);
+
+    finishJSTest();
+});
+
+&lt;/script&gt;
+
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaespkcs1v1_5importspkikeyemptyusagesexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-spki-key-empty-usages-expected.txt (0 => 209657)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-spki-key-empty-usages-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-spki-key-empty-usages-expected.txt        2016-12-10 08:57:42 UTC (rev 209657)
</span><span class="lines">@@ -0,0 +1,18 @@
</span><ins>+Test importing a SPKI RSAES-PKCS1-v1_5 key with empty usages
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Importing a key...
+PASS publicKey.toString() is '[object CryptoKey]'
+PASS publicKey.type is 'public'
+PASS publicKey.extractable is true
+PASS publicKey.algorithm.name is 'RSAES-PKCS1-v1_5'
+PASS publicKey.algorithm.modulusLength is 2048
+PASS bytesToHexString(publicKey.algorithm.publicExponent) is '010001'
+PASS publicKey.algorithm.hash is undefined.
+PASS publicKey.usages is [ ]
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaespkcs1v1_5importspkikeyemptyusageshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-spki-key-empty-usages.html (0 => 209657)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-spki-key-empty-usages.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-spki-key-empty-usages.html        2016-12-10 08:57:42 UTC (rev 209657)
</span><span class="lines">@@ -0,0 +1,40 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test importing a SPKI RSAES-PKCS1-v1_5 key with empty usages&quot;);
+
+jsTestIsAsync = true;
+
+// Generated from OpenSSL
+var spkiKey = Base64URL.parse(&quot;MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwCjRCtFwvSNYMZ07u5SxARxglJl75T7bUZXFsDVxHkMhpNC2RaN4jWE5bwYUDMeD2fVmxhpaUQn/6AbFLh6gHxtwrCfc7rIo/SfDdGd3GkRlXK5xXwGuM6MvP9nuZHaarIyArRFh2U2UZxFlVsKI0pSHo6n58W1fPZ1syOoVEZ/WYE6gLhMMwfpeAm97mro7mekRdMULOV/mR5Ul3CHm9Zt93Dc8GpnPA8bhLiB0VNyGTEMa06nJul4gj1sjxLDoUvZY2EWq7oUUnfLBUYMfiqK0kQcW94wvBrIq2DQUApLyTTbaAOY46TLwX6c8LtubJriYKTC5a9Bb0/7ovTWB0wIDAQAB&quot;);
+var extractable = true;
+
+debug(&quot;Importing a key...&quot;);
+crypto.subtle.importKey(&quot;spki&quot;, spkiKey, &quot;RSAES-PKCS1-v1_5&quot;, extractable, [ ]).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;publicKey.toString()&quot;, &quot;'[object CryptoKey]'&quot;);
+    shouldBe(&quot;publicKey.type&quot;, &quot;'public'&quot;);
+    shouldBe(&quot;publicKey.extractable&quot;, &quot;true&quot;);
+    shouldBe(&quot;publicKey.algorithm.name&quot;, &quot;'RSAES-PKCS1-v1_5'&quot;);
+    shouldBe(&quot;publicKey.algorithm.modulusLength&quot;, &quot;2048&quot;);
+    shouldBe(&quot;bytesToHexString(publicKey.algorithm.publicExponent)&quot;, &quot;'010001'&quot;);
+    shouldBeUndefined(&quot;publicKey.algorithm.hash&quot;);
+    shouldBe(&quot;publicKey.usages&quot;, &quot;[ ]&quot;);
+
+    finishJSTest();
+});
+
+&lt;/script&gt;
+
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersassapkcs1v1_5importjwkpublickeyemptyusagesexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-empty-usages-expected.txt (0 => 209657)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-empty-usages-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-empty-usages-expected.txt        2016-12-10 08:57:42 UTC (rev 209657)
</span><span class="lines">@@ -0,0 +1,18 @@
</span><ins>+Test importing a JWK RSASSA-PKCS1-v1_5 public key with SHA-1 and empty usages
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Importing a key...
+PASS publicKey.toString() is '[object CryptoKey]'
+PASS publicKey.type is 'public'
+PASS publicKey.extractable is true
+PASS publicKey.algorithm.name is 'RSASSA-PKCS1-v1_5'
+PASS publicKey.algorithm.modulusLength is 2048
+PASS bytesToHexString(publicKey.algorithm.publicExponent) is '010001'
+PASS publicKey.algorithm.hash.name is 'SHA-1'
+PASS publicKey.usages is [ ]
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersassapkcs1v1_5importjwkpublickeyemptyusageshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-empty-usages.html (0 => 209657)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-empty-usages.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-empty-usages.html        2016-12-10 08:57:42 UTC (rev 209657)
</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 RSASSA-PKCS1-v1_5 public key with SHA-1 and empty usages&quot;);
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: &quot;RSA&quot;,
+    alg: &quot;RS1&quot;,
+    use: &quot;sig&quot;,
+    key_ops: [&quot;verify&quot;],
+    ext: true,
+    n: &quot;rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw&quot;,
+    e: &quot;AQAB&quot;
+};
+var extractable = true;
+
+debug(&quot;Importing a key...&quot;);
+crypto.subtle.importKey(&quot;jwk&quot;, jwkKey, {name: &quot;RSASSA-PKCS1-v1_5&quot;, hash: &quot;SHA-1&quot;}, extractable, [ ]).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;publicKey.toString()&quot;, &quot;'[object CryptoKey]'&quot;);
+    shouldBe(&quot;publicKey.type&quot;, &quot;'public'&quot;);
+    shouldBe(&quot;publicKey.extractable&quot;, &quot;true&quot;);
+    shouldBe(&quot;publicKey.algorithm.name&quot;, &quot;'RSASSA-PKCS1-v1_5'&quot;);
+    shouldBe(&quot;publicKey.algorithm.modulusLength&quot;, &quot;2048&quot;);
+    shouldBe(&quot;bytesToHexString(publicKey.algorithm.publicExponent)&quot;, &quot;'010001'&quot;);
+    shouldBe(&quot;publicKey.algorithm.hash.name&quot;, &quot;'SHA-1'&quot;);
+    shouldBe(&quot;publicKey.usages&quot;, &quot;[ ]&quot;);
+
+    finishJSTest();
+});
+
+&lt;/script&gt;
+
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersassapkcs1v1_5importspkikeyemptyusagesexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-spki-key-empty-usages-expected.txt (0 => 209657)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-spki-key-empty-usages-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-spki-key-empty-usages-expected.txt        2016-12-10 08:57:42 UTC (rev 209657)
</span><span class="lines">@@ -0,0 +1,18 @@
</span><ins>+Test importing a SPKI RSASSA-PKCS1-v1_5 key with empty usages
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Importing a key...
+PASS publicKey.toString() is '[object CryptoKey]'
+PASS publicKey.type is 'public'
+PASS publicKey.extractable is true
+PASS publicKey.algorithm.name is 'RSASSA-PKCS1-v1_5'
+PASS publicKey.algorithm.modulusLength is 2048
+PASS bytesToHexString(publicKey.algorithm.publicExponent) is '010001'
+PASS publicKey.algorithm.hash.name is 'SHA-1'
+PASS publicKey.usages is [ ]
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersassapkcs1v1_5importspkikeyemptyusageshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-spki-key-empty-usages.html (0 => 209657)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-spki-key-empty-usages.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-spki-key-empty-usages.html        2016-12-10 08:57:42 UTC (rev 209657)
</span><span class="lines">@@ -0,0 +1,40 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test importing a SPKI RSASSA-PKCS1-v1_5 key with empty usages&quot;);
+
+jsTestIsAsync = true;
+
+// Generated from OpenSSL
+var spkiKey = Base64URL.parse(&quot;MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwCjRCtFwvSNYMZ07u5SxARxglJl75T7bUZXFsDVxHkMhpNC2RaN4jWE5bwYUDMeD2fVmxhpaUQn/6AbFLh6gHxtwrCfc7rIo/SfDdGd3GkRlXK5xXwGuM6MvP9nuZHaarIyArRFh2U2UZxFlVsKI0pSHo6n58W1fPZ1syOoVEZ/WYE6gLhMMwfpeAm97mro7mekRdMULOV/mR5Ul3CHm9Zt93Dc8GpnPA8bhLiB0VNyGTEMa06nJul4gj1sjxLDoUvZY2EWq7oUUnfLBUYMfiqK0kQcW94wvBrIq2DQUApLyTTbaAOY46TLwX6c8LtubJriYKTC5a9Bb0/7ovTWB0wIDAQAB&quot;);
+var extractable = true;
+
+debug(&quot;Importing a key...&quot;);
+crypto.subtle.importKey(&quot;spki&quot;, spkiKey, {name: &quot;RSASSA-PKCS1-v1_5&quot;, hash: &quot;sha-1&quot;}, extractable, [ ]).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;publicKey.toString()&quot;, &quot;'[object CryptoKey]'&quot;);
+    shouldBe(&quot;publicKey.type&quot;, &quot;'public'&quot;);
+    shouldBe(&quot;publicKey.extractable&quot;, &quot;true&quot;);
+    shouldBe(&quot;publicKey.algorithm.name&quot;, &quot;'RSASSA-PKCS1-v1_5'&quot;);
+    shouldBe(&quot;publicKey.algorithm.modulusLength&quot;, &quot;2048&quot;);
+    shouldBe(&quot;bytesToHexString(publicKey.algorithm.publicExponent)&quot;, &quot;'010001'&quot;);
+    shouldBe(&quot;publicKey.algorithm.hash.name&quot;, &quot;'SHA-1'&quot;);
+    shouldBe(&quot;publicKey.usages&quot;, &quot;[ ]&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="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (209656 => 209657)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog        2016-12-10 08:43:46 UTC (rev 209656)
+++ trunk/LayoutTests/imported/w3c/ChangeLog        2016-12-10 08:57:42 UTC (rev 209657)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2016-12-10  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
+
+        [WebCrypto] RSA algorithms should allow importing keys without usages
+        https://bugs.webkit.org/show_bug.cgi?id=165680
+        &lt;rdar://problem/29601354&gt;
+
+        Reviewed by Brent Fulgham.
+
+        * WebCryptoAPI/encrypt_decrypt/test_rsa_oaep-expected.txt:
+
</ins><span class="cx"> 2016-12-09  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Ignore LayoutTests/imported/w3c/web-platform-tests/config.json
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cWebCryptoAPIencrypt_decrypttest_rsa_oaepexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/WebCryptoAPI/encrypt_decrypt/test_rsa_oaep-expected.txt (209656 => 209657)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/WebCryptoAPI/encrypt_decrypt/test_rsa_oaep-expected.txt        2016-12-10 08:43:46 UTC (rev 209656)
+++ trunk/LayoutTests/imported/w3c/WebCryptoAPI/encrypt_decrypt/test_rsa_oaep-expected.txt        2016-12-10 08:57:42 UTC (rev 209657)
</span><span class="lines">@@ -97,16 +97,16 @@
</span><span class="cx"> PASS RSA-OAEP with SHA-256 and a label using privateKey to encrypt 
</span><span class="cx"> PASS RSA-OAEP with SHA-384 and a label using privateKey to encrypt 
</span><span class="cx"> PASS RSA-OAEP with SHA-512 and a label using privateKey to encrypt 
</span><del>-FAIL importVectorKeys step: RSA-OAEP with SHA-1 and no label no encrypt usage assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-1 and no label. Message: ''A required parameter was missing or out-of-range'' Reached unreachable code
-FAIL importVectorKeys step: RSA-OAEP with SHA-256 and no label no encrypt usage assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-256 and no label. Message: ''A required parameter was missing or out-of-range'' Reached unreachable code
-FAIL importVectorKeys step: RSA-OAEP with SHA-384 and no label no encrypt usage assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-384 and no label. Message: ''A required parameter was missing or out-of-range'' Reached unreachable code
-FAIL importVectorKeys step: RSA-OAEP with SHA-512 and no label no encrypt usage assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-512 and no label. Message: ''A required parameter was missing or out-of-range'' Reached unreachable code
-FAIL importVectorKeys step: RSA-OAEP with SHA-1 and empty label no encrypt usage assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-1 and empty label. Message: ''A required parameter was missing or out-of-range'' Reached unreachable code
-FAIL importVectorKeys step: RSA-OAEP with SHA-256 and empty label no encrypt usage assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-256 and empty label. Message: ''A required parameter was missing or out-of-range'' Reached unreachable code
-FAIL importVectorKeys step: RSA-OAEP with SHA-384 and empty label no encrypt usage assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-384 and empty label. Message: ''A required parameter was missing or out-of-range'' Reached unreachable code
-FAIL importVectorKeys step: RSA-OAEP with SHA-512 and empty label no encrypt usage assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-512 and empty label. Message: ''A required parameter was missing or out-of-range'' Reached unreachable code
-FAIL importVectorKeys step: RSA-OAEP with SHA-1 and a label no encrypt usage assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-1 and a label. Message: ''A required parameter was missing or out-of-range'' Reached unreachable code
-FAIL importVectorKeys step: RSA-OAEP with SHA-256 and a label no encrypt usage assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-256 and a label. Message: ''A required parameter was missing or out-of-range'' Reached unreachable code
-FAIL importVectorKeys step: RSA-OAEP with SHA-384 and a label no encrypt usage assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-384 and a label. Message: ''A required parameter was missing or out-of-range'' Reached unreachable code
-FAIL importVectorKeys step: RSA-OAEP with SHA-512 and a label no encrypt usage assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-512 and a label. Message: ''A required parameter was missing or out-of-range'' Reached unreachable code
</del><ins>+PASS RSA-OAEP with SHA-1 and no label no encrypt usage 
+PASS RSA-OAEP with SHA-256 and no label no encrypt usage 
+PASS RSA-OAEP with SHA-384 and no label no encrypt usage 
+PASS RSA-OAEP with SHA-512 and no label no encrypt usage 
+PASS RSA-OAEP with SHA-1 and empty label no encrypt usage 
+PASS RSA-OAEP with SHA-256 and empty label no encrypt usage 
+PASS RSA-OAEP with SHA-384 and empty label no encrypt usage 
+PASS RSA-OAEP with SHA-512 and empty label no encrypt usage 
+PASS RSA-OAEP with SHA-1 and a label no encrypt usage 
+PASS RSA-OAEP with SHA-256 and a label no encrypt usage 
+PASS RSA-OAEP with SHA-384 and a label no encrypt usage 
+PASS RSA-OAEP with SHA-512 and a label no encrypt usage 
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (209656 => 209657)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-12-10 08:43:46 UTC (rev 209656)
+++ trunk/Source/WebCore/ChangeLog        2016-12-10 08:57:42 UTC (rev 209657)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2016-12-10  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
+
+        [WebCrypto] RSA algorithms should allow importing keys without usages
+        https://bugs.webkit.org/show_bug.cgi?id=165680
+        &lt;rdar://problem/29601354&gt;
+
+        Reviewed by Brent Fulgham.
+
+        Tests: crypto/subtle/rsa-oaep-import-jwk-public-key-empty-usages.html
+               crypto/subtle/rsa-oaep-import-spki-key-empty-usages.html
+               crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-empty-usages.html
+               crypto/subtle/rsaes-pkcs1-v1_5-import-spki-key-empty-usages.html
+               crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-empty-usages.html
+               crypto/subtle/rsassa-pkcs1-v1_5-import-spki-key-empty-usages.html
+
+        * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp:
+        (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::importKey):
+        * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp:
+        (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::importKey):
+        * crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp:
+        (WebCore::CryptoAlgorithmRSA_OAEP::importKey):
+
</ins><span class="cx"> 2016-12-10  Frederic Wang  &lt;fred.wang@free.fr&gt;
</span><span class="cx"> 
</span><span class="cx">         Add STIX Two Math to the list of math fonts in mathml.css
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSAES_PKCS1_v1_5cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp (209656 => 209657)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp        2016-12-10 08:43:46 UTC (rev 209656)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp        2016-12-10 08:57:42 UTC (rev 209657)
</span><span class="lines">@@ -105,7 +105,7 @@
</span><span class="cx">     switch (format) {
</span><span class="cx">     case SubtleCrypto::KeyFormat::Jwk: {
</span><span class="cx">         JsonWebKey key = WTFMove(WTF::get&lt;JsonWebKey&gt;(data));
</span><del>-        if ((key.d &amp;&amp; (usages ^ CryptoKeyUsageDecrypt)) || (!key.d &amp;&amp; (usages ^ CryptoKeyUsageEncrypt))) {
</del><ins>+        if (usages &amp;&amp; ((key.d &amp;&amp; (usages ^ CryptoKeyUsageDecrypt)) || (!key.d &amp;&amp; (usages ^ CryptoKeyUsageEncrypt)))) {
</ins><span class="cx">             exceptionCallback(SYNTAX_ERR);
</span><span class="cx">             return;
</span><span class="cx">         }
</span><span class="lines">@@ -121,7 +121,7 @@
</span><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx">     case SubtleCrypto::KeyFormat::Spki: {
</span><del>-        if (usages ^ CryptoKeyUsageEncrypt) {
</del><ins>+        if (usages &amp;&amp; (usages ^ CryptoKeyUsageEncrypt)) {
</ins><span class="cx">             exceptionCallback(SYNTAX_ERR);
</span><span class="cx">             return;
</span><span class="cx">         }
</span><span class="lines">@@ -129,7 +129,7 @@
</span><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx">     case SubtleCrypto::KeyFormat::Pkcs8: {
</span><del>-        if (usages ^ CryptoKeyUsageDecrypt) {
</del><ins>+        if (usages &amp;&amp; (usages ^ CryptoKeyUsageDecrypt)) {
</ins><span class="cx">             exceptionCallback(SYNTAX_ERR);
</span><span class="cx">             return;
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSASSA_PKCS1_v1_5cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp (209656 => 209657)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp        2016-12-10 08:43:46 UTC (rev 209656)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp        2016-12-10 08:57:42 UTC (rev 209657)
</span><span class="lines">@@ -116,7 +116,7 @@
</span><span class="cx">     case SubtleCrypto::KeyFormat::Jwk: {
</span><span class="cx">         JsonWebKey key = WTFMove(WTF::get&lt;JsonWebKey&gt;(data));
</span><span class="cx"> 
</span><del>-        if ((key.d &amp;&amp; (usages ^ CryptoKeyUsageSign)) || (!key.d &amp;&amp; (usages ^ CryptoKeyUsageVerify))) {
</del><ins>+        if (usages &amp;&amp; ((key.d &amp;&amp; (usages ^ CryptoKeyUsageSign)) || (!key.d &amp;&amp; (usages ^ CryptoKeyUsageVerify)))) {
</ins><span class="cx">             exceptionCallback(SYNTAX_ERR);
</span><span class="cx">             return;
</span><span class="cx">         }
</span><span class="lines">@@ -154,7 +154,7 @@
</span><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx">     case SubtleCrypto::KeyFormat::Spki: {
</span><del>-        if (usages ^ CryptoKeyUsageVerify) {
</del><ins>+        if (usages &amp;&amp; (usages ^ CryptoKeyUsageVerify)) {
</ins><span class="cx">             exceptionCallback(SYNTAX_ERR);
</span><span class="cx">             return;
</span><span class="cx">         }
</span><span class="lines">@@ -163,7 +163,7 @@
</span><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx">     case SubtleCrypto::KeyFormat::Pkcs8: {
</span><del>-        if (usages ^ CryptoKeyUsageSign) {
</del><ins>+        if (usages &amp;&amp; (usages ^ CryptoKeyUsageSign)) {
</ins><span class="cx">             exceptionCallback(SYNTAX_ERR);
</span><span class="cx">             return;
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSA_OAEPcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp (209656 => 209657)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp        2016-12-10 08:43:46 UTC (rev 209656)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp        2016-12-10 08:57:42 UTC (rev 209657)
</span><span class="lines">@@ -128,6 +128,7 @@
</span><span class="cx">             isUsagesAllowed = isUsagesAllowed || !(usages ^ CryptoKeyUsageWrapKey);
</span><span class="cx">             isUsagesAllowed = isUsagesAllowed || !(usages ^ (CryptoKeyUsageEncrypt | CryptoKeyUsageWrapKey));
</span><span class="cx">         }
</span><ins>+        isUsagesAllowed = isUsagesAllowed || !usages;
</ins><span class="cx">         if (!isUsagesAllowed) {
</span><span class="cx">             exceptionCallback(SYNTAX_ERR);
</span><span class="cx">             return;
</span><span class="lines">@@ -167,7 +168,7 @@
</span><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx">     case SubtleCrypto::KeyFormat::Spki: {
</span><del>-        if ((usages ^ CryptoKeyUsageEncrypt) &amp;&amp; (usages ^ CryptoKeyUsageWrapKey) &amp;&amp; (usages ^ (CryptoKeyUsageEncrypt | CryptoKeyUsageWrapKey))) {
</del><ins>+        if (usages &amp;&amp; (usages ^ CryptoKeyUsageEncrypt) &amp;&amp; (usages ^ CryptoKeyUsageWrapKey) &amp;&amp; (usages ^ (CryptoKeyUsageEncrypt | CryptoKeyUsageWrapKey))) {
</ins><span class="cx">             exceptionCallback(SYNTAX_ERR);
</span><span class="cx">             return;
</span><span class="cx">         }
</span><span class="lines">@@ -176,7 +177,7 @@
</span><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx">     case SubtleCrypto::KeyFormat::Pkcs8: {
</span><del>-        if ((usages ^ CryptoKeyUsageDecrypt) &amp;&amp; (usages ^ CryptoKeyUsageUnwrapKey) &amp;&amp; (usages ^ (CryptoKeyUsageDecrypt | CryptoKeyUsageUnwrapKey))) {
</del><ins>+        if (usages &amp;&amp; (usages ^ CryptoKeyUsageDecrypt) &amp;&amp; (usages ^ CryptoKeyUsageUnwrapKey) &amp;&amp; (usages ^ (CryptoKeyUsageDecrypt | CryptoKeyUsageUnwrapKey))) {
</ins><span class="cx">             exceptionCallback(SYNTAX_ERR);
</span><span class="cx">             return;
</span><span class="cx">         }
</span></span></pre>
</div>
</div>

</body>
</html>