<!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>[159310] 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/159310">159310</a></dd>
<dt>Author</dt> <dd>ap@apple.com</dd>
<dt>Date</dt> <dd>2013-11-14 13:44:25 -0800 (Thu, 14 Nov 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Implement raw format for WebCrypto key export
https://bugs.webkit.org/show_bug.cgi?id=124376

Reviewed by Anders Carlsson.

Source/WebCore: 

Tests: crypto/subtle/aes-export-key.html
       crypto/subtle/hmac-export-key.html

A CryptoKey just exports its native CryptoKeyData, which will also work nicely for
JWK format soon. For spki and pkcs8, we'll need to figure out the best way to
utilize platform library support for ASN.1, but we are not there yet.

* bindings/js/JSSubtleCryptoCustom.cpp:
(WebCore::JSSubtleCrypto::exportKey):
* crypto/CryptoKey.h:
* crypto/SubtleCrypto.idl:
* crypto/keys/CryptoKeyAES.cpp:
(WebCore::CryptoKeyAES::exportData):
* crypto/keys/CryptoKeyAES.h:
* crypto/keys/CryptoKeyHMAC.cpp:
(WebCore::CryptoKeyHMAC::exportData):
* crypto/keys/CryptoKeyHMAC.h:

* crypto/keys/CryptoKeyRSA.h:
* crypto/mac/CryptoKeyRSAMac.cpp:
(WebCore::CryptoKeyRSA::exportData):
Added a dummy implementation for RSA.

LayoutTests: 

* crypto/subtle/aes-export-key-expected.txt: Added.
* crypto/subtle/aes-export-key.html: Added.
* crypto/subtle/hmac-export-key-expected.txt: Added.
* crypto/subtle/hmac-export-key.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSSubtleCryptoCustomcpp">trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoCryptoKeyh">trunk/Source/WebCore/crypto/CryptoKey.h</a></li>
<li><a href="#trunkSourceWebCorecryptoSubtleCryptoidl">trunk/Source/WebCore/crypto/SubtleCrypto.idl</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="#trunkSourceWebCorecryptokeysCryptoKeyRSAh">trunk/Source/WebCore/crypto/keys/CryptoKeyRSA.h</a></li>
<li><a href="#trunkSourceWebCorecryptomacCryptoKeyRSAMaccpp">trunk/Source/WebCore/crypto/mac/CryptoKeyRSAMac.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestscryptosubtleaesexportkeyexpectedtxt">trunk/LayoutTests/crypto/subtle/aes-export-key-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleaesexportkeyhtml">trunk/LayoutTests/crypto/subtle/aes-export-key.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacexportkeyexpectedtxt">trunk/LayoutTests/crypto/subtle/hmac-export-key-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacexportkeyhtml">trunk/LayoutTests/crypto/subtle/hmac-export-key.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (159309 => 159310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2013-11-14 21:40:53 UTC (rev 159309)
+++ trunk/LayoutTests/ChangeLog        2013-11-14 21:44:25 UTC (rev 159310)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2013-11-14  Alexey Proskuryakov  &lt;ap@apple.com&gt;
+
+        Implement raw format for WebCrypto key export
+        https://bugs.webkit.org/show_bug.cgi?id=124376
+
+        Reviewed by Anders Carlsson.
+
+        * crypto/subtle/aes-export-key-expected.txt: Added.
+        * crypto/subtle/aes-export-key.html: Added.
+        * crypto/subtle/hmac-export-key-expected.txt: Added.
+        * crypto/subtle/hmac-export-key.html: Added.
+
</ins><span class="cx"> 2013-11-14  Bear Travis  &lt;betravis@adobe.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [CSS Shapes] Accept the new &lt;box&gt; value for shape-outside
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtleaesexportkeyexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/aes-export-key-expected.txt (0 => 159310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-export-key-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/aes-export-key-expected.txt        2013-11-14 21:44:25 UTC (rev 159310)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+Test exporting an AES key.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Importing a JWK key...
+Exporting the key as raw data...
+PASS byteArrayToHexString(new Uint8Array(exportedData)) is '[8e 73 b0 f7 da 0e 64 52 c8 10 f3 2b 80 90 79 e5 62 f8 ea d2 52 2c 6b 7b]'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins><span class="cx">Property changes on: trunk/LayoutTests/crypto/subtle/aes-export-key-expected.txt
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkLayoutTestscryptosubtleaesexportkeyhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/aes-export-key.html (0 => 159310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-export-key.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/aes-export-key.html        2013-11-14 21:44:25 UTC (rev 159310)
</span><span class="lines">@@ -0,0 +1,44 @@
</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.&quot;);
+
+jsTestIsAsync = true;
+
+if (!window.subtle)
+    window.crypto.subtle = window.crypto.webkitSubtle;
+
+var extractable = true;
+
+var jwkKey = {
+    &quot;kty&quot;: &quot;oct&quot;,
+    &quot;k&quot;: &quot;jnOw99oOZFLIEPMrgJB55WL46tJSLGt7&quot;
+};
+
+var jwkKeyAsArrayBuffer = asciiToArrayBuffer(JSON.stringify(jwkKey));
+
+debug(&quot;Importing a JWK key...&quot;);
+crypto.subtle.importKey(&quot;jwk&quot;, jwkKeyAsArrayBuffer, &quot;AES-CBC&quot;, extractable, []).then(function(result) {
+    key = result;
+
+    debug(&quot;Exporting the key as raw data...&quot;);
+    return crypto.subtle.exportKey(&quot;raw&quot;, key);
+}).then(function(result) {
+    exportedData = result;
+    shouldBe(&quot;byteArrayToHexString(new Uint8Array(exportedData))&quot;, &quot;'[8e 73 b0 f7 da 0e 64 52 c8 10 f3 2b 80 90 79 e5 62 f8 ea d2 52 2c 6b 7b]'&quot;);
+
+    finishJSTest();
+});
+&lt;/script&gt;
+
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins><span class="cx">Property changes on: trunk/LayoutTests/crypto/subtle/aes-export-key.html
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="trunkLayoutTestscryptosubtlehmacexportkeyexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-export-key-expected.txt (0 => 159310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-export-key-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-export-key-expected.txt        2013-11-14 21:44:25 UTC (rev 159310)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+Test exporting an AES key.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Importing a JWK key...
+Exporting the key as raw data...
+PASS byteArrayToHexString(new Uint8Array(exportedData)) is '[6a 18 e4 9f ef f7 f3 b7 e0 9e c8 9b 7f 6d ea b2 f6 a1 8e 49 fe ff 7f 3b 7e 09 ec 89 b7 f6 de ab]'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins><span class="cx">Property changes on: trunk/LayoutTests/crypto/subtle/hmac-export-key-expected.txt
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkLayoutTestscryptosubtlehmacexportkeyhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-export-key.html (0 => 159310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-export-key.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-export-key.html        2013-11-14 21:44:25 UTC (rev 159310)
</span><span class="lines">@@ -0,0 +1,44 @@
</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.&quot;);
+
+jsTestIsAsync = true;
+
+if (!window.subtle)
+    window.crypto.subtle = window.crypto.webkitSubtle;
+
+var extractable = true;
+
+var jwkKey = {
+    &quot;kty&quot;: &quot;oct&quot;,
+    &quot;k&quot;: &quot;ahjkn-_387fgnsibf23qsvahjkn-_387fgnsibf23qs&quot;
+};
+
+var jwkKeyAsArrayBuffer = asciiToArrayBuffer(JSON.stringify(jwkKey));
+
+debug(&quot;Importing a JWK key...&quot;);
+crypto.subtle.importKey(&quot;jwk&quot;, jwkKeyAsArrayBuffer, { name: &quot;HMAC&quot;, hash: &quot;SHA-512&quot; }, extractable, [&quot;sign&quot;, &quot;verify&quot;]).then(function(result) {
+    key = result;
+
+    debug(&quot;Exporting the key as raw data...&quot;);
+    return crypto.subtle.exportKey(&quot;raw&quot;, key);
+}).then(function(result) {
+    exportedData = result;
+    shouldBe(&quot;byteArrayToHexString(new Uint8Array(exportedData))&quot;, &quot;'[6a 18 e4 9f ef f7 f3 b7 e0 9e c8 9b 7f 6d ea b2 f6 a1 8e 49 fe ff 7f 3b 7e 09 ec 89 b7 f6 de ab]'&quot;);
+
+    finishJSTest();
+});
+&lt;/script&gt;
+
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins><span class="cx">Property changes on: trunk/LayoutTests/crypto/subtle/hmac-export-key.html
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (159309 => 159310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2013-11-14 21:40:53 UTC (rev 159309)
+++ trunk/Source/WebCore/ChangeLog        2013-11-14 21:44:25 UTC (rev 159310)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2013-11-14  Alexey Proskuryakov  &lt;ap@apple.com&gt;
+
+        Implement raw format for WebCrypto key export
+        https://bugs.webkit.org/show_bug.cgi?id=124376
+
+        Reviewed by Anders Carlsson.
+
+        Tests: crypto/subtle/aes-export-key.html
+               crypto/subtle/hmac-export-key.html
+
+        A CryptoKey just exports its native CryptoKeyData, which will also work nicely for
+        JWK format soon. For spki and pkcs8, we'll need to figure out the best way to
+        utilize platform library support for ASN.1, but we are not there yet.
+
+        * bindings/js/JSSubtleCryptoCustom.cpp:
+        (WebCore::JSSubtleCrypto::exportKey):
+        * crypto/CryptoKey.h:
+        * crypto/SubtleCrypto.idl:
+        * crypto/keys/CryptoKeyAES.cpp:
+        (WebCore::CryptoKeyAES::exportData):
+        * crypto/keys/CryptoKeyAES.h:
+        * crypto/keys/CryptoKeyHMAC.cpp:
+        (WebCore::CryptoKeyHMAC::exportData):
+        * crypto/keys/CryptoKeyHMAC.h:
+
+        * crypto/keys/CryptoKeyRSA.h:
+        * crypto/mac/CryptoKeyRSAMac.cpp:
+        (WebCore::CryptoKeyRSA::exportData):
+        Added a dummy implementation for RSA.
+
</ins><span class="cx"> 2013-11-14  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Web Inspector: Simply generated domain dispatch methods for domains with few commands
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSSubtleCryptoCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp (159309 => 159310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp        2013-11-14 21:40:53 UTC (rev 159309)
+++ trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp        2013-11-14 21:44:25 UTC (rev 159310)
</span><span class="lines">@@ -32,6 +32,8 @@
</span><span class="cx"> #include &quot;CryptoAlgorithmParameters.h&quot;
</span><span class="cx"> #include &quot;CryptoAlgorithmRegistry.h&quot;
</span><span class="cx"> #include &quot;CryptoKeyData.h&quot;
</span><ins>+#include &quot;CryptoKeyDataOctetSequence.h&quot;
+#include &quot;CryptoKeyDataRSAComponents.h&quot;
</ins><span class="cx"> #include &quot;CryptoKeySerializationRaw.h&quot;
</span><span class="cx"> #include &quot;Document.h&quot;
</span><span class="cx"> #include &quot;ExceptionCode.h&quot;
</span><span class="lines">@@ -506,6 +508,56 @@
</span><span class="cx">     return promise;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+JSValue JSSubtleCrypto::exportKey(JSC::ExecState* exec)
+{
+    if (exec-&gt;argumentCount() &lt; 2)
+        return exec-&gt;vm().throwException(exec, createNotEnoughArgumentsError(exec));
+
+    CryptoKeyFormat keyFormat;
+    if (!cryptoKeyFormatFromJSValue(exec, exec-&gt;argument(0), keyFormat)) {
+        ASSERT(exec-&gt;hadException());
+        return jsUndefined();
+    }
+
+    RefPtr&lt;CryptoKey&gt; key = toCryptoKey(exec-&gt;uncheckedArgument(1));
+    if (!key)
+        return throwTypeError(exec);
+
+    JSPromise* promise = JSPromise::createWithResolver(exec-&gt;vm(), globalObject());
+    auto promiseWrapper = PromiseWrapper::create(globalObject(), promise);
+
+    if (!key-&gt;extractable()) {
+        m_impl-&gt;document()-&gt;addConsoleMessage(JSMessageSource, ErrorMessageLevel, &quot;Key is not extractable&quot;);
+        promiseWrapper-&gt;reject(nullptr);
+        return promise;
+    }
+
+    std::unique_ptr&lt;CryptoKeyData&gt; keyData = key-&gt;exportData();
+    if (!keyData) {
+        // FIXME: Shouldn't happen once all key types implement exportData().
+        promiseWrapper-&gt;reject(nullptr);
+        return promise;
+    }
+
+    switch (keyFormat) {
+    case CryptoKeyFormat::Raw:
+        if (isCryptoKeyDataOctetSequence(*keyData)) {
+            Vector&lt;unsigned char&gt; result;
+            result.appendVector(toCryptoKeyDataOctetSequence(*keyData).octetSequence());
+            promiseWrapper-&gt;fulfill(result);
+        } else {
+            m_impl-&gt;document()-&gt;addConsoleMessage(JSMessageSource, ErrorMessageLevel, &quot;Key cannot be exported to raw format&quot;);
+            promiseWrapper-&gt;reject(nullptr);
+        }
+        break;
+    default:
+        throwTypeError(exec, &quot;Unsupported key format&quot;);
+        return jsUndefined();
+    }
+
+    return promise;
+}
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoCryptoKeyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/CryptoKey.h (159309 => 159310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/CryptoKey.h        2013-11-14 21:40:53 UTC (rev 159309)
+++ trunk/Source/WebCore/crypto/CryptoKey.h        2013-11-14 21:44:25 UTC (rev 159310)
</span><span class="lines">@@ -38,6 +38,7 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> class CryptoAlgorithmDescriptionBuilder;
</span><ins>+class CryptoKeyData;
</ins><span class="cx"> 
</span><span class="cx"> ENUM_CLASS(CryptoKeyClass) {
</span><span class="cx">     HMAC,
</span><span class="lines">@@ -59,6 +60,8 @@
</span><span class="cx"> 
</span><span class="cx">     bool allows(CryptoKeyUsage usage) const { return usage == (m_usages &amp; usage); }
</span><span class="cx"> 
</span><ins>+    virtual std::unique_ptr&lt;CryptoKeyData&gt; exportData() const = 0;
+
</ins><span class="cx">     static Vector&lt;char&gt; randomData(size_t);
</span><span class="cx"> 
</span><span class="cx"> private:
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoSubtleCryptoidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/SubtleCrypto.idl (159309 => 159310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/SubtleCrypto.idl        2013-11-14 21:40:53 UTC (rev 159309)
+++ trunk/Source/WebCore/crypto/SubtleCrypto.idl        2013-11-14 21:44:25 UTC (rev 159310)
</span><span class="lines">@@ -36,4 +36,5 @@
</span><span class="cx">     [Custom] Promise digest(AlgorithmIdentifier algorithm, sequence&lt;CryptoOperationData&gt; data);
</span><span class="cx">     [Custom] Promise generateKey(AlgorithmIdentifier algorithm, optional boolean extractable, optional KeyUsage[] keyUsages);
</span><span class="cx">     [Custom] Promise importKey(KeyFormat format, CryptoOperationData keyData, AlgorithmIdentifier? algorithm, optional boolean extractable, optional KeyUsage[] keyUsages);
</span><ins>+    [Custom] Promise exportKey(KeyFormat format, Key key);
</ins><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCorecryptokeysCryptoKeyAEScpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyAES.cpp (159309 => 159310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/keys/CryptoKeyAES.cpp        2013-11-14 21:40:53 UTC (rev 159309)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyAES.cpp        2013-11-14 21:44:25 UTC (rev 159310)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;CryptoAlgorithmDescriptionBuilder.h&quot;
</span><span class="cx"> #include &quot;CryptoAlgorithmRegistry.h&quot;
</span><ins>+#include &quot;CryptoKeyDataOctetSequence.h&quot;
</ins><span class="cx"> #include &lt;wtf/text/WTFString.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -62,6 +63,12 @@
</span><span class="cx">     builder.add(&quot;length&quot;, m_key.size() * 8);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+std::unique_ptr&lt;CryptoKeyData&gt; CryptoKeyAES::exportData() const
+{
+    ASSERT(extractable());
+    return CryptoKeyDataOctetSequence::create(m_key);
+}
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(SUBTLE_CRYPTO)
</span></span></pre></div>
<a id="trunkSourceWebCorecryptokeysCryptoKeyAESh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyAES.h (159309 => 159310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/keys/CryptoKeyAES.h        2013-11-14 21:40:53 UTC (rev 159309)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyAES.h        2013-11-14 21:44:25 UTC (rev 159310)
</span><span class="lines">@@ -48,11 +48,12 @@
</span><span class="cx"> 
</span><span class="cx">     const Vector&lt;char&gt;&amp; key() const { return m_key; }
</span><span class="cx"> 
</span><del>-    virtual void buildAlgorithmDescription(CryptoAlgorithmDescriptionBuilder&amp;) const OVERRIDE;
-
</del><span class="cx"> private:
</span><span class="cx">     CryptoKeyAES(CryptoAlgorithmIdentifier, const Vector&lt;char&gt;&amp; key, bool extractable, CryptoKeyUsage);
</span><span class="cx"> 
</span><ins>+    virtual void buildAlgorithmDescription(CryptoAlgorithmDescriptionBuilder&amp;) const OVERRIDE;
+    virtual std::unique_ptr&lt;CryptoKeyData&gt; exportData() const OVERRIDE;
+
</ins><span class="cx">     Vector&lt;char&gt; m_key;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorecryptokeysCryptoKeyHMACcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.cpp (159309 => 159310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.cpp        2013-11-14 21:40:53 UTC (rev 159309)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.cpp        2013-11-14 21:44:25 UTC (rev 159310)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;CryptoAlgorithmDescriptionBuilder.h&quot;
</span><span class="cx"> #include &quot;CryptoAlgorithmRegistry.h&quot;
</span><ins>+#include &quot;CryptoKeyDataOctetSequence.h&quot;
</ins><span class="cx"> #include &lt;wtf/text/WTFString.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -77,6 +78,12 @@
</span><span class="cx">     builder.add(&quot;length&quot;, m_key.size());
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+std::unique_ptr&lt;CryptoKeyData&gt; CryptoKeyHMAC::exportData() const
+{
+    ASSERT(extractable());
+    return CryptoKeyDataOctetSequence::create(m_key);
+}
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(SUBTLE_CRYPTO)
</span></span></pre></div>
<a id="trunkSourceWebCorecryptokeysCryptoKeyHMACh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.h (159309 => 159310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.h        2013-11-14 21:40:53 UTC (rev 159309)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.h        2013-11-14 21:44:25 UTC (rev 159310)
</span><span class="lines">@@ -48,11 +48,12 @@
</span><span class="cx"> 
</span><span class="cx">     const Vector&lt;char&gt;&amp; key() const { return m_key; }
</span><span class="cx"> 
</span><del>-    virtual void buildAlgorithmDescription(CryptoAlgorithmDescriptionBuilder&amp;) const OVERRIDE;
-
</del><span class="cx"> private:
</span><span class="cx">     CryptoKeyHMAC(const Vector&lt;char&gt;&amp; key, CryptoAlgorithmIdentifier hash, bool extractable, CryptoKeyUsage);
</span><span class="cx"> 
</span><ins>+    virtual void buildAlgorithmDescription(CryptoAlgorithmDescriptionBuilder&amp;) const OVERRIDE;
+    virtual std::unique_ptr&lt;CryptoKeyData&gt; exportData() const OVERRIDE;
+
</ins><span class="cx">     CryptoAlgorithmIdentifier m_hash;
</span><span class="cx">     Vector&lt;char&gt; m_key;
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCorecryptokeysCryptoKeyRSAh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyRSA.h (159309 => 159310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/keys/CryptoKeyRSA.h        2013-11-14 21:40:53 UTC (rev 159309)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyRSA.h        2013-11-14 21:44:25 UTC (rev 159310)
</span><span class="lines">@@ -58,11 +58,12 @@
</span><span class="cx"> 
</span><span class="cx">     PlatformRSAKey platformKey() const { return m_platformKey; }
</span><span class="cx"> 
</span><del>-    virtual void buildAlgorithmDescription(CryptoAlgorithmDescriptionBuilder&amp;) const OVERRIDE;
-
</del><span class="cx"> private:
</span><span class="cx">     CryptoKeyRSA(CryptoAlgorithmIdentifier, CryptoKeyType, PlatformRSAKey, bool extractable, CryptoKeyUsage);
</span><span class="cx"> 
</span><ins>+    virtual void buildAlgorithmDescription(CryptoAlgorithmDescriptionBuilder&amp;) const OVERRIDE;
+    virtual std::unique_ptr&lt;CryptoKeyData&gt; exportData() const OVERRIDE;
+
</ins><span class="cx">     PlatformRSAKey m_platformKey;
</span><span class="cx"> 
</span><span class="cx">     bool m_restrictedToSpecificHash;
</span></span></pre></div>
<a id="trunkSourceWebCorecryptomacCryptoKeyRSAMaccpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/mac/CryptoKeyRSAMac.cpp (159309 => 159310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/mac/CryptoKeyRSAMac.cpp        2013-11-14 21:40:53 UTC (rev 159309)
+++ trunk/Source/WebCore/crypto/mac/CryptoKeyRSAMac.cpp        2013-11-14 21:44:25 UTC (rev 159310)
</span><span class="lines">@@ -143,6 +143,13 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+std::unique_ptr&lt;CryptoKeyData&gt; CryptoKeyRSA::exportData() const
+{
+    // Not implemented yet.
+    ASSERT(extractable());
+    return nullptr;
+}
+
</ins><span class="cx"> static bool bigIntegerToUInt32(const Vector&lt;char&gt;&amp; bigInteger, uint32_t&amp; result)
</span><span class="cx"> {
</span><span class="cx">     result = 0;
</span></span></pre>
</div>
</div>

</body>
</html>