<!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>[208737] 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/208737">208737</a></dd>
<dt>Author</dt> <dd>jiewen_tan@apple.com</dd>
<dt>Date</dt> <dd>2016-11-15 11:08:25 -0800 (Tue, 15 Nov 2016)</dd>
</dl>

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

Reviewed by Brent Fulgham.

LayoutTests/imported/w3c:

* WebCryptoAPI/idlharness-expected.txt:

Source/WebCore:

This patch does following few things:
1. It updates the SubtleCrypto::exportKey method to match the latest spec:
   https://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-exportKey.
   It also refers to the latest Editor's Draft to a certain degree:
   https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-exportKey.
2. It implements exportKey operations of the following algorithms: AES-CBC, AES-KW,
   HMAC, RSAES-PKCS1-V1_5, RSASSA-PKCS1-V1_5, and RSA-OAEP.
3. It also fixes the following bugs:
   https://bugs.webkit.org/show_bug.cgi?id=156114,
   &lt;rdar://problem/21773066&gt;.
Note: We currently only support Raw and Jwk key format.

Tests: crypto/subtle/aes-cbc-generate-export-key-jwk-length-128.html
       crypto/subtle/aes-cbc-generate-export-key-jwk-length-192.html
       crypto/subtle/aes-cbc-generate-export-key-jwk-length-256.html
       crypto/subtle/aes-cbc-generate-export-key-raw.html
       crypto/subtle/aes-export-key-malformed-parameters.html
       crypto/subtle/aes-kw-generate-export-key-jwk-length-128.html
       crypto/subtle/aes-kw-generate-export-key-jwk-length-192.html
       crypto/subtle/aes-kw-generate-export-key-jwk-length-256.html
       crypto/subtle/aes-kw-generate-export-raw-key.html
       crypto/subtle/export-key-malformed-parameters.html
       crypto/subtle/hmac-export-key-malformed-parameters.html
       crypto/subtle/hmac-generate-export-key-jwk-sha1.html
       crypto/subtle/hmac-generate-export-key-jwk-sha224.html
       crypto/subtle/hmac-generate-export-key-jwk-sha256.html
       crypto/subtle/hmac-generate-export-key-jwk-sha384.html
       crypto/subtle/hmac-generate-export-key-jwk-sha512.html
       crypto/subtle/hmac-generate-export-raw-key.html
       crypto/subtle/hmac-import-key-malformed-parameters.html
       crypto/subtle/rsa-export-key-malformed-parameters.html
       crypto/subtle/rsa-oaep-generate-export-key-jwk-sha1.html
       crypto/subtle/rsa-oaep-generate-export-key-jwk-sha224.html
       crypto/subtle/rsa-oaep-generate-export-key-jwk-sha256.html
       crypto/subtle/rsa-oaep-generate-export-key-jwk-sha384.html
       crypto/subtle/rsa-oaep-generate-export-key-jwk-sha512.html
       crypto/subtle/rsaes-pkcs1-v1_5-generate-export-key-jwk.html
       crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha1.html
       crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha224.html
       crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha256.html
       crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha384.html
       crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha512.html
       crypto/workers/subtle/aes-generate-export-key-jwk.html
       crypto/workers/subtle/aes-generate-export-key-raw.html
       crypto/workers/subtle/hmac-generate-export-key-jwk.html
       crypto/workers/subtle/hmac-generate-export-key-raw.html
       crypto/workers/subtle/rsa-generate-export-key-jwk.html

* bindings/js/JSSubtleCryptoCustom.cpp:
(WebCore::toJSValueFromJsonWebKey):
(WebCore::jsSubtleCryptoFunctionExportKeyPromise):
(WebCore::JSSubtleCrypto::exportKey):
* crypto/CryptoAlgorithm.cpp:
(WebCore::CryptoAlgorithm::exportKey):
* crypto/CryptoAlgorithm.h:
* crypto/SubtleCrypto.idl:
* crypto/algorithms/CryptoAlgorithmAES_CBC.cpp:
(WebCore::CryptoAlgorithmAES_CBC::importKey):
(WebCore::CryptoAlgorithmAES_CBC::exportKey):
* crypto/algorithms/CryptoAlgorithmAES_CBC.h:
* crypto/algorithms/CryptoAlgorithmAES_KW.cpp:
(WebCore::CryptoAlgorithmAES_KW::importKey):
(WebCore::CryptoAlgorithmAES_KW::exportKey):
* crypto/algorithms/CryptoAlgorithmAES_KW.h:
* crypto/algorithms/CryptoAlgorithmHMAC.cpp:
(WebCore::CryptoAlgorithmHMAC::importKey):
(WebCore::CryptoAlgorithmHMAC::exportKey):
* crypto/algorithms/CryptoAlgorithmHMAC.h:
* crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp:
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::importKey):
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::exportKey):
* crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h:
* crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp:
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::importKey):
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::exportKey):
* crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h:
* crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp:
(WebCore::CryptoAlgorithmRSA_OAEP::importKey):
(WebCore::CryptoAlgorithmRSA_OAEP::exportKey):
* crypto/algorithms/CryptoAlgorithmRSA_OAEP.h:
* crypto/keys/CryptoKeyAES.cpp:
(WebCore::CryptoKeyAES::exportJwk):
* crypto/keys/CryptoKeyAES.h:
* crypto/keys/CryptoKeyHMAC.cpp:
(WebCore::CryptoKeyHMAC::exportJwk):
* crypto/keys/CryptoKeyHMAC.h:
* crypto/keys/CryptoKeyRSA.cpp:
(WebCore::CryptoKeyRSA::exportJwk):
* crypto/keys/CryptoKeyRSA.h:

LayoutTests:

Besides adding test cases for SubtleCrypto::exportKey, this patch also corrects a typo:
hmac-import-malformed-parameters* =&gt; hmac-import-key-malformed-parameters*.

* crypto/subtle/aes-cbc-generate-export-key-jwk-length-128-expected.txt: Added.
* crypto/subtle/aes-cbc-generate-export-key-jwk-length-128.html: Added.
* crypto/subtle/aes-cbc-generate-export-key-jwk-length-192-expected.txt: Added.
* crypto/subtle/aes-cbc-generate-export-key-jwk-length-192.html: Added.
* crypto/subtle/aes-cbc-generate-export-key-jwk-length-256-expected.txt: Added.
* crypto/subtle/aes-cbc-generate-export-key-jwk-length-256.html: Added.
* crypto/subtle/aes-cbc-generate-export-key-raw-expected.txt: Added.
* crypto/subtle/aes-cbc-generate-export-key-raw.html: Added.
* crypto/subtle/aes-export-key-malformed-parameters-expected.txt: Added.
* crypto/subtle/aes-export-key-malformed-parameters.html: Added.
* crypto/subtle/aes-kw-generate-export-key-jwk-length-128-expected.txt: Added.
* crypto/subtle/aes-kw-generate-export-key-jwk-length-128.html: Added.
* crypto/subtle/aes-kw-generate-export-key-jwk-length-192-expected.txt: Added.
* crypto/subtle/aes-kw-generate-export-key-jwk-length-192.html: Added.
* crypto/subtle/aes-kw-generate-export-key-jwk-length-256-expected.txt: Added.
* crypto/subtle/aes-kw-generate-export-key-jwk-length-256.html: Added.
* crypto/subtle/aes-kw-generate-export-raw-key-expected.txt: Added.
* crypto/subtle/aes-kw-generate-export-raw-key.html: Added.
* crypto/subtle/export-key-malformed-parameters-expected.txt: Added.
* crypto/subtle/export-key-malformed-parameters.html: Added.
* crypto/subtle/hmac-export-key-malformed-parameters-expected.txt: Added.
* crypto/subtle/hmac-export-key-malformed-parameters.html: Added.
* crypto/subtle/hmac-generate-export-key-jwk-sha1-expected.txt: Added.
* crypto/subtle/hmac-generate-export-key-jwk-sha1.html: Added.
* crypto/subtle/hmac-generate-export-key-jwk-sha224-expected.txt: Added.
* crypto/subtle/hmac-generate-export-key-jwk-sha224.html: Added.
* crypto/subtle/hmac-generate-export-key-jwk-sha256-expected.txt: Added.
* crypto/subtle/hmac-generate-export-key-jwk-sha256.html: Added.
* crypto/subtle/hmac-generate-export-key-jwk-sha384-expected.txt: Added.
* crypto/subtle/hmac-generate-export-key-jwk-sha384.html: Added.
* crypto/subtle/hmac-generate-export-key-jwk-sha512-expected.txt: Added.
* crypto/subtle/hmac-generate-export-key-jwk-sha512.html: Added.
* crypto/subtle/hmac-generate-export-raw-key-expected.txt: Added.
* crypto/subtle/hmac-generate-export-raw-key.html: Added.
* crypto/subtle/hmac-import-key-malformed-parameters-expected.txt: Renamed from LayoutTests/crypto/subtle/hmac-import-malformed-parameters-expected.txt.
* crypto/subtle/hmac-import-key-malformed-parameters.html: Renamed from LayoutTests/crypto/subtle/hmac-import-malformed-parameters.html.
* crypto/subtle/rsa-export-key-malformed-parameters-expected.txt: Added.
* crypto/subtle/rsa-export-key-malformed-parameters.html: Added.
* crypto/subtle/rsa-oaep-generate-export-key-jwk-sha1-expected.txt: Added.
* crypto/subtle/rsa-oaep-generate-export-key-jwk-sha1.html: Added.
* crypto/subtle/rsa-oaep-generate-export-key-jwk-sha224-expected.txt: Added.
* crypto/subtle/rsa-oaep-generate-export-key-jwk-sha224.html: Added.
* crypto/subtle/rsa-oaep-generate-export-key-jwk-sha256-expected.txt: Added.
* crypto/subtle/rsa-oaep-generate-export-key-jwk-sha256.html: Added.
* crypto/subtle/rsa-oaep-generate-export-key-jwk-sha384-expected.txt: Added.
* crypto/subtle/rsa-oaep-generate-export-key-jwk-sha384.html: Added.
* crypto/subtle/rsa-oaep-generate-export-key-jwk-sha512-expected.txt: Added.
* crypto/subtle/rsa-oaep-generate-export-key-jwk-sha512.html: Added.
* crypto/subtle/rsaes-pkcs1-v1_5-generate-export-key-jwk-expected.txt: Added.
* crypto/subtle/rsaes-pkcs1-v1_5-generate-export-key-jwk.html: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha1-expected.txt: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha1.html: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha224-expected.txt: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha224.html: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha256-expected.txt: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha256.html: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha384-expected.txt: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha384.html: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha512-expected.txt: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha512.html: Added.
* crypto/workers/subtle/aes-generate-export-key-jwk-expected.txt: Added.
* crypto/workers/subtle/aes-generate-export-key-jwk.html: Added.
* crypto/workers/subtle/aes-generate-export-key-raw-expected.txt: Added.
* crypto/workers/subtle/aes-generate-export-key-raw.html: Added.
* crypto/workers/subtle/hmac-generate-export-key-jwk-expected.txt: Added.
* crypto/workers/subtle/hmac-generate-export-key-jwk.html: Added.
* crypto/workers/subtle/hmac-generate-export-key-raw-expected.txt: Added.
* crypto/workers/subtle/hmac-generate-export-key-raw.html: Added.
* crypto/workers/subtle/resources/aes-generate-export-key-jwk.js: Added.
* crypto/workers/subtle/resources/aes-generate-export-key-raw.js: Added.
* crypto/workers/subtle/resources/hmac-generate-export-key-jwk.js: Added.
* crypto/workers/subtle/resources/hmac-generate-export-key-raw.js: Added.
* crypto/workers/subtle/resources/rsa-generate-export-key-jwk.js: Added.
* crypto/workers/subtle/rsa-generate-export-key-jwk-expected.txt: Added.
* crypto/workers/subtle/rsa-generate-export-key-jwk.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cWebCryptoAPIidlharnessexpectedtxt">trunk/LayoutTests/imported/w3c/WebCryptoAPI/idlharness-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSSubtleCryptoCustomcpp">trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoCryptoAlgorithmcpp">trunk/Source/WebCore/crypto/CryptoAlgorithm.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoCryptoAlgorithmh">trunk/Source/WebCore/crypto/CryptoAlgorithm.h</a></li>
<li><a href="#trunkSourceWebCorecryptoSubtleCryptoidl">trunk/Source/WebCore/crypto/SubtleCrypto.idl</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmAES_CBCcpp">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmAES_CBCh">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.h</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmAES_KWcpp">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmAES_KWh">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.h</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmHMACcpp">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmHMACh">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.h</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSAES_PKCS1_v1_5cpp">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSAES_PKCS1_v1_5h">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSASSA_PKCS1_v1_5cpp">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSASSA_PKCS1_v1_5h">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSA_OAEPcpp">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSA_OAEPh">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.h</a></li>
<li><a href="#trunkSourceWebCorecryptokeysCryptoKeyAEScpp">trunk/Source/WebCore/crypto/keys/CryptoKeyAES.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptokeysCryptoKeyAESh">trunk/Source/WebCore/crypto/keys/CryptoKeyAES.h</a></li>
<li><a href="#trunkSourceWebCorecryptokeysCryptoKeyHMACcpp">trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptokeysCryptoKeyHMACh">trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.h</a></li>
<li><a href="#trunkSourceWebCorecryptokeysCryptoKeyRSAcpp">trunk/Source/WebCore/crypto/keys/CryptoKeyRSA.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptokeysCryptoKeyRSAh">trunk/Source/WebCore/crypto/keys/CryptoKeyRSA.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestscryptosubtleaescbcgenerateexportkeyjwklength128expectedtxt">trunk/LayoutTests/crypto/subtle/aes-cbc-generate-export-key-jwk-length-128-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleaescbcgenerateexportkeyjwklength128html">trunk/LayoutTests/crypto/subtle/aes-cbc-generate-export-key-jwk-length-128.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleaescbcgenerateexportkeyjwklength192expectedtxt">trunk/LayoutTests/crypto/subtle/aes-cbc-generate-export-key-jwk-length-192-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleaescbcgenerateexportkeyjwklength192html">trunk/LayoutTests/crypto/subtle/aes-cbc-generate-export-key-jwk-length-192.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleaescbcgenerateexportkeyjwklength256expectedtxt">trunk/LayoutTests/crypto/subtle/aes-cbc-generate-export-key-jwk-length-256-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleaescbcgenerateexportkeyjwklength256html">trunk/LayoutTests/crypto/subtle/aes-cbc-generate-export-key-jwk-length-256.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleaescbcgenerateexportkeyrawexpectedtxt">trunk/LayoutTests/crypto/subtle/aes-cbc-generate-export-key-raw-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleaescbcgenerateexportkeyrawhtml">trunk/LayoutTests/crypto/subtle/aes-cbc-generate-export-key-raw.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleaesexportkeymalformedparametersexpectedtxt">trunk/LayoutTests/crypto/subtle/aes-export-key-malformed-parameters-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleaesexportkeymalformedparametershtml">trunk/LayoutTests/crypto/subtle/aes-export-key-malformed-parameters.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleaeskwgenerateexportkeyjwklength128expectedtxt">trunk/LayoutTests/crypto/subtle/aes-kw-generate-export-key-jwk-length-128-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleaeskwgenerateexportkeyjwklength128html">trunk/LayoutTests/crypto/subtle/aes-kw-generate-export-key-jwk-length-128.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleaeskwgenerateexportkeyjwklength192expectedtxt">trunk/LayoutTests/crypto/subtle/aes-kw-generate-export-key-jwk-length-192-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleaeskwgenerateexportkeyjwklength192html">trunk/LayoutTests/crypto/subtle/aes-kw-generate-export-key-jwk-length-192.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleaeskwgenerateexportkeyjwklength256expectedtxt">trunk/LayoutTests/crypto/subtle/aes-kw-generate-export-key-jwk-length-256-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleaeskwgenerateexportkeyjwklength256html">trunk/LayoutTests/crypto/subtle/aes-kw-generate-export-key-jwk-length-256.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleaeskwgenerateexportrawkeyexpectedtxt">trunk/LayoutTests/crypto/subtle/aes-kw-generate-export-raw-key-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleaeskwgenerateexportrawkeyhtml">trunk/LayoutTests/crypto/subtle/aes-kw-generate-export-raw-key.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleexportkeymalformedparametersexpectedtxt">trunk/LayoutTests/crypto/subtle/export-key-malformed-parameters-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleexportkeymalformedparametershtml">trunk/LayoutTests/crypto/subtle/export-key-malformed-parameters.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacexportkeymalformedparametersexpectedtxt">trunk/LayoutTests/crypto/subtle/hmac-export-key-malformed-parameters-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacexportkeymalformedparametershtml">trunk/LayoutTests/crypto/subtle/hmac-export-key-malformed-parameters.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacgenerateexportkeyjwksha1expectedtxt">trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha1-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacgenerateexportkeyjwksha1html">trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha1.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacgenerateexportkeyjwksha224expectedtxt">trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha224-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacgenerateexportkeyjwksha224html">trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha224.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacgenerateexportkeyjwksha256expectedtxt">trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha256-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacgenerateexportkeyjwksha256html">trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha256.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacgenerateexportkeyjwksha384expectedtxt">trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha384-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacgenerateexportkeyjwksha384html">trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha384.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacgenerateexportkeyjwksha512expectedtxt">trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha512-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacgenerateexportkeyjwksha512html">trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha512.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacgenerateexportrawkeyexpectedtxt">trunk/LayoutTests/crypto/subtle/hmac-generate-export-raw-key-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacgenerateexportrawkeyhtml">trunk/LayoutTests/crypto/subtle/hmac-generate-export-raw-key.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacimportkeymalformedparametersexpectedtxt">trunk/LayoutTests/crypto/subtle/hmac-import-key-malformed-parameters-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacimportkeymalformedparametershtml">trunk/LayoutTests/crypto/subtle/hmac-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="#trunkLayoutTestscryptosubtlersaoaepgenerateexportkeyjwksha1expectedtxt">trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha1-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaoaepgenerateexportkeyjwksha1html">trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha1.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaoaepgenerateexportkeyjwksha224expectedtxt">trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha224-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaoaepgenerateexportkeyjwksha224html">trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha224.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaoaepgenerateexportkeyjwksha256expectedtxt">trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha256-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaoaepgenerateexportkeyjwksha256html">trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha256.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaoaepgenerateexportkeyjwksha384expectedtxt">trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha384-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaoaepgenerateexportkeyjwksha384html">trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha384.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaoaepgenerateexportkeyjwksha512expectedtxt">trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha512-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaoaepgenerateexportkeyjwksha512html">trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha512.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaespkcs1v1_5generateexportkeyjwkexpectedtxt">trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-generate-export-key-jwk-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaespkcs1v1_5generateexportkeyjwkhtml">trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-generate-export-key-jwk.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5generateexportkeyjwksha1expectedtxt">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha1-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5generateexportkeyjwksha1html">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha1.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5generateexportkeyjwksha224expectedtxt">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha224-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5generateexportkeyjwksha224html">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha224.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5generateexportkeyjwksha256expectedtxt">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha256-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5generateexportkeyjwksha256html">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha256.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5generateexportkeyjwksha384expectedtxt">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha384-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5generateexportkeyjwksha384html">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha384.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5generateexportkeyjwksha512expectedtxt">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha512-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5generateexportkeyjwksha512html">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha512.html</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtleaesgenerateexportkeyjwkexpectedtxt">trunk/LayoutTests/crypto/workers/subtle/aes-generate-export-key-jwk-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtleaesgenerateexportkeyjwkhtml">trunk/LayoutTests/crypto/workers/subtle/aes-generate-export-key-jwk.html</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtleaesgenerateexportkeyrawexpectedtxt">trunk/LayoutTests/crypto/workers/subtle/aes-generate-export-key-raw-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtleaesgenerateexportkeyrawhtml">trunk/LayoutTests/crypto/workers/subtle/aes-generate-export-key-raw.html</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtlehmacgenerateexportkeyjwkexpectedtxt">trunk/LayoutTests/crypto/workers/subtle/hmac-generate-export-key-jwk-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtlehmacgenerateexportkeyjwkhtml">trunk/LayoutTests/crypto/workers/subtle/hmac-generate-export-key-jwk.html</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtlehmacgenerateexportkeyrawexpectedtxt">trunk/LayoutTests/crypto/workers/subtle/hmac-generate-export-key-raw-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtlehmacgenerateexportkeyrawhtml">trunk/LayoutTests/crypto/workers/subtle/hmac-generate-export-key-raw.html</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtleresourcesaesgenerateexportkeyjwkjs">trunk/LayoutTests/crypto/workers/subtle/resources/aes-generate-export-key-jwk.js</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtleresourcesaesgenerateexportkeyrawjs">trunk/LayoutTests/crypto/workers/subtle/resources/aes-generate-export-key-raw.js</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtleresourceshmacgenerateexportkeyjwkjs">trunk/LayoutTests/crypto/workers/subtle/resources/hmac-generate-export-key-jwk.js</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtleresourceshmacgenerateexportkeyrawjs">trunk/LayoutTests/crypto/workers/subtle/resources/hmac-generate-export-key-raw.js</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtleresourcesrsagenerateexportkeyjwkjs">trunk/LayoutTests/crypto/workers/subtle/resources/rsa-generate-export-key-jwk.js</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtlersagenerateexportkeyjwkexpectedtxt">trunk/LayoutTests/crypto/workers/subtle/rsa-generate-export-key-jwk-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtlersagenerateexportkeyjwkhtml">trunk/LayoutTests/crypto/workers/subtle/rsa-generate-export-key-jwk.html</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkLayoutTestscryptosubtlehmacimportmalformedparametersexpectedtxt">trunk/LayoutTests/crypto/subtle/hmac-import-malformed-parameters-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacimportmalformedparametershtml">trunk/LayoutTests/crypto/subtle/hmac-import-malformed-parameters.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (208736 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-11-15 19:04:22 UTC (rev 208736)
+++ trunk/LayoutTests/ChangeLog        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -1,3 +1,90 @@
</span><ins>+2016-11-14  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
+
+        Update SubtleCrypto::exportKey to match the latest spec
+        https://bugs.webkit.org/show_bug.cgi?id=164722
+        &lt;rdar://problem/29251740&gt;
+
+        Reviewed by Brent Fulgham.
+
+        Besides adding test cases for SubtleCrypto::exportKey, this patch also corrects a typo:
+        hmac-import-malformed-parameters* =&gt; hmac-import-key-malformed-parameters*.
+
+        * crypto/subtle/aes-cbc-generate-export-key-jwk-length-128-expected.txt: Added.
+        * crypto/subtle/aes-cbc-generate-export-key-jwk-length-128.html: Added.
+        * crypto/subtle/aes-cbc-generate-export-key-jwk-length-192-expected.txt: Added.
+        * crypto/subtle/aes-cbc-generate-export-key-jwk-length-192.html: Added.
+        * crypto/subtle/aes-cbc-generate-export-key-jwk-length-256-expected.txt: Added.
+        * crypto/subtle/aes-cbc-generate-export-key-jwk-length-256.html: Added.
+        * crypto/subtle/aes-cbc-generate-export-key-raw-expected.txt: Added.
+        * crypto/subtle/aes-cbc-generate-export-key-raw.html: Added.
+        * crypto/subtle/aes-export-key-malformed-parameters-expected.txt: Added.
+        * crypto/subtle/aes-export-key-malformed-parameters.html: Added.
+        * crypto/subtle/aes-kw-generate-export-key-jwk-length-128-expected.txt: Added.
+        * crypto/subtle/aes-kw-generate-export-key-jwk-length-128.html: Added.
+        * crypto/subtle/aes-kw-generate-export-key-jwk-length-192-expected.txt: Added.
+        * crypto/subtle/aes-kw-generate-export-key-jwk-length-192.html: Added.
+        * crypto/subtle/aes-kw-generate-export-key-jwk-length-256-expected.txt: Added.
+        * crypto/subtle/aes-kw-generate-export-key-jwk-length-256.html: Added.
+        * crypto/subtle/aes-kw-generate-export-raw-key-expected.txt: Added.
+        * crypto/subtle/aes-kw-generate-export-raw-key.html: Added.
+        * crypto/subtle/export-key-malformed-parameters-expected.txt: Added.
+        * crypto/subtle/export-key-malformed-parameters.html: Added.
+        * crypto/subtle/hmac-export-key-malformed-parameters-expected.txt: Added.
+        * crypto/subtle/hmac-export-key-malformed-parameters.html: Added.
+        * crypto/subtle/hmac-generate-export-key-jwk-sha1-expected.txt: Added.
+        * crypto/subtle/hmac-generate-export-key-jwk-sha1.html: Added.
+        * crypto/subtle/hmac-generate-export-key-jwk-sha224-expected.txt: Added.
+        * crypto/subtle/hmac-generate-export-key-jwk-sha224.html: Added.
+        * crypto/subtle/hmac-generate-export-key-jwk-sha256-expected.txt: Added.
+        * crypto/subtle/hmac-generate-export-key-jwk-sha256.html: Added.
+        * crypto/subtle/hmac-generate-export-key-jwk-sha384-expected.txt: Added.
+        * crypto/subtle/hmac-generate-export-key-jwk-sha384.html: Added.
+        * crypto/subtle/hmac-generate-export-key-jwk-sha512-expected.txt: Added.
+        * crypto/subtle/hmac-generate-export-key-jwk-sha512.html: Added.
+        * crypto/subtle/hmac-generate-export-raw-key-expected.txt: Added.
+        * crypto/subtle/hmac-generate-export-raw-key.html: Added.
+        * crypto/subtle/hmac-import-key-malformed-parameters-expected.txt: Renamed from LayoutTests/crypto/subtle/hmac-import-malformed-parameters-expected.txt.
+        * crypto/subtle/hmac-import-key-malformed-parameters.html: Renamed from LayoutTests/crypto/subtle/hmac-import-malformed-parameters.html.
+        * crypto/subtle/rsa-export-key-malformed-parameters-expected.txt: Added.
+        * crypto/subtle/rsa-export-key-malformed-parameters.html: Added.
+        * crypto/subtle/rsa-oaep-generate-export-key-jwk-sha1-expected.txt: Added.
+        * crypto/subtle/rsa-oaep-generate-export-key-jwk-sha1.html: Added.
+        * crypto/subtle/rsa-oaep-generate-export-key-jwk-sha224-expected.txt: Added.
+        * crypto/subtle/rsa-oaep-generate-export-key-jwk-sha224.html: Added.
+        * crypto/subtle/rsa-oaep-generate-export-key-jwk-sha256-expected.txt: Added.
+        * crypto/subtle/rsa-oaep-generate-export-key-jwk-sha256.html: Added.
+        * crypto/subtle/rsa-oaep-generate-export-key-jwk-sha384-expected.txt: Added.
+        * crypto/subtle/rsa-oaep-generate-export-key-jwk-sha384.html: Added.
+        * crypto/subtle/rsa-oaep-generate-export-key-jwk-sha512-expected.txt: Added.
+        * crypto/subtle/rsa-oaep-generate-export-key-jwk-sha512.html: Added.
+        * crypto/subtle/rsaes-pkcs1-v1_5-generate-export-key-jwk-expected.txt: Added.
+        * crypto/subtle/rsaes-pkcs1-v1_5-generate-export-key-jwk.html: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha1-expected.txt: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha1.html: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha224-expected.txt: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha224.html: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha256-expected.txt: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha256.html: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha384-expected.txt: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha384.html: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha512-expected.txt: Added.
+        * crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha512.html: Added.
+        * crypto/workers/subtle/aes-generate-export-key-jwk-expected.txt: Added.
+        * crypto/workers/subtle/aes-generate-export-key-jwk.html: Added.
+        * crypto/workers/subtle/aes-generate-export-key-raw-expected.txt: Added.
+        * crypto/workers/subtle/aes-generate-export-key-raw.html: Added.
+        * crypto/workers/subtle/hmac-generate-export-key-jwk-expected.txt: Added.
+        * crypto/workers/subtle/hmac-generate-export-key-jwk.html: Added.
+        * crypto/workers/subtle/hmac-generate-export-key-raw-expected.txt: Added.
+        * crypto/workers/subtle/hmac-generate-export-key-raw.html: Added.
+        * crypto/workers/subtle/resources/aes-generate-export-key-jwk.js: Added.
+        * crypto/workers/subtle/resources/aes-generate-export-key-raw.js: Added.
+        * crypto/workers/subtle/resources/hmac-generate-export-key-jwk.js: Added.
+        * crypto/workers/subtle/resources/hmac-generate-export-key-raw.js: Added.
+        * crypto/workers/subtle/resources/rsa-generate-export-key-jwk.js: Added.
+        * crypto/workers/subtle/rsa-generate-export-key-jwk-expected.txt: Added.
+        * crypto/workers/subtle/rsa-generate-export-key-jwk.html: Added.
+
</ins><span class="cx"> 2016-11-15  Jon Lee  &lt;jonlee@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Remove HasMediaCaptureDevice
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtleaescbcgenerateexportkeyjwklength128expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/aes-cbc-generate-export-key-jwk-length-128-expected.txt (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-cbc-generate-export-key-jwk-length-128-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/aes-cbc-generate-export-key-jwk-length-128-expected.txt        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+Test exporting a 128 bits AES-CBC key with JWK format
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Generating a key...
+Exporting a key...
+PASS key.kty is 'oct'
+PASS key.key_ops is ['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']
+PASS key.alg is 'A128CBC'
+PASS key.ext is true
+PASS Base64URL.parse(key.k).byteLength is 16
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleaescbcgenerateexportkeyjwklength128html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/aes-cbc-generate-export-key-jwk-length-128.html (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-cbc-generate-export-key-jwk-length-128.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/aes-cbc-generate-export-key-jwk-length-128.html        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,37 @@
</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 128 bits AES-CBC key with JWK format&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = true;
+
+debug(&quot;Generating a key...&quot;);
+crypto.subtle.generateKey({name: &quot;aes-cbc&quot;, length: 128}, extractable, [&quot;decrypt&quot;, &quot;encrypt&quot;, &quot;unwrapKey&quot;, &quot;wrapKey&quot;]).then(function(key) {
+    debug(&quot;Exporting a key...&quot;);
+    return crypto.subtle.exportKey(&quot;jwk&quot;, key);
+}).then(function(result) {
+    key = result;
+
+    shouldBe(&quot;key.kty&quot;, &quot;'oct'&quot;);
+    shouldBe(&quot;key.key_ops&quot;, &quot;['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']&quot;);
+    shouldBe(&quot;key.alg&quot;, &quot;'A128CBC'&quot;);
+    shouldBe(&quot;key.ext&quot;, &quot;true&quot;);
+    shouldBe(&quot;Base64URL.parse(key.k).byteLength&quot;, &quot;16&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="trunkLayoutTestscryptosubtleaescbcgenerateexportkeyjwklength192expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/aes-cbc-generate-export-key-jwk-length-192-expected.txt (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-cbc-generate-export-key-jwk-length-192-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/aes-cbc-generate-export-key-jwk-length-192-expected.txt        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+Test exporting a 192 bits AES-CBC key with JWK format
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Generating a key...
+Exporting a key...
+PASS key.kty is 'oct'
+PASS key.key_ops is ['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']
+PASS key.alg is 'A192CBC'
+PASS key.ext is true
+PASS Base64URL.parse(key.k).byteLength is 24
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleaescbcgenerateexportkeyjwklength192html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/aes-cbc-generate-export-key-jwk-length-192.html (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-cbc-generate-export-key-jwk-length-192.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/aes-cbc-generate-export-key-jwk-length-192.html        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,37 @@
</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 192 bits AES-CBC key with JWK format&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = true;
+
+debug(&quot;Generating a key...&quot;);
+crypto.subtle.generateKey({name: &quot;aes-cbc&quot;, length: 192}, extractable, [&quot;decrypt&quot;, &quot;encrypt&quot;, &quot;unwrapKey&quot;, &quot;wrapKey&quot;]).then(function(key) {
+    debug(&quot;Exporting a key...&quot;);
+    return crypto.subtle.exportKey(&quot;jwk&quot;, key);
+}).then(function(result) {
+    key = result;
+
+    shouldBe(&quot;key.kty&quot;, &quot;'oct'&quot;);
+    shouldBe(&quot;key.key_ops&quot;, &quot;['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']&quot;);
+    shouldBe(&quot;key.alg&quot;, &quot;'A192CBC'&quot;);
+    shouldBe(&quot;key.ext&quot;, &quot;true&quot;);
+    shouldBe(&quot;Base64URL.parse(key.k).byteLength&quot;, &quot;24&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="trunkLayoutTestscryptosubtleaescbcgenerateexportkeyjwklength256expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/aes-cbc-generate-export-key-jwk-length-256-expected.txt (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-cbc-generate-export-key-jwk-length-256-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/aes-cbc-generate-export-key-jwk-length-256-expected.txt        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+Test exporting a 256 bits AES-CBC key with JWK format
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Generating a key...
+Exporting a key...
+PASS key.kty is 'oct'
+PASS key.key_ops is ['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']
+PASS key.alg is 'A256CBC'
+PASS key.ext is true
+PASS Base64URL.parse(key.k).byteLength is 32
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleaescbcgenerateexportkeyjwklength256html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/aes-cbc-generate-export-key-jwk-length-256.html (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-cbc-generate-export-key-jwk-length-256.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/aes-cbc-generate-export-key-jwk-length-256.html        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,37 @@
</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 256 bits AES-CBC key with JWK format&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = true;
+
+debug(&quot;Generating a key...&quot;);
+crypto.subtle.generateKey({name: &quot;aes-cbc&quot;, length: 256}, extractable, [&quot;decrypt&quot;, &quot;encrypt&quot;, &quot;unwrapKey&quot;, &quot;wrapKey&quot;]).then(function(key) {
+    debug(&quot;Exporting a key...&quot;);
+    return crypto.subtle.exportKey(&quot;jwk&quot;, key);
+}).then(function(result) {
+    key = result;
+
+    shouldBe(&quot;key.kty&quot;, &quot;'oct'&quot;);
+    shouldBe(&quot;key.key_ops&quot;, &quot;['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']&quot;);
+    shouldBe(&quot;key.alg&quot;, &quot;'A256CBC'&quot;);
+    shouldBe(&quot;key.ext&quot;, &quot;true&quot;);
+    shouldBe(&quot;Base64URL.parse(key.k).byteLength&quot;, &quot;32&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="trunkLayoutTestscryptosubtleaescbcgenerateexportkeyrawexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/aes-cbc-generate-export-key-raw-expected.txt (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-cbc-generate-export-key-raw-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/aes-cbc-generate-export-key-raw-expected.txt        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+Test exporting an AES-CBC key with raw format
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Generating a key...
+Exporting a key...
+PASS key.byteLength is 16
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleaescbcgenerateexportkeyrawhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/aes-cbc-generate-export-key-raw.html (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-cbc-generate-export-key-raw.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/aes-cbc-generate-export-key-raw.html        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,32 @@
</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 an AES-CBC key with raw format&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = true;
+
+debug(&quot;Generating a key...&quot;);
+crypto.subtle.generateKey({name: &quot;aes-cbc&quot;, length: 128}, extractable, [&quot;decrypt&quot;, &quot;encrypt&quot;, &quot;unwrapKey&quot;, &quot;wrapKey&quot;]).then(function(key) {
+    debug(&quot;Exporting a key...&quot;);
+    return crypto.subtle.exportKey(&quot;raw&quot;, key);
+}).then(function(result) {
+    key = result;
+    shouldBe(&quot;key.byteLength&quot;, &quot;16&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="trunkLayoutTestscryptosubtleaesexportkeymalformedparametersexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/aes-export-key-malformed-parameters-expected.txt (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-export-key-malformed-parameters-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/aes-export-key-malformed-parameters-expected.txt        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,13 @@
</span><ins>+Test exporting an AES key with malformed parameters
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS crypto.subtle.exportKey(&quot;spki&quot;, key) rejected promise  with NotSupportedError (DOM Exception 9): The algorithm is not supported.
+PASS crypto.subtle.exportKey(&quot;pkcs8&quot;, key) rejected promise  with NotSupportedError (DOM Exception 9): The algorithm is not supported.
+PASS crypto.subtle.exportKey(&quot;spki&quot;, key) rejected promise  with NotSupportedError (DOM Exception 9): The algorithm is not supported.
+PASS crypto.subtle.exportKey(&quot;pkcs8&quot;, key) rejected promise  with NotSupportedError (DOM Exception 9): The algorithm is not supported.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleaesexportkeymalformedparametershtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/aes-export-key-malformed-parameters.html (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-export-key-malformed-parameters.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/aes-export-key-malformed-parameters.html        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,39 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test exporting an AES key with malformed parameters&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = true;
+
+crypto.subtle.generateKey({name: &quot;aes-cbc&quot;, length: 128}, extractable, [&quot;decrypt&quot;, &quot;encrypt&quot;, &quot;unwrapKey&quot;, &quot;wrapKey&quot;]).then(function(result) {
+    key = result;
+
+    // Not support format.
+    return shouldReject('crypto.subtle.exportKey(&quot;spki&quot;, key)');
+}).then(function() {
+    return shouldReject('crypto.subtle.exportKey(&quot;pkcs8&quot;, key)');
+}).then(function() {
+    return crypto.subtle.generateKey({name: &quot;aes-kw&quot;, length: 128}, extractable, [&quot;unwrapKey&quot;, &quot;wrapKey&quot;]);
+}).then(function(result) {
+    key = result;
+
+    // Not support format.
+    return shouldReject('crypto.subtle.exportKey(&quot;spki&quot;, key)');
+}).then(function() {
+    return shouldReject('crypto.subtle.exportKey(&quot;pkcs8&quot;, key)');
+}).then(finishJSTest, 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="trunkLayoutTestscryptosubtleaeskwgenerateexportkeyjwklength128expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/aes-kw-generate-export-key-jwk-length-128-expected.txt (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-kw-generate-export-key-jwk-length-128-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/aes-kw-generate-export-key-jwk-length-128-expected.txt        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+Test exporting a 128 bits AES-KW key with JWK format
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Generating a key...
+Exporting a key...
+PASS key.kty is 'oct'
+PASS key.key_ops is ['unwrapKey', 'wrapKey']
+PASS key.alg is 'A128KW'
+PASS key.ext is true
+PASS Base64URL.parse(key.k).byteLength is 16
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleaeskwgenerateexportkeyjwklength128html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/aes-kw-generate-export-key-jwk-length-128.html (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-kw-generate-export-key-jwk-length-128.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/aes-kw-generate-export-key-jwk-length-128.html        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,37 @@
</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 128 bits AES-KW key with JWK format&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = true;
+
+debug(&quot;Generating a key...&quot;);
+crypto.subtle.generateKey({name: &quot;aes-kw&quot;, length: 128}, extractable, [&quot;unwrapKey&quot;, &quot;wrapKey&quot;]).then(function(key) {
+    debug(&quot;Exporting a key...&quot;);
+    return crypto.subtle.exportKey(&quot;jwk&quot;, key);
+}).then(function(result) {
+    key = result;
+
+    shouldBe(&quot;key.kty&quot;, &quot;'oct'&quot;);
+    shouldBe(&quot;key.key_ops&quot;, &quot;['unwrapKey', 'wrapKey']&quot;);
+    shouldBe(&quot;key.alg&quot;, &quot;'A128KW'&quot;);
+    shouldBe(&quot;key.ext&quot;, &quot;true&quot;);
+    shouldBe(&quot;Base64URL.parse(key.k).byteLength&quot;, &quot;16&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="trunkLayoutTestscryptosubtleaeskwgenerateexportkeyjwklength192expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/aes-kw-generate-export-key-jwk-length-192-expected.txt (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-kw-generate-export-key-jwk-length-192-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/aes-kw-generate-export-key-jwk-length-192-expected.txt        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+Test exporting a 192 bits AES-KW key with JWK format
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Generating a key...
+Exporting a key...
+PASS key.kty is 'oct'
+PASS key.key_ops is ['unwrapKey', 'wrapKey']
+PASS key.alg is 'A192KW'
+PASS key.ext is true
+PASS Base64URL.parse(key.k).byteLength is 24
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleaeskwgenerateexportkeyjwklength192html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/aes-kw-generate-export-key-jwk-length-192.html (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-kw-generate-export-key-jwk-length-192.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/aes-kw-generate-export-key-jwk-length-192.html        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,37 @@
</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 192 bits AES-KW key with JWK format&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = true;
+
+debug(&quot;Generating a key...&quot;);
+crypto.subtle.generateKey({name: &quot;aes-kw&quot;, length: 192}, extractable, [&quot;unwrapKey&quot;, &quot;wrapKey&quot;]).then(function(key) {
+    debug(&quot;Exporting a key...&quot;);
+    return crypto.subtle.exportKey(&quot;jwk&quot;, key);
+}).then(function(result) {
+    key = result;
+
+    shouldBe(&quot;key.kty&quot;, &quot;'oct'&quot;);
+    shouldBe(&quot;key.key_ops&quot;, &quot;['unwrapKey', 'wrapKey']&quot;);
+    shouldBe(&quot;key.alg&quot;, &quot;'A192KW'&quot;);
+    shouldBe(&quot;key.ext&quot;, &quot;true&quot;);
+    shouldBe(&quot;Base64URL.parse(key.k).byteLength&quot;, &quot;24&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="trunkLayoutTestscryptosubtleaeskwgenerateexportkeyjwklength256expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/aes-kw-generate-export-key-jwk-length-256-expected.txt (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-kw-generate-export-key-jwk-length-256-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/aes-kw-generate-export-key-jwk-length-256-expected.txt        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+Test exporting a 256 bits AES-KW key with JWK format
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Generating a key...
+Exporting a key...
+PASS key.kty is 'oct'
+PASS key.key_ops is ['unwrapKey', 'wrapKey']
+PASS key.alg is 'A256KW'
+PASS key.ext is true
+PASS Base64URL.parse(key.k).byteLength is 32
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleaeskwgenerateexportkeyjwklength256html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/aes-kw-generate-export-key-jwk-length-256.html (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-kw-generate-export-key-jwk-length-256.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/aes-kw-generate-export-key-jwk-length-256.html        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,37 @@
</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 256 bits AES-KW key with JWK format&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = true;
+
+debug(&quot;Generating a key...&quot;);
+crypto.subtle.generateKey({name: &quot;aes-kw&quot;, length: 256}, extractable, [&quot;unwrapKey&quot;, &quot;wrapKey&quot;]).then(function(key) {
+    debug(&quot;Exporting a key...&quot;);
+    return crypto.subtle.exportKey(&quot;jwk&quot;, key);
+}).then(function(result) {
+    key = result;
+
+    shouldBe(&quot;key.kty&quot;, &quot;'oct'&quot;);
+    shouldBe(&quot;key.key_ops&quot;, &quot;['unwrapKey', 'wrapKey']&quot;);
+    shouldBe(&quot;key.alg&quot;, &quot;'A256KW'&quot;);
+    shouldBe(&quot;key.ext&quot;, &quot;true&quot;);
+    shouldBe(&quot;Base64URL.parse(key.k).byteLength&quot;, &quot;32&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="trunkLayoutTestscryptosubtleaeskwgenerateexportrawkeyexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/aes-kw-generate-export-raw-key-expected.txt (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-kw-generate-export-raw-key-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/aes-kw-generate-export-raw-key-expected.txt        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+Test exporting an AES-KW key with raw format
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Generating a key...
+Exporting a key...
+PASS key.byteLength is 32
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleaeskwgenerateexportrawkeyhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/aes-kw-generate-export-raw-key.html (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-kw-generate-export-raw-key.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/aes-kw-generate-export-raw-key.html        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,32 @@
</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 an AES-KW key with raw format&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = true;
+
+debug(&quot;Generating a key...&quot;);
+crypto.subtle.generateKey({name: &quot;aes-kw&quot;, length: 256}, extractable, [&quot;unwrapKey&quot;, &quot;wrapKey&quot;]).then(function(key) {
+    debug(&quot;Exporting a key...&quot;);
+    return crypto.subtle.exportKey(&quot;raw&quot;, key);
+}).then(function(result) {
+    key = result;
+    shouldBe(&quot;key.byteLength&quot;, &quot;32&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="trunkLayoutTestscryptosubtleexportkeymalformedparametersexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/export-key-malformed-parameters-expected.txt (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/export-key-malformed-parameters-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/export-key-malformed-parameters-expected.txt        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,20 @@
</span><ins>+Test exporting a key with malformed parameters
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS crypto.subtle.exportKey() rejected promise  with TypeError: Not enough arguments.
+PASS crypto.subtle.exportKey(1) rejected promise  with TypeError: Not enough arguments.
+PASS crypto.subtle.exportKey(&quot;raw&quot;, 1) rejected promise  with TypeError: Invalid CryptoKey.
+PASS crypto.subtle.exportKey(&quot;raw&quot;, true) rejected promise  with TypeError: Invalid CryptoKey.
+PASS crypto.subtle.exportKey(&quot;raw&quot;, null) rejected promise  with TypeError: Invalid CryptoKey.
+PASS crypto.subtle.exportKey(&quot;raw&quot;, undefined) rejected promise  with TypeError: Invalid CryptoKey.
+PASS crypto.subtle.exportKey(&quot;raw&quot;, Symbol()) rejected promise  with TypeError: Invalid CryptoKey.
+PASS crypto.subtle.exportKey(&quot;raw&quot;, { }) rejected promise  with TypeError: Invalid CryptoKey.
+PASS crypto.subtle.exportKey(&quot;raw&quot;, &quot;foo&quot;) rejected promise  with TypeError: Invalid CryptoKey.
+PASS crypto.subtle.exportKey(&quot;raw&quot;, fakedKey) rejected promise  with TypeError: Invalid CryptoKey.
+PASS crypto.subtle.exportKey(&quot;raw&quot;, key) rejected promise  with InvalidAccessError (DOM Exception 15): The CryptoKey is nonextractable.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleexportkeymalformedparametershtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/export-key-malformed-parameters.html (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/export-key-malformed-parameters.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/export-key-malformed-parameters.html        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,50 @@
</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 key with malformed parameters&quot;);
+
+jsTestIsAsync = true;
+
+var nonExtractable = false;
+
+var fakedKey = {
+    type: &quot;secret&quot;,
+    extractable: true,
+    algorithm: {name: &quot;AES-CBC&quot;, length: 128},
+    usages: [&quot;encrypt&quot;, &quot;decrypt&quot;]
+}
+
+crypto.subtle.generateKey({name: &quot;aes-cbc&quot;, length: 128}, nonExtractable, [&quot;decrypt&quot;, &quot;encrypt&quot;, &quot;unwrapKey&quot;, &quot;wrapKey&quot;]).then(function(result) {
+    key = result;
+
+    // Export nonextractable key.
+    shouldReject('crypto.subtle.exportKey(&quot;raw&quot;, key)');
+
+    finishJSTest();
+});
+
+// Not enough arguments.
+shouldReject('crypto.subtle.exportKey()');
+shouldReject('crypto.subtle.exportKey(1)');
+// Wrong CryptoKey.
+shouldReject('crypto.subtle.exportKey(&quot;raw&quot;, 1)');
+shouldReject('crypto.subtle.exportKey(&quot;raw&quot;, true)');
+shouldReject('crypto.subtle.exportKey(&quot;raw&quot;, null)');
+shouldReject('crypto.subtle.exportKey(&quot;raw&quot;, undefined)');
+shouldReject('crypto.subtle.exportKey(&quot;raw&quot;, Symbol())');
+shouldReject('crypto.subtle.exportKey(&quot;raw&quot;, { })');
+shouldReject('crypto.subtle.exportKey(&quot;raw&quot;, &quot;foo&quot;)');
+shouldReject('crypto.subtle.exportKey(&quot;raw&quot;, fakedKey)');
+&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="trunkLayoutTestscryptosubtlehmacexportkeymalformedparametersexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-export-key-malformed-parameters-expected.txt (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-export-key-malformed-parameters-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-export-key-malformed-parameters-expected.txt        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+Test exporting an HMAC key with malformed parameters
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS crypto.subtle.exportKey(&quot;spki&quot;, key) rejected promise  with NotSupportedError (DOM Exception 9): The algorithm is not supported.
+PASS crypto.subtle.exportKey(&quot;pkcs8&quot;, key) rejected promise  with NotSupportedError (DOM Exception 9): The algorithm is not supported.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlehmacexportkeymalformedparametershtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-export-key-malformed-parameters.html (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-export-key-malformed-parameters.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-export-key-malformed-parameters.html        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,30 @@
</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 an HMAC key with malformed parameters&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = true;
+
+crypto.subtle.generateKey({name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]).then(function(result) {
+    key = result;
+
+    // Not support format.
+    return shouldReject('crypto.subtle.exportKey(&quot;spki&quot;, key)');
+}).then(function() {
+    return shouldReject('crypto.subtle.exportKey(&quot;pkcs8&quot;, key)');
+}).then(finishJSTest, 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="trunkLayoutTestscryptosubtlehmacgenerateexportkeyjwksha1expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha1-expected.txt (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha1-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha1-expected.txt        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+Test exporting a SHA-1 HMAC key with JWK format
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Generating a key...
+Exporting a key...
+PASS key.kty is 'oct'
+PASS key.key_ops is ['sign', 'verify']
+PASS key.alg is 'HS1'
+PASS key.ext is true
+PASS Base64URL.parse(key.k).byteLength is 64
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlehmacgenerateexportkeyjwksha1html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha1.html (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha1.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha1.html        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,37 @@
</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 SHA-1 HMAC key with JWK format&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = true;
+
+debug(&quot;Generating a key...&quot;);
+crypto.subtle.generateKey({name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]).then(function(key) {
+    debug(&quot;Exporting a key...&quot;);
+    return crypto.subtle.exportKey(&quot;jwk&quot;, key);
+}).then(function(result) {
+    key = result;
+
+    shouldBe(&quot;key.kty&quot;, &quot;'oct'&quot;);
+    shouldBe(&quot;key.key_ops&quot;, &quot;['sign', 'verify']&quot;);
+    shouldBe(&quot;key.alg&quot;, &quot;'HS1'&quot;);
+    shouldBe(&quot;key.ext&quot;, &quot;true&quot;);
+    shouldBe(&quot;Base64URL.parse(key.k).byteLength&quot;, &quot;64&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="trunkLayoutTestscryptosubtlehmacgenerateexportkeyjwksha224expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha224-expected.txt (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha224-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha224-expected.txt        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+Test exporting a SHA-224 HMAC key with JWK format
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Generating a key...
+Exporting a key...
+PASS key.kty is 'oct'
+PASS key.key_ops is ['sign', 'verify']
+PASS key.alg is 'HS224'
+PASS key.ext is true
+PASS Base64URL.parse(key.k).byteLength is 64
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlehmacgenerateexportkeyjwksha224html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha224.html (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha224.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha224.html        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,37 @@
</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 SHA-224 HMAC key with JWK format&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = true;
+
+debug(&quot;Generating a key...&quot;);
+crypto.subtle.generateKey({name: &quot;hmac&quot;, hash: &quot;sha-224&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]).then(function(key) {
+    debug(&quot;Exporting a key...&quot;);
+    return crypto.subtle.exportKey(&quot;jwk&quot;, key);
+}).then(function(result) {
+    key = result;
+
+    shouldBe(&quot;key.kty&quot;, &quot;'oct'&quot;);
+    shouldBe(&quot;key.key_ops&quot;, &quot;['sign', 'verify']&quot;);
+    shouldBe(&quot;key.alg&quot;, &quot;'HS224'&quot;);
+    shouldBe(&quot;key.ext&quot;, &quot;true&quot;);
+    shouldBe(&quot;Base64URL.parse(key.k).byteLength&quot;, &quot;64&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="trunkLayoutTestscryptosubtlehmacgenerateexportkeyjwksha256expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha256-expected.txt (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha256-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha256-expected.txt        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+Test exporting a SHA-256 HMAC key with JWK format
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Generating a key...
+Exporting a key...
+PASS key.kty is 'oct'
+PASS key.key_ops is ['sign', 'verify']
+PASS key.alg is 'HS256'
+PASS key.ext is true
+PASS Base64URL.parse(key.k).byteLength is 64
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlehmacgenerateexportkeyjwksha256html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha256.html (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha256.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha256.html        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,37 @@
</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 SHA-256 HMAC key with JWK format&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = true;
+
+debug(&quot;Generating a key...&quot;);
+crypto.subtle.generateKey({name: &quot;hmac&quot;, hash: &quot;sha-256&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]).then(function(key) {
+    debug(&quot;Exporting a key...&quot;);
+    return crypto.subtle.exportKey(&quot;jwk&quot;, key);
+}).then(function(result) {
+    key = result;
+
+    shouldBe(&quot;key.kty&quot;, &quot;'oct'&quot;);
+    shouldBe(&quot;key.key_ops&quot;, &quot;['sign', 'verify']&quot;);
+    shouldBe(&quot;key.alg&quot;, &quot;'HS256'&quot;);
+    shouldBe(&quot;key.ext&quot;, &quot;true&quot;);
+    shouldBe(&quot;Base64URL.parse(key.k).byteLength&quot;, &quot;64&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="trunkLayoutTestscryptosubtlehmacgenerateexportkeyjwksha384expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha384-expected.txt (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha384-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha384-expected.txt        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+Test exporting a SHA-384 HMAC key with JWK format
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Generating a key...
+Exporting a key...
+PASS key.kty is 'oct'
+PASS key.key_ops is ['sign', 'verify']
+PASS key.alg is 'HS384'
+PASS key.ext is true
+PASS Base64URL.parse(key.k).byteLength is 128
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlehmacgenerateexportkeyjwksha384html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha384.html (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha384.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha384.html        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,37 @@
</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 SHA-384 HMAC key with JWK format&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = true;
+
+debug(&quot;Generating a key...&quot;);
+crypto.subtle.generateKey({name: &quot;hmac&quot;, hash: &quot;sha-384&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]).then(function(key) {
+    debug(&quot;Exporting a key...&quot;);
+    return crypto.subtle.exportKey(&quot;jwk&quot;, key);
+}).then(function(result) {
+    key = result;
+
+    shouldBe(&quot;key.kty&quot;, &quot;'oct'&quot;);
+    shouldBe(&quot;key.key_ops&quot;, &quot;['sign', 'verify']&quot;);
+    shouldBe(&quot;key.alg&quot;, &quot;'HS384'&quot;);
+    shouldBe(&quot;key.ext&quot;, &quot;true&quot;);
+    shouldBe(&quot;Base64URL.parse(key.k).byteLength&quot;, &quot;128&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="trunkLayoutTestscryptosubtlehmacgenerateexportkeyjwksha512expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha512-expected.txt (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha512-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha512-expected.txt        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+Test exporting a SHA-512 HMAC key with JWK format
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Generating a key...
+Exporting a key...
+PASS key.kty is 'oct'
+PASS key.key_ops is ['sign', 'verify']
+PASS key.alg is 'HS512'
+PASS key.ext is true
+PASS Base64URL.parse(key.k).byteLength is 128
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlehmacgenerateexportkeyjwksha512html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha512.html (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha512.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-generate-export-key-jwk-sha512.html        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,37 @@
</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 SHA-512 HMAC key with JWK format&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = true;
+
+debug(&quot;Generating a key...&quot;);
+crypto.subtle.generateKey({name: &quot;hmac&quot;, hash: &quot;sha-512&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]).then(function(key) {
+    debug(&quot;Exporting a key...&quot;);
+    return crypto.subtle.exportKey(&quot;jwk&quot;, key);
+}).then(function(result) {
+    key = result;
+
+    shouldBe(&quot;key.kty&quot;, &quot;'oct'&quot;);
+    shouldBe(&quot;key.key_ops&quot;, &quot;['sign', 'verify']&quot;);
+    shouldBe(&quot;key.alg&quot;, &quot;'HS512'&quot;);
+    shouldBe(&quot;key.ext&quot;, &quot;true&quot;);
+    shouldBe(&quot;Base64URL.parse(key.k).byteLength&quot;, &quot;128&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="trunkLayoutTestscryptosubtlehmacgenerateexportrawkeyexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-generate-export-raw-key-expected.txt (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-generate-export-raw-key-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-generate-export-raw-key-expected.txt        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+Test exporting an HMAC key with raw format
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Generating a key...
+Exporting a key...
+PASS key.byteLength is 64
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlehmacgenerateexportrawkeyhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-generate-export-raw-key.html (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-generate-export-raw-key.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-generate-export-raw-key.html        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,32 @@
</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 an HMAC key with raw format&quot;);
+
+jsTestIsAsync = true;
+
+var extractable = true;
+
+debug(&quot;Generating a key...&quot;);
+crypto.subtle.generateKey({name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]).then(function(key) {
+    debug(&quot;Exporting a key...&quot;);
+    return crypto.subtle.exportKey(&quot;raw&quot;, key);
+}).then(function(result) {
+    key = result;
+    shouldBe(&quot;key.byteLength&quot;, &quot;64&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="trunkLayoutTestscryptosubtlehmacimportkeymalformedparametersexpectedtxtfromrev208736trunkLayoutTestscryptosubtlehmacimportmalformedparametersexpectedtxt"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/crypto/subtle/hmac-import-key-malformed-parameters-expected.txt (from rev 208736, trunk/LayoutTests/crypto/subtle/hmac-import-malformed-parameters-expected.txt) (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-import-key-malformed-parameters-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-import-key-malformed-parameters-expected.txt        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,23 @@
</span><ins>+Test importing an HMAC key with malformed parameters
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS crypto.subtle.importKey(&quot;raw&quot;, asciiToUint8Array(&quot;&quot;), {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey(&quot;raw&quot;, rawKey, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;, length: 257}, extractable, [&quot;sign&quot;, &quot;verify&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey(&quot;raw&quot;, rawKey, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;, length: 248}, extractable, [&quot;sign&quot;, &quot;verify&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;RSA&quot;}, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;}, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS224&quot;}, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS256&quot;}, {name: &quot;hmac&quot;, hash: &quot;sha-224&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS384&quot;}, {name: &quot;hmac&quot;, hash: &quot;sha-256&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS512&quot;}, {name: &quot;hmac&quot;, hash: &quot;sha-384&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS1&quot;}, {name: &quot;hmac&quot;, hash: &quot;sha-512&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: &quot;!!!&quot;, alg: &quot;foo&quot;}, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS1&quot;, use: &quot;enc&quot;}, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS1&quot;, key_ops: [&quot;sign&quot;]}, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS1&quot;, ext: false}, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlehmacimportkeymalformedparametershtmlfromrev208736trunkLayoutTestscryptosubtlehmacimportmalformedparametershtml"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/crypto/subtle/hmac-import-key-malformed-parameters.html (from rev 208736, trunk/LayoutTests/crypto/subtle/hmac-import-malformed-parameters.html) (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-import-key-malformed-parameters.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-import-key-malformed-parameters.html        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,45 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test importing an HMAC key with malformed parameters&quot;);
+
+var rawKey = asciiToUint8Array(&quot;jnOw99oOZFLIEPMrgJB55WL46tJSLGt7&quot;);
+var extractable = true;
+
+var k = &quot;YWJjZGVmZ2gxMjM0NTY3OA&quot;;
+
+// wrong length
+shouldReject('crypto.subtle.importKey(&quot;raw&quot;, asciiToUint8Array(&quot;&quot;), {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;])');
+shouldReject('crypto.subtle.importKey(&quot;raw&quot;, rawKey, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;, length: 257}, extractable, [&quot;sign&quot;, &quot;verify&quot;])');
+shouldReject('crypto.subtle.importKey(&quot;raw&quot;, rawKey, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;, length: 248}, extractable, [&quot;sign&quot;, &quot;verify&quot;])');
+// Jwk: Wrong kty
+shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;RSA&quot;}, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;])');
+// Jwk: missing k
+shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;}, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;])');
+// Jwk: wrong hash and alg
+shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS224&quot;}, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;])');
+shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS256&quot;}, {name: &quot;hmac&quot;, hash: &quot;sha-224&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;])');
+shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS384&quot;}, {name: &quot;hmac&quot;, hash: &quot;sha-256&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;])');
+shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS512&quot;}, {name: &quot;hmac&quot;, hash: &quot;sha-384&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;])');
+shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS1&quot;}, {name: &quot;hmac&quot;, hash: &quot;sha-512&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;])');
+// Jwk: wrong k format
+shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: &quot;!!!&quot;, alg: &quot;foo&quot;}, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;])');
+// Jwk: wrong use
+shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS1&quot;, use: &quot;enc&quot;}, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;])');
+// Jwk: wrong key_ops
+shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS1&quot;, key_ops: [&quot;sign&quot;]}, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;])');
+// Jwk: wrong ext
+shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS1&quot;, ext: false}, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;])');
+&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="trunkLayoutTestscryptosubtlehmacimportmalformedparametersexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/crypto/subtle/hmac-import-malformed-parameters-expected.txt (208736 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-import-malformed-parameters-expected.txt        2016-11-15 19:04:22 UTC (rev 208736)
+++ trunk/LayoutTests/crypto/subtle/hmac-import-malformed-parameters-expected.txt        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -1,23 +0,0 @@
</span><del>-Test importing an HMAC key with malformed parameters
-
-On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
-
-
-PASS crypto.subtle.importKey(&quot;raw&quot;, asciiToUint8Array(&quot;&quot;), {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
-PASS crypto.subtle.importKey(&quot;raw&quot;, rawKey, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;, length: 257}, extractable, [&quot;sign&quot;, &quot;verify&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
-PASS crypto.subtle.importKey(&quot;raw&quot;, rawKey, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;, length: 248}, extractable, [&quot;sign&quot;, &quot;verify&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
-PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;RSA&quot;}, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
-PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;}, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
-PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS224&quot;}, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
-PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS256&quot;}, {name: &quot;hmac&quot;, hash: &quot;sha-224&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
-PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS384&quot;}, {name: &quot;hmac&quot;, hash: &quot;sha-256&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
-PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS512&quot;}, {name: &quot;hmac&quot;, hash: &quot;sha-384&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
-PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS1&quot;}, {name: &quot;hmac&quot;, hash: &quot;sha-512&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
-PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: &quot;!!!&quot;, alg: &quot;foo&quot;}, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
-PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS1&quot;, use: &quot;enc&quot;}, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
-PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS1&quot;, key_ops: [&quot;sign&quot;]}, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
-PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS1&quot;, ext: false}, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
</del></span></pre></div>
<a id="trunkLayoutTestscryptosubtlehmacimportmalformedparametershtml"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/crypto/subtle/hmac-import-malformed-parameters.html (208736 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-import-malformed-parameters.html        2016-11-15 19:04:22 UTC (rev 208736)
+++ trunk/LayoutTests/crypto/subtle/hmac-import-malformed-parameters.html        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -1,45 +0,0 @@
</span><del>-&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 an HMAC key with malformed parameters&quot;);
-
-var rawKey = asciiToUint8Array(&quot;jnOw99oOZFLIEPMrgJB55WL46tJSLGt7&quot;);
-var extractable = true;
-
-var k = &quot;YWJjZGVmZ2gxMjM0NTY3OA&quot;;
-
-// wrong length
-shouldReject('crypto.subtle.importKey(&quot;raw&quot;, asciiToUint8Array(&quot;&quot;), {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;])');
-shouldReject('crypto.subtle.importKey(&quot;raw&quot;, rawKey, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;, length: 257}, extractable, [&quot;sign&quot;, &quot;verify&quot;])');
-shouldReject('crypto.subtle.importKey(&quot;raw&quot;, rawKey, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;, length: 248}, extractable, [&quot;sign&quot;, &quot;verify&quot;])');
-// Jwk: Wrong kty
-shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;RSA&quot;}, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;])');
-// Jwk: missing k
-shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;}, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;])');
-// Jwk: wrong hash and alg
-shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS224&quot;}, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;])');
-shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS256&quot;}, {name: &quot;hmac&quot;, hash: &quot;sha-224&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;])');
-shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS384&quot;}, {name: &quot;hmac&quot;, hash: &quot;sha-256&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;])');
-shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS512&quot;}, {name: &quot;hmac&quot;, hash: &quot;sha-384&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;])');
-shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS1&quot;}, {name: &quot;hmac&quot;, hash: &quot;sha-512&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;])');
-// Jwk: wrong k format
-shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: &quot;!!!&quot;, alg: &quot;foo&quot;}, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;])');
-// Jwk: wrong use
-shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS1&quot;, use: &quot;enc&quot;}, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;])');
-// Jwk: wrong key_ops
-shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS1&quot;, key_ops: [&quot;sign&quot;]}, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;])');
-// Jwk: wrong ext
-shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS1&quot;, ext: false}, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;])');
-&lt;/script&gt;
-
-&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
-&lt;/body&gt;
-&lt;/html&gt;
</del></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaexportkeymalformedparametersexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-export-key-malformed-parameters-expected.txt (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-export-key-malformed-parameters-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-export-key-malformed-parameters-expected.txt        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+Test exporting a RSA key with malformed parameters
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS crypto.subtle.exportKey(&quot;spki&quot;, publicKey) rejected promise  with NotSupportedError (DOM Exception 9): The algorithm is not supported.
+PASS crypto.subtle.exportKey(&quot;pkcs8&quot;, publicKey) rejected promise  with NotSupportedError (DOM Exception 9): The algorithm is not supported.
+PASS crypto.subtle.exportKey(&quot;raw&quot;, publicKey) rejected promise  with NotSupportedError (DOM Exception 9): The algorithm is not supported.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaexportkeymalformedparametershtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-export-key-malformed-parameters.html (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-export-key-malformed-parameters.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-export-key-malformed-parameters.html        2016-11-15 19:08:25 UTC (rev 208737)
</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 RSA key with malformed parameters&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;
+
+crypto.subtle.generateKey(algorithmKeyGen, extractable, [&quot;decrypt&quot;, &quot;encrypt&quot;, &quot;wrapKey&quot;, &quot;unwrapKey&quot;]).then(function(result) {
+    publicKey = result.publicKey;
+
+    // Currently not support format.
+    return shouldReject('crypto.subtle.exportKey(&quot;spki&quot;, publicKey)');
+}).then(function() {
+    return shouldReject('crypto.subtle.exportKey(&quot;pkcs8&quot;, publicKey)');
+}).then(function() {
+    // Not support format.
+    return shouldReject('crypto.subtle.exportKey(&quot;raw&quot;, publicKey)');
+}).then(finishJSTest, 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="trunkLayoutTestscryptosubtlersaoaepgenerateexportkeyjwksha1expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha1-expected.txt (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha1-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha1-expected.txt        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,25 @@
</span><ins>+Test exporting a SHA-1 RSA-OAEP key pair with JWK 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.kty is 'RSA'
+PASS publicKey.key_ops is ['encrypt', 'wrapKey']
+PASS publicKey.alg is 'RSA-OAEP'
+PASS publicKey.ext is true
+PASS Base64URL.parse(publicKey.n).byteLength is 256
+PASS bytesToHexString(Base64URL.parse(publicKey.e)) is '010001'
+Exporting the private key...
+PASS privateKey.kty is 'RSA'
+PASS privateKey.key_ops is ['decrypt', 'unwrapKey']
+PASS privateKey.alg is 'RSA-OAEP'
+PASS privateKey.ext is true
+PASS Base64URL.parse(privateKey.n).byteLength is 256
+PASS bytesToHexString(Base64URL.parse(privateKey.e)) is '010001'
+PASS privateKey.oth is undefined.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaoaepgenerateexportkeyjwksha1html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha1.html (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha1.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha1.html        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,60 @@
</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 SHA-1 RSA-OAEP key pair with JWK 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;jwk&quot;, keyPair.publicKey);
+}).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;publicKey.kty&quot;, &quot;'RSA'&quot;);
+    shouldBe(&quot;publicKey.key_ops&quot;, &quot;['encrypt', 'wrapKey']&quot;);
+    shouldBe(&quot;publicKey.alg&quot;, &quot;'RSA-OAEP'&quot;);
+    shouldBe(&quot;publicKey.ext&quot;, &quot;true&quot;);
+    shouldBe(&quot;Base64URL.parse(publicKey.n).byteLength&quot;, &quot;256&quot;);
+    shouldBe(&quot;bytesToHexString(Base64URL.parse(publicKey.e))&quot;, &quot;'010001'&quot;);
+
+    debug(&quot;Exporting the private key...&quot;);
+    return crypto.subtle.exportKey(&quot;jwk&quot;, keyPair.privateKey);
+}).then(function(result) {
+    privateKey = result;
+
+    shouldBe(&quot;privateKey.kty&quot;, &quot;'RSA'&quot;);
+    shouldBe(&quot;privateKey.key_ops&quot;, &quot;['decrypt', 'unwrapKey']&quot;);
+    shouldBe(&quot;privateKey.alg&quot;, &quot;'RSA-OAEP'&quot;);
+    shouldBe(&quot;privateKey.ext&quot;, &quot;true&quot;);
+    shouldBe(&quot;Base64URL.parse(privateKey.n).byteLength&quot;, &quot;256&quot;);
+    shouldBe(&quot;bytesToHexString(Base64URL.parse(privateKey.e))&quot;, &quot;'010001'&quot;);
+    shouldBeUndefined(&quot;privateKey.oth&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="trunkLayoutTestscryptosubtlersaoaepgenerateexportkeyjwksha224expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha224-expected.txt (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha224-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha224-expected.txt        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,25 @@
</span><ins>+Test exporting a SHA-224 RSA-OAEP key pair with JWK 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.kty is 'RSA'
+PASS publicKey.key_ops is ['encrypt', 'wrapKey']
+PASS publicKey.alg is 'RSA-OAEP-224'
+PASS publicKey.ext is true
+PASS Base64URL.parse(publicKey.n).byteLength is 256
+PASS bytesToHexString(Base64URL.parse(publicKey.e)) is '010001'
+Exporting the private key...
+PASS privateKey.kty is 'RSA'
+PASS privateKey.key_ops is ['decrypt', 'unwrapKey']
+PASS privateKey.alg is 'RSA-OAEP-224'
+PASS privateKey.ext is true
+PASS Base64URL.parse(privateKey.n).byteLength is 256
+PASS bytesToHexString(Base64URL.parse(privateKey.e)) is '010001'
+PASS privateKey.oth is undefined.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaoaepgenerateexportkeyjwksha224html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha224.html (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha224.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha224.html        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,60 @@
</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 SHA-224 RSA-OAEP key pair with JWK 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-224&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;jwk&quot;, keyPair.publicKey);
+}).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;publicKey.kty&quot;, &quot;'RSA'&quot;);
+    shouldBe(&quot;publicKey.key_ops&quot;, &quot;['encrypt', 'wrapKey']&quot;);
+    shouldBe(&quot;publicKey.alg&quot;, &quot;'RSA-OAEP-224'&quot;);
+    shouldBe(&quot;publicKey.ext&quot;, &quot;true&quot;);
+    shouldBe(&quot;Base64URL.parse(publicKey.n).byteLength&quot;, &quot;256&quot;);
+    shouldBe(&quot;bytesToHexString(Base64URL.parse(publicKey.e))&quot;, &quot;'010001'&quot;);
+
+    debug(&quot;Exporting the private key...&quot;);
+    return crypto.subtle.exportKey(&quot;jwk&quot;, keyPair.privateKey);
+}).then(function(result) {
+    privateKey = result;
+
+    shouldBe(&quot;privateKey.kty&quot;, &quot;'RSA'&quot;);
+    shouldBe(&quot;privateKey.key_ops&quot;, &quot;['decrypt', 'unwrapKey']&quot;);
+    shouldBe(&quot;privateKey.alg&quot;, &quot;'RSA-OAEP-224'&quot;);
+    shouldBe(&quot;privateKey.ext&quot;, &quot;true&quot;);
+    shouldBe(&quot;Base64URL.parse(privateKey.n).byteLength&quot;, &quot;256&quot;);
+    shouldBe(&quot;bytesToHexString(Base64URL.parse(privateKey.e))&quot;, &quot;'010001'&quot;);
+    shouldBeUndefined(&quot;privateKey.oth&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="trunkLayoutTestscryptosubtlersaoaepgenerateexportkeyjwksha256expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha256-expected.txt (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha256-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha256-expected.txt        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,25 @@
</span><ins>+Test exporting a SHA-256 RSA-OAEP key pair with JWK 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.kty is 'RSA'
+PASS publicKey.key_ops is ['encrypt', 'wrapKey']
+PASS publicKey.alg is 'RSA-OAEP-256'
+PASS publicKey.ext is true
+PASS Base64URL.parse(publicKey.n).byteLength is 256
+PASS bytesToHexString(Base64URL.parse(publicKey.e)) is '010001'
+Exporting the private key...
+PASS privateKey.kty is 'RSA'
+PASS privateKey.key_ops is ['decrypt', 'unwrapKey']
+PASS privateKey.alg is 'RSA-OAEP-256'
+PASS privateKey.ext is true
+PASS Base64URL.parse(privateKey.n).byteLength is 256
+PASS bytesToHexString(Base64URL.parse(privateKey.e)) is '010001'
+PASS privateKey.oth is undefined.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaoaepgenerateexportkeyjwksha256html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha256.html (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha256.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha256.html        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,60 @@
</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 SHA-256 RSA-OAEP key pair with JWK 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-256&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;jwk&quot;, keyPair.publicKey);
+}).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;publicKey.kty&quot;, &quot;'RSA'&quot;);
+    shouldBe(&quot;publicKey.key_ops&quot;, &quot;['encrypt', 'wrapKey']&quot;);
+    shouldBe(&quot;publicKey.alg&quot;, &quot;'RSA-OAEP-256'&quot;);
+    shouldBe(&quot;publicKey.ext&quot;, &quot;true&quot;);
+    shouldBe(&quot;Base64URL.parse(publicKey.n).byteLength&quot;, &quot;256&quot;);
+    shouldBe(&quot;bytesToHexString(Base64URL.parse(publicKey.e))&quot;, &quot;'010001'&quot;);
+
+    debug(&quot;Exporting the private key...&quot;);
+    return crypto.subtle.exportKey(&quot;jwk&quot;, keyPair.privateKey);
+}).then(function(result) {
+    privateKey = result;
+
+    shouldBe(&quot;privateKey.kty&quot;, &quot;'RSA'&quot;);
+    shouldBe(&quot;privateKey.key_ops&quot;, &quot;['decrypt', 'unwrapKey']&quot;);
+    shouldBe(&quot;privateKey.alg&quot;, &quot;'RSA-OAEP-256'&quot;);
+    shouldBe(&quot;privateKey.ext&quot;, &quot;true&quot;);
+    shouldBe(&quot;Base64URL.parse(privateKey.n).byteLength&quot;, &quot;256&quot;);
+    shouldBe(&quot;bytesToHexString(Base64URL.parse(privateKey.e))&quot;, &quot;'010001'&quot;);
+    shouldBeUndefined(&quot;privateKey.oth&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="trunkLayoutTestscryptosubtlersaoaepgenerateexportkeyjwksha384expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha384-expected.txt (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha384-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha384-expected.txt        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,25 @@
</span><ins>+Test exporting a SHA-384 RSA-OAEP key pair with JWK 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.kty is 'RSA'
+PASS publicKey.key_ops is ['encrypt', 'wrapKey']
+PASS publicKey.alg is 'RSA-OAEP-384'
+PASS publicKey.ext is true
+PASS Base64URL.parse(publicKey.n).byteLength is 256
+PASS bytesToHexString(Base64URL.parse(publicKey.e)) is '010001'
+Exporting the private key...
+PASS privateKey.kty is 'RSA'
+PASS privateKey.key_ops is ['decrypt', 'unwrapKey']
+PASS privateKey.alg is 'RSA-OAEP-384'
+PASS privateKey.ext is true
+PASS Base64URL.parse(privateKey.n).byteLength is 256
+PASS bytesToHexString(Base64URL.parse(privateKey.e)) is '010001'
+PASS privateKey.oth is undefined.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaoaepgenerateexportkeyjwksha384html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha384.html (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha384.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha384.html        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,60 @@
</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 SHA-384 RSA-OAEP key pair with JWK 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-384&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;jwk&quot;, keyPair.publicKey);
+}).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;publicKey.kty&quot;, &quot;'RSA'&quot;);
+    shouldBe(&quot;publicKey.key_ops&quot;, &quot;['encrypt', 'wrapKey']&quot;);
+    shouldBe(&quot;publicKey.alg&quot;, &quot;'RSA-OAEP-384'&quot;);
+    shouldBe(&quot;publicKey.ext&quot;, &quot;true&quot;);
+    shouldBe(&quot;Base64URL.parse(publicKey.n).byteLength&quot;, &quot;256&quot;);
+    shouldBe(&quot;bytesToHexString(Base64URL.parse(publicKey.e))&quot;, &quot;'010001'&quot;);
+
+    debug(&quot;Exporting the private key...&quot;);
+    return crypto.subtle.exportKey(&quot;jwk&quot;, keyPair.privateKey);
+}).then(function(result) {
+    privateKey = result;
+
+    shouldBe(&quot;privateKey.kty&quot;, &quot;'RSA'&quot;);
+    shouldBe(&quot;privateKey.key_ops&quot;, &quot;['decrypt', 'unwrapKey']&quot;);
+    shouldBe(&quot;privateKey.alg&quot;, &quot;'RSA-OAEP-384'&quot;);
+    shouldBe(&quot;privateKey.ext&quot;, &quot;true&quot;);
+    shouldBe(&quot;Base64URL.parse(privateKey.n).byteLength&quot;, &quot;256&quot;);
+    shouldBe(&quot;bytesToHexString(Base64URL.parse(privateKey.e))&quot;, &quot;'010001'&quot;);
+    shouldBeUndefined(&quot;privateKey.oth&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="trunkLayoutTestscryptosubtlersaoaepgenerateexportkeyjwksha512expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha512-expected.txt (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha512-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha512-expected.txt        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,25 @@
</span><ins>+Test exporting a SHA-512 RSA-OAEP key pair with JWK 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.kty is 'RSA'
+PASS publicKey.key_ops is ['encrypt', 'wrapKey']
+PASS publicKey.alg is 'RSA-OAEP-512'
+PASS publicKey.ext is true
+PASS Base64URL.parse(publicKey.n).byteLength is 256
+PASS bytesToHexString(Base64URL.parse(publicKey.e)) is '010001'
+Exporting the private key...
+PASS privateKey.kty is 'RSA'
+PASS privateKey.key_ops is ['decrypt', 'unwrapKey']
+PASS privateKey.alg is 'RSA-OAEP-512'
+PASS privateKey.ext is true
+PASS Base64URL.parse(privateKey.n).byteLength is 256
+PASS bytesToHexString(Base64URL.parse(privateKey.e)) is '010001'
+PASS privateKey.oth is undefined.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaoaepgenerateexportkeyjwksha512html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha512.html (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha512.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-export-key-jwk-sha512.html        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,60 @@
</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 SHA-512 RSA-OAEP key pair with JWK 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-512&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;jwk&quot;, keyPair.publicKey);
+}).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;publicKey.kty&quot;, &quot;'RSA'&quot;);
+    shouldBe(&quot;publicKey.key_ops&quot;, &quot;['encrypt', 'wrapKey']&quot;);
+    shouldBe(&quot;publicKey.alg&quot;, &quot;'RSA-OAEP-512'&quot;);
+    shouldBe(&quot;publicKey.ext&quot;, &quot;true&quot;);
+    shouldBe(&quot;Base64URL.parse(publicKey.n).byteLength&quot;, &quot;256&quot;);
+    shouldBe(&quot;bytesToHexString(Base64URL.parse(publicKey.e))&quot;, &quot;'010001'&quot;);
+
+    debug(&quot;Exporting the private key...&quot;);
+    return crypto.subtle.exportKey(&quot;jwk&quot;, keyPair.privateKey);
+}).then(function(result) {
+    privateKey = result;
+
+    shouldBe(&quot;privateKey.kty&quot;, &quot;'RSA'&quot;);
+    shouldBe(&quot;privateKey.key_ops&quot;, &quot;['decrypt', 'unwrapKey']&quot;);
+    shouldBe(&quot;privateKey.alg&quot;, &quot;'RSA-OAEP-512'&quot;);
+    shouldBe(&quot;privateKey.ext&quot;, &quot;true&quot;);
+    shouldBe(&quot;Base64URL.parse(privateKey.n).byteLength&quot;, &quot;256&quot;);
+    shouldBe(&quot;bytesToHexString(Base64URL.parse(privateKey.e))&quot;, &quot;'010001'&quot;);
+    shouldBeUndefined(&quot;privateKey.oth&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_5generateexportkeyjwkexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-generate-export-key-jwk-expected.txt (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-generate-export-key-jwk-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-generate-export-key-jwk-expected.txt        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,25 @@
</span><ins>+Test exporting a RSAES-PKCS1-v1_5 key pair with JWK 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.kty is 'RSA'
+PASS publicKey.key_ops is ['encrypt']
+PASS publicKey.alg is 'RSA1_5'
+PASS publicKey.ext is true
+PASS Base64URL.parse(publicKey.n).byteLength is 256
+PASS bytesToHexString(Base64URL.parse(publicKey.e)) is '010001'
+Exporting the private key...
+PASS privateKey.kty is 'RSA'
+PASS privateKey.key_ops is ['decrypt']
+PASS privateKey.alg is 'RSA1_5'
+PASS privateKey.ext is true
+PASS Base64URL.parse(privateKey.n).byteLength is 256
+PASS bytesToHexString(Base64URL.parse(privateKey.e)) is '010001'
+PASS privateKey.oth is undefined.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaespkcs1v1_5generateexportkeyjwkhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-generate-export-key-jwk.html (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-generate-export-key-jwk.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-generate-export-key-jwk.html        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,59 @@
</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 key pair with JWK 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;jwk&quot;, keyPair.publicKey);
+}).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;publicKey.kty&quot;, &quot;'RSA'&quot;);
+    shouldBe(&quot;publicKey.key_ops&quot;, &quot;['encrypt']&quot;);
+    shouldBe(&quot;publicKey.alg&quot;, &quot;'RSA1_5'&quot;);
+    shouldBe(&quot;publicKey.ext&quot;, &quot;true&quot;);
+    shouldBe(&quot;Base64URL.parse(publicKey.n).byteLength&quot;, &quot;256&quot;);
+    shouldBe(&quot;bytesToHexString(Base64URL.parse(publicKey.e))&quot;, &quot;'010001'&quot;);
+
+    debug(&quot;Exporting the private key...&quot;);
+    return crypto.subtle.exportKey(&quot;jwk&quot;, keyPair.privateKey);
+}).then(function(result) {
+    privateKey = result;
+
+    shouldBe(&quot;privateKey.kty&quot;, &quot;'RSA'&quot;);
+    shouldBe(&quot;privateKey.key_ops&quot;, &quot;['decrypt']&quot;);
+    shouldBe(&quot;privateKey.alg&quot;, &quot;'RSA1_5'&quot;);
+    shouldBe(&quot;privateKey.ext&quot;, &quot;true&quot;);
+    shouldBe(&quot;Base64URL.parse(privateKey.n).byteLength&quot;, &quot;256&quot;);
+    shouldBe(&quot;bytesToHexString(Base64URL.parse(privateKey.e))&quot;, &quot;'010001'&quot;);
+    shouldBeUndefined(&quot;privateKey.oth&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_5generateexportkeyjwksha1expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha1-expected.txt (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha1-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha1-expected.txt        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,25 @@
</span><ins>+Test exporting a SHA-1 RSASSA-PKCS1-v1_5 key pair with JWK 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.kty is 'RSA'
+PASS publicKey.key_ops is ['verify']
+PASS publicKey.alg is 'RS1'
+PASS publicKey.ext is true
+PASS Base64URL.parse(publicKey.n).byteLength is 256
+PASS bytesToHexString(Base64URL.parse(publicKey.e)) is '010001'
+Exporting the private key...
+PASS privateKey.kty is 'RSA'
+PASS privateKey.key_ops is ['sign']
+PASS privateKey.alg is 'RS1'
+PASS privateKey.ext is true
+PASS Base64URL.parse(privateKey.n).byteLength is 256
+PASS bytesToHexString(Base64URL.parse(privateKey.e)) is '010001'
+PASS privateKey.oth is undefined.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersassapkcs1v1_5generateexportkeyjwksha1html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha1.html (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha1.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha1.html        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,60 @@
</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 SHA-1 RSASSA-PKCS1-v1_5 key pair with JWK 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;jwk&quot;, keyPair.publicKey);
+}).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;publicKey.kty&quot;, &quot;'RSA'&quot;);
+    shouldBe(&quot;publicKey.key_ops&quot;, &quot;['verify']&quot;);
+    shouldBe(&quot;publicKey.alg&quot;, &quot;'RS1'&quot;);
+    shouldBe(&quot;publicKey.ext&quot;, &quot;true&quot;);
+    shouldBe(&quot;Base64URL.parse(publicKey.n).byteLength&quot;, &quot;256&quot;);
+    shouldBe(&quot;bytesToHexString(Base64URL.parse(publicKey.e))&quot;, &quot;'010001'&quot;);
+
+    debug(&quot;Exporting the private key...&quot;);
+    return crypto.subtle.exportKey(&quot;jwk&quot;, keyPair.privateKey);
+}).then(function(result) {
+    privateKey = result;
+
+    shouldBe(&quot;privateKey.kty&quot;, &quot;'RSA'&quot;);
+    shouldBe(&quot;privateKey.key_ops&quot;, &quot;['sign']&quot;);
+    shouldBe(&quot;privateKey.alg&quot;, &quot;'RS1'&quot;);
+    shouldBe(&quot;privateKey.ext&quot;, &quot;true&quot;);
+    shouldBe(&quot;Base64URL.parse(privateKey.n).byteLength&quot;, &quot;256&quot;);
+    shouldBe(&quot;bytesToHexString(Base64URL.parse(privateKey.e))&quot;, &quot;'010001'&quot;);
+    shouldBeUndefined(&quot;privateKey.oth&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_5generateexportkeyjwksha224expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha224-expected.txt (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha224-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha224-expected.txt        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,25 @@
</span><ins>+Test exporting a SHA-224 RSASSA-PKCS1-v1_5 key pair with JWK 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.kty is 'RSA'
+PASS publicKey.key_ops is ['verify']
+PASS publicKey.alg is 'RS224'
+PASS publicKey.ext is true
+PASS Base64URL.parse(publicKey.n).byteLength is 256
+PASS bytesToHexString(Base64URL.parse(publicKey.e)) is '010001'
+Exporting the private key...
+PASS privateKey.kty is 'RSA'
+PASS privateKey.key_ops is ['sign']
+PASS privateKey.alg is 'RS224'
+PASS privateKey.ext is true
+PASS Base64URL.parse(privateKey.n).byteLength is 256
+PASS bytesToHexString(Base64URL.parse(privateKey.e)) is '010001'
+PASS privateKey.oth is undefined.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersassapkcs1v1_5generateexportkeyjwksha224html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha224.html (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha224.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha224.html        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,60 @@
</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 SHA-224 RSASSA-PKCS1-v1_5 key pair with JWK 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-224&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;jwk&quot;, keyPair.publicKey);
+}).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;publicKey.kty&quot;, &quot;'RSA'&quot;);
+    shouldBe(&quot;publicKey.key_ops&quot;, &quot;['verify']&quot;);
+    shouldBe(&quot;publicKey.alg&quot;, &quot;'RS224'&quot;);
+    shouldBe(&quot;publicKey.ext&quot;, &quot;true&quot;);
+    shouldBe(&quot;Base64URL.parse(publicKey.n).byteLength&quot;, &quot;256&quot;);
+    shouldBe(&quot;bytesToHexString(Base64URL.parse(publicKey.e))&quot;, &quot;'010001'&quot;);
+
+    debug(&quot;Exporting the private key...&quot;);
+    return crypto.subtle.exportKey(&quot;jwk&quot;, keyPair.privateKey);
+}).then(function(result) {
+    privateKey = result;
+
+    shouldBe(&quot;privateKey.kty&quot;, &quot;'RSA'&quot;);
+    shouldBe(&quot;privateKey.key_ops&quot;, &quot;['sign']&quot;);
+    shouldBe(&quot;privateKey.alg&quot;, &quot;'RS224'&quot;);
+    shouldBe(&quot;privateKey.ext&quot;, &quot;true&quot;);
+    shouldBe(&quot;Base64URL.parse(privateKey.n).byteLength&quot;, &quot;256&quot;);
+    shouldBe(&quot;bytesToHexString(Base64URL.parse(privateKey.e))&quot;, &quot;'010001'&quot;);
+    shouldBeUndefined(&quot;privateKey.oth&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_5generateexportkeyjwksha256expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha256-expected.txt (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha256-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha256-expected.txt        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,25 @@
</span><ins>+Test exporting a SHA-256 RSASSA-PKCS1-v1_5 key pair with JWK 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.kty is 'RSA'
+PASS publicKey.key_ops is ['verify']
+PASS publicKey.alg is 'RS256'
+PASS publicKey.ext is true
+PASS Base64URL.parse(publicKey.n).byteLength is 256
+PASS bytesToHexString(Base64URL.parse(publicKey.e)) is '010001'
+Exporting the private key...
+PASS privateKey.kty is 'RSA'
+PASS privateKey.key_ops is ['sign']
+PASS privateKey.alg is 'RS256'
+PASS privateKey.ext is true
+PASS Base64URL.parse(privateKey.n).byteLength is 256
+PASS bytesToHexString(Base64URL.parse(privateKey.e)) is '010001'
+PASS privateKey.oth is undefined.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersassapkcs1v1_5generateexportkeyjwksha256html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha256.html (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha256.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha256.html        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,60 @@
</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 SHA-256 RSASSA-PKCS1-v1_5 key pair with JWK 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-256&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;jwk&quot;, keyPair.publicKey);
+}).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;publicKey.kty&quot;, &quot;'RSA'&quot;);
+    shouldBe(&quot;publicKey.key_ops&quot;, &quot;['verify']&quot;);
+    shouldBe(&quot;publicKey.alg&quot;, &quot;'RS256'&quot;);
+    shouldBe(&quot;publicKey.ext&quot;, &quot;true&quot;);
+    shouldBe(&quot;Base64URL.parse(publicKey.n).byteLength&quot;, &quot;256&quot;);
+    shouldBe(&quot;bytesToHexString(Base64URL.parse(publicKey.e))&quot;, &quot;'010001'&quot;);
+
+    debug(&quot;Exporting the private key...&quot;);
+    return crypto.subtle.exportKey(&quot;jwk&quot;, keyPair.privateKey);
+}).then(function(result) {
+    privateKey = result;
+
+    shouldBe(&quot;privateKey.kty&quot;, &quot;'RSA'&quot;);
+    shouldBe(&quot;privateKey.key_ops&quot;, &quot;['sign']&quot;);
+    shouldBe(&quot;privateKey.alg&quot;, &quot;'RS256'&quot;);
+    shouldBe(&quot;privateKey.ext&quot;, &quot;true&quot;);
+    shouldBe(&quot;Base64URL.parse(privateKey.n).byteLength&quot;, &quot;256&quot;);
+    shouldBe(&quot;bytesToHexString(Base64URL.parse(privateKey.e))&quot;, &quot;'010001'&quot;);
+    shouldBeUndefined(&quot;privateKey.oth&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_5generateexportkeyjwksha384expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha384-expected.txt (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha384-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha384-expected.txt        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,25 @@
</span><ins>+Test exporting a SHA-384 RSASSA-PKCS1-v1_5 key pair with JWK 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.kty is 'RSA'
+PASS publicKey.key_ops is ['verify']
+PASS publicKey.alg is 'RS384'
+PASS publicKey.ext is true
+PASS Base64URL.parse(publicKey.n).byteLength is 256
+PASS bytesToHexString(Base64URL.parse(publicKey.e)) is '010001'
+Exporting the private key...
+PASS privateKey.kty is 'RSA'
+PASS privateKey.key_ops is ['sign']
+PASS privateKey.alg is 'RS384'
+PASS privateKey.ext is true
+PASS Base64URL.parse(privateKey.n).byteLength is 256
+PASS bytesToHexString(Base64URL.parse(privateKey.e)) is '010001'
+PASS privateKey.oth is undefined.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersassapkcs1v1_5generateexportkeyjwksha384html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha384.html (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha384.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha384.html        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,60 @@
</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 SHA-384 RSASSA-PKCS1-v1_5 key pair with JWK 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-384&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;jwk&quot;, keyPair.publicKey);
+}).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;publicKey.kty&quot;, &quot;'RSA'&quot;);
+    shouldBe(&quot;publicKey.key_ops&quot;, &quot;['verify']&quot;);
+    shouldBe(&quot;publicKey.alg&quot;, &quot;'RS384'&quot;);
+    shouldBe(&quot;publicKey.ext&quot;, &quot;true&quot;);
+    shouldBe(&quot;Base64URL.parse(publicKey.n).byteLength&quot;, &quot;256&quot;);
+    shouldBe(&quot;bytesToHexString(Base64URL.parse(publicKey.e))&quot;, &quot;'010001'&quot;);
+
+    debug(&quot;Exporting the private key...&quot;);
+    return crypto.subtle.exportKey(&quot;jwk&quot;, keyPair.privateKey);
+}).then(function(result) {
+    privateKey = result;
+
+    shouldBe(&quot;privateKey.kty&quot;, &quot;'RSA'&quot;);
+    shouldBe(&quot;privateKey.key_ops&quot;, &quot;['sign']&quot;);
+    shouldBe(&quot;privateKey.alg&quot;, &quot;'RS384'&quot;);
+    shouldBe(&quot;privateKey.ext&quot;, &quot;true&quot;);
+    shouldBe(&quot;Base64URL.parse(privateKey.n).byteLength&quot;, &quot;256&quot;);
+    shouldBe(&quot;bytesToHexString(Base64URL.parse(privateKey.e))&quot;, &quot;'010001'&quot;);
+    shouldBeUndefined(&quot;privateKey.oth&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_5generateexportkeyjwksha512expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha512-expected.txt (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha512-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha512-expected.txt        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,25 @@
</span><ins>+Test exporting a SHA-512 RSASSA-PKCS1-v1_5 key pair with JWK 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.kty is 'RSA'
+PASS publicKey.key_ops is ['verify']
+PASS publicKey.alg is 'RS512'
+PASS publicKey.ext is true
+PASS Base64URL.parse(publicKey.n).byteLength is 256
+PASS bytesToHexString(Base64URL.parse(publicKey.e)) is '010001'
+Exporting the private key...
+PASS privateKey.kty is 'RSA'
+PASS privateKey.key_ops is ['sign']
+PASS privateKey.alg is 'RS512'
+PASS privateKey.ext is true
+PASS Base64URL.parse(privateKey.n).byteLength is 256
+PASS bytesToHexString(Base64URL.parse(privateKey.e)) is '010001'
+PASS privateKey.oth is undefined.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersassapkcs1v1_5generateexportkeyjwksha512html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha512.html (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha512.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha512.html        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,60 @@
</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 SHA-512 RSASSA-PKCS1-v1_5 key pair with JWK 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-512&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;jwk&quot;, keyPair.publicKey);
+}).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;publicKey.kty&quot;, &quot;'RSA'&quot;);
+    shouldBe(&quot;publicKey.key_ops&quot;, &quot;['verify']&quot;);
+    shouldBe(&quot;publicKey.alg&quot;, &quot;'RS512'&quot;);
+    shouldBe(&quot;publicKey.ext&quot;, &quot;true&quot;);
+    shouldBe(&quot;Base64URL.parse(publicKey.n).byteLength&quot;, &quot;256&quot;);
+    shouldBe(&quot;bytesToHexString(Base64URL.parse(publicKey.e))&quot;, &quot;'010001'&quot;);
+
+    debug(&quot;Exporting the private key...&quot;);
+    return crypto.subtle.exportKey(&quot;jwk&quot;, keyPair.privateKey);
+}).then(function(result) {
+    privateKey = result;
+
+    shouldBe(&quot;privateKey.kty&quot;, &quot;'RSA'&quot;);
+    shouldBe(&quot;privateKey.key_ops&quot;, &quot;['sign']&quot;);
+    shouldBe(&quot;privateKey.alg&quot;, &quot;'RS512'&quot;);
+    shouldBe(&quot;privateKey.ext&quot;, &quot;true&quot;);
+    shouldBe(&quot;Base64URL.parse(privateKey.n).byteLength&quot;, &quot;256&quot;);
+    shouldBe(&quot;bytesToHexString(Base64URL.parse(privateKey.e))&quot;, &quot;'010001'&quot;);
+    shouldBeUndefined(&quot;privateKey.oth&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="trunkLayoutTestscryptoworkerssubtleaesgenerateexportkeyjwkexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/aes-generate-export-key-jwk-expected.txt (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/aes-generate-export-key-jwk-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/aes-generate-export-key-jwk-expected.txt        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,17 @@
</span><ins>+[Worker] Test exporting an AES key using AES-CBC algorithm in workers with JWK format.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Starting worker: resources/aes-generate-export-key-jwk.js
+[Worker] Generating a key...
+[Worker] Exporting a key...
+PASS [Worker] key.kty is 'oct'
+PASS [Worker] key.key_ops is ['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']
+PASS [Worker] key.alg is 'A128CBC'
+PASS [Worker] key.ext is true
+PASS [Worker] Base64URL.parse(key.k).byteLength is 16
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtleaesgenerateexportkeyjwkhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/aes-generate-export-key-jwk.html (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/aes-generate-export-key-jwk.html                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/aes-generate-export-key-jwk.html        2016-11-15 19:08:25 UTC (rev 208737)
</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/aes-generate-export-key-jwk.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="trunkLayoutTestscryptoworkerssubtleaesgenerateexportkeyrawexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/aes-generate-export-key-raw-expected.txt (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/aes-generate-export-key-raw-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/aes-generate-export-key-raw-expected.txt        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+[Worker] Test exporting an AES key using AES-CBC algorithm in workers with raw format.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Starting worker: resources/aes-generate-export-key-raw.js
+[Worker] Generating a key...
+[Worker] Generating a key...
+PASS [Worker] crypto.subtle.exportKey(&quot;spki&quot;, key) rejected promise  with NotSupportedError (DOM Exception 9): The algorithm is not supported.
+PASS [Worker] crypto.subtle.exportKey(&quot;pkcs8&quot;, key) rejected promise  with NotSupportedError (DOM Exception 9): The algorithm is not supported.
+[Worker] Exporting a key...
+PASS [Worker] key.byteLength is 16
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtleaesgenerateexportkeyrawhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/aes-generate-export-key-raw.html (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/aes-generate-export-key-raw.html                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/aes-generate-export-key-raw.html        2016-11-15 19:08:25 UTC (rev 208737)
</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/aes-generate-export-key-raw.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="trunkLayoutTestscryptoworkerssubtlehmacgenerateexportkeyjwkexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/hmac-generate-export-key-jwk-expected.txt (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/hmac-generate-export-key-jwk-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/hmac-generate-export-key-jwk-expected.txt        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,17 @@
</span><ins>+[Worker] Test exporting a HMAC key in workers with JWK format.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Starting worker: resources/hmac-generate-export-key-jwk.js
+[Worker] Generating a key...
+[Worker] Exporting a key...
+PASS [Worker] key.kty is 'oct'
+PASS [Worker] key.key_ops is ['sign', 'verify']
+PASS [Worker] key.alg is 'HS1'
+PASS [Worker] key.ext is true
+PASS [Worker] Base64URL.parse(key.k).byteLength is 64
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtlehmacgenerateexportkeyjwkhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/hmac-generate-export-key-jwk.html (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/hmac-generate-export-key-jwk.html                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/hmac-generate-export-key-jwk.html        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;script src=&quot;../../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;script&gt;
+        worker = startWorker('resources/hmac-generate-export-key-jwk.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="trunkLayoutTestscryptoworkerssubtlehmacgenerateexportkeyrawexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/hmac-generate-export-key-raw-expected.txt (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/hmac-generate-export-key-raw-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/hmac-generate-export-key-raw-expected.txt        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+[Worker] Test exporting an HMAC key in workers with raw format.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Starting worker: resources/hmac-generate-export-key-raw.js
+[Worker] Generating a key...
+[Worker] Generating a key...
+PASS [Worker] crypto.subtle.exportKey(&quot;spki&quot;, key) rejected promise  with NotSupportedError (DOM Exception 9): The algorithm is not supported.
+PASS [Worker] crypto.subtle.exportKey(&quot;pkcs8&quot;, key) rejected promise  with NotSupportedError (DOM Exception 9): The algorithm is not supported.
+[Worker] Exporting a key...
+PASS [Worker] key.byteLength is 64
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtlehmacgenerateexportkeyrawhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/hmac-generate-export-key-raw.html (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/hmac-generate-export-key-raw.html                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/hmac-generate-export-key-raw.html        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;script src=&quot;../../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;script&gt;
+        worker = startWorker('resources/hmac-generate-export-key-raw.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="trunkLayoutTestscryptoworkerssubtleresourcesaesgenerateexportkeyjwkjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/resources/aes-generate-export-key-jwk.js (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/resources/aes-generate-export-key-jwk.js                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/resources/aes-generate-export-key-jwk.js        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,23 @@
</span><ins>+importScripts('../../../../resources/js-test-pre.js');
+importScripts('../../../resources/common.js');
+
+description(&quot;Test exporting an AES key using AES-CBC algorithm in workers with JWK format.&quot;);
+jsTestIsAsync = true;
+
+var extractable = true;
+
+debug(&quot;Generating a key...&quot;);
+crypto.subtle.generateKey({name: &quot;aes-cbc&quot;, length: 128}, extractable, [&quot;decrypt&quot;, &quot;encrypt&quot;, &quot;unwrapKey&quot;, &quot;wrapKey&quot;]).then(function(key) {
+    debug(&quot;Exporting a key...&quot;);
+    return crypto.subtle.exportKey(&quot;jwk&quot;, key);
+}).then(function(result) {
+    key = result;
+
+    shouldBe(&quot;key.kty&quot;, &quot;'oct'&quot;);
+    shouldBe(&quot;key.key_ops&quot;, &quot;['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']&quot;);
+    shouldBe(&quot;key.alg&quot;, &quot;'A128CBC'&quot;);
+    shouldBe(&quot;key.ext&quot;, &quot;true&quot;);
+    shouldBe(&quot;Base64URL.parse(key.k).byteLength&quot;, &quot;16&quot;);
+
+    finishJSTest();
+});
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtleresourcesaesgenerateexportkeyrawjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/resources/aes-generate-export-key-raw.js (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/resources/aes-generate-export-key-raw.js                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/resources/aes-generate-export-key-raw.js        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,26 @@
</span><ins>+importScripts('../../../../resources/js-test-pre.js');
+
+description(&quot;Test exporting an AES key using AES-CBC algorithm in workers with raw format.&quot;);
+jsTestIsAsync = true;
+
+var extractable = true;
+
+debug(&quot;Generating a key...&quot;);
+crypto.subtle.generateKey({name: &quot;aes-cbc&quot;, length: 128}, extractable, [&quot;decrypt&quot;, &quot;encrypt&quot;, &quot;unwrapKey&quot;, &quot;wrapKey&quot;]).then(function(result) {
+    key = result;
+
+    // Not support format.
+    shouldReject('crypto.subtle.exportKey(&quot;spki&quot;, key)');
+    shouldReject('crypto.subtle.exportKey(&quot;pkcs8&quot;, key)');
+
+    debug(&quot;Generating a key...&quot;);
+    return crypto.subtle.generateKey({name: &quot;aes-cbc&quot;, length: 128}, extractable, [&quot;decrypt&quot;, &quot;encrypt&quot;, &quot;unwrapKey&quot;, &quot;wrapKey&quot;]);
+}).then(function(key) {
+    debug(&quot;Exporting a key...&quot;);
+    return crypto.subtle.exportKey(&quot;raw&quot;, key);
+}).then(function(result) {
+    key = result;
+    shouldBe(&quot;key.byteLength&quot;, &quot;16&quot;);
+
+    finishJSTest();
+});
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtleresourceshmacgenerateexportkeyjwkjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/resources/hmac-generate-export-key-jwk.js (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/resources/hmac-generate-export-key-jwk.js                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/resources/hmac-generate-export-key-jwk.js        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,23 @@
</span><ins>+importScripts('../../../../resources/js-test-pre.js');
+importScripts('../../../resources/common.js');
+
+description(&quot;Test exporting a HMAC key in workers with JWK format.&quot;);
+jsTestIsAsync = true;
+
+var extractable = true;
+
+debug(&quot;Generating a key...&quot;);
+crypto.subtle.generateKey({name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]).then(function(key) {
+    debug(&quot;Exporting a key...&quot;);
+    return crypto.subtle.exportKey(&quot;jwk&quot;, key);
+}).then(function(result) {
+    key = result;
+
+    shouldBe(&quot;key.kty&quot;, &quot;'oct'&quot;);
+    shouldBe(&quot;key.key_ops&quot;, &quot;['sign', 'verify']&quot;);
+    shouldBe(&quot;key.alg&quot;, &quot;'HS1'&quot;);
+    shouldBe(&quot;key.ext&quot;, &quot;true&quot;);
+    shouldBe(&quot;Base64URL.parse(key.k).byteLength&quot;, &quot;64&quot;);
+
+    finishJSTest();
+});
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtleresourceshmacgenerateexportkeyrawjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/resources/hmac-generate-export-key-raw.js (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/resources/hmac-generate-export-key-raw.js                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/resources/hmac-generate-export-key-raw.js        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,26 @@
</span><ins>+importScripts('../../../../resources/js-test-pre.js');
+
+description(&quot;Test exporting an HMAC key in workers with raw format.&quot;);
+jsTestIsAsync = true;
+
+var extractable = true;
+
+debug(&quot;Generating a key...&quot;);
+crypto.subtle.generateKey({name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]).then(function(result) {
+    key = result;
+
+    // Not support format.
+    shouldReject('crypto.subtle.exportKey(&quot;spki&quot;, key)');
+    shouldReject('crypto.subtle.exportKey(&quot;pkcs8&quot;, key)');
+
+    debug(&quot;Generating a key...&quot;);
+    return crypto.subtle.generateKey({name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;])
+}).then(function(key) {
+    debug(&quot;Exporting a key...&quot;);
+    return crypto.subtle.exportKey(&quot;raw&quot;, key);
+}).then(function(result) {
+    key = result;
+    shouldBe(&quot;key.byteLength&quot;, &quot;64&quot;);
+
+    finishJSTest();
+});
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtleresourcesrsagenerateexportkeyjwkjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/resources/rsa-generate-export-key-jwk.js (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/resources/rsa-generate-export-key-jwk.js                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/resources/rsa-generate-export-key-jwk.js        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,49 @@
</span><ins>+importScripts('../../../../resources/js-test-pre.js');
+importScripts('../../../resources/common.js');
+
+description(&quot;Test exporting a RSA key pair using RSA-OAEP algorithm in workers with JWK 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;
+
+debug(&quot;Generating a key...&quot;);
+crypto.subtle.generateKey(algorithmKeyGen, extractable, [&quot;decrypt&quot;, &quot;encrypt&quot;, &quot;wrapKey&quot;, &quot;unwrapKey&quot;]).then(function(result) {
+    keyPair = result;
+
+    // Not support format.
+    shouldReject('crypto.subtle.exportKey(&quot;raw&quot;, keyPair.publicKey)');
+
+    debug(&quot;Exporting the public key...&quot;);
+    return crypto.subtle.exportKey(&quot;jwk&quot;, keyPair.publicKey);
+}).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;publicKey.kty&quot;, &quot;'RSA'&quot;);
+    shouldBe(&quot;publicKey.key_ops&quot;, &quot;['encrypt', 'wrapKey']&quot;);
+    shouldBe(&quot;publicKey.alg&quot;, &quot;'RSA-OAEP'&quot;);
+    shouldBe(&quot;publicKey.ext&quot;, &quot;true&quot;);
+    shouldBe(&quot;Base64URL.parse(publicKey.n).byteLength&quot;, &quot;256&quot;);
+    shouldBe(&quot;bytesToHexString(Base64URL.parse(publicKey.e))&quot;, &quot;'010001'&quot;);
+
+    debug(&quot;Exporting the private key...&quot;);
+    return crypto.subtle.exportKey(&quot;jwk&quot;, keyPair.privateKey);
+}).then(function(result) {
+    privateKey = result;
+
+    shouldBe(&quot;privateKey.kty&quot;, &quot;'RSA'&quot;);
+    shouldBe(&quot;privateKey.key_ops&quot;, &quot;['decrypt', 'unwrapKey']&quot;);
+    shouldBe(&quot;privateKey.alg&quot;, &quot;'RSA-OAEP'&quot;);
+    shouldBe(&quot;privateKey.ext&quot;, &quot;true&quot;);
+    shouldBe(&quot;Base64URL.parse(privateKey.n).byteLength&quot;, &quot;256&quot;);
+    shouldBe(&quot;bytesToHexString(Base64URL.parse(privateKey.e))&quot;, &quot;'010001'&quot;);
+    shouldBeUndefined(&quot;privateKey.oth&quot;);
+
+    finishJSTest();
+});
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtlersagenerateexportkeyjwkexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/rsa-generate-export-key-jwk-expected.txt (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/rsa-generate-export-key-jwk-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/rsa-generate-export-key-jwk-expected.txt        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -0,0 +1,27 @@
</span><ins>+[Worker] Test exporting a RSA key pair using RSA-OAEP algorithm in workers with JWK format.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Starting worker: resources/rsa-generate-export-key-jwk.js
+[Worker] Generating a key...
+[Worker] Exporting the public key...
+PASS [Worker] crypto.subtle.exportKey(&quot;raw&quot;, keyPair.publicKey) rejected promise  with NotSupportedError (DOM Exception 9): The algorithm is not supported.
+PASS [Worker] publicKey.kty is 'RSA'
+PASS [Worker] publicKey.key_ops is ['encrypt', 'wrapKey']
+PASS [Worker] publicKey.alg is 'RSA-OAEP'
+PASS [Worker] publicKey.ext is true
+PASS [Worker] Base64URL.parse(publicKey.n).byteLength is 256
+PASS [Worker] bytesToHexString(Base64URL.parse(publicKey.e)) is '010001'
+[Worker] Exporting the private key...
+PASS [Worker] privateKey.kty is 'RSA'
+PASS [Worker] privateKey.key_ops is ['decrypt', 'unwrapKey']
+PASS [Worker] privateKey.alg is 'RSA-OAEP'
+PASS [Worker] privateKey.ext is true
+PASS [Worker] Base64URL.parse(privateKey.n).byteLength is 256
+PASS [Worker] bytesToHexString(Base64URL.parse(privateKey.e)) is '010001'
+PASS [Worker] privateKey.oth is undefined.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtlersagenerateexportkeyjwkhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/rsa-generate-export-key-jwk.html (0 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/rsa-generate-export-key-jwk.html                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/rsa-generate-export-key-jwk.html        2016-11-15 19:08:25 UTC (rev 208737)
</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-generate-export-key-jwk.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 (208736 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog        2016-11-15 19:04:22 UTC (rev 208736)
+++ trunk/LayoutTests/imported/w3c/ChangeLog        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2016-11-14  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
+
+        Update SubtleCrypto::exportKey to match the latest spec
+        https://bugs.webkit.org/show_bug.cgi?id=164722
+        &lt;rdar://problem/29251740&gt;
+
+        Reviewed by Brent Fulgham.
+
+        * WebCryptoAPI/idlharness-expected.txt:
+
</ins><span class="cx"> 2016-11-14  Youenn Fablet  &lt;youenn@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Support WPT templated tests
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cWebCryptoAPIidlharnessexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/WebCryptoAPI/idlharness-expected.txt (208736 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/WebCryptoAPI/idlharness-expected.txt        2016-11-15 19:04:22 UTC (rev 208736)
+++ trunk/LayoutTests/imported/w3c/WebCryptoAPI/idlharness-expected.txt        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -61,8 +61,8 @@
</span><span class="cx"> FAIL SubtleCrypto interface: calling deriveBits(AlgorithmIdentifier,CryptoKey,unsigned long) on crypto.subtle with too few arguments must throw TypeError assert_inherits: property &quot;deriveBits&quot; not found in prototype chain
</span><span class="cx"> PASS SubtleCrypto interface: crypto.subtle must inherit property &quot;importKey&quot; with the proper type (8) 
</span><span class="cx"> PASS SubtleCrypto interface: calling importKey(KeyFormat,[object Object],[object Object],AlgorithmIdentifier,boolean,[object Object]) on crypto.subtle with too few arguments must throw TypeError 
</span><del>-FAIL SubtleCrypto interface: crypto.subtle must inherit property &quot;exportKey&quot; with the proper type (9) assert_inherits: property &quot;exportKey&quot; not found in prototype chain
-FAIL SubtleCrypto interface: calling exportKey(KeyFormat,CryptoKey) on crypto.subtle with too few arguments must throw TypeError assert_inherits: property &quot;exportKey&quot; not found in prototype chain
</del><ins>+PASS SubtleCrypto interface: crypto.subtle must inherit property &quot;exportKey&quot; with the proper type (9) 
+PASS SubtleCrypto interface: calling exportKey(KeyFormat,CryptoKey) on crypto.subtle with too few arguments must throw TypeError 
</ins><span class="cx"> FAIL SubtleCrypto interface: crypto.subtle must inherit property &quot;wrapKey&quot; with the proper type (10) assert_inherits: property &quot;wrapKey&quot; not found in prototype chain
</span><span class="cx"> FAIL SubtleCrypto interface: calling wrapKey(KeyFormat,CryptoKey,CryptoKey,AlgorithmIdentifier) on crypto.subtle with too few arguments must throw TypeError assert_inherits: property &quot;wrapKey&quot; not found in prototype chain
</span><span class="cx"> FAIL SubtleCrypto interface: crypto.subtle must inherit property &quot;unwrapKey&quot; with the proper type (11) assert_inherits: property &quot;unwrapKey&quot; not found in prototype chain
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (208736 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-11-15 19:04:22 UTC (rev 208736)
+++ trunk/Source/WebCore/ChangeLog        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -1,3 +1,101 @@
</span><ins>+2016-11-14  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
+
+        Update SubtleCrypto::exportKey to match the latest spec
+        https://bugs.webkit.org/show_bug.cgi?id=164722
+        &lt;rdar://problem/29251740&gt;
+
+        Reviewed by Brent Fulgham.
+
+        This patch does following few things:
+        1. It updates the SubtleCrypto::exportKey method to match the latest spec:
+           https://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-exportKey.
+           It also refers to the latest Editor's Draft to a certain degree:
+           https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-exportKey.
+        2. It implements exportKey operations of the following algorithms: AES-CBC, AES-KW,
+           HMAC, RSAES-PKCS1-V1_5, RSASSA-PKCS1-V1_5, and RSA-OAEP.
+        3. It also fixes the following bugs:
+           https://bugs.webkit.org/show_bug.cgi?id=156114,
+           &lt;rdar://problem/21773066&gt;.
+        Note: We currently only support Raw and Jwk key format.
+
+        Tests: crypto/subtle/aes-cbc-generate-export-key-jwk-length-128.html
+               crypto/subtle/aes-cbc-generate-export-key-jwk-length-192.html
+               crypto/subtle/aes-cbc-generate-export-key-jwk-length-256.html
+               crypto/subtle/aes-cbc-generate-export-key-raw.html
+               crypto/subtle/aes-export-key-malformed-parameters.html
+               crypto/subtle/aes-kw-generate-export-key-jwk-length-128.html
+               crypto/subtle/aes-kw-generate-export-key-jwk-length-192.html
+               crypto/subtle/aes-kw-generate-export-key-jwk-length-256.html
+               crypto/subtle/aes-kw-generate-export-raw-key.html
+               crypto/subtle/export-key-malformed-parameters.html
+               crypto/subtle/hmac-export-key-malformed-parameters.html
+               crypto/subtle/hmac-generate-export-key-jwk-sha1.html
+               crypto/subtle/hmac-generate-export-key-jwk-sha224.html
+               crypto/subtle/hmac-generate-export-key-jwk-sha256.html
+               crypto/subtle/hmac-generate-export-key-jwk-sha384.html
+               crypto/subtle/hmac-generate-export-key-jwk-sha512.html
+               crypto/subtle/hmac-generate-export-raw-key.html
+               crypto/subtle/hmac-import-key-malformed-parameters.html
+               crypto/subtle/rsa-export-key-malformed-parameters.html
+               crypto/subtle/rsa-oaep-generate-export-key-jwk-sha1.html
+               crypto/subtle/rsa-oaep-generate-export-key-jwk-sha224.html
+               crypto/subtle/rsa-oaep-generate-export-key-jwk-sha256.html
+               crypto/subtle/rsa-oaep-generate-export-key-jwk-sha384.html
+               crypto/subtle/rsa-oaep-generate-export-key-jwk-sha512.html
+               crypto/subtle/rsaes-pkcs1-v1_5-generate-export-key-jwk.html
+               crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha1.html
+               crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha224.html
+               crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha256.html
+               crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha384.html
+               crypto/subtle/rsassa-pkcs1-v1_5-generate-export-key-jwk-sha512.html
+               crypto/workers/subtle/aes-generate-export-key-jwk.html
+               crypto/workers/subtle/aes-generate-export-key-raw.html
+               crypto/workers/subtle/hmac-generate-export-key-jwk.html
+               crypto/workers/subtle/hmac-generate-export-key-raw.html
+               crypto/workers/subtle/rsa-generate-export-key-jwk.html
+
+        * bindings/js/JSSubtleCryptoCustom.cpp:
+        (WebCore::toJSValueFromJsonWebKey):
+        (WebCore::jsSubtleCryptoFunctionExportKeyPromise):
+        (WebCore::JSSubtleCrypto::exportKey):
+        * crypto/CryptoAlgorithm.cpp:
+        (WebCore::CryptoAlgorithm::exportKey):
+        * crypto/CryptoAlgorithm.h:
+        * crypto/SubtleCrypto.idl:
+        * crypto/algorithms/CryptoAlgorithmAES_CBC.cpp:
+        (WebCore::CryptoAlgorithmAES_CBC::importKey):
+        (WebCore::CryptoAlgorithmAES_CBC::exportKey):
+        * crypto/algorithms/CryptoAlgorithmAES_CBC.h:
+        * crypto/algorithms/CryptoAlgorithmAES_KW.cpp:
+        (WebCore::CryptoAlgorithmAES_KW::importKey):
+        (WebCore::CryptoAlgorithmAES_KW::exportKey):
+        * crypto/algorithms/CryptoAlgorithmAES_KW.h:
+        * crypto/algorithms/CryptoAlgorithmHMAC.cpp:
+        (WebCore::CryptoAlgorithmHMAC::importKey):
+        (WebCore::CryptoAlgorithmHMAC::exportKey):
+        * crypto/algorithms/CryptoAlgorithmHMAC.h:
+        * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp:
+        (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::importKey):
+        (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::exportKey):
+        * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h:
+        * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp:
+        (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::importKey):
+        (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::exportKey):
+        * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h:
+        * crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp:
+        (WebCore::CryptoAlgorithmRSA_OAEP::importKey):
+        (WebCore::CryptoAlgorithmRSA_OAEP::exportKey):
+        * crypto/algorithms/CryptoAlgorithmRSA_OAEP.h:
+        * crypto/keys/CryptoKeyAES.cpp:
+        (WebCore::CryptoKeyAES::exportJwk):
+        * crypto/keys/CryptoKeyAES.h:
+        * crypto/keys/CryptoKeyHMAC.cpp:
+        (WebCore::CryptoKeyHMAC::exportJwk):
+        * crypto/keys/CryptoKeyHMAC.h:
+        * crypto/keys/CryptoKeyRSA.cpp:
+        (WebCore::CryptoKeyRSA::exportJwk):
+        * crypto/keys/CryptoKeyRSA.h:
+
</ins><span class="cx"> 2016-11-15  Jon Lee  &lt;jonlee@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Remove HasMediaCaptureDevice
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSSubtleCryptoCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp (208736 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp        2016-11-15 19:04:22 UTC (rev 208736)
+++ trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -43,6 +43,7 @@
</span><span class="cx"> #include &quot;ScriptState.h&quot;
</span><span class="cx"> #include &lt;runtime/Error.h&gt;
</span><span class="cx"> #include &lt;runtime/IteratorOperations.h&gt;
</span><ins>+#include &lt;runtime/JSArray.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> using namespace JSC;
</span><span class="cx"> 
</span><span class="lines">@@ -307,6 +308,61 @@
</span><span class="cx">     return result;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+// FIXME: We should get rid of this once https://bugs.webkit.org/show_bug.cgi?id=163711 is fixed.
+static JSValue toJSValueFromJsonWebKey(JSDOMGlobalObject&amp; globalObject, JsonWebKey&amp;&amp; key)
+{
+    ExecState&amp; state = *globalObject.globalExec();
+    VM&amp; vm = state.vm();
+
+    auto* result = constructEmptyObject(&amp;state);
+    result-&gt;putDirect(vm, Identifier::fromString(&amp;vm, &quot;kty&quot;), toJS&lt;IDLDOMString&gt;(state, key.kty));
+    if (key.use)
+        result-&gt;putDirect(vm, Identifier::fromString(&amp;vm, &quot;use&quot;), toJS&lt;IDLDOMString&gt;(state, key.use.value()));
+    if (key.key_ops)
+        result-&gt;putDirect(vm, Identifier::fromString(&amp;vm, &quot;key_ops&quot;), toJS&lt;IDLSequence&lt;IDLEnumeration&lt;CryptoKeyUsage&gt;&gt;&gt;(state, globalObject, key.key_ops.value()));
+    if (key.alg)
+        result-&gt;putDirect(vm, Identifier::fromString(&amp;vm, &quot;alg&quot;), toJS&lt;IDLDOMString&gt;(state, key.alg.value()));
+    if (key.ext)
+        result-&gt;putDirect(vm, Identifier::fromString(&amp;vm, &quot;ext&quot;), toJS&lt;IDLBoolean&gt;(state, key.ext.value()));
+    if (key.crv)
+        result-&gt;putDirect(vm, Identifier::fromString(&amp;vm, &quot;crv&quot;), toJS&lt;IDLDOMString&gt;(state, key.crv.value()));
+    if (key.x)
+        result-&gt;putDirect(vm, Identifier::fromString(&amp;vm, &quot;x&quot;), toJS&lt;IDLDOMString&gt;(state, key.x.value()));
+    if (key.y)
+        result-&gt;putDirect(vm, Identifier::fromString(&amp;vm, &quot;y&quot;), toJS&lt;IDLDOMString&gt;(state, key.y.value()));
+    if (key.d)
+        result-&gt;putDirect(vm, Identifier::fromString(&amp;vm, &quot;d&quot;), toJS&lt;IDLDOMString&gt;(state, key.d.value()));
+    if (key.n)
+        result-&gt;putDirect(vm, Identifier::fromString(&amp;vm, &quot;n&quot;), toJS&lt;IDLDOMString&gt;(state, key.n.value()));
+    if (key.e)
+        result-&gt;putDirect(vm, Identifier::fromString(&amp;vm, &quot;e&quot;), toJS&lt;IDLDOMString&gt;(state, key.e.value()));
+    if (key.p)
+        result-&gt;putDirect(vm, Identifier::fromString(&amp;vm, &quot;p&quot;), toJS&lt;IDLDOMString&gt;(state, key.p.value()));
+    if (key.q)
+        result-&gt;putDirect(vm, Identifier::fromString(&amp;vm, &quot;q&quot;), toJS&lt;IDLDOMString&gt;(state, key.q.value()));
+    if (key.dp)
+        result-&gt;putDirect(vm, Identifier::fromString(&amp;vm, &quot;dp&quot;), toJS&lt;IDLDOMString&gt;(state, key.dp.value()));
+    if (key.dq)
+        result-&gt;putDirect(vm, Identifier::fromString(&amp;vm, &quot;dq&quot;), toJS&lt;IDLDOMString&gt;(state, key.dq.value()));
+    if (key.qi)
+        result-&gt;putDirect(vm, Identifier::fromString(&amp;vm, &quot;qi&quot;), toJS&lt;IDLDOMString&gt;(state, key.qi.value()));
+    if (key.oth) {
+        MarkedArgumentBuffer list;
+        for (auto&amp; value : key.oth.value()) {
+            auto* info = constructEmptyObject(&amp;state);
+            info-&gt;putDirect(vm, Identifier::fromString(&amp;vm, &quot;r&quot;), toJS&lt;IDLDOMString&gt;(state, value.r));
+            info-&gt;putDirect(vm, Identifier::fromString(&amp;vm, &quot;d&quot;), toJS&lt;IDLDOMString&gt;(state, value.d));
+            info-&gt;putDirect(vm, Identifier::fromString(&amp;vm, &quot;t&quot;), toJS&lt;IDLDOMString&gt;(state, value.t));
+            list.append(info);
+        }
+        result-&gt;putDirect(vm, Identifier::fromString(&amp;vm, &quot;oth&quot;), constructArray(&amp;state, static_cast&lt;Structure*&gt;(nullptr), list));
+    }
+    if (key.k)
+        result-&gt;putDirect(vm, Identifier::fromString(&amp;vm, &quot;k&quot;), toJS&lt;IDLDOMString&gt;(state, key.k.value()));
+
+    return result;
+}
+
</ins><span class="cx"> static void jsSubtleCryptoFunctionGenerateKeyPromise(ExecState&amp; state, Ref&lt;DeferredPromise&gt;&amp;&amp; promise)
</span><span class="cx"> {
</span><span class="cx">     VM&amp; vm = state.vm();
</span><span class="lines">@@ -350,8 +406,8 @@
</span><span class="cx">         rejectWithException(WTFMove(capturedPromise), ec);
</span><span class="cx">     };
</span><span class="cx"> 
</span><del>-    // The spec suggests we should perform the following task asynchronously regardless what kind of keys it produces
-    // as of 11 December 2014: https://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-generateKey
</del><ins>+    // The 11 December 2014 version of the specification suggests we should perform the following task asynchronously
+    // regardless what kind of keys it produces: https://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-generateKey
</ins><span class="cx">     // That's simply not efficient for AES and HMAC keys. Therefore, we perform it as an async task conditionally.
</span><span class="cx">     algorithm-&gt;generateKey(WTFMove(params), extractable, keyUsages, WTFMove(callback), WTFMove(exceptionCallback), *scriptExecutionContextFromExecState(&amp;state));
</span><span class="cx"> }
</span><span class="lines">@@ -395,12 +451,82 @@
</span><span class="cx">         rejectWithException(WTFMove(capturedPromise), ec);
</span><span class="cx">     };
</span><span class="cx"> 
</span><del>-    // The spec suggests we should perform the following task asynchronously as of 11 December 2014:
</del><ins>+    // The 11 December 2014 version of the specification suggests we should perform the following task asynchronously:
</ins><span class="cx">     // https://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-importKey
</span><del>-    // That's simply not necessary. Therefore, we perform it synchronously.
</del><ins>+    // It is not beneficial for less time consuming operations. Therefore, we perform it synchronously.
</ins><span class="cx">     algorithm-&gt;importKey(format, WTFMove(keyData), WTFMove(params), extractable, keyUsages, WTFMove(callback), WTFMove(exceptionCallback));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static void jsSubtleCryptoFunctionExportKeyPromise(ExecState&amp; state, Ref&lt;DeferredPromise&gt;&amp;&amp; promise)
+{
+    VM&amp; vm = state.vm();
+    auto scope = DECLARE_THROW_SCOPE(vm);
+
+    if (UNLIKELY(state.argumentCount() &lt; 2)) {
+        promise-&gt;reject&lt;JSValue&gt;(createNotEnoughArgumentsError(&amp;state));
+        return;
+    }
+
+    auto format = convertEnumeration&lt;SubtleCrypto::KeyFormat&gt;(state, state.uncheckedArgument(0));
+    RETURN_IF_EXCEPTION(scope, void());
+
+    RefPtr&lt;CryptoKey&gt; key = JSCryptoKey::toWrapped(state.uncheckedArgument(1));
+    if (!key) {
+        promise-&gt;reject&lt;JSValue&gt;(createTypeError(&amp;state, ASCIILiteral(&quot;Invalid CryptoKey&quot;)));
+        return;
+    }
+
+    switch (key-&gt;algorithmIdentifier()) {
+    case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
+    case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
+    case CryptoAlgorithmIdentifier::RSA_PSS:
+    case CryptoAlgorithmIdentifier::RSA_OAEP:
+    case CryptoAlgorithmIdentifier::AES_CTR:
+    case CryptoAlgorithmIdentifier::AES_CBC:
+    case CryptoAlgorithmIdentifier::AES_CMAC:
+    case CryptoAlgorithmIdentifier::AES_GCM:
+    case CryptoAlgorithmIdentifier::AES_CFB:
+    case CryptoAlgorithmIdentifier::AES_KW:
+    case CryptoAlgorithmIdentifier::HMAC:
+        break;
+    default:
+        promise-&gt;reject&lt;JSValue&gt;(createDOMException(&amp;state, NOT_SUPPORTED_ERR, ASCIILiteral(&quot;The operation is not supported&quot;)));
+        return;
+    }
+
+    if (!key-&gt;extractable()) {
+        promise-&gt;reject&lt;JSValue&gt;(createDOMException(&amp;state, INVALID_ACCESS_ERR, ASCIILiteral(&quot;The CryptoKey is nonextractable&quot;)));
+        return;
+    }
+
+    auto algorithm = createAlgorithm(state, key-&gt;algorithmIdentifier());
+    RETURN_IF_EXCEPTION(scope, void());
+
+    auto callback = [capturedPromise = promise.copyRef()](SubtleCrypto::KeyFormat format, KeyData&amp;&amp; key) mutable {
+        switch (format) {
+        case SubtleCrypto::KeyFormat::Spki:
+        case SubtleCrypto::KeyFormat::Pkcs8:
+        case SubtleCrypto::KeyFormat::Raw: {
+            Vector&lt;uint8_t&gt;&amp; rawKey = WTF::get&lt;Vector&lt;uint8_t&gt;&gt;(key);
+            fulfillPromiseWithArrayBuffer(WTFMove(capturedPromise), rawKey.data(), rawKey.size());
+            return;
+        }
+        case SubtleCrypto::KeyFormat::Jwk:
+            capturedPromise-&gt;resolve(toJSValueFromJsonWebKey(*(capturedPromise-&gt;globalObject()), WTFMove(WTF::get&lt;JsonWebKey&gt;(key))));
+            return;
+        }
+        ASSERT_NOT_REACHED();
+    };
+    auto exceptionCallback = [capturedPromise =  promise.copyRef()](ExceptionCode ec) mutable {
+        rejectWithException(WTFMove(capturedPromise), ec);
+    };
+
+    // The 11 December 2014 version of the specification suggests we should perform the following task asynchronously:
+    // https://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-exportKey
+    // It is not beneficial for less time consuming operations. Therefore, we perform it synchronously.
+    algorithm-&gt;exportKey(format, WTFMove(key), WTFMove(callback), WTFMove(exceptionCallback));
+}
+
</ins><span class="cx"> JSValue JSSubtleCrypto::generateKey(ExecState&amp; state)
</span><span class="cx"> {
</span><span class="cx">     return callPromiseFunction&lt;jsSubtleCryptoFunctionGenerateKeyPromise, PromiseExecutionScope::WindowOrWorker&gt;(state);
</span><span class="lines">@@ -411,6 +537,11 @@
</span><span class="cx">     return callPromiseFunction&lt;jsSubtleCryptoFunctionImportKeyPromise, PromiseExecutionScope::WindowOrWorker&gt;(state);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+JSValue JSSubtleCrypto::exportKey(ExecState&amp; state)
+{
+    return callPromiseFunction&lt;jsSubtleCryptoFunctionExportKeyPromise, PromiseExecutionScope::WindowOrWorker&gt;(state);
+}
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoCryptoAlgorithmcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/CryptoAlgorithm.cpp (208736 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/CryptoAlgorithm.cpp        2016-11-15 19:04:22 UTC (rev 208736)
+++ trunk/Source/WebCore/crypto/CryptoAlgorithm.cpp        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -42,6 +42,11 @@
</span><span class="cx">     exceptionCallback(NOT_SUPPORTED_ERR);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void CryptoAlgorithm::exportKey(SubtleCrypto::KeyFormat, RefPtr&lt;WebCore::CryptoKey&gt;&amp;&amp;, KeyDataCallback&amp;&amp;, ExceptionCallback&amp;&amp; exceptionCallback)
+{
+    exceptionCallback(NOT_SUPPORTED_ERR);
+}
+
</ins><span class="cx"> ExceptionOr&lt;void&gt; CryptoAlgorithm::encrypt(const CryptoAlgorithmParametersDeprecated&amp;, const CryptoKey&amp;, const CryptoOperationData&amp;, VectorCallback&amp;&amp;, VoidCallback&amp;&amp;)
</span><span class="cx"> {
</span><span class="cx">     return Exception { NOT_SUPPORTED_ERR };
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoCryptoAlgorithmh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/CryptoAlgorithm.h (208736 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/CryptoAlgorithm.h        2016-11-15 19:04:22 UTC (rev 208736)
+++ trunk/Source/WebCore/crypto/CryptoAlgorithm.h        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -61,9 +61,11 @@
</span><span class="cx">     using VectorCallback = WTF::Function&lt;void(const Vector&lt;uint8_t&gt;&amp;)&gt;;
</span><span class="cx">     using VoidCallback = WTF::Function&lt;void()&gt;;
</span><span class="cx">     using ExceptionCallback = WTF::Function&lt;void(ExceptionCode)&gt;;
</span><ins>+    using KeyDataCallback = WTF::Function&lt;void(SubtleCrypto::KeyFormat, KeyData&amp;&amp;)&gt;;
</ins><span class="cx"> 
</span><span class="cx">     virtual void generateKey(const std::unique_ptr&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&amp;&amp;, ExceptionCallback&amp;&amp;, ScriptExecutionContext&amp;);
</span><span class="cx">     virtual void importKey(SubtleCrypto::KeyFormat, KeyData&amp;&amp;, const std::unique_ptr&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, bool extractable, CryptoKeyUsageBitmap, KeyCallback&amp;&amp;, ExceptionCallback&amp;&amp;);
</span><ins>+    virtual void exportKey(SubtleCrypto::KeyFormat, RefPtr&lt;CryptoKey&gt;&amp;&amp;, KeyDataCallback&amp;&amp;, ExceptionCallback&amp;&amp;);
</ins><span class="cx"> 
</span><span class="cx">     // The following will be deprecated.
</span><span class="cx">     virtual ExceptionOr&lt;void&gt; encrypt(const CryptoAlgorithmParametersDeprecated&amp;, const CryptoKey&amp;, const CryptoOperationData&amp;, VectorCallback&amp;&amp;, VoidCallback&amp;&amp; failureCallback);
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoSubtleCryptoidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/SubtleCrypto.idl (208736 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/SubtleCrypto.idl        2016-11-15 19:04:22 UTC (rev 208736)
+++ trunk/Source/WebCore/crypto/SubtleCrypto.idl        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -34,4 +34,5 @@
</span><span class="cx">     // FIXME: Should this return a Promise&lt;(CryptoKey or CryptoKeyPair)&gt;?
</span><span class="cx">     [Custom] Promise&lt;any&gt; generateKey(AlgorithmIdentifier algorithm, boolean extractable, sequence&lt;CryptoKeyUsage&gt; keyUsages);
</span><span class="cx">     [Custom] Promise&lt;CryptoKey&gt; importKey(KeyFormat format, (BufferSource or JsonWebKey) keyData, AlgorithmIdentifier algorithm, boolen extractable, sequence&lt;CryptoKeyUsage&gt; keyUsages);
</span><ins>+    [Custom] Promise&lt;any&gt; exportKey(KeyFormat format, CryptoKey key);
</ins><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmAES_CBCcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.cpp (208736 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.cpp        2016-11-15 19:04:22 UTC (rev 208736)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.cpp        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -37,6 +37,10 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+static const char* const ALG128 = &quot;A128CBC&quot;;
+static const char* const ALG192 = &quot;A192CBC&quot;;
+static const char* const ALG256 = &quot;A256CBC&quot;;
+
</ins><span class="cx"> static inline bool usagesAreInvalidForCryptoAlgorithmAES_CBC(CryptoKeyUsageBitmap usages)
</span><span class="cx"> {
</span><span class="cx">     return usages &amp; (CryptoKeyUsageSign | CryptoKeyUsageVerify | CryptoKeyUsageDeriveKey | CryptoKeyUsageDeriveBits);
</span><span class="lines">@@ -94,11 +98,11 @@
</span><span class="cx">         auto checkAlgCallback = [](size_t length, const Optional&lt;String&gt;&amp; alg) -&gt; bool {
</span><span class="cx">             switch (length) {
</span><span class="cx">             case CryptoKeyAES::s_length128:
</span><del>-                return !alg || alg.value() == &quot;A128CBC&quot;;
</del><ins>+                return !alg || alg.value() == ALG128;
</ins><span class="cx">             case CryptoKeyAES::s_length192:
</span><del>-                return !alg || alg.value() == &quot;A192CBC&quot;;
</del><ins>+                return !alg || alg.value() == ALG192;
</ins><span class="cx">             case CryptoKeyAES::s_length256:
</span><del>-                return !alg || alg.value() == &quot;A256CBC&quot;;
</del><ins>+                return !alg || alg.value() == ALG256;
</ins><span class="cx">             }
</span><span class="cx">             return false;
</span><span class="cx">         };
</span><span class="lines">@@ -117,6 +121,46 @@
</span><span class="cx">     callback(*result);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void CryptoAlgorithmAES_CBC::exportKey(SubtleCrypto::KeyFormat format, RefPtr&lt;CryptoKey&gt;&amp;&amp; key, KeyDataCallback&amp;&amp; callback, ExceptionCallback&amp;&amp; exceptionCallback)
+{
+    const auto&amp; aesKey = downcast&lt;CryptoKeyAES&gt;(*key);
+
+    if (aesKey.key().isEmpty()) {
+        exceptionCallback(OperationError);
+        return;
+    }
+
+    KeyData result;
+    switch (format) {
+    case SubtleCrypto::KeyFormat::Raw:
+        result = Vector&lt;uint8_t&gt;(aesKey.key());
+        break;
+    case SubtleCrypto::KeyFormat::Jwk: {
+        JsonWebKey jwk = aesKey.exportJwk();
+        switch (aesKey.key().size() * 8) {
+        case CryptoKeyAES::s_length128:
+            jwk.alg = String(ALG128);
+            break;
+        case CryptoKeyAES::s_length192:
+            jwk.alg = String(ALG192);
+            break;
+        case CryptoKeyAES::s_length256:
+            jwk.alg = String(ALG256);
+            break;
+        default:
+            ASSERT_NOT_REACHED();
+        }
+        result = WTFMove(jwk);
+        break;
+    }
+    default:
+        exceptionCallback(NOT_SUPPORTED_ERR);
+        return;
+    }
+
+    callback(format, WTFMove(result));
+}
+
</ins><span class="cx"> ExceptionOr&lt;void&gt; CryptoAlgorithmAES_CBC::encrypt(const CryptoAlgorithmParametersDeprecated&amp; parameters, const CryptoKey&amp; key, const CryptoOperationData&amp; data, VectorCallback&amp;&amp; callback, VoidCallback&amp;&amp; failureCallback)
</span><span class="cx"> {
</span><span class="cx">     auto&amp; aesCBCParameters = downcast&lt;CryptoAlgorithmAesCbcParamsDeprecated&gt;(parameters);
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmAES_CBCh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.h (208736 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.h        2016-11-15 19:04:22 UTC (rev 208736)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.h        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -46,6 +46,7 @@
</span><span class="cx"> 
</span><span class="cx">     void generateKey(const std::unique_ptr&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&amp;&amp;, ExceptionCallback&amp;&amp;, ScriptExecutionContext&amp;) final;
</span><span class="cx">     void importKey(SubtleCrypto::KeyFormat, KeyData&amp;&amp;, const std::unique_ptr&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, bool extractable, CryptoKeyUsageBitmap, KeyCallback&amp;&amp;, ExceptionCallback&amp;&amp;) final;
</span><ins>+    void exportKey(SubtleCrypto::KeyFormat, RefPtr&lt;CryptoKey&gt;&amp;&amp;, KeyDataCallback&amp;&amp;, ExceptionCallback&amp;&amp;) final;
</ins><span class="cx"> 
</span><span class="cx">     ExceptionOr&lt;void&gt; encrypt(const CryptoAlgorithmParametersDeprecated&amp;, const CryptoKey&amp;, const CryptoOperationData&amp;, VectorCallback&amp;&amp;, VoidCallback&amp;&amp; failureCallback) final;
</span><span class="cx">     ExceptionOr&lt;void&gt; decrypt(const CryptoAlgorithmParametersDeprecated&amp;, const CryptoKey&amp;, const CryptoOperationData&amp;, VectorCallback&amp;&amp;, VoidCallback&amp;&amp; failureCallback) final;
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmAES_KWcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.cpp (208736 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.cpp        2016-11-15 19:04:22 UTC (rev 208736)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.cpp        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -36,6 +36,10 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+static const char* const ALG128 = &quot;A128KW&quot;;
+static const char* const ALG192 = &quot;A192KW&quot;;
+static const char* const ALG256 = &quot;A256KW&quot;;
+
</ins><span class="cx"> static inline bool usagesAreInvalidForCryptoAlgorithmAES_KW(CryptoKeyUsageBitmap usages)
</span><span class="cx"> {
</span><span class="cx">     return usages &amp; (CryptoKeyUsageSign | CryptoKeyUsageVerify | CryptoKeyUsageDeriveKey | CryptoKeyUsageDeriveBits | CryptoKeyUsageEncrypt | CryptoKeyUsageDecrypt);
</span><span class="lines">@@ -91,11 +95,11 @@
</span><span class="cx">         result = CryptoKeyAES::importJwk(parameters-&gt;identifier, WTFMove(WTF::get&lt;JsonWebKey&gt;(data)), extractable, usages, [](size_t length, const Optional&lt;String&gt;&amp; alg) -&gt; bool {
</span><span class="cx">             switch (length) {
</span><span class="cx">             case CryptoKeyAES::s_length128:
</span><del>-                return !alg || alg.value() == &quot;A128KW&quot;;
</del><ins>+                return !alg || alg.value() == ALG128;
</ins><span class="cx">             case CryptoKeyAES::s_length192:
</span><del>-                return !alg || alg.value() == &quot;A192KW&quot;;
</del><ins>+                return !alg || alg.value() == ALG192;
</ins><span class="cx">             case CryptoKeyAES::s_length256:
</span><del>-                return !alg || alg.value() == &quot;A256KW&quot;;
</del><ins>+                return !alg || alg.value() == ALG256;
</ins><span class="cx">             }
</span><span class="cx">             return false;
</span><span class="cx">         });
</span><span class="lines">@@ -113,6 +117,46 @@
</span><span class="cx">     callback(*result);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void CryptoAlgorithmAES_KW::exportKey(SubtleCrypto::KeyFormat format, RefPtr&lt;CryptoKey&gt;&amp;&amp; key, KeyDataCallback&amp;&amp; callback, ExceptionCallback&amp;&amp; exceptionCallback)
+{
+    const auto&amp; aesKey = downcast&lt;CryptoKeyAES&gt;(*key);
+
+    if (aesKey.key().isEmpty()) {
+        exceptionCallback(OperationError);
+        return;
+    }
+
+    KeyData result;
+    switch (format) {
+    case SubtleCrypto::KeyFormat::Raw:
+        result = Vector&lt;uint8_t&gt;(aesKey.key());
+        break;
+    case SubtleCrypto::KeyFormat::Jwk: {
+        JsonWebKey jwk = aesKey.exportJwk();
+        switch (aesKey.key().size() * 8) {
+        case CryptoKeyAES::s_length128:
+            jwk.alg = String(ALG128);
+            break;
+        case CryptoKeyAES::s_length192:
+            jwk.alg = String(ALG192);
+            break;
+        case CryptoKeyAES::s_length256:
+            jwk.alg = String(ALG256);
+            break;
+        default:
+            ASSERT_NOT_REACHED();
+        }
+        result = WTFMove(jwk);
+        break;
+    }
+    default:
+        exceptionCallback(NOT_SUPPORTED_ERR);
+        return;
+    }
+
+    callback(format, WTFMove(result));
+}
+
</ins><span class="cx"> ExceptionOr&lt;void&gt; CryptoAlgorithmAES_KW::encryptForWrapKey(const CryptoAlgorithmParametersDeprecated&amp;, const CryptoKey&amp; key, const CryptoOperationData&amp; data, VectorCallback&amp;&amp; callback, VoidCallback&amp;&amp; failureCallback)
</span><span class="cx"> {
</span><span class="cx">     if (!keyAlgorithmMatches(key))
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmAES_KWh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.h (208736 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.h        2016-11-15 19:04:22 UTC (rev 208736)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.h        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -45,6 +45,7 @@
</span><span class="cx"> 
</span><span class="cx">     void generateKey(const std::unique_ptr&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&amp;&amp;, ExceptionCallback&amp;&amp;, ScriptExecutionContext&amp;) final;
</span><span class="cx">     void importKey(SubtleCrypto::KeyFormat, KeyData&amp;&amp;, const std::unique_ptr&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, bool extractable, CryptoKeyUsageBitmap, KeyCallback&amp;&amp;, ExceptionCallback&amp;&amp;) final;
</span><ins>+    void exportKey(SubtleCrypto::KeyFormat, RefPtr&lt;CryptoKey&gt;&amp;&amp;, KeyDataCallback&amp;&amp;, ExceptionCallback&amp;&amp;) final;
</ins><span class="cx"> 
</span><span class="cx">     ExceptionOr&lt;void&gt; encryptForWrapKey(const CryptoAlgorithmParametersDeprecated&amp;, const CryptoKey&amp;, const CryptoOperationData&amp;, VectorCallback&amp;&amp;, VoidCallback&amp;&amp; failureCallback) final;
</span><span class="cx">     ExceptionOr&lt;void&gt; decryptForUnwrapKey(const CryptoAlgorithmParametersDeprecated&amp;, const CryptoKey&amp;, const CryptoOperationData&amp;, VectorCallback&amp;&amp;, VoidCallback&amp;&amp; failureCallback) final;
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmHMACcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp (208736 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp        2016-11-15 19:04:22 UTC (rev 208736)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -37,6 +37,12 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+static const char* const ALG1 = &quot;HS1&quot;;
+static const char* const ALG224 = &quot;HS224&quot;;
+static const char* const ALG256 = &quot;HS256&quot;;
+static const char* const ALG384 = &quot;HS384&quot;;
+static const char* const ALG512 = &quot;HS512&quot;;
+
</ins><span class="cx"> static inline bool usagesAreInvalidForCryptoAlgorithmHMAC(CryptoKeyUsageBitmap usages)
</span><span class="cx"> {
</span><span class="cx">     return usages &amp; (CryptoKeyUsageEncrypt | CryptoKeyUsageDecrypt | CryptoKeyUsageDeriveKey | CryptoKeyUsageDeriveBits | CryptoKeyUsageWrapKey | CryptoKeyUsageUnwrapKey);
</span><span class="lines">@@ -104,15 +110,15 @@
</span><span class="cx">         auto checkAlgCallback = [](CryptoAlgorithmIdentifier hash, const Optional&lt;String&gt;&amp; alg) -&gt; bool {
</span><span class="cx">             switch (hash) {
</span><span class="cx">             case CryptoAlgorithmIdentifier::SHA_1:
</span><del>-                return !alg || alg.value() == &quot;HS1&quot;;
</del><ins>+                return !alg || alg.value() == ALG1;
</ins><span class="cx">             case CryptoAlgorithmIdentifier::SHA_224:
</span><del>-                return !alg || alg.value() == &quot;HS224&quot;;
</del><ins>+                return !alg || alg.value() == ALG224;
</ins><span class="cx">             case CryptoAlgorithmIdentifier::SHA_256:
</span><del>-                return !alg || alg.value() == &quot;HS256&quot;;
</del><ins>+                return !alg || alg.value() == ALG256;
</ins><span class="cx">             case CryptoAlgorithmIdentifier::SHA_384:
</span><del>-                return !alg || alg.value() == &quot;HS384&quot;;
</del><ins>+                return !alg || alg.value() == ALG384;
</ins><span class="cx">             case CryptoAlgorithmIdentifier::SHA_512:
</span><del>-                return !alg || alg.value() == &quot;HS512&quot;;
</del><ins>+                return !alg || alg.value() == ALG512;
</ins><span class="cx">             default:
</span><span class="cx">                 return false;
</span><span class="cx">             }
</span><span class="lines">@@ -133,6 +139,52 @@
</span><span class="cx">     callback(*result);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void CryptoAlgorithmHMAC::exportKey(SubtleCrypto::KeyFormat format, RefPtr&lt;CryptoKey&gt;&amp;&amp; key, KeyDataCallback&amp;&amp; callback, ExceptionCallback&amp;&amp; exceptionCallback)
+{
+    const auto&amp; hmacKey = downcast&lt;CryptoKeyHMAC&gt;(*key);
+
+    if (hmacKey.key().isEmpty()) {
+        exceptionCallback(OperationError);
+        return;
+    }
+
+    KeyData result;
+    switch (format) {
+    case SubtleCrypto::KeyFormat::Raw:
+        result = Vector&lt;uint8_t&gt;(hmacKey.key());
+        break;
+    case SubtleCrypto::KeyFormat::Jwk: {
+        JsonWebKey jwk = hmacKey.exportJwk();
+        switch (hmacKey.hashAlgorithmIdentifier()) {
+        case CryptoAlgorithmIdentifier::SHA_1:
+            jwk.alg = String(ALG1);
+            break;
+        case CryptoAlgorithmIdentifier::SHA_224:
+            jwk.alg = String(ALG224);
+            break;
+        case CryptoAlgorithmIdentifier::SHA_256:
+            jwk.alg = String(ALG256);
+            break;
+        case CryptoAlgorithmIdentifier::SHA_384:
+            jwk.alg = String(ALG384);
+            break;
+        case CryptoAlgorithmIdentifier::SHA_512:
+            jwk.alg = String(ALG512);
+            break;
+        default:
+            ASSERT_NOT_REACHED();
+        }
+        result = WTFMove(jwk);
+        break;
+    }
+    default:
+        exceptionCallback(NOT_SUPPORTED_ERR);
+        return;
+    }
+
+    callback(format, WTFMove(result));
+}
+
</ins><span class="cx"> ExceptionOr&lt;void&gt; CryptoAlgorithmHMAC::sign(const CryptoAlgorithmParametersDeprecated&amp; parameters, const CryptoKey&amp; key, const CryptoOperationData&amp; data, VectorCallback&amp;&amp; callback, VoidCallback&amp;&amp; failureCallback)
</span><span class="cx"> {
</span><span class="cx">     auto&amp; hmacParameters = downcast&lt;CryptoAlgorithmHmacParamsDeprecated&gt;(parameters);
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmHMACh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.h (208736 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.h        2016-11-15 19:04:22 UTC (rev 208736)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.h        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -46,6 +46,7 @@
</span><span class="cx"> 
</span><span class="cx">     void generateKey(const std::unique_ptr&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&amp;&amp;, ExceptionCallback&amp;&amp;, ScriptExecutionContext&amp;) final;
</span><span class="cx">     void importKey(SubtleCrypto::KeyFormat, KeyData&amp;&amp;, const std::unique_ptr&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, bool extractable, CryptoKeyUsageBitmap, KeyCallback&amp;&amp;, ExceptionCallback&amp;&amp;) final;
</span><ins>+    void exportKey(SubtleCrypto::KeyFormat, RefPtr&lt;CryptoKey&gt;&amp;&amp;, KeyDataCallback&amp;&amp;, ExceptionCallback&amp;&amp;) final;
</ins><span class="cx"> 
</span><span class="cx">     // The following will be deprecated.
</span><span class="cx">     ExceptionOr&lt;void&gt; sign(const CryptoAlgorithmParametersDeprecated&amp;, const CryptoKey&amp;, const CryptoOperationData&amp;, VectorCallback&amp;&amp;, VoidCallback&amp;&amp; failureCallback) final;
</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 (208736 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp        2016-11-15 19:04:22 UTC (rev 208736)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -38,6 +38,8 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+static const char* const ALG = &quot;RSA1_5&quot;;
+
</ins><span class="cx"> Ref&lt;CryptoAlgorithm&gt; CryptoAlgorithmRSAES_PKCS1_v1_5::create()
</span><span class="cx"> {
</span><span class="cx">     return adoptRef(*new CryptoAlgorithmRSAES_PKCS1_v1_5);
</span><span class="lines">@@ -92,7 +94,7 @@
</span><span class="cx">             exceptionCallback(DataError);
</span><span class="cx">             return;
</span><span class="cx">         }
</span><del>-        if (key.alg &amp;&amp; key.alg.value() != &quot;RSA1_5&quot;) {
</del><ins>+        if (key.alg &amp;&amp; key.alg.value() != ALG) {
</ins><span class="cx">             exceptionCallback(DataError);
</span><span class="cx">             return;
</span><span class="cx">         }
</span><span class="lines">@@ -111,6 +113,31 @@
</span><span class="cx">     callback(*result);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void CryptoAlgorithmRSAES_PKCS1_v1_5::exportKey(SubtleCrypto::KeyFormat format, RefPtr&lt;CryptoKey&gt;&amp;&amp; key, KeyDataCallback&amp;&amp; callback, ExceptionCallback&amp;&amp; exceptionCallback)
+{
+    const auto&amp; rsaKey = downcast&lt;CryptoKeyRSA&gt;(*key);
+
+    if (!rsaKey.keySizeInBits()) {
+        exceptionCallback(OperationError);
+        return;
+    }
+
+    KeyData result;
+    switch (format) {
+    case SubtleCrypto::KeyFormat::Jwk: {
+        JsonWebKey jwk = rsaKey.exportJwk();
+        jwk.alg = String(ALG);
+        result = WTFMove(jwk);
+        break;
+    }
+    default:
+        exceptionCallback(NOT_SUPPORTED_ERR);
+        return;
+    }
+
+    callback(format, WTFMove(result));
+}
+
</ins><span class="cx"> ExceptionOr&lt;void&gt; CryptoAlgorithmRSAES_PKCS1_v1_5::encrypt(const CryptoAlgorithmParametersDeprecated&amp;, const CryptoKey&amp; key, const CryptoOperationData&amp; data, VectorCallback&amp;&amp; callback, VoidCallback&amp;&amp; failureCallback)
</span><span class="cx"> {
</span><span class="cx">     if (!keyAlgorithmMatches(key))
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSAES_PKCS1_v1_5h"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h (208736 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h        2016-11-15 19:04:22 UTC (rev 208736)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -46,6 +46,7 @@
</span><span class="cx"> 
</span><span class="cx">     void generateKey(const std::unique_ptr&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&amp;&amp;, ExceptionCallback&amp;&amp;, ScriptExecutionContext&amp;) final;
</span><span class="cx">     void importKey(SubtleCrypto::KeyFormat, KeyData&amp;&amp;, const std::unique_ptr&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, bool extractable, CryptoKeyUsageBitmap, KeyCallback&amp;&amp;, ExceptionCallback&amp;&amp;) final;
</span><ins>+    void exportKey(SubtleCrypto::KeyFormat, RefPtr&lt;CryptoKey&gt;&amp;&amp;, KeyDataCallback&amp;&amp;, ExceptionCallback&amp;&amp;) final;
</ins><span class="cx"> 
</span><span class="cx">     // The following will be deprecated.
</span><span class="cx">     ExceptionOr&lt;void&gt; encrypt(const CryptoAlgorithmParametersDeprecated&amp;, const CryptoKey&amp;, const CryptoOperationData&amp;, VectorCallback&amp;&amp;, VoidCallback&amp;&amp; failureCallback) final;
</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 (208736 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp        2016-11-15 19:04:22 UTC (rev 208736)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -40,6 +40,12 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+static const char* const ALG1 = &quot;RS1&quot;;
+static const char* const ALG224 = &quot;RS224&quot;;
+static const char* const ALG256 = &quot;RS256&quot;;
+static const char* const ALG384 = &quot;RS384&quot;;
+static const char* const ALG512 = &quot;RS512&quot;;
+
</ins><span class="cx"> Ref&lt;CryptoAlgorithm&gt; CryptoAlgorithmRSASSA_PKCS1_v1_5::create()
</span><span class="cx"> {
</span><span class="cx">     return adoptRef(*new CryptoAlgorithmRSASSA_PKCS1_v1_5);
</span><span class="lines">@@ -103,19 +109,19 @@
</span><span class="cx">         bool isMatched = false;
</span><span class="cx">         switch (rsaParameters.hashIdentifier) {
</span><span class="cx">         case CryptoAlgorithmIdentifier::SHA_1:
</span><del>-            isMatched = !key.alg || key.alg.value() == &quot;RS1&quot;;
</del><ins>+            isMatched = !key.alg || key.alg.value() == ALG1;
</ins><span class="cx">             break;
</span><span class="cx">         case CryptoAlgorithmIdentifier::SHA_224:
</span><del>-            isMatched = !key.alg || key.alg.value() == &quot;RS224&quot;;
</del><ins>+            isMatched = !key.alg || key.alg.value() == ALG224;
</ins><span class="cx">             break;
</span><span class="cx">         case CryptoAlgorithmIdentifier::SHA_256:
</span><del>-            isMatched = !key.alg || key.alg.value() == &quot;RS256&quot;;
</del><ins>+            isMatched = !key.alg || key.alg.value() == ALG256;
</ins><span class="cx">             break;
</span><span class="cx">         case CryptoAlgorithmIdentifier::SHA_384:
</span><del>-            isMatched = !key.alg || key.alg.value() == &quot;RS384&quot;;
</del><ins>+            isMatched = !key.alg || key.alg.value() == ALG384;
</ins><span class="cx">             break;
</span><span class="cx">         case CryptoAlgorithmIdentifier::SHA_512:
</span><del>-            isMatched = !key.alg || key.alg.value() == &quot;RS512&quot;;
</del><ins>+            isMatched = !key.alg || key.alg.value() == ALG512;
</ins><span class="cx">             break;
</span><span class="cx">         default:
</span><span class="cx">             break;
</span><span class="lines">@@ -140,6 +146,49 @@
</span><span class="cx">     callback(*result);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void CryptoAlgorithmRSASSA_PKCS1_v1_5::exportKey(SubtleCrypto::KeyFormat format, RefPtr&lt;CryptoKey&gt;&amp;&amp; key, KeyDataCallback&amp;&amp; callback, ExceptionCallback&amp;&amp; exceptionCallback)
+{
+    const auto&amp; rsaKey = downcast&lt;CryptoKeyRSA&gt;(*key);
+
+    if (!rsaKey.keySizeInBits()) {
+        exceptionCallback(OperationError);
+        return;
+    }
+
+    KeyData result;
+    switch (format) {
+    case SubtleCrypto::KeyFormat::Jwk: {
+        JsonWebKey jwk = rsaKey.exportJwk();
+        switch (rsaKey.hashAlgorithmIdentifier()) {
+        case CryptoAlgorithmIdentifier::SHA_1:
+            jwk.alg = String(ALG1);
+            break;
+        case CryptoAlgorithmIdentifier::SHA_224:
+            jwk.alg = String(ALG224);
+            break;
+        case CryptoAlgorithmIdentifier::SHA_256:
+            jwk.alg = String(ALG256);
+            break;
+        case CryptoAlgorithmIdentifier::SHA_384:
+            jwk.alg = String(ALG384);
+            break;
+        case CryptoAlgorithmIdentifier::SHA_512:
+            jwk.alg = String(ALG512);
+            break;
+        default:
+            ASSERT_NOT_REACHED();
+        }
+        result = WTFMove(jwk);
+        break;
+    }
+    default:
+        exceptionCallback(NOT_SUPPORTED_ERR);
+        return;
+    }
+
+    callback(format, WTFMove(result));
+}
+
</ins><span class="cx"> ExceptionOr&lt;void&gt; CryptoAlgorithmRSASSA_PKCS1_v1_5::sign(const CryptoAlgorithmParametersDeprecated&amp; parameters, const CryptoKey&amp; key, const CryptoOperationData&amp; data, VectorCallback&amp;&amp; callback, VoidCallback&amp;&amp; failureCallback)
</span><span class="cx"> {
</span><span class="cx">     auto&amp; rsaSSAParameters = downcast&lt;CryptoAlgorithmRsaSsaParamsDeprecated&gt;(parameters);
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSASSA_PKCS1_v1_5h"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h (208736 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h        2016-11-15 19:04:22 UTC (rev 208736)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -46,6 +46,7 @@
</span><span class="cx"> 
</span><span class="cx">     void generateKey(const std::unique_ptr&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&amp;&amp;, ExceptionCallback&amp;&amp;, ScriptExecutionContext&amp;) final;
</span><span class="cx">     void importKey(SubtleCrypto::KeyFormat, KeyData&amp;&amp;, const std::unique_ptr&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, bool extractable, CryptoKeyUsageBitmap, KeyCallback&amp;&amp;, ExceptionCallback&amp;&amp;) final;
</span><ins>+    void exportKey(SubtleCrypto::KeyFormat, RefPtr&lt;CryptoKey&gt;&amp;&amp;, KeyDataCallback&amp;&amp;, ExceptionCallback&amp;&amp;) final;
</ins><span class="cx"> 
</span><span class="cx">     ExceptionOr&lt;void&gt; sign(const CryptoAlgorithmParametersDeprecated&amp;, const CryptoKey&amp;, const CryptoOperationData&amp;, VectorCallback&amp;&amp;, VoidCallback&amp;&amp; failureCallback) final;
</span><span class="cx">     ExceptionOr&lt;void&gt; verify(const CryptoAlgorithmParametersDeprecated&amp;, const CryptoKey&amp;, const CryptoOperationData&amp; signature, const CryptoOperationData&amp;, BoolCallback&amp;&amp;, VoidCallback&amp;&amp; failureCallback) final;
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSA_OAEPcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp (208736 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp        2016-11-15 19:04:22 UTC (rev 208736)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -40,6 +40,12 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+static const char* const ALG1 = &quot;RSA-OAEP&quot;;
+static const char* const ALG224 = &quot;RSA-OAEP-224&quot;;
+static const char* const ALG256 = &quot;RSA-OAEP-256&quot;;
+static const char* const ALG384 = &quot;RSA-OAEP-384&quot;;
+static const char* const ALG512 = &quot;RSA-OAEP-512&quot;;
+
</ins><span class="cx"> Ref&lt;CryptoAlgorithm&gt; CryptoAlgorithmRSA_OAEP::create()
</span><span class="cx"> {
</span><span class="cx">     return adoptRef(*new CryptoAlgorithmRSA_OAEP);
</span><span class="lines">@@ -114,19 +120,19 @@
</span><span class="cx">         bool isMatched = false;
</span><span class="cx">         switch (rsaParameters.hashIdentifier) {
</span><span class="cx">         case CryptoAlgorithmIdentifier::SHA_1:
</span><del>-            isMatched = !key.alg || key.alg.value() == &quot;RSA-OAEP&quot;;
</del><ins>+            isMatched = !key.alg || key.alg.value() == ALG1;
</ins><span class="cx">             break;
</span><span class="cx">         case CryptoAlgorithmIdentifier::SHA_224:
</span><del>-            isMatched = !key.alg || key.alg.value() == &quot;RSA-OAEP-224&quot;;
</del><ins>+            isMatched = !key.alg || key.alg.value() == ALG224;
</ins><span class="cx">             break;
</span><span class="cx">         case CryptoAlgorithmIdentifier::SHA_256:
</span><del>-            isMatched = !key.alg || key.alg.value() == &quot;RSA-OAEP-256&quot;;
</del><ins>+            isMatched = !key.alg || key.alg.value() == ALG256;
</ins><span class="cx">             break;
</span><span class="cx">         case CryptoAlgorithmIdentifier::SHA_384:
</span><del>-            isMatched = !key.alg || key.alg.value() == &quot;RSA-OAEP-384&quot;;
</del><ins>+            isMatched = !key.alg || key.alg.value() == ALG384;
</ins><span class="cx">             break;
</span><span class="cx">         case CryptoAlgorithmIdentifier::SHA_512:
</span><del>-            isMatched = !key.alg || key.alg.value() == &quot;RSA-OAEP-512&quot;;
</del><ins>+            isMatched = !key.alg || key.alg.value() == ALG512;
</ins><span class="cx">             break;
</span><span class="cx">         default:
</span><span class="cx">             break;
</span><span class="lines">@@ -151,6 +157,49 @@
</span><span class="cx">     callback(*result);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void CryptoAlgorithmRSA_OAEP::exportKey(SubtleCrypto::KeyFormat format, RefPtr&lt;CryptoKey&gt;&amp;&amp; key, KeyDataCallback&amp;&amp; callback, ExceptionCallback&amp;&amp; exceptionCallback)
+{
+    const auto&amp; rsaKey = downcast&lt;CryptoKeyRSA&gt;(*key);
+
+    if (!rsaKey.keySizeInBits()) {
+        exceptionCallback(OperationError);
+        return;
+    }
+
+    KeyData result;
+    switch (format) {
+    case SubtleCrypto::KeyFormat::Jwk: {
+        JsonWebKey jwk = rsaKey.exportJwk();
+        switch (rsaKey.hashAlgorithmIdentifier()) {
+        case CryptoAlgorithmIdentifier::SHA_1:
+            jwk.alg = String(ALG1);
+            break;
+        case CryptoAlgorithmIdentifier::SHA_224:
+            jwk.alg = String(ALG224);
+            break;
+        case CryptoAlgorithmIdentifier::SHA_256:
+            jwk.alg = String(ALG256);
+            break;
+        case CryptoAlgorithmIdentifier::SHA_384:
+            jwk.alg = String(ALG384);
+            break;
+        case CryptoAlgorithmIdentifier::SHA_512:
+            jwk.alg = String(ALG512);
+            break;
+        default:
+            ASSERT_NOT_REACHED();
+        }
+        result = WTFMove(jwk);
+        break;
+    }
+    default:
+        exceptionCallback(NOT_SUPPORTED_ERR);
+        return;
+    }
+
+    callback(format, WTFMove(result));
+}
+
</ins><span class="cx"> ExceptionOr&lt;void&gt; CryptoAlgorithmRSA_OAEP::encrypt(const CryptoAlgorithmParametersDeprecated&amp; parameters, const CryptoKey&amp; key, const CryptoOperationData&amp; data, VectorCallback&amp;&amp; callback, VoidCallback&amp;&amp; failureCallback)
</span><span class="cx"> {
</span><span class="cx">     auto&amp; rsaOAEPParameters = downcast&lt;CryptoAlgorithmRsaOaepParamsDeprecated&gt;(parameters);
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSA_OAEPh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.h (208736 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.h        2016-11-15 19:04:22 UTC (rev 208736)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.h        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -46,6 +46,7 @@
</span><span class="cx"> 
</span><span class="cx">     void generateKey(const std::unique_ptr&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&amp;&amp;, ExceptionCallback&amp;&amp;, ScriptExecutionContext&amp;) final;
</span><span class="cx">     void importKey(SubtleCrypto::KeyFormat, KeyData&amp;&amp;, const std::unique_ptr&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, bool extractable, CryptoKeyUsageBitmap, KeyCallback&amp;&amp;, ExceptionCallback&amp;&amp;) final;
</span><ins>+    void exportKey(SubtleCrypto::KeyFormat, RefPtr&lt;CryptoKey&gt;&amp;&amp;, KeyDataCallback&amp;&amp;, ExceptionCallback&amp;&amp;) final;
</ins><span class="cx"> 
</span><span class="cx">     ExceptionOr&lt;void&gt; encrypt(const CryptoAlgorithmParametersDeprecated&amp;, const CryptoKey&amp;, const CryptoOperationData&amp;, VectorCallback&amp;&amp;, VoidCallback&amp;&amp; failureCallback) final;
</span><span class="cx">     ExceptionOr&lt;void&gt; decrypt(const CryptoAlgorithmParametersDeprecated&amp;, const CryptoKey&amp;, const CryptoOperationData&amp;, VectorCallback&amp;&amp;, VoidCallback&amp;&amp; failureCallback) final;
</span></span></pre></div>
<a id="trunkSourceWebCorecryptokeysCryptoKeyAEScpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyAES.cpp (208736 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/keys/CryptoKeyAES.cpp        2016-11-15 19:04:22 UTC (rev 208736)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyAES.cpp        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -104,6 +104,16 @@
</span><span class="cx">     return adoptRef(new CryptoKeyAES(algorithm, WTFMove(octetSequence), extractable, usages));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+JsonWebKey CryptoKeyAES::exportJwk() const
+{
+    JsonWebKey result;
+    result.kty = &quot;oct&quot;;
+    result.k = base64URLEncode(m_key);
+    result.key_ops = usages();
+    result.ext = extractable();
+    return result;
+}
+
</ins><span class="cx"> std::unique_ptr&lt;KeyAlgorithm&gt; CryptoKeyAES::buildAlgorithm() const
</span><span class="cx"> {
</span><span class="cx">     return std::make_unique&lt;AesKeyAlgorithm&gt;(CryptoAlgorithmRegistry::singleton().name(algorithmIdentifier()), m_key.size() * 8);
</span></span></pre></div>
<a id="trunkSourceWebCorecryptokeysCryptoKeyAESh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyAES.h (208736 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/keys/CryptoKeyAES.h        2016-11-15 19:04:22 UTC (rev 208736)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyAES.h        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -74,6 +74,7 @@
</span><span class="cx">     CryptoKeyClass keyClass() const final { return CryptoKeyClass::AES; }
</span><span class="cx"> 
</span><span class="cx">     const Vector&lt;uint8_t&gt;&amp; key() const { return m_key; }
</span><ins>+    JsonWebKey exportJwk() const;
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     CryptoKeyAES(CryptoAlgorithmIdentifier, const Vector&lt;uint8_t&gt;&amp; key, bool extractable, CryptoKeyUsageBitmap);
</span></span></pre></div>
<a id="trunkSourceWebCorecryptokeysCryptoKeyHMACcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.cpp (208736 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.cpp        2016-11-15 19:04:22 UTC (rev 208736)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.cpp        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -114,6 +114,16 @@
</span><span class="cx">     return CryptoKeyHMAC::importRaw(lengthBits, hash, WTFMove(octetSequence), extractable, usages);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+JsonWebKey CryptoKeyHMAC::exportJwk() const
+{
+    JsonWebKey result;
+    result.kty = &quot;oct&quot;;
+    result.k = base64URLEncode(m_key);
+    result.key_ops = usages();
+    result.ext = extractable();
+    return result;
+}
+
</ins><span class="cx"> std::unique_ptr&lt;KeyAlgorithm&gt; CryptoKeyHMAC::buildAlgorithm() const
</span><span class="cx"> {
</span><span class="cx">     return std::make_unique&lt;HmacKeyAlgorithm&gt;(CryptoAlgorithmRegistry::singleton().name(algorithmIdentifier()),
</span></span></pre></div>
<a id="trunkSourceWebCorecryptokeysCryptoKeyHMACh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.h (208736 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.h        2016-11-15 19:04:22 UTC (rev 208736)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.h        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -70,6 +70,7 @@
</span><span class="cx">     CryptoKeyClass keyClass() const final { return CryptoKeyClass::HMAC; }
</span><span class="cx"> 
</span><span class="cx">     const Vector&lt;uint8_t&gt;&amp; key() const { return m_key; }
</span><ins>+    JsonWebKey exportJwk() 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="trunkSourceWebCorecryptokeysCryptoKeyRSAcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyRSA.cpp (208736 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/keys/CryptoKeyRSA.cpp        2016-11-15 19:04:22 UTC (rev 208736)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyRSA.cpp        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -108,6 +108,46 @@
</span><span class="cx">     return CryptoKeyRSA::create(algorithm, hash.valueOr(CryptoAlgorithmIdentifier::SHA_1), !!hash, *privateKeyComponents, extractable, usages);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+JsonWebKey CryptoKeyRSA::exportJwk() const
+{
+    JsonWebKey result;
+    result.kty = &quot;RSA&quot;;
+    result.key_ops = usages();
+    result.ext = extractable();
+
+    auto keyData = exportData();
+    const auto&amp; rsaKeyData = downcast&lt;CryptoKeyDataRSAComponents&gt;(*keyData);
+    // public key
+    result.n = base64URLEncode(rsaKeyData.modulus());
+    result.e = base64URLEncode(rsaKeyData.exponent());
+    if (rsaKeyData.type() == CryptoKeyDataRSAComponents::Type::Public)
+        return result;
+
+    // private key
+    result.d = base64URLEncode(rsaKeyData.privateExponent());
+    if (!rsaKeyData.hasAdditionalPrivateKeyParameters())
+        return result;
+
+    result.p = base64URLEncode(rsaKeyData.firstPrimeInfo().primeFactor);
+    result.q = base64URLEncode(rsaKeyData.secondPrimeInfo().primeFactor);
+    result.dp = base64URLEncode(rsaKeyData.firstPrimeInfo().factorCRTExponent);
+    result.dq = base64URLEncode(rsaKeyData.secondPrimeInfo().factorCRTExponent);
+    result.qi = base64URLEncode(rsaKeyData.secondPrimeInfo().factorCRTCoefficient);
+    if (rsaKeyData.otherPrimeInfos().isEmpty())
+        return result;
+
+    Vector&lt;RsaOtherPrimesInfo&gt; oth;
+    for (auto info : rsaKeyData.otherPrimeInfos()) {
+        RsaOtherPrimesInfo otherInfo;
+        otherInfo.r = base64URLEncode(info.primeFactor);
+        otherInfo.d = base64URLEncode(info.factorCRTExponent);
+        otherInfo.t = base64URLEncode(info.factorCRTCoefficient);
+        oth.append(WTFMove(otherInfo));
+    }
+    result.oth = WTFMove(oth);
+    return result;
+}
+
</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 (208736 => 208737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/keys/CryptoKeyRSA.h        2016-11-15 19:04:22 UTC (rev 208736)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyRSA.h        2016-11-15 19:08:25 UTC (rev 208737)
</span><span class="lines">@@ -103,7 +103,10 @@
</span><span class="cx">     static RefPtr&lt;CryptoKeyRSA&gt; importJwk(CryptoAlgorithmIdentifier, Optional&lt;CryptoAlgorithmIdentifier&gt; hash, JsonWebKey&amp;&amp;, bool extractable, CryptoKeyUsageBitmap);
</span><span class="cx"> 
</span><span class="cx">     PlatformRSAKey platformKey() const { return m_platformKey; }
</span><ins>+    JsonWebKey exportJwk() const;
</ins><span class="cx"> 
</span><ins>+    CryptoAlgorithmIdentifier hashAlgorithmIdentifier() const { return m_hash; }
+
</ins><span class="cx"> private:
</span><span class="cx">     CryptoKeyRSA(CryptoAlgorithmIdentifier, CryptoAlgorithmIdentifier hash, bool hasHash, CryptoKeyType, PlatformRSAKey, bool extractable, CryptoKeyUsageBitmap);
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>