<!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>[209437] 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/209437">209437</a></dd>
<dt>Author</dt> <dd>jiewen_tan@apple.com</dd>
<dt>Date</dt> <dd>2016-12-06 17:15:20 -0800 (Tue, 06 Dec 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>[Part 1 of 2] Add support for SPKI format while doing SubtleCrypto.importKey/exportKey
https://bugs.webkit.org/show_bug.cgi?id=129978
&lt;rdar://problem/21799829&gt;

LayoutTests/imported/w3c:

Reviewed by Brent Fulgham.

* WebCryptoAPI/encrypt_decrypt/test_rsa_oaep-expected.txt:

Source/WebCore:

This is part 1 of Bug 129978. In this patch, it adds the SPKI format support for
SubtleCrypto.importKey/exportKey. Currently support algorithms are RSAES-PKCS1-v1_5,
RSASSA-PKCS1-v1_5 and RSA-OAEP.

Reviewed by Brent Fulgham.

Tests: crypto/subtle/rsa-import-jwk-key-export-spki-key.html
       crypto/subtle/rsa-import-spki-key-export-jwk-key.html
       crypto/subtle/rsa-import-spki-key-export-spki-key.html
       crypto/subtle/rsa-import-spki-small-key.html
       crypto/subtle/rsa-oaep-generate-export-key-spki.html
       crypto/subtle/rsa-oaep-import-spki-key.html
       crypto/subtle/rsaes-pkcs1-v1_5-generate-export-key-spki.html
       crypto/subtle/rsaes-pkcs1-v1_5-import-spki-key.html
       crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-spki.html
       crypto/subtle/rsassa-pkcs1-v1_5-import-spki-key.html
       crypto/workers/subtle/rsa-export-spki-key.html
       crypto/workers/subtle/rsa-import-spki-key.html

* bindings/js/JSSubtleCryptoCustom.cpp:
(WebCore::toKeyData):
* crypto/CommonCryptoUtilities.h:
* crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp:
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::importKey):
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::exportKey):
* crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp:
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::importKey):
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::exportKey):
* crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp:
(WebCore::CryptoAlgorithmRSA_OAEP::importKey):
(WebCore::CryptoAlgorithmRSA_OAEP::exportKey):
* crypto/gnutls/CryptoKeyRSAGnuTLS.cpp:
(WebCore::CryptoKeyRSA::importSpki):
(WebCore::CryptoKeyRSA::exportSpki):
* crypto/keys/CryptoKeyRSA.h:
* crypto/mac/CryptoKeyRSAMac.cpp:
(WebCore::bytesUsedToEncodedLength):
(WebCore::bytesNeededForEncodedLength):
(WebCore::addEncodedASN1Length):
(WebCore::CryptoKeyRSA::importSpki):
(WebCore::CryptoKeyRSA::exportSpki):

LayoutTests:

Reviewed by Brent Fulgham.

* crypto/subtle/import-key-malformed-parameters-expected.txt:
* crypto/subtle/import-key-malformed-parameters.html:
* crypto/subtle/rsa-export-key-malformed-parameters-expected.txt:
* crypto/subtle/rsa-export-key-malformed-parameters.html:
* crypto/subtle/rsa-import-jwk-key-export-spki-key-expected.txt: Added.
* crypto/subtle/rsa-import-jwk-key-export-spki-key.html: Added.
* crypto/subtle/rsa-import-key-malformed-parameters-expected.txt:
* crypto/subtle/rsa-import-key-malformed-parameters.html:
* crypto/subtle/rsa-import-spki-key-export-jwk-key-expected.txt: Added.
* crypto/subtle/rsa-import-spki-key-export-jwk-key.html: Added.
* crypto/subtle/rsa-import-spki-key-export-spki-key-expected.txt: Added.
* crypto/subtle/rsa-import-spki-key-export-spki-key.html: Added.
* crypto/subtle/rsa-import-spki-small-key-expected.txt: Added.
* crypto/subtle/rsa-import-spki-small-key.html: Added.
* crypto/subtle/rsa-oaep-generate-export-key-spki-expected.txt: Added.
* crypto/subtle/rsa-oaep-generate-export-key-spki.html: Added.
* crypto/subtle/rsa-oaep-import-spki-key-expected.txt: Added.
* crypto/subtle/rsa-oaep-import-spki-key.html: Added.
* crypto/subtle/rsaes-pkcs1-v1_5-generate-export-key-spki-expected.txt: Added.
* crypto/subtle/rsaes-pkcs1-v1_5-generate-export-key-spki.html: Added.
* crypto/subtle/rsaes-pkcs1-v1_5-import-spki-key-expected.txt: Added.
* crypto/subtle/rsaes-pkcs1-v1_5-import-spki-key.html: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-spki-expected.txt: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-spki.html: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-spki-key-expected.txt: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-spki-key.html: Added.
* crypto/workers/subtle/resources/rsa-export-spki-key.js: Added.
* crypto/workers/subtle/resources/rsa-import-spki-key.js: Added.
* crypto/workers/subtle/rsa-export-spki-key-expected.txt: Added.
* crypto/workers/subtle/rsa-export-spki-key.html: Added.
* crypto/workers/subtle/rsa-import-spki-key-expected.txt: Added.
* crypto/workers/subtle/rsa-import-spki-key.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestscryptosubtleimportkeymalformedparametersexpectedtxt">trunk/LayoutTests/crypto/subtle/import-key-malformed-parameters-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleimportkeymalformedparametershtml">trunk/LayoutTests/crypto/subtle/import-key-malformed-parameters.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaexportkeymalformedparametersexpectedtxt">trunk/LayoutTests/crypto/subtle/rsa-export-key-malformed-parameters-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaexportkeymalformedparametershtml">trunk/LayoutTests/crypto/subtle/rsa-export-key-malformed-parameters.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaimportkeymalformedparametersexpectedtxt">trunk/LayoutTests/crypto/subtle/rsa-import-key-malformed-parameters-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaimportkeymalformedparametershtml">trunk/LayoutTests/crypto/subtle/rsa-import-key-malformed-parameters.html</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="#trunkSourceWebCorebindingsjsJSSubtleCryptoCustomcpp">trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoCommonCryptoUtilitiesh">trunk/Source/WebCore/crypto/CommonCryptoUtilities.h</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSAES_PKCS1_v1_5cpp">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp</a></li>
<li><a href="#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>
<li><a href="#trunkSourceWebCorecryptognutlsCryptoKeyRSAGnuTLScpp">trunk/Source/WebCore/crypto/gnutls/CryptoKeyRSAGnuTLS.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptokeysCryptoKeyRSAh">trunk/Source/WebCore/crypto/keys/CryptoKeyRSA.h</a></li>
<li><a href="#trunkSourceWebCorecryptomacCryptoKeyRSAMaccpp">trunk/Source/WebCore/crypto/mac/CryptoKeyRSAMac.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestscryptosubtlersaimportjwkkeyexportspkikeyexpectedtxt">trunk/LayoutTests/crypto/subtle/rsa-import-jwk-key-export-spki-key-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaimportjwkkeyexportspkikeyhtml">trunk/LayoutTests/crypto/subtle/rsa-import-jwk-key-export-spki-key.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaimportspkikeyexportjwkkeyexpectedtxt">trunk/LayoutTests/crypto/subtle/rsa-import-spki-key-export-jwk-key-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaimportspkikeyexportjwkkeyhtml">trunk/LayoutTests/crypto/subtle/rsa-import-spki-key-export-jwk-key.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaimportspkikeyexportspkikeyexpectedtxt">trunk/LayoutTests/crypto/subtle/rsa-import-spki-key-export-spki-key-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaimportspkikeyexportspkikeyhtml">trunk/LayoutTests/crypto/subtle/rsa-import-spki-key-export-spki-key.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaimportspkismallkeyexpectedtxt">trunk/LayoutTests/crypto/subtle/rsa-import-spki-small-key-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaimportspkismallkeyhtml">trunk/LayoutTests/crypto/subtle/rsa-import-spki-small-key.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaoaepgenerateexportkeyspkiexpectedtxt">trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-spki-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaoaepgenerateexportkeyspkihtml">trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-spki.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaoaepimportspkikeyexpectedtxt">trunk/LayoutTests/crypto/subtle/rsa-oaep-import-spki-key-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaoaepimportspkikeyhtml">trunk/LayoutTests/crypto/subtle/rsa-oaep-import-spki-key.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaespkcs1v1_5generateexportkeyspkiexpectedtxt">trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-generate-export-key-spki-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaespkcs1v1_5generateexportkeyspkihtml">trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-generate-export-key-spki.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaespkcs1v1_5importspkikeyexpectedtxt">trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-spki-key-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaespkcs1v1_5importspkikeyhtml">trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-spki-key.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5generateexportkeyspkiexpectedtxt">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-spki-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5generateexportkeyspkihtml">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-spki.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5importspkikeyexpectedtxt">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-spki-key-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5importspkikeyhtml">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-spki-key.html</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtleresourcesrsaexportspkikeyjs">trunk/LayoutTests/crypto/workers/subtle/resources/rsa-export-spki-key.js</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtleresourcesrsaimportspkikeyjs">trunk/LayoutTests/crypto/workers/subtle/resources/rsa-import-spki-key.js</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtlersaexportspkikeyexpectedtxt">trunk/LayoutTests/crypto/workers/subtle/rsa-export-spki-key-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtlersaexportspkikeyhtml">trunk/LayoutTests/crypto/workers/subtle/rsa-export-spki-key.html</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtlersaimportspkikeyexpectedtxt">trunk/LayoutTests/crypto/workers/subtle/rsa-import-spki-key-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtlersaimportspkikeyhtml">trunk/LayoutTests/crypto/workers/subtle/rsa-import-spki-key.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (209436 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-12-07 00:46:23 UTC (rev 209436)
+++ trunk/LayoutTests/ChangeLog        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -1,3 +1,44 @@
</span><ins>+2016-12-05  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
+
+        [Part 1 of 2] Add support for SPKI format while doing SubtleCrypto.importKey/exportKey
+        https://bugs.webkit.org/show_bug.cgi?id=129978
+        &lt;rdar://problem/21799829&gt;
+
+        Reviewed by Brent Fulgham.
+
+        * crypto/subtle/import-key-malformed-parameters-expected.txt:
+        * crypto/subtle/import-key-malformed-parameters.html:
+        * crypto/subtle/rsa-export-key-malformed-parameters-expected.txt:
+        * crypto/subtle/rsa-export-key-malformed-parameters.html:
+        * crypto/subtle/rsa-import-jwk-key-export-spki-key-expected.txt: Added.
+        * crypto/subtle/rsa-import-jwk-key-export-spki-key.html: Added.
+        * crypto/subtle/rsa-import-key-malformed-parameters-expected.txt:
+        * crypto/subtle/rsa-import-key-malformed-parameters.html:
+        * crypto/subtle/rsa-import-spki-key-export-jwk-key-expected.txt: Added.
+        * crypto/subtle/rsa-import-spki-key-export-jwk-key.html: Added.
+        * crypto/subtle/rsa-import-spki-key-export-spki-key-expected.txt: Added.
+        * crypto/subtle/rsa-import-spki-key-export-spki-key.html: Added.
+        * crypto/subtle/rsa-import-spki-small-key-expected.txt: Added.
+        * crypto/subtle/rsa-import-spki-small-key.html: Added.
+        * crypto/subtle/rsa-oaep-generate-export-key-spki-expected.txt: Added.
+        * crypto/subtle/rsa-oaep-generate-export-key-spki.html: Added.
+        * crypto/subtle/rsa-oaep-import-spki-key-expected.txt: Added.
+        * crypto/subtle/rsa-oaep-import-spki-key.html: Added.
+        * crypto/subtle/rsaes-pkcs1-v1_5-generate-export-key-spki-expected.txt: Added.
+        * crypto/subtle/rsaes-pkcs1-v1_5-generate-export-key-spki.html: Added.
+        * crypto/subtle/rsaes-pkcs1-v1_5-import-spki-key-expected.txt: Added.
+        * crypto/subtle/rsaes-pkcs1-v1_5-import-spki-key.html: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-spki-expected.txt: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-spki.html: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-import-spki-key-expected.txt: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-import-spki-key.html: Added.
+        * crypto/workers/subtle/resources/rsa-export-spki-key.js: Added.
+        * crypto/workers/subtle/resources/rsa-import-spki-key.js: Added.
+        * crypto/workers/subtle/rsa-export-spki-key-expected.txt: Added.
+        * crypto/workers/subtle/rsa-export-spki-key.html: Added.
+        * crypto/workers/subtle/rsa-import-spki-key-expected.txt: Added.
+        * crypto/workers/subtle/rsa-import-spki-key.html: Added.
+
</ins><span class="cx"> 2016-12-06  Antoine Quint  &lt;graouts@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Modern Media Controls] Media controls use the fullscreen layout after going from inline to fullscreen to PiP to inline
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtleimportkeymalformedparametersexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/crypto/subtle/import-key-malformed-parameters-expected.txt (209436 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/import-key-malformed-parameters-expected.txt        2016-12-07 00:46:23 UTC (rev 209436)
+++ trunk/LayoutTests/crypto/subtle/import-key-malformed-parameters-expected.txt        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -16,7 +16,6 @@
</span><span class="cx"> PASS crypto.subtle.importKey({ }, rawKey, &quot;aes-cbc&quot;, extractable, [&quot;encrypt&quot;, &quot;decrypt&quot;, &quot;wrapKey&quot;, &quot;unwrapKey&quot;]) rejected promise  with TypeError: Type error.
</span><span class="cx"> PASS crypto.subtle.importKey(&quot;foo&quot;, rawKey, &quot;aes-cbc&quot;, extractable, [&quot;encrypt&quot;, &quot;decrypt&quot;, &quot;wrapKey&quot;, &quot;unwrapKey&quot;]) rejected promise  with TypeError: Type error.
</span><span class="cx"> PASS crypto.subtle.importKey(&quot;pkcs8&quot;, rawKey, &quot;rsaes-pkcs1-v1_5&quot;, extractable, [&quot;encrypt&quot;, &quot;decrypt&quot;]) rejected promise  with NotSupportedError (DOM Exception 9): The operation is not supported..
</span><del>-PASS crypto.subtle.importKey(&quot;spki&quot;, rawKey, &quot;rsaes-pkcs1-v1_5&quot;, extractable, [&quot;encrypt&quot;, &quot;decrypt&quot;]) rejected promise  with NotSupportedError (DOM Exception 9): The operation is not supported..
</del><span class="cx"> PASS crypto.subtle.importKey(&quot;raw&quot;, jwkKey, &quot;aes-cbc&quot;, extractable, [&quot;encrypt&quot;, &quot;decrypt&quot;, &quot;wrapKey&quot;, &quot;unwrapKey&quot;]) rejected promise  with TypeError: Type error.
</span><span class="cx"> PASS crypto.subtle.importKey(&quot;raw&quot;, 1, &quot;aes-cbc&quot;, extractable, [&quot;encrypt&quot;, &quot;decrypt&quot;, &quot;wrapKey&quot;, &quot;unwrapKey&quot;]) rejected promise  with TypeError: Type error.
</span><span class="cx"> PASS crypto.subtle.importKey(&quot;raw&quot;, true, &quot;aes-cbc&quot;, extractable, [&quot;encrypt&quot;, &quot;decrypt&quot;, &quot;wrapKey&quot;, &quot;unwrapKey&quot;]) rejected promise  with TypeError: Type error.
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtleimportkeymalformedparametershtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/crypto/subtle/import-key-malformed-parameters.html (209436 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/import-key-malformed-parameters.html        2016-12-07 00:46:23 UTC (rev 209436)
+++ trunk/LayoutTests/crypto/subtle/import-key-malformed-parameters.html        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -50,7 +50,6 @@
</span><span class="cx"> shouldReject('crypto.subtle.importKey(&quot;foo&quot;, rawKey, &quot;aes-cbc&quot;, extractable, [&quot;encrypt&quot;, &quot;decrypt&quot;, &quot;wrapKey&quot;, &quot;unwrapKey&quot;])');
</span><span class="cx"> // Currently not support formats.
</span><span class="cx"> shouldReject('crypto.subtle.importKey(&quot;pkcs8&quot;, rawKey, &quot;rsaes-pkcs1-v1_5&quot;, extractable, [&quot;encrypt&quot;, &quot;decrypt&quot;])');
</span><del>-shouldReject('crypto.subtle.importKey(&quot;spki&quot;, rawKey, &quot;rsaes-pkcs1-v1_5&quot;, extractable, [&quot;encrypt&quot;, &quot;decrypt&quot;])');
</del><span class="cx"> // Wrong KeyData.
</span><span class="cx"> shouldReject('crypto.subtle.importKey(&quot;raw&quot;, jwkKey, &quot;aes-cbc&quot;, extractable, [&quot;encrypt&quot;, &quot;decrypt&quot;, &quot;wrapKey&quot;, &quot;unwrapKey&quot;])');
</span><span class="cx"> shouldReject('crypto.subtle.importKey(&quot;raw&quot;, 1, &quot;aes-cbc&quot;, extractable, [&quot;encrypt&quot;, &quot;decrypt&quot;, &quot;wrapKey&quot;, &quot;unwrapKey&quot;])');
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaexportkeymalformedparametersexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/crypto/subtle/rsa-export-key-malformed-parameters-expected.txt (209436 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-export-key-malformed-parameters-expected.txt        2016-12-07 00:46:23 UTC (rev 209436)
+++ trunk/LayoutTests/crypto/subtle/rsa-export-key-malformed-parameters-expected.txt        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -3,9 +3,9 @@
</span><span class="cx"> On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-PASS crypto.subtle.exportKey(&quot;spki&quot;, publicKey) rejected promise  with NotSupportedError (DOM Exception 9): The algorithm is not supported.
</del><span class="cx"> PASS crypto.subtle.exportKey(&quot;pkcs8&quot;, publicKey) rejected promise  with NotSupportedError (DOM Exception 9): The algorithm is not supported.
</span><span class="cx"> PASS crypto.subtle.exportKey(&quot;raw&quot;, publicKey) rejected promise  with NotSupportedError (DOM Exception 9): The algorithm is not supported.
</span><ins>+PASS crypto.subtle.exportKey(&quot;spki&quot;, privateKey) rejected promise  with InvalidAccessError (DOM Exception 15): The requested operation is not valid for the provided 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="trunkLayoutTestscryptosubtlersaexportkeymalformedparametershtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/crypto/subtle/rsa-export-key-malformed-parameters.html (209436 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-export-key-malformed-parameters.html        2016-12-07 00:46:23 UTC (rev 209436)
+++ trunk/LayoutTests/crypto/subtle/rsa-export-key-malformed-parameters.html        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -24,14 +24,16 @@
</span><span class="cx"> 
</span><span class="cx"> crypto.subtle.generateKey(algorithmKeyGen, extractable, [&quot;decrypt&quot;, &quot;encrypt&quot;, &quot;wrapKey&quot;, &quot;unwrapKey&quot;]).then(function(result) {
</span><span class="cx">     publicKey = result.publicKey;
</span><ins>+    privateKey = result.privateKey;
</ins><span class="cx"> 
</span><span class="cx">     // Currently not support format.
</span><del>-    return shouldReject('crypto.subtle.exportKey(&quot;spki&quot;, publicKey)');
-}).then(function() {
</del><span class="cx">     return shouldReject('crypto.subtle.exportKey(&quot;pkcs8&quot;, publicKey)');
</span><span class="cx"> }).then(function() {
</span><span class="cx">     // Not support format.
</span><span class="cx">     return shouldReject('crypto.subtle.exportKey(&quot;raw&quot;, publicKey)');
</span><ins>+}).then(function() {
+    // Wrong key and format.
+    return shouldReject('crypto.subtle.exportKey(&quot;spki&quot;, privateKey)');
</ins><span class="cx"> }).then(finishJSTest, finishJSTest);
</span><span class="cx"> 
</span><span class="cx"> &lt;/script&gt;
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaimportjwkkeyexportspkikeyexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-import-jwk-key-export-spki-key-expected.txt (0 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-import-jwk-key-export-spki-key-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-import-jwk-key-export-spki-key-expected.txt        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+Test importing a JWK RSA-OAEP public key with SHA-1 and then export it in SPKI format
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Importing a key...
+Exporting a key...
+PASS exportedSpkiKey.byteLength is 294
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaimportjwkkeyexportspkikeyhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-import-jwk-key-export-spki-key.html (0 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-import-jwk-key-export-spki-key.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-import-jwk-key-export-spki-key.html        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -0,0 +1,42 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test importing a JWK RSA-OAEP public key with SHA-1 and then export it in SPKI format&quot;);
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: &quot;RSA&quot;,
+    alg: &quot;RSA-OAEP&quot;,
+    key_ops: [&quot;encrypt&quot;, &quot;wrapKey&quot;],
+    ext: true,
+    n: &quot;p55Xl-DyqKL06TE8GCuXd_e-ruTqVB19iDH6DwTIknTyM0fl8EY6qsyOBNTxjpLDsOldEJ8QblG78WY7xYTZtNn-fimz5eG80bwSZ6FUO10z3ikeKzPPC7K4AA196rMoiEu2G4mSfqeg5zz6_iqHf8u_md_n8yk_iPaXJ9RVT-W4zEQQ6WSlsOtYa7blSSAlq0JYDJciNeE0RGqUU-UjcxUWIEnT2ODHGRzSfKHgc8O3fGt4dpVm0op1yItBcSAY-0_f1p_YrVDo8bsyq2uodyDGYhcuQgYJ0NjMgT_rb8rUPpR3bUitd-IZJd_NO9i_NmvbnQfgl6kfnxe_2kM4Tw&quot;,
+    e: &quot;AQAB&quot;
+};
+var extractable = true;
+
+debug(&quot;Importing a key...&quot;);
+crypto.subtle.importKey(&quot;jwk&quot;, jwkKey, {name: &quot;RSA-OAEP&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;encrypt&quot;, &quot;wrapKey&quot;]).then(function(cryptoKey) {
+    debug(&quot;Exporting a key...&quot;);
+    return crypto.subtle.exportKey(&quot;spki&quot;, cryptoKey);
+}).then(function(result) {
+    exportedSpkiKey = result;
+
+    shouldBe(&quot;exportedSpkiKey.byteLength&quot;, &quot;294&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="trunkLayoutTestscryptosubtlersaimportkeymalformedparametersexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/crypto/subtle/rsa-import-key-malformed-parameters-expected.txt (209436 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-import-key-malformed-parameters-expected.txt        2016-12-07 00:46:23 UTC (rev 209436)
+++ trunk/LayoutTests/crypto/subtle/rsa-import-key-malformed-parameters-expected.txt        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -36,6 +36,9 @@
</span><span class="cx"> PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;RSA&quot;, n: n, e: e, d: d, p: p, q: q, dq: dq, qi: qi}, &quot;RSAES-PKCS1-v1_5&quot;, extractable, [&quot;decrypt&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
</span><span class="cx"> PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;RSA&quot;, n: n, e: e, d: d, p: p, q: q, dp: dp, qi: qi}, &quot;RSAES-PKCS1-v1_5&quot;, extractable, [&quot;decrypt&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
</span><span class="cx"> PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;RSA&quot;, n: n, e: e, d: d, p: p, q: q, dp: dp, dq: dq}, &quot;RSAES-PKCS1-v1_5&quot;, extractable, [&quot;decrypt&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
</span><ins>+PASS crypto.subtle.importKey(&quot;spki&quot;, spkiKey, &quot;RSAES-PKCS1-v1_5&quot;, extractable, [&quot;decrypt&quot;]) rejected promise  with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
+PASS crypto.subtle.importKey(&quot;spki&quot;, spkiKey, {name: &quot;RSASSA-PKCS1-v1_5&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;]) rejected promise  with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
+PASS crypto.subtle.importKey(&quot;spki&quot;, spkiKey, {name: &quot;RSA-OAEP&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;decrypt&quot;, &quot;unwrapKey&quot;]) rejected promise  with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
</ins><span class="cx"> PASS successfullyParsed is true
</span><span class="cx"> 
</span><span class="cx"> TEST COMPLETE
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaimportkeymalformedparametershtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/crypto/subtle/rsa-import-key-malformed-parameters.html (209436 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-import-key-malformed-parameters.html        2016-12-07 00:46:23 UTC (rev 209436)
+++ trunk/LayoutTests/crypto/subtle/rsa-import-key-malformed-parameters.html        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -21,6 +21,7 @@
</span><span class="cx"> var dp = &quot;fBzDzYDUBmBQGop7Hn0dvf_T27V6RqpctWo074CQZcFbP2atFVtKSj3viWT3xid2VHzcgiDHdfpM3nEVlEO1wwIonGCSvdjGEOZiiFVOjrZAOVxA8guOjyyFvqbXke06VwPIIVvfKeSU2zuhbP__1tt6F_fxow4Kb2xonGT0GGk&quot;;
</span><span class="cx"> var dq = &quot;jmE2DiIPdhwDgLXAQpIaBqQ81bO3XfVT_LRULAwwwwlPuQV148H04zlh9TJ6Y2GZHYokV1U0eOBpJxfkb7dLYtpJpuiBjRf4yIUEoGlkkI_QlJnFSFr-YjGRdfNHqWBkxlSMZL770R9mIATndGkH7z5x-r9KwBZFC4FCG2hg_zE&quot;;
</span><span class="cx"> var qi = &quot;YCX_pLwbMBA1ThVH0WcwmnytqNcrMCEwTm7ByA2eU6nWbQrULvf7m9_kzfLUcjsnpAVlBQG5JMXMy0Sq4ptwbywsa5-G8KAOOOR2L3v4hC-Eys9ftgFM_3i0o40eeQH4b3haPbntrIeMg8IzlOuVYKf9-2QuKDoWeRdd7NsdxTk&quot;;
</span><ins>+var spkiKey = hexStringToUint8Array(&quot;30820122300d06092a864886f70d01010105000382010f003082010a0282010100d61051c4920d4c7c04a33beabb2412bedc4173fdbe82c7db80f0052d00abd32e01656d2105abef4fa5417bb868bb77780c08d20cfe9e2d767ee952970941398f8bea59a966772b1d89f19693cfff5faba22ba39ef7982ac46257180d557d3cbf3f7e65dd835d1d351e679a841b904a3cf24a0323aac0bb89705777507c76f57663b6d846e995a63057ceb48053ddf9282a366d6dc6cbdceb2ebcb3b374c7dc49da160cba8a3656211b8597a39ef9b8cc44d0c5735f870679ffcb1cb9321bbfbc307844d3174ef5dc144a951071340f4d156bead21fd3d9bd4641afa5851512264b4eed228b5d6324de428b00cbb89a1a88cb138d59de0b4ad75f2196e0e7ba890203010001&quot;);
</ins><span class="cx"> 
</span><span class="cx"> // Jwk: Wrong usages
</span><span class="cx"> shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;RSA&quot;, n: n, e: e}, &quot;RSAES-PKCS1-v1_5&quot;, extractable, [&quot;decrypt&quot;])');
</span><span class="lines">@@ -64,6 +65,10 @@
</span><span class="cx"> shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;RSA&quot;, n: n, e: e, d: d, p: p, q: q, dq: dq, qi: qi}, &quot;RSAES-PKCS1-v1_5&quot;, extractable, [&quot;decrypt&quot;])');
</span><span class="cx"> shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;RSA&quot;, n: n, e: e, d: d, p: p, q: q, dp: dp, qi: qi}, &quot;RSAES-PKCS1-v1_5&quot;, extractable, [&quot;decrypt&quot;])');
</span><span class="cx"> shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;RSA&quot;, n: n, e: e, d: d, p: p, q: q, dp: dp, dq: dq}, &quot;RSAES-PKCS1-v1_5&quot;, extractable, [&quot;decrypt&quot;])');
</span><ins>+// Spki: Wrong usages
+shouldReject('crypto.subtle.importKey(&quot;spki&quot;, spkiKey, &quot;RSAES-PKCS1-v1_5&quot;, extractable, [&quot;decrypt&quot;])');
+shouldReject('crypto.subtle.importKey(&quot;spki&quot;, spkiKey, {name: &quot;RSASSA-PKCS1-v1_5&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;])');
+shouldReject('crypto.subtle.importKey(&quot;spki&quot;, spkiKey, {name: &quot;RSA-OAEP&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;decrypt&quot;, &quot;unwrapKey&quot;])');
</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="trunkLayoutTestscryptosubtlersaimportspkikeyexportjwkkeyexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-import-spki-key-export-jwk-key-expected.txt (0 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-import-spki-key-export-jwk-key-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-import-spki-key-export-jwk-key-expected.txt        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -0,0 +1,17 @@
</span><ins>+Test importing a SPKI RSA-OAEP public key and then export it in JWK format
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Importing a key...
+Exporting a key...
+PASS exportedJwkKey.kty is jwkKey.kty
+PASS exportedJwkKey.alg is jwkKey.alg
+PASS exportedJwkKey.key_ops is jwkKey.key_ops
+PASS exportedJwkKey.ext is jwkKey.ext
+PASS exportedJwkKey.n is jwkKey.n
+PASS exportedJwkKey.e is jwkKey.e
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaimportspkikeyexportjwkkeyhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-import-spki-key-export-jwk-key.html (0 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-import-spki-key-export-jwk-key.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-import-spki-key-export-jwk-key.html        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -0,0 +1,48 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test importing a SPKI RSA-OAEP public key and then export it in JWK format&quot;);
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: &quot;RSA&quot;,
+    alg: &quot;RSA-OAEP&quot;,
+    key_ops: [&quot;encrypt&quot;, &quot;wrapKey&quot;],
+    ext: true,
+    n: &quot;1hBRxJINTHwEozvquyQSvtxBc_2-gsfbgPAFLQCr0y4BZW0hBavvT6VBe7hou3d4DAjSDP6eLXZ-6VKXCUE5j4vqWalmdysdifGWk8__X6uiK6Oe95gqxGJXGA1VfTy_P35l3YNdHTUeZ5qEG5BKPPJKAyOqwLuJcFd3UHx29XZjtthG6ZWmMFfOtIBT3fkoKjZtbcbL3OsuvLOzdMfcSdoWDLqKNlYhG4WXo575uMxE0MVzX4cGef_LHLkyG7-8MHhE0xdO9dwUSpUQcTQPTRVr6tIf09m9RkGvpYUVEiZLTu0ii11jJN5CiwDLuJoaiMsTjVneC0rXXyGW4Oe6iQ&quot;,
+    e: &quot;AQAB&quot;
+};
+var spkiKey = hexStringToUint8Array(&quot;30820122300d06092a864886f70d01010105000382010f003082010a0282010100d61051c4920d4c7c04a33beabb2412bedc4173fdbe82c7db80f0052d00abd32e01656d2105abef4fa5417bb868bb77780c08d20cfe9e2d767ee952970941398f8bea59a966772b1d89f19693cfff5faba22ba39ef7982ac46257180d557d3cbf3f7e65dd835d1d351e679a841b904a3cf24a0323aac0bb89705777507c76f57663b6d846e995a63057ceb48053ddf9282a366d6dc6cbdceb2ebcb3b374c7dc49da160cba8a3656211b8597a39ef9b8cc44d0c5735f870679ffcb1cb9321bbfbc307844d3174ef5dc144a951071340f4d156bead21fd3d9bd4641afa5851512264b4eed228b5d6324de428b00cbb89a1a88cb138d59de0b4ad75f2196e0e7ba890203010001&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, [&quot;encrypt&quot;, &quot;wrapKey&quot;]).then(function(cryptoKey) {
+    debug(&quot;Exporting a key...&quot;);
+    return crypto.subtle.exportKey(&quot;jwk&quot;, cryptoKey);
+}).then(function(result) {
+    exportedJwkKey = result;
+
+    shouldBe(&quot;exportedJwkKey.kty&quot;, &quot;jwkKey.kty&quot;);
+    shouldBe(&quot;exportedJwkKey.alg&quot;, &quot;jwkKey.alg&quot;);
+    shouldBe(&quot;exportedJwkKey.key_ops&quot;, &quot;jwkKey.key_ops&quot;);
+    shouldBe(&quot;exportedJwkKey.ext&quot;, &quot;jwkKey.ext&quot;);
+    shouldBe(&quot;exportedJwkKey.n&quot;, &quot;jwkKey.n&quot;);
+    shouldBe(&quot;exportedJwkKey.e&quot;, &quot;jwkKey.e&quot;);
+
+    finishJSTest();
+});
+
+&lt;/script&gt;
+
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaimportspkikeyexportspkikeyexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-import-spki-key-export-spki-key-expected.txt (0 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-import-spki-key-export-spki-key-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-import-spki-key-export-spki-key-expected.txt        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+Test importing a SPKI RSA-OAEP key and then export it in SPKI format
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Importing a key...
+PASS bytesToHexString(publicKey) is spkiKeyHex
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaimportspkikeyexportspkikeyhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-import-spki-key-export-spki-key.html (0 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-import-spki-key-export-spki-key.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-import-spki-key-export-spki-key.html        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -0,0 +1,35 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test importing a SPKI RSA-OAEP key and then export it in SPKI format&quot;);
+
+jsTestIsAsync = true;
+
+var spkiKeyHex = &quot;30820122300d06092a864886f70d01010105000382010f003082010a0282010100d61051c4920d4c7c04a33beabb2412bedc4173fdbe82c7db80f0052d00abd32e01656d2105abef4fa5417bb868bb77780c08d20cfe9e2d767ee952970941398f8bea59a966772b1d89f19693cfff5faba22ba39ef7982ac46257180d557d3cbf3f7e65dd835d1d351e679a841b904a3cf24a0323aac0bb89705777507c76f57663b6d846e995a63057ceb48053ddf9282a366d6dc6cbdceb2ebcb3b374c7dc49da160cba8a3656211b8597a39ef9b8cc44d0c5735f870679ffcb1cb9321bbfbc307844d3174ef5dc144a951071340f4d156bead21fd3d9bd4641afa5851512264b4eed228b5d6324de428b00cbb89a1a88cb138d59de0b4ad75f2196e0e7ba890203010001&quot;;
+var spkiKey = hexStringToUint8Array(spkiKeyHex);
+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, [&quot;encrypt&quot;, &quot;wrapKey&quot;]).then(function(publicKey) {
+    return crypto.subtle.exportKey(&quot;spki&quot;, publicKey);
+}).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;bytesToHexString(publicKey)&quot;, &quot;spkiKeyHex&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="trunkLayoutTestscryptosubtlersaimportspkismallkeyexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-import-spki-small-key-expected.txt (0 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-import-spki-small-key-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-import-spki-small-key-expected.txt        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -0,0 +1,18 @@
</span><ins>+Test importing a SPKI RSA 64 bit key
+
+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 64
+PASS bytesToHexString(publicKey.algorithm.publicExponent) is '010001'
+PASS publicKey.algorithm.hash.name is 'SHA-1'
+PASS publicKey.usages is ['encrypt', 'wrapKey']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaimportspkismallkeyhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-import-spki-small-key.html (0 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-import-spki-small-key.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-import-spki-small-key.html        2016-12-07 01:15:20 UTC (rev 209437)
</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 64 bit key&quot;);
+
+jsTestIsAsync = true;
+
+// Generated from OpenSSL
+var spkiKey = Base64URL.parse(&quot;MCQwDQYJKoZIhvcNAQEBBQADEwAwEAIJAKNxac33yAq/AgMBAAE=&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, [&quot;encrypt&quot;, &quot;wrapKey&quot;]).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;64&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;['encrypt', 'wrapKey']&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="trunkLayoutTestscryptosubtlersaoaepgenerateexportkeyspkiexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-spki-expected.txt (0 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-spki-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-spki-expected.txt        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+Test exporting a RSA-OAEP public key with SPKI format.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Generating a key pair...
+Exporting the public key...
+PASS publicKey.byteLength is 294
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaoaepgenerateexportkeyspkihtmlfromrev209436trunkLayoutTestscryptosubtlersaexportkeymalformedparametershtml"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-spki.html (from rev 209436, trunk/LayoutTests/crypto/subtle/rsa-export-key-malformed-parameters.html) (0 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-spki.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-spki.html        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -0,0 +1,42 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test exporting a RSA-OAEP public key with SPKI format.&quot;);
+
+jsTestIsAsync = true;
+
+var algorithmKeyGen = {
+    name: &quot;RSA-OAEP&quot;,
+    // RsaKeyGenParams
+    modulusLength: 2048,
+    publicExponent: new Uint8Array([0x01, 0x00, 0x01]),  // Equivalent to 65537
+    hash: &quot;sha-1&quot;
+};
+var extractable = true;
+
+var keyPair;
+debug(&quot;Generating a key pair...&quot;);
+crypto.subtle.generateKey(algorithmKeyGen, extractable, [&quot;decrypt&quot;, &quot;encrypt&quot;, &quot;wrapKey&quot;, &quot;unwrapKey&quot;]).then(function(result) {
+    keyPair = result;
+    debug(&quot;Exporting the public key...&quot;);
+    return crypto.subtle.exportKey(&quot;spki&quot;, keyPair.publicKey);
+}).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;publicKey.byteLength&quot;, &quot;294&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="trunkLayoutTestscryptosubtlersaoaepimportspkikeyexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-oaep-import-spki-key-expected.txt (0 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-import-spki-key-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-import-spki-key-expected.txt        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -0,0 +1,18 @@
</span><ins>+Test importing a SPKI RSA-OAEP key
+
+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 ['encrypt', 'wrapKey']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaoaepimportspkikeyhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-oaep-import-spki-key.html (0 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-import-spki-key.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-import-spki-key.html        2016-12-07 01:15:20 UTC (rev 209437)
</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&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, [&quot;encrypt&quot;, &quot;wrapKey&quot;]).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;['encrypt', 'wrapKey']&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_5generateexportkeyspkiexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-generate-export-key-spki-expected.txt (0 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-generate-export-key-spki-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-generate-export-key-spki-expected.txt        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+Test exporting a RSAES-PKCS1-v1_5 public key with SPKI format.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Generating a key pair...
+Exporting the public key...
+PASS publicKey.byteLength is 294
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaespkcs1v1_5generateexportkeyspkihtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-generate-export-key-spki.html (0 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-generate-export-key-spki.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-generate-export-key-spki.html        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -0,0 +1,41 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test exporting a RSAES-PKCS1-v1_5 public key with SPKI format.&quot;);
+
+jsTestIsAsync = true;
+
+var algorithmKeyGen = {
+    name: &quot;RSAES-PKCS1-v1_5&quot;,
+    // RsaKeyGenParams
+    modulusLength: 2048,
+    publicExponent: new Uint8Array([0x01, 0x00, 0x01]),  // Equivalent to 65537
+};
+var extractable = true;
+
+var keyPair;
+debug(&quot;Generating a key pair...&quot;);
+crypto.subtle.generateKey(algorithmKeyGen, extractable, [&quot;decrypt&quot;, &quot;encrypt&quot;]).then(function(result) {
+    keyPair = result;
+    debug(&quot;Exporting the public key...&quot;);
+    return crypto.subtle.exportKey(&quot;spki&quot;, keyPair.publicKey);
+}).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;publicKey.byteLength&quot;, &quot;294&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_5importspkikeyexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-spki-key-expected.txt (0 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-spki-key-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-spki-key-expected.txt        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -0,0 +1,18 @@
</span><ins>+Test importing a SPKI RSAES-PKCS1-v1_5 key
+
+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 ['encrypt']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaespkcs1v1_5importspkikeyhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-spki-key.html (0 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-spki-key.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-spki-key.html        2016-12-07 01:15:20 UTC (rev 209437)
</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&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, [&quot;encrypt&quot;]).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;['encrypt']&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_5generateexportkeyspkiexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-spki-expected.txt (0 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-spki-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-spki-expected.txt        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+Test exporting a RSASSA-PKCS1-v1_5 public key with SPKI format.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Generating a key pair...
+Exporting the public key...
+PASS publicKey.byteLength is 294
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersassapkcs1v1_5generateexportkeyspkihtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-spki.html (0 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-spki.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-spki.html        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -0,0 +1,42 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test exporting a RSASSA-PKCS1-v1_5 public key with SPKI format.&quot;);
+
+jsTestIsAsync = true;
+
+var algorithmKeyGen = {
+    name: &quot;RSASSA-PKCS1-v1_5&quot;,
+    // RsaKeyGenParams
+    modulusLength: 2048,
+    publicExponent: new Uint8Array([0x01, 0x00, 0x01]),  // Equivalent to 65537
+    hash: &quot;sha-1&quot;,
+};
+var extractable = true;
+
+var keyPair;
+debug(&quot;Generating a key pair...&quot;);
+crypto.subtle.generateKey(algorithmKeyGen, extractable, [&quot;sign&quot;, &quot;verify&quot;]).then(function(result) {
+    keyPair = result;
+    debug(&quot;Exporting the public key...&quot;);
+    return crypto.subtle.exportKey(&quot;spki&quot;, keyPair.publicKey);
+}).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;publicKey.byteLength&quot;, &quot;294&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_5importspkikeyexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-spki-key-expected.txt (0 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-spki-key-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-spki-key-expected.txt        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -0,0 +1,18 @@
</span><ins>+Test importing a SPKI RSASSA-PKCS1-v1_5 key
+
+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 ['verify']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersassapkcs1v1_5importspkikeyhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-spki-key.html (0 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-spki-key.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-spki-key.html        2016-12-07 01:15:20 UTC (rev 209437)
</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&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, [&quot;verify&quot;]).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;['verify']&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="trunkLayoutTestscryptoworkerssubtleresourcesrsaexportspkikeyjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/resources/rsa-export-spki-key.js (0 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/resources/rsa-export-spki-key.js                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/resources/rsa-export-spki-key.js        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -0,0 +1,29 @@
</span><ins>+importScripts('../../../../resources/js-test-pre.js');
+importScripts(&quot;../../../resources/common.js&quot;);
+
+description(&quot;Test exporting a RSA-OAEP public key with SPKI format in workers.&quot;);
+
+jsTestIsAsync = true;
+
+var algorithmKeyGen = {
+    name: &quot;RSA-OAEP&quot;,
+    // RsaKeyGenParams
+    modulusLength: 2048,
+    publicExponent: new Uint8Array([0x01, 0x00, 0x01]),  // Equivalent to 65537
+    hash: &quot;sha-1&quot;
+};
+var extractable = true;
+
+var keyPair;
+debug(&quot;Generating a key pair...&quot;);
+crypto.subtle.generateKey(algorithmKeyGen, extractable, [&quot;decrypt&quot;, &quot;encrypt&quot;, &quot;wrapKey&quot;, &quot;unwrapKey&quot;]).then(function(result) {
+    keyPair = result;
+    debug(&quot;Exporting the public key...&quot;);
+    return crypto.subtle.exportKey(&quot;spki&quot;, keyPair.publicKey);
+}).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;publicKey.byteLength&quot;, &quot;294&quot;);
+
+    finishJSTest();
+});
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtleresourcesrsaimportspkikeyjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/resources/rsa-import-spki-key.js (0 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/resources/rsa-import-spki-key.js                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/resources/rsa-import-spki-key.js        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -0,0 +1,27 @@
</span><ins>+importScripts('../../../../resources/js-test-pre.js');
+importScripts(&quot;../../../resources/common.js&quot;);
+
+description(&quot;Test importing a SPKI RSA key in workers&quot;);
+
+jsTestIsAsync = true;
+
+var spkiKey = hexStringToUint8Array(&quot;30820122300d06092a864886f70d01010105000382010f003082010a0282010100d61051c4920d4c7c04a33beabb2412bedc4173fdbe82c7db80f0052d00abd32e01656d2105abef4fa5417bb868bb77780c08d20cfe9e2d767ee952970941398f8bea59a966772b1d89f19693cfff5faba22ba39ef7982ac46257180d557d3cbf3f7e65dd835d1d351e679a841b904a3cf24a0323aac0bb89705777507c76f57663b6d846e995a63057ceb48053ddf9282a366d6dc6cbdceb2ebcb3b374c7dc49da160cba8a3656211b8597a39ef9b8cc44d0c5735f870679ffcb1cb9321bbfbc307844d3174ef5dc144a951071340f4d156bead21fd3d9bd4641afa5851512264b4eed228b5d6324de428b00cbb89a1a88cb138d59de0b4ad75f2196e0e7ba890203010001&quot;);
+var extractable = true;
+
+shouldReject('crypto.subtle.importKey(&quot;spki&quot;, spkiKey, {name: &quot;RSA-OAEP&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;decrypt&quot;, &quot;unwrapKey&quot;])');
+
+debug(&quot;Importing a key...&quot;);
+crypto.subtle.importKey(&quot;spki&quot;, spkiKey, {name: &quot;RSA-OAEP&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;encrypt&quot;, &quot;wrapKey&quot;]).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;['encrypt', 'wrapKey']&quot;);
+
+    finishJSTest();
+});
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtlersaexportspkikeyexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/rsa-export-spki-key-expected.txt (0 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/rsa-export-spki-key-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/rsa-export-spki-key-expected.txt        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -0,0 +1,13 @@
</span><ins>+[Worker] Test exporting a RSA-OAEP public key with SPKI format in workers.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Starting worker: resources/rsa-export-spki-key.js
+[Worker] Generating a key pair...
+[Worker] Exporting the public key...
+PASS [Worker] publicKey.byteLength is 294
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtlersaexportspkikeyhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/rsa-export-spki-key.html (0 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/rsa-export-spki-key.html                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/rsa-export-spki-key.html        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;script src=&quot;../../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;script&gt;
+        worker = startWorker('resources/rsa-export-spki-key.js');
+    &lt;/script&gt;
+    &lt;script src=&quot;../../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtlersaimportspkikeyexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/rsa-import-spki-key-expected.txt (0 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/rsa-import-spki-key-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/rsa-import-spki-key-expected.txt        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -0,0 +1,20 @@
</span><ins>+[Worker] Test importing a SPKI RSA key in workers
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Starting worker: resources/rsa-import-spki-key.js
+[Worker] Importing a key...
+PASS [Worker] crypto.subtle.importKey(&quot;spki&quot;, spkiKey, {name: &quot;RSA-OAEP&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;decrypt&quot;, &quot;unwrapKey&quot;]) rejected promise  with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
+PASS [Worker] publicKey.toString() is '[object CryptoKey]'
+PASS [Worker] publicKey.type is 'public'
+PASS [Worker] publicKey.extractable is true
+PASS [Worker] publicKey.algorithm.name is 'RSA-OAEP'
+PASS [Worker] publicKey.algorithm.modulusLength is 2048
+PASS [Worker] bytesToHexString(publicKey.algorithm.publicExponent) is '010001'
+PASS [Worker] publicKey.algorithm.hash.name is 'SHA-1'
+PASS [Worker] publicKey.usages is ['encrypt', 'wrapKey']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtlersaimportspkikeyhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/rsa-import-spki-key.html (0 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/rsa-import-spki-key.html                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/rsa-import-spki-key.html        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;script src=&quot;../../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;script&gt;
+        worker = startWorker('resources/rsa-import-spki-key.js');
+    &lt;/script&gt;
+    &lt;script src=&quot;../../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (209436 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog        2016-12-07 00:46:23 UTC (rev 209436)
+++ trunk/LayoutTests/imported/w3c/ChangeLog        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2016-12-05  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
+
+        [Part 1 of 2] Add support for SPKI format while doing SubtleCrypto.importKey/exportKey
+        https://bugs.webkit.org/show_bug.cgi?id=129978
+        &lt;rdar://problem/21799829&gt;
+
+        Reviewed by Brent Fulgham.
+
+        * WebCryptoAPI/encrypt_decrypt/test_rsa_oaep-expected.txt:
+
</ins><span class="cx"> 2016-12-01  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Update SubtleCrypto::unwrapKey to match the latest spec
</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 (209436 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/WebCryptoAPI/encrypt_decrypt/test_rsa_oaep-expected.txt        2016-12-07 00:46:23 UTC (rev 209436)
+++ trunk/LayoutTests/imported/w3c/WebCryptoAPI/encrypt_decrypt/test_rsa_oaep-expected.txt        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -97,16 +97,16 @@
</span><span class="cx"> FAIL importVectorKeys step: RSA-OAEP with SHA-256 and a label using privateKey to encrypt assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-256 and a label. Message: ''The operation is not supported.'' Reached unreachable code
</span><span class="cx"> FAIL importVectorKeys step: RSA-OAEP with SHA-384 and a label using privateKey to encrypt assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-384 and a label. Message: ''The operation is not supported.'' Reached unreachable code
</span><span class="cx"> FAIL importVectorKeys step: RSA-OAEP with SHA-512 and a label using privateKey to encrypt assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-512 and a label. Message: ''The operation is not supported.'' Reached unreachable code
</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: ''The operation is not supported.'' 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: ''The operation is not supported.'' 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: ''The operation is not supported.'' 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: ''The operation is not supported.'' 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: ''The operation is not supported.'' 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: ''The operation is not supported.'' 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: ''The operation is not supported.'' 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: ''The operation is not supported.'' 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: ''The operation is not supported.'' 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: ''The operation is not supported.'' 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: ''The operation is not supported.'' 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: ''The operation is not supported.'' Reached unreachable code
</del><ins>+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
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (209436 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-12-07 00:46:23 UTC (rev 209436)
+++ trunk/Source/WebCore/ChangeLog        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -1,3 +1,51 @@
</span><ins>+2016-12-05  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
+
+        [Part 1 of 2] Add support for SPKI format while doing SubtleCrypto.importKey/exportKey
+        https://bugs.webkit.org/show_bug.cgi?id=129978
+        &lt;rdar://problem/21799829&gt;
+
+        This is part 1 of Bug 129978. In this patch, it adds the SPKI format support for
+        SubtleCrypto.importKey/exportKey. Currently support algorithms are RSAES-PKCS1-v1_5,
+        RSASSA-PKCS1-v1_5 and RSA-OAEP.
+
+        Reviewed by Brent Fulgham.
+
+        Tests: crypto/subtle/rsa-import-jwk-key-export-spki-key.html
+               crypto/subtle/rsa-import-spki-key-export-jwk-key.html
+               crypto/subtle/rsa-import-spki-key-export-spki-key.html
+               crypto/subtle/rsa-import-spki-small-key.html
+               crypto/subtle/rsa-oaep-generate-export-key-spki.html
+               crypto/subtle/rsa-oaep-import-spki-key.html
+               crypto/subtle/rsaes-pkcs1-v1_5-generate-export-key-spki.html
+               crypto/subtle/rsaes-pkcs1-v1_5-import-spki-key.html
+               crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-spki.html
+               crypto/subtle/rsassa-pkcs1-v1_5-import-spki-key.html
+               crypto/workers/subtle/rsa-export-spki-key.html
+               crypto/workers/subtle/rsa-import-spki-key.html
+
+        * bindings/js/JSSubtleCryptoCustom.cpp:
+        (WebCore::toKeyData):
+        * crypto/CommonCryptoUtilities.h:
+        * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp:
+        (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::importKey):
+        (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::exportKey):
+        * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp:
+        (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::importKey):
+        (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::exportKey):
+        * crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp:
+        (WebCore::CryptoAlgorithmRSA_OAEP::importKey):
+        (WebCore::CryptoAlgorithmRSA_OAEP::exportKey):
+        * crypto/gnutls/CryptoKeyRSAGnuTLS.cpp:
+        (WebCore::CryptoKeyRSA::importSpki):
+        (WebCore::CryptoKeyRSA::exportSpki):
+        * crypto/keys/CryptoKeyRSA.h:
+        * crypto/mac/CryptoKeyRSAMac.cpp:
+        (WebCore::bytesUsedToEncodedLength):
+        (WebCore::bytesNeededForEncodedLength):
+        (WebCore::addEncodedASN1Length):
+        (WebCore::CryptoKeyRSA::importSpki):
+        (WebCore::CryptoKeyRSA::exportSpki):
+
</ins><span class="cx"> 2016-12-06  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix editing text flakiness introduced in r209411
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSSubtleCryptoCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp (209436 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp        2016-12-07 00:46:23 UTC (rev 209436)
+++ trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -341,10 +341,10 @@
</span><span class="cx"> 
</span><span class="cx">     KeyData result;
</span><span class="cx">     switch (format) {
</span><del>-    case SubtleCrypto::KeyFormat::Spki:
</del><span class="cx">     case SubtleCrypto::KeyFormat::Pkcs8:
</span><span class="cx">         setDOMException(&amp;state, NOT_SUPPORTED_ERR);
</span><span class="cx">         return result;
</span><ins>+    case SubtleCrypto::KeyFormat::Spki:
</ins><span class="cx">     case SubtleCrypto::KeyFormat::Raw: {
</span><span class="cx">         BufferSource bufferSource = convert&lt;IDLBufferSource&gt;(state, value);
</span><span class="cx">         RETURN_IF_EXCEPTION(scope, result);
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoCommonCryptoUtilitiesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/CommonCryptoUtilities.h (209436 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/CommonCryptoUtilities.h        2016-12-07 00:46:23 UTC (rev 209436)
+++ trunk/Source/WebCore/crypto/CommonCryptoUtilities.h        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -82,6 +82,8 @@
</span><span class="cx"> extern &quot;C&quot; CCCryptorStatus CCRSAGetKeyComponents(CCRSACryptorRef rsaKey, uint8_t *modulus, size_t *modulusLength, uint8_t *exponent, size_t *exponentLength, uint8_t *p, size_t *pLength, uint8_t *q, size_t *qLength);
</span><span class="cx"> extern &quot;C&quot; CCRSAKeyType CCRSAGetKeyType(CCRSACryptorRef key);
</span><span class="cx"> extern &quot;C&quot; CCCryptorStatus CCCryptorGCM(CCOperation op, CCAlgorithm alg, const void* key, size_t keyLength, const void* iv, size_t ivLen, const void* aData, size_t aDataLen, const void* dataIn, size_t dataInLength, void* dataOut, const void* tag, size_t* tagLength);
</span><ins>+extern &quot;C&quot; CCCryptorStatus CCRSACryptorImport(const void *keyPackage, size_t keyPackageLen, CCRSACryptorRef *key);
+extern &quot;C&quot; CCCryptorStatus CCRSACryptorExport(CCRSACryptorRef key, void *out, size_t *outLen);
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSAES_PKCS1_v1_5cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp (209436 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp        2016-12-07 00:46:23 UTC (rev 209436)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -120,6 +120,14 @@
</span><span class="cx">         result = CryptoKeyRSA::importJwk(parameters-&gt;identifier, std::nullopt, WTFMove(key), extractable, usages);
</span><span class="cx">         break;
</span><span class="cx">     }
</span><ins>+    case SubtleCrypto::KeyFormat::Spki: {
+        if (usages ^ CryptoKeyUsageEncrypt) {
+            exceptionCallback(SYNTAX_ERR);
+            return;
+        }
+        result = CryptoKeyRSA::importSpki(parameters-&gt;identifier, std::nullopt, WTFMove(WTF::get&lt;Vector&lt;uint8_t&gt;&gt;(data)), extractable, usages);
+        break;
+    }
</ins><span class="cx">     default:
</span><span class="cx">         exceptionCallback(NOT_SUPPORTED_ERR);
</span><span class="cx">         return;
</span><span class="lines">@@ -149,6 +157,15 @@
</span><span class="cx">         result = WTFMove(jwk);
</span><span class="cx">         break;
</span><span class="cx">     }
</span><ins>+    case SubtleCrypto::KeyFormat::Spki: {
+        auto spki = rsaKey.exportSpki();
+        if (spki.hasException()) {
+            exceptionCallback(spki.releaseException().code());
+            return;
+        }
+        result = spki.releaseReturnValue();
+        break;
+    }
</ins><span class="cx">     default:
</span><span class="cx">         exceptionCallback(NOT_SUPPORTED_ERR);
</span><span class="cx">         return;
</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 (209436 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp        2016-12-07 00:46:23 UTC (rev 209436)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -153,6 +153,15 @@
</span><span class="cx">         result = CryptoKeyRSA::importJwk(rsaParameters.identifier, rsaParameters.hashIdentifier, WTFMove(key), extractable, usages);
</span><span class="cx">         break;
</span><span class="cx">     }
</span><ins>+    case SubtleCrypto::KeyFormat::Spki: {
+        if (usages ^ CryptoKeyUsageVerify) {
+            exceptionCallback(SYNTAX_ERR);
+            return;
+        }
+        // FIXME: &lt;webkit.org/b/165436&gt;
+        result = CryptoKeyRSA::importSpki(rsaParameters.identifier, rsaParameters.hashIdentifier, WTFMove(WTF::get&lt;Vector&lt;uint8_t&gt;&gt;(data)), extractable, usages);
+        break;
+    }
</ins><span class="cx">     default:
</span><span class="cx">         exceptionCallback(NOT_SUPPORTED_ERR);
</span><span class="cx">         return;
</span><span class="lines">@@ -200,6 +209,15 @@
</span><span class="cx">         result = WTFMove(jwk);
</span><span class="cx">         break;
</span><span class="cx">     }
</span><ins>+    case SubtleCrypto::KeyFormat::Spki: {
+        auto spki = rsaKey.exportSpki();
+        if (spki.hasException()) {
+            exceptionCallback(spki.releaseException().code());
+            return;
+        }
+        result = spki.releaseReturnValue();
+        break;
+    }
</ins><span class="cx">     default:
</span><span class="cx">         exceptionCallback(NOT_SUPPORTED_ERR);
</span><span class="cx">         return;
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSA_OAEPcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp (209436 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp        2016-12-07 00:46:23 UTC (rev 209436)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -166,6 +166,15 @@
</span><span class="cx">         result = CryptoKeyRSA::importJwk(rsaParameters.identifier, rsaParameters.hashIdentifier, WTFMove(key), extractable, usages);
</span><span class="cx">         break;
</span><span class="cx">     }
</span><ins>+    case SubtleCrypto::KeyFormat::Spki: {
+        if ((usages ^ CryptoKeyUsageEncrypt) &amp;&amp; (usages ^ CryptoKeyUsageWrapKey) &amp;&amp; (usages ^ (CryptoKeyUsageEncrypt | CryptoKeyUsageWrapKey))) {
+            exceptionCallback(SYNTAX_ERR);
+            return;
+        }
+        // FIXME: &lt;webkit.org/b/165436&gt;
+        result = CryptoKeyRSA::importSpki(rsaParameters.identifier, rsaParameters.hashIdentifier, WTFMove(WTF::get&lt;Vector&lt;uint8_t&gt;&gt;(data)), extractable, usages);
+        break;
+    }
</ins><span class="cx">     default:
</span><span class="cx">         exceptionCallback(NOT_SUPPORTED_ERR);
</span><span class="cx">         return;
</span><span class="lines">@@ -213,6 +222,16 @@
</span><span class="cx">         result = WTFMove(jwk);
</span><span class="cx">         break;
</span><span class="cx">     }
</span><ins>+    case SubtleCrypto::KeyFormat::Spki: {
+        // FIXME: &lt;webkit.org/b/165437&gt;
+        auto spki = rsaKey.exportSpki();
+        if (spki.hasException()) {
+            exceptionCallback(spki.releaseException().code());
+            return;
+        }
+        result = spki.releaseReturnValue();
+        break;
+    }
</ins><span class="cx">     default:
</span><span class="cx">         exceptionCallback(NOT_SUPPORTED_ERR);
</span><span class="cx">         return;
</span></span></pre></div>
<a id="trunkSourceWebCorecryptognutlsCryptoKeyRSAGnuTLScpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/gnutls/CryptoKeyRSAGnuTLS.cpp (209436 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/gnutls/CryptoKeyRSAGnuTLS.cpp        2016-12-07 00:46:23 UTC (rev 209436)
+++ trunk/Source/WebCore/crypto/gnutls/CryptoKeyRSAGnuTLS.cpp        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> #include &quot;CryptoAlgorithmRegistry.h&quot;
</span><span class="cx"> #include &quot;CryptoKeyDataRSAComponents.h&quot;
</span><span class="cx"> #include &quot;CryptoKeyPair.h&quot;
</span><ins>+#include &quot;ExceptionCode.h&quot;
</ins><span class="cx"> #include &quot;NotImplemented.h&quot;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -111,6 +112,20 @@
</span><span class="cx">     UNUSED_PARAM(context);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+RefPtr&lt;CryptoKeyRSA&gt; CryptoKeyRSA::importSpki(CryptoAlgorithmIdentifier, std::optional&lt;CryptoAlgorithmIdentifier&gt;, Vector&lt;uint8_t&gt;&amp;&amp;, bool, CryptoKeyUsageBitmap)
+{
+    notImplemented();
+
+    return nullptr;
+}
+
+ExceptionOr&lt;Vector&lt;uint8_t&gt;&gt; CryptoKeyRSA::exportSpki() const
+{
+    notImplemented();
+
+    return Exception { NOT_SUPPORTED_ERR };
+}
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(SUBTLE_CRYPTO)
</span></span></pre></div>
<a id="trunkSourceWebCorecryptokeysCryptoKeyRSAh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyRSA.h (209436 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/keys/CryptoKeyRSA.h        2016-12-07 00:46:23 UTC (rev 209436)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyRSA.h        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> #pragma once
</span><span class="cx"> 
</span><span class="cx"> #include &quot;CryptoKey.h&quot;
</span><ins>+#include &quot;ExceptionOr.h&quot;
</ins><span class="cx"> #include &lt;wtf/Function.h&gt;
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(SUBTLE_CRYPTO)
</span><span class="lines">@@ -101,9 +102,11 @@
</span><span class="cx">     using VoidCallback = WTF::Function&lt;void()&gt;;
</span><span class="cx">     static void generatePair(CryptoAlgorithmIdentifier, CryptoAlgorithmIdentifier hash, bool hasHash, unsigned modulusLength, const Vector&lt;uint8_t&gt;&amp; publicExponent, bool extractable, CryptoKeyUsageBitmap, KeyPairCallback&amp;&amp;, VoidCallback&amp;&amp; failureCallback, ScriptExecutionContext*);
</span><span class="cx">     static RefPtr&lt;CryptoKeyRSA&gt; importJwk(CryptoAlgorithmIdentifier, std::optional&lt;CryptoAlgorithmIdentifier&gt; hash, JsonWebKey&amp;&amp;, bool extractable, CryptoKeyUsageBitmap);
</span><ins>+    static RefPtr&lt;CryptoKeyRSA&gt; importSpki(CryptoAlgorithmIdentifier, std::optional&lt;CryptoAlgorithmIdentifier&gt; hash, Vector&lt;uint8_t&gt;&amp;&amp;, bool extractable, CryptoKeyUsageBitmap);
</ins><span class="cx"> 
</span><span class="cx">     PlatformRSAKey platformKey() const { return m_platformKey; }
</span><span class="cx">     JsonWebKey exportJwk() const;
</span><ins>+    ExceptionOr&lt;Vector&lt;uint8_t&gt;&gt; exportSpki() const;
</ins><span class="cx"> 
</span><span class="cx">     CryptoAlgorithmIdentifier hashAlgorithmIdentifier() const { return m_hash; }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorecryptomacCryptoKeyRSAMaccpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/mac/CryptoKeyRSAMac.cpp (209436 => 209437)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/mac/CryptoKeyRSAMac.cpp        2016-12-07 00:46:23 UTC (rev 209436)
+++ trunk/Source/WebCore/crypto/mac/CryptoKeyRSAMac.cpp        2016-12-07 01:15:20 UTC (rev 209437)
</span><span class="lines">@@ -32,11 +32,19 @@
</span><span class="cx"> #include &quot;CryptoAlgorithmRegistry.h&quot;
</span><span class="cx"> #include &quot;CryptoKeyDataRSAComponents.h&quot;
</span><span class="cx"> #include &quot;CryptoKeyPair.h&quot;
</span><ins>+#include &quot;ExceptionCode.h&quot;
</ins><span class="cx"> #include &quot;ScriptExecutionContext.h&quot;
</span><span class="cx"> #include &lt;wtf/MainThread.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+// OID rsaEncryption: 1.2.840.113549.1.1.1. Per https://tools.ietf.org/html/rfc3279#section-2.3.1
+static unsigned char RSAOIDHeader[] = {0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00};
+// Per X.690 08/2015: https://www.itu.int/rec/T-REC-X.680-X.693/en
+static unsigned char SequenceMark = 0x30;
+static unsigned char BitStringMark = 0x03;
+static unsigned char InitialOctet = 0x00;
+
</ins><span class="cx"> // FIXME: We should get rid of magic number 16384. It assumes that the length of provided key will not exceed 16KB.
</span><span class="cx"> // https://bugs.webkit.org/show_bug.cgi?id=164942
</span><span class="cx"> static CCCryptorStatus getPublicKeyComponents(CCRSACryptorRef rsaKey, Vector&lt;uint8_t&gt;&amp; modulus, Vector&lt;uint8_t&gt;&amp; publicExponent)
</span><span class="lines">@@ -235,6 +243,41 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static size_t bytesUsedToEncodedLength(uint8_t octet)
+{
+    if (octet &lt; 128)
+        return 1;
+    return octet - 127;
+}
+
+static size_t bytesNeededForEncodedLength(size_t length)
+{
+    if (!length)
+        return 0;
+    size_t result = 1;
+    while (result &lt; sizeof(length) &amp;&amp; length &gt;= (1 &lt;&lt; (result * 8)))
+        result += 1;
+    return result;
+}
+
+static void addEncodedASN1Length(Vector&lt;uint8_t&gt;&amp; in, size_t length)
+{
+    if (length &lt; 128) {
+        in.append(length);
+        return;
+    }
+
+    size_t extraBytes = bytesNeededForEncodedLength(length);
+    in.append(128 + extraBytes);
+
+    size_t lastPosition = in.size() + extraBytes - 1;
+    in.grow(in.size() + extraBytes);
+    for (size_t i = 0; i &lt; extraBytes; i++) {
+        in[lastPosition - i] = length &amp; 0xff;
+        length = length &gt;&gt; 8;
+    }
+}
+
</ins><span class="cx"> // FIXME: We should use WorkQueue here instead of dispatch_async once WebKitSubtleCrypto is deprecated.
</span><span class="cx"> // https://bugs.webkit.org/show_bug.cgi?id=164943
</span><span class="cx"> void CryptoKeyRSA::generatePair(CryptoAlgorithmIdentifier algorithm, CryptoAlgorithmIdentifier hash, bool hasHash, unsigned modulusLength, const Vector&lt;uint8_t&gt;&amp; publicExponent, bool extractable, CryptoKeyUsageBitmap usage, KeyPairCallback&amp;&amp; callback, VoidCallback&amp;&amp; failureCallback, ScriptExecutionContext* context)
</span><span class="lines">@@ -280,6 +323,61 @@
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+RefPtr&lt;CryptoKeyRSA&gt; CryptoKeyRSA::importSpki(CryptoAlgorithmIdentifier identifier, std::optional&lt;CryptoAlgorithmIdentifier&gt; hash, Vector&lt;uint8_t&gt;&amp;&amp; keyData, bool extractable, CryptoKeyUsageBitmap usages)
+{
+    // The current SecLibrary cannot import a SPKI format binary. Hence, we need to strip out the SPKI header.
+    // This hack can be removed when &lt;rdar://problem/29523286&gt; is resolved.
+    // The header format we assume is: SequenceMark(1) + Length(?) + rsaEncryption(15) + BitStringMark(1) + Length(?) + InitialOctet(1).
+    // The header format could be varied. However since we don't have a full-fledged ASN.1 encoder/decoder, we want to restrict it to
+    // the most common one for now.
+    // Per https://tools.ietf.org/html/rfc5280#section-4.1. subjectPublicKeyInfo.
+    size_t headerSize = 1;
+    if (keyData.size() &lt; headerSize)
+        return nullptr;
+    headerSize += bytesUsedToEncodedLength(keyData[headerSize]) + sizeof(RSAOIDHeader) + sizeof(BitStringMark);
+    if (keyData.size() &lt; headerSize)
+        return nullptr;
+    headerSize += bytesUsedToEncodedLength(keyData[headerSize]) + sizeof(InitialOctet);
+
+    CCRSACryptorRef ccPublicKey;
+    if (CCRSACryptorImport(keyData.data() + headerSize, keyData.size() - headerSize, &amp;ccPublicKey))
+        return nullptr;
+
+    // Notice: CryptoAlgorithmIdentifier::SHA_1 is just a placeholder. It should not have any effect if hash is std::nullopt.
+    return adoptRef(new CryptoKeyRSA(identifier, hash.value_or(CryptoAlgorithmIdentifier::SHA_1), !!hash, CryptoKeyType::Public, ccPublicKey, extractable, usages));
+}
+
+ExceptionOr&lt;Vector&lt;uint8_t&gt;&gt; CryptoKeyRSA::exportSpki() const
+{
+    if (type() != CryptoKeyType::Public)
+        return Exception { INVALID_ACCESS_ERR };
+
+    // The current SecLibrary cannot output a valid SPKI format binary. Hence, we need the following hack.
+    // This hack can be removed when &lt;rdar://problem/29523286&gt; is resolved.
+    // Estimated size in produced bytes format. Per https://tools.ietf.org/html/rfc3279#section-2.3.1. RSAPublicKey.
+    // O(size) = Sequence(1) + Length(3) + Integer(1) + Length(3) + Modulus + Integer(1) + Length(3) + Exponent
+    Vector&lt;uint8_t&gt; keyBytes(keySizeInBits() / 4);
+    size_t keySize = keyBytes.size();
+    if (CCRSACryptorExport(platformKey(), keyBytes.data(), &amp;keySize))
+        return Exception { OperationError };
+    keyBytes.shrink(keySize);
+
+    // RSAOIDHeader + BitStringMark + Length + keySize + InitialOctet
+    size_t totalSize = sizeof(RSAOIDHeader) + bytesNeededForEncodedLength(keySize + 1) + keySize + 3;
+
+    // Per https://tools.ietf.org/html/rfc5280#section-4.1. subjectPublicKeyInfo.
+    Vector&lt;uint8_t&gt; result;
+    result.append(SequenceMark);
+    addEncodedASN1Length(result, totalSize);
+    result.append(RSAOIDHeader, sizeof(RSAOIDHeader));
+    result.append(BitStringMark);
+    addEncodedASN1Length(result, keySize + 1);
+    result.append(InitialOctet);
+    result.append(keyBytes.data(), keyBytes.size());
+
+    return WTFMove(result);
+}
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(SUBTLE_CRYPTO)
</span></span></pre>
</div>
</div>

</body>
</html>