<!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>[205941] 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/205941">205941</a></dd>
<dt>Author</dt> <dd>jiewen_tan@apple.com</dd>
<dt>Date</dt> <dd>2016-09-14 17:19:12 -0700 (Wed, 14 Sep 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>WebCrypto algorithms should be exposed via KeyAlgorithm dictionary
https://bugs.webkit.org/show_bug.cgi?id=128748
&lt;rdar://problem/27359438&gt;

Reviewed by Brent Fulgham and Chris Dumez.

Source/WebCore:

Replace custom CryptoAlgorithmBuilder/buildAlgorithmDescription with KeyAlgorithm dictionary which is
defined by the spec: https://www.w3.org/TR/WebCryptoAPI/#key-algorithm-dictionary. Moreover, mark
CryptoKey.usages as CachedAttribute.

Tests: crypto/subtle/crypto-key-algorithm-gc.html
       crypto/subtle/crypto-key-usages-gc.html

* PlatformEfl.cmake:
* PlatformGTK.cmake:
* PlatformMac.cmake:
Remove CryptoAlgorithmDescriptionBuilder.cpp.
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSCryptoAlgorithmBuilder.cpp:
(WebCore::JSCryptoAlgorithmBuilder::add):
(WebCore::JSCryptoAlgorithmBuilder::createEmptyClone): Deleted.
* bindings/js/JSCryptoAlgorithmBuilder.h:
* bindings/js/JSCryptoKeyCustom.cpp:
(WebCore::JSCryptoKey::algorithm):
Get rid of dependency on CryptoAlgorithmDescriptionBuilder.
* crypto/CryptoAlgorithmDescriptionBuilder.cpp: Removed.
* crypto/CryptoAlgorithmDescriptionBuilder.h: Removed.
Replace it with KeyAlgorithm.
* crypto/CryptoKey.cpp:
(WebCore::CryptoKey::CryptoKey):
(WebCore::CryptoKey::buildAlgorithmDescription): Deleted.
* crypto/CryptoKey.h:
(WebCore::KeyAlgorithm::KeyAlgorithm):
(WebCore::KeyAlgorithm::~KeyAlgorithm):
(WebCore::CryptoKey::algorithmIdentifier):
* crypto/CryptoKey.idl:
Add KeyAlgorithm dictionary which is returned via CryptoKey.buildAlgorithm() method,
and rename m_algorithm to m_algorithmIdentifier to distingush it with newly
added KeyAlgorithm dictionary.
* crypto/gnutls/CryptoKeyRSAGnuTLS.cpp:
(WebCore::buildAlgorithm):
(WebCore::CryptoKeyRSA::buildAlgorithmDescription): Deleted.
* crypto/keys/CryptoKeyAES.cpp:
(WebCore::CryptoKeyAES::buildAlgorithm):
(WebCore::CryptoKeyAES::buildAlgorithmDescription): Deleted.
* crypto/keys/CryptoKeyAES.h:
(WebCore::AesKeyAlgorithm::AesKeyAlgorithm):
(WebCore::AesKeyAlgorithm::~AesKeyAlgorithm):
* crypto/keys/CryptoKeyHMAC.cpp:
(WebCore::CryptoKeyHMAC::buildAlgorithm):
(WebCore::CryptoKeyHMAC::buildAlgorithmDescription): Deleted.
* crypto/keys/CryptoKeyHMAC.h:
(WebCore::HmacKeyAlgorithm::HmacKeyAlgorithm):
(WebCore::HmacKeyAlgorithm::~HmacKeyAlgorithm):
* crypto/keys/CryptoKeyRSA.h:
(WebCore::RsaKeyAlgorithm::RsaKeyAlgorithm):
(WebCore::RsaKeyAlgorithm::~RsaKeyAlgorithm):
(WebCore::RsaHashedKeyAlgorithm::RsaHashedKeyAlgorithm):
(WebCore::RsaHashedKeyAlgorithm::~RsaHashedKeyAlgorithm):
* crypto/mac/CryptoKeyRSAMac.cpp:
(WebCore::CryptoKeyRSA::buildAlgorithm):
(WebCore::CryptoKeyRSA::buildAlgorithmDescription): Deleted.

LayoutTests:

* crypto/subtle/crypto-key-algorithm-gc-expected.txt: Added.
* crypto/subtle/crypto-key-algorithm-gc.html: Added.
* crypto/subtle/crypto-key-usages-gc-expected.txt: Added.
* crypto/subtle/crypto-key-usages-gc.html: Added.
* crypto/subtle/hmac-generate-key-expected.txt:
* crypto/subtle/hmac-generate-key.html:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacgeneratekeyexpectedtxt">trunk/LayoutTests/crypto/subtle/hmac-generate-key-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacgeneratekeyhtml">trunk/LayoutTests/crypto/subtle/hmac-generate-key.html</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorePlatformEflcmake">trunk/Source/WebCore/PlatformEfl.cmake</a></li>
<li><a href="#trunkSourceWebCorePlatformGTKcmake">trunk/Source/WebCore/PlatformGTK.cmake</a></li>
<li><a href="#trunkSourceWebCorePlatformMaccmake">trunk/Source/WebCore/PlatformMac.cmake</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSCryptoAlgorithmBuildercpp">trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmBuilder.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSCryptoAlgorithmBuilderh">trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmBuilder.h</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSCryptoKeyCustomcpp">trunk/Source/WebCore/bindings/js/JSCryptoKeyCustom.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoCryptoKeycpp">trunk/Source/WebCore/crypto/CryptoKey.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoCryptoKeyh">trunk/Source/WebCore/crypto/CryptoKey.h</a></li>
<li><a href="#trunkSourceWebCorecryptoCryptoKeyidl">trunk/Source/WebCore/crypto/CryptoKey.idl</a></li>
<li><a href="#trunkSourceWebCorecryptognutlsCryptoKeyRSAGnuTLScpp">trunk/Source/WebCore/crypto/gnutls/CryptoKeyRSAGnuTLS.cpp</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="#trunkLayoutTestscryptosubtlecryptokeyalgorithmgcexpectedtxt">trunk/LayoutTests/crypto/subtle/crypto-key-algorithm-gc-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlecryptokeyalgorithmgchtml">trunk/LayoutTests/crypto/subtle/crypto-key-algorithm-gc.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlecryptokeyusagesgcexpectedtxt">trunk/LayoutTests/crypto/subtle/crypto-key-usages-gc-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlecryptokeyusagesgchtml">trunk/LayoutTests/crypto/subtle/crypto-key-usages-gc.html</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebCorecryptoCryptoAlgorithmDescriptionBuildercpp">trunk/Source/WebCore/crypto/CryptoAlgorithmDescriptionBuilder.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoCryptoAlgorithmDescriptionBuilderh">trunk/Source/WebCore/crypto/CryptoAlgorithmDescriptionBuilder.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (205940 => 205941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-09-15 00:16:51 UTC (rev 205940)
+++ trunk/LayoutTests/ChangeLog        2016-09-15 00:19:12 UTC (rev 205941)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2016-09-14  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
+
+        WebCrypto algorithms should be exposed via KeyAlgorithm dictionary
+        https://bugs.webkit.org/show_bug.cgi?id=128748
+        &lt;rdar://problem/27359438&gt;
+
+        Reviewed by Brent Fulgham and Chris Dumez.
+
+        * crypto/subtle/crypto-key-algorithm-gc-expected.txt: Added.
+        * crypto/subtle/crypto-key-algorithm-gc.html: Added.
+        * crypto/subtle/crypto-key-usages-gc-expected.txt: Added.
+        * crypto/subtle/crypto-key-usages-gc.html: Added.
+        * crypto/subtle/hmac-generate-key-expected.txt:
+        * crypto/subtle/hmac-generate-key.html:
+
</ins><span class="cx"> 2016-09-14  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         REGRESSION (r205670): ASSERTION FAILED: methodTable(vm)-&gt;toThis(this, exec, NotStrictMode) == this
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtlecryptokeyalgorithmgcexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/crypto-key-algorithm-gc-expected.txt (0 => 205941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/crypto-key-algorithm-gc-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/crypto-key-algorithm-gc-expected.txt        2016-09-15 00:19:12 UTC (rev 205941)
</span><span class="lines">@@ -0,0 +1,13 @@
</span><ins>+Test that CryptoKey.algorithm preserves custom properties.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+
+Generating a HMAC key with default length...
+PASS key.algorithm === key.algorithm is true
+PASS key.algorithm.foo is &quot;bar&quot;
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlecryptokeyalgorithmgchtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/crypto-key-algorithm-gc.html (0 => 205941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/crypto-key-algorithm-gc.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/crypto-key-algorithm-gc.html        2016-09-15 00:19:12 UTC (rev 205941)
</span><span class="lines">@@ -0,0 +1,44 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;meta charset=&quot;utf-8&quot;&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;script&gt;
+
+description(&quot;Test that CryptoKey.algorithm preserves custom properties.&quot;);
+jsTestIsAsync = true;
+
+debug(&quot;\nGenerating a HMAC key with default length...&quot;);
+crypto.subtle.generateKey({name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, true, [&quot;sign&quot;, &quot;verify&quot;]).then(function(result) {
+    key = result;
+    startTest();
+});
+
+function startTest()
+{
+    shouldBeTrue(&quot;key.algorithm === key.algorithm&quot;);
+    key.algorithm.foo = &quot;bar&quot;;
+    gc();
+    setTimeout(continueTest, 10);
+}
+
+function continueTest()
+{
+    gc();
+    setTimeout(finishTest, 10);
+}
+
+function finishTest()
+{
+    gc();
+    shouldBeEqualToString('key.algorithm.foo', 'bar');
+    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="trunkLayoutTestscryptosubtlecryptokeyusagesgcexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/crypto-key-usages-gc-expected.txt (0 => 205941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/crypto-key-usages-gc-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/crypto-key-usages-gc-expected.txt        2016-09-15 00:19:12 UTC (rev 205941)
</span><span class="lines">@@ -0,0 +1,13 @@
</span><ins>+Test that CryptoKey.usages preserves custom properties.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+
+Generating a HMAC key with default length...
+PASS key.usages === key.usages is true
+PASS key.usages.foo is &quot;bar&quot;
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlecryptokeyusagesgchtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/crypto-key-usages-gc.html (0 => 205941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/crypto-key-usages-gc.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/crypto-key-usages-gc.html        2016-09-15 00:19:12 UTC (rev 205941)
</span><span class="lines">@@ -0,0 +1,44 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;meta charset=&quot;utf-8&quot;&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;script&gt;
+
+description(&quot;Test that CryptoKey.usages preserves custom properties.&quot;);
+jsTestIsAsync = true;
+
+debug(&quot;\nGenerating a HMAC key with default length...&quot;);
+crypto.subtle.generateKey({name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, true, [&quot;sign&quot;, &quot;verify&quot;]).then(function(result) {
+    key = result;
+    startTest();
+});
+
+function startTest()
+{
+    shouldBeTrue(&quot;key.usages === key.usages&quot;);
+    key.usages.foo = &quot;bar&quot;;
+    gc();
+    setTimeout(continueTest, 10);
+}
+
+function continueTest()
+{
+    gc();
+    setTimeout(finishTest, 10);
+}
+
+function finishTest()
+{
+    gc();
+    shouldBeEqualToString('key.usages.foo', 'bar');
+    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="trunkLayoutTestscryptosubtlehmacgeneratekeyexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/crypto/subtle/hmac-generate-key-expected.txt (205940 => 205941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-generate-key-expected.txt        2016-09-15 00:16:51 UTC (rev 205940)
+++ trunk/LayoutTests/crypto/subtle/hmac-generate-key-expected.txt        2016-09-15 00:19:12 UTC (rev 205941)
</span><span class="lines">@@ -13,6 +13,7 @@
</span><span class="cx"> PASS key.extractable is true
</span><span class="cx"> PASS key.algorithm.name is 'HMAC'
</span><span class="cx"> PASS key.algorithm.length is 64
</span><ins>+PASS key.algorithm.hash.name is 'SHA-1'
</ins><span class="cx"> PASS key.usages is [&quot;sign&quot;, &quot;verify&quot;]
</span><span class="cx"> 
</span><span class="cx"> Generating a key with custom length...
</span><span class="lines">@@ -20,6 +21,7 @@
</span><span class="cx"> PASS key.extractable is true
</span><span class="cx"> PASS key.algorithm.name is 'HMAC'
</span><span class="cx"> PASS key.algorithm.length is 5
</span><ins>+PASS key.algorithm.hash.name is 'SHA-1'
</ins><span class="cx"> PASS key.usages is [&quot;sign&quot;]
</span><span class="cx"> PASS successfullyParsed is true
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtlehmacgeneratekeyhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/crypto/subtle/hmac-generate-key.html (205940 => 205941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-generate-key.html        2016-09-15 00:16:51 UTC (rev 205940)
+++ trunk/LayoutTests/crypto/subtle/hmac-generate-key.html        2016-09-15 00:19:12 UTC (rev 205941)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx">     shouldBe(&quot;key.extractable&quot;, &quot;true&quot;);
</span><span class="cx">     shouldBe(&quot;key.algorithm.name&quot;, &quot;'HMAC'&quot;);
</span><span class="cx">     shouldBe(&quot;key.algorithm.length&quot;, &quot;64&quot;);
</span><ins>+    shouldBe(&quot;key.algorithm.hash.name&quot;, &quot;'SHA-1'&quot;);
</ins><span class="cx">     shouldBe(&quot;key.usages&quot;, '[&quot;sign&quot;, &quot;verify&quot;]');
</span><span class="cx"> 
</span><span class="cx">     debug(&quot;\nGenerating a key with custom length...&quot;);
</span><span class="lines">@@ -39,6 +40,7 @@
</span><span class="cx">     shouldBe(&quot;key.extractable&quot;, &quot;true&quot;);
</span><span class="cx">     shouldBe(&quot;key.algorithm.name&quot;, &quot;'HMAC'&quot;);
</span><span class="cx">     shouldBe(&quot;key.algorithm.length&quot;, &quot;5&quot;);
</span><ins>+    shouldBe(&quot;key.algorithm.hash.name&quot;, &quot;'SHA-1'&quot;);
</ins><span class="cx">     shouldBe(&quot;key.usages&quot;, '[&quot;sign&quot;]');
</span><span class="cx">     finishJSTest();
</span><span class="cx"> });
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (205940 => 205941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-09-15 00:16:51 UTC (rev 205940)
+++ trunk/Source/WebCore/ChangeLog        2016-09-15 00:19:12 UTC (rev 205941)
</span><span class="lines">@@ -1,3 +1,68 @@
</span><ins>+2016-09-14  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
+
+        WebCrypto algorithms should be exposed via KeyAlgorithm dictionary
+        https://bugs.webkit.org/show_bug.cgi?id=128748
+        &lt;rdar://problem/27359438&gt;
+
+        Reviewed by Brent Fulgham and Chris Dumez.
+
+        Replace custom CryptoAlgorithmBuilder/buildAlgorithmDescription with KeyAlgorithm dictionary which is
+        defined by the spec: https://www.w3.org/TR/WebCryptoAPI/#key-algorithm-dictionary. Moreover, mark
+        CryptoKey.usages as CachedAttribute.
+
+        Tests: crypto/subtle/crypto-key-algorithm-gc.html
+               crypto/subtle/crypto-key-usages-gc.html
+
+        * PlatformEfl.cmake:
+        * PlatformGTK.cmake:
+        * PlatformMac.cmake:
+        Remove CryptoAlgorithmDescriptionBuilder.cpp.
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSCryptoAlgorithmBuilder.cpp:
+        (WebCore::JSCryptoAlgorithmBuilder::add):
+        (WebCore::JSCryptoAlgorithmBuilder::createEmptyClone): Deleted.
+        * bindings/js/JSCryptoAlgorithmBuilder.h:
+        * bindings/js/JSCryptoKeyCustom.cpp:
+        (WebCore::JSCryptoKey::algorithm):
+        Get rid of dependency on CryptoAlgorithmDescriptionBuilder.
+        * crypto/CryptoAlgorithmDescriptionBuilder.cpp: Removed.
+        * crypto/CryptoAlgorithmDescriptionBuilder.h: Removed.
+        Replace it with KeyAlgorithm.
+        * crypto/CryptoKey.cpp:
+        (WebCore::CryptoKey::CryptoKey):
+        (WebCore::CryptoKey::buildAlgorithmDescription): Deleted.
+        * crypto/CryptoKey.h:
+        (WebCore::KeyAlgorithm::KeyAlgorithm):
+        (WebCore::KeyAlgorithm::~KeyAlgorithm):
+        (WebCore::CryptoKey::algorithmIdentifier):
+        * crypto/CryptoKey.idl:
+        Add KeyAlgorithm dictionary which is returned via CryptoKey.buildAlgorithm() method,
+        and rename m_algorithm to m_algorithmIdentifier to distingush it with newly
+        added KeyAlgorithm dictionary.
+        * crypto/gnutls/CryptoKeyRSAGnuTLS.cpp:
+        (WebCore::buildAlgorithm):
+        (WebCore::CryptoKeyRSA::buildAlgorithmDescription): Deleted.
+        * crypto/keys/CryptoKeyAES.cpp:
+        (WebCore::CryptoKeyAES::buildAlgorithm):
+        (WebCore::CryptoKeyAES::buildAlgorithmDescription): Deleted.
+        * crypto/keys/CryptoKeyAES.h:
+        (WebCore::AesKeyAlgorithm::AesKeyAlgorithm):
+        (WebCore::AesKeyAlgorithm::~AesKeyAlgorithm):
+        * crypto/keys/CryptoKeyHMAC.cpp:
+        (WebCore::CryptoKeyHMAC::buildAlgorithm):
+        (WebCore::CryptoKeyHMAC::buildAlgorithmDescription): Deleted.
+        * crypto/keys/CryptoKeyHMAC.h:
+        (WebCore::HmacKeyAlgorithm::HmacKeyAlgorithm):
+        (WebCore::HmacKeyAlgorithm::~HmacKeyAlgorithm):
+        * crypto/keys/CryptoKeyRSA.h:
+        (WebCore::RsaKeyAlgorithm::RsaKeyAlgorithm):
+        (WebCore::RsaKeyAlgorithm::~RsaKeyAlgorithm):
+        (WebCore::RsaHashedKeyAlgorithm::RsaHashedKeyAlgorithm):
+        (WebCore::RsaHashedKeyAlgorithm::~RsaHashedKeyAlgorithm):
+        * crypto/mac/CryptoKeyRSAMac.cpp:
+        (WebCore::CryptoKeyRSA::buildAlgorithm):
+        (WebCore::CryptoKeyRSA::buildAlgorithmDescription): Deleted.
+
</ins><span class="cx"> 2016-09-14  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         REGRESSION (r205670): ASSERTION FAILED: methodTable(vm)-&gt;toThis(this, exec, NotStrictMode) == this
</span></span></pre></div>
<a id="trunkSourceWebCorePlatformEflcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PlatformEfl.cmake (205940 => 205941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PlatformEfl.cmake        2016-09-15 00:16:51 UTC (rev 205940)
+++ trunk/Source/WebCore/PlatformEfl.cmake        2016-09-15 00:19:12 UTC (rev 205941)
</span><span class="lines">@@ -403,7 +403,6 @@
</span><span class="cx"> if (ENABLE_SUBTLE_CRYPTO)
</span><span class="cx">     list(APPEND WebCore_SOURCES
</span><span class="cx">         crypto/CryptoAlgorithm.cpp
</span><del>-        crypto/CryptoAlgorithmDescriptionBuilder.cpp
</del><span class="cx">         crypto/CryptoAlgorithmRegistry.cpp
</span><span class="cx">         crypto/CryptoKey.cpp
</span><span class="cx">         crypto/CryptoKeyPair.cpp
</span></span></pre></div>
<a id="trunkSourceWebCorePlatformGTKcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PlatformGTK.cmake (205940 => 205941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PlatformGTK.cmake        2016-09-15 00:16:51 UTC (rev 205940)
+++ trunk/Source/WebCore/PlatformGTK.cmake        2016-09-15 00:19:12 UTC (rev 205941)
</span><span class="lines">@@ -397,7 +397,6 @@
</span><span class="cx"> if (ENABLE_SUBTLE_CRYPTO)
</span><span class="cx">     list(APPEND WebCore_SOURCES
</span><span class="cx">         crypto/CryptoAlgorithm.cpp
</span><del>-        crypto/CryptoAlgorithmDescriptionBuilder.cpp
</del><span class="cx">         crypto/CryptoAlgorithmRegistry.cpp
</span><span class="cx">         crypto/CryptoKey.cpp
</span><span class="cx">         crypto/CryptoKeyPair.cpp
</span></span></pre></div>
<a id="trunkSourceWebCorePlatformMaccmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PlatformMac.cmake (205940 => 205941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PlatformMac.cmake        2016-09-15 00:16:51 UTC (rev 205940)
+++ trunk/Source/WebCore/PlatformMac.cmake        2016-09-15 00:19:12 UTC (rev 205941)
</span><span class="lines">@@ -176,7 +176,6 @@
</span><span class="cx"> 
</span><span class="cx">     crypto/CommonCryptoUtilities.cpp
</span><span class="cx">     crypto/CryptoAlgorithm.cpp
</span><del>-    crypto/CryptoAlgorithmDescriptionBuilder.cpp
</del><span class="cx">     crypto/CryptoAlgorithmRegistry.cpp
</span><span class="cx">     crypto/CryptoKey.cpp
</span><span class="cx">     crypto/CryptoKeyPair.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (205940 => 205941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-09-15 00:16:51 UTC (rev 205940)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-09-15 00:19:12 UTC (rev 205941)
</span><span class="lines">@@ -5976,8 +5976,6 @@
</span><span class="cx">                 E157A8E418173A3A009F821D /* CryptoKey.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E157A8E218173A3A009F821D /* CryptoKey.cpp */; };
</span><span class="cx">                 E157A8E518173A3A009F821D /* CryptoKey.h in Headers */ = {isa = PBXBuildFile; fileRef = E157A8E318173A3A009F821D /* CryptoKey.h */; };
</span><span class="cx">                 E157A8E818184C67009F821D /* JSCryptoKeyCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E157A8E618184C67009F821D /* JSCryptoKeyCustom.cpp */; };
</span><del>-                E157A8EC181851AC009F821D /* CryptoAlgorithmDescriptionBuilder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E157A8EA181851AC009F821D /* CryptoAlgorithmDescriptionBuilder.cpp */; };
-                E157A8ED181851AC009F821D /* CryptoAlgorithmDescriptionBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = E157A8EB181851AC009F821D /* CryptoAlgorithmDescriptionBuilder.h */; };
</del><span class="cx">                 E157A8F018185425009F821D /* JSCryptoAlgorithmBuilder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E157A8EE18185425009F821D /* JSCryptoAlgorithmBuilder.cpp */; };
</span><span class="cx">                 E157A8F118185425009F821D /* JSCryptoAlgorithmBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = E157A8EF18185425009F821D /* JSCryptoAlgorithmBuilder.h */; };
</span><span class="cx">                 E15A36D71104572000B7B639 /* XMLNSNames.h in Headers */ = {isa = PBXBuildFile; fileRef = E15A36D61104572000B7B639 /* XMLNSNames.h */; };
</span><span class="lines">@@ -13559,8 +13557,6 @@
</span><span class="cx">                 E157A8E218173A3A009F821D /* CryptoKey.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoKey.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E157A8E318173A3A009F821D /* CryptoKey.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoKey.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E157A8E618184C67009F821D /* JSCryptoKeyCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCryptoKeyCustom.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><del>-                E157A8EA181851AC009F821D /* CryptoAlgorithmDescriptionBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoAlgorithmDescriptionBuilder.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
-                E157A8EB181851AC009F821D /* CryptoAlgorithmDescriptionBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmDescriptionBuilder.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</del><span class="cx">                 E157A8EE18185425009F821D /* JSCryptoAlgorithmBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCryptoAlgorithmBuilder.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E157A8EF18185425009F821D /* JSCryptoAlgorithmBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCryptoAlgorithmBuilder.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E15A36D61104572000B7B639 /* XMLNSNames.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XMLNSNames.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -22196,8 +22192,6 @@
</span><span class="cx">                                 E1FE137318402A6700892F13 /* CommonCryptoUtilities.h */,
</span><span class="cx">                                 E172AF6B180F24C600FBADB9 /* CryptoAlgorithm.cpp */,
</span><span class="cx">                                 E172AF6C180F24C600FBADB9 /* CryptoAlgorithm.h */,
</span><del>-                                E157A8EA181851AC009F821D /* CryptoAlgorithmDescriptionBuilder.cpp */,
-                                E157A8EB181851AC009F821D /* CryptoAlgorithmDescriptionBuilder.h */,
</del><span class="cx">                                 E1C657241816E69D00256CDD /* CryptoAlgorithmIdentifier.h */,
</span><span class="cx">                                 E1C657261816F9FE00256CDD /* CryptoAlgorithmParameters.h */,
</span><span class="cx">                                 E1FF8F6A180DB5BE00132674 /* CryptoAlgorithmRegistry.cpp */,
</span><span class="lines">@@ -24094,7 +24088,6 @@
</span><span class="cx">                                 E1FE137B184D21BB00892F13 /* CryptoAlgorithmAES_KW.h in Headers */,
</span><span class="cx">                                 E125F83A1824104800D84CD9 /* CryptoAlgorithmAesCbcParams.h in Headers */,
</span><span class="cx">                                 E19AC3F71824E5D100349426 /* CryptoAlgorithmAesKeyGenParams.h in Headers */,
</span><del>-                                E157A8ED181851AC009F821D /* CryptoAlgorithmDescriptionBuilder.h in Headers */,
</del><span class="cx">                                 E125F8321822F11B00D84CD9 /* CryptoAlgorithmHMAC.h in Headers */,
</span><span class="cx">                                 E19DA29C18189ADD00088BC8 /* CryptoAlgorithmHmacKeyParams.h in Headers */,
</span><span class="cx">                                 E1C6571F1816E50300256CDD /* CryptoAlgorithmHmacParams.h in Headers */,
</span><span class="lines">@@ -27808,7 +27801,6 @@
</span><span class="cx">                                 E125F845182425C900D84CD9 /* CryptoAlgorithmAES_CBCMac.cpp in Sources */,
</span><span class="cx">                                 E1FE137A184D21BB00892F13 /* CryptoAlgorithmAES_KW.cpp in Sources */,
</span><span class="cx">                                 E1FE137E184D270200892F13 /* CryptoAlgorithmAES_KWMac.cpp in Sources */,
</span><del>-                                E157A8EC181851AC009F821D /* CryptoAlgorithmDescriptionBuilder.cpp in Sources */,
</del><span class="cx">                                 E125F8311822F11B00D84CD9 /* CryptoAlgorithmHMAC.cpp in Sources */,
</span><span class="cx">                                 E125F8381822F1EB00D84CD9 /* CryptoAlgorithmHMACMac.cpp in Sources */,
</span><span class="cx">                                 E1FF8F6C180DB5BE00132674 /* CryptoAlgorithmRegistry.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSCryptoAlgorithmBuildercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmBuilder.cpp (205940 => 205941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmBuilder.cpp        2016-09-15 00:16:51 UTC (rev 205940)
+++ trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmBuilder.cpp        2016-09-15 00:19:12 UTC (rev 205941)
</span><span class="lines">@@ -48,11 +48,6 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-std::unique_ptr&lt;CryptoAlgorithmDescriptionBuilder&gt; JSCryptoAlgorithmBuilder::createEmptyClone() const
-{
-    return std::make_unique&lt;JSCryptoAlgorithmBuilder&gt;(m_exec);
-}
-
</del><span class="cx"> void JSCryptoAlgorithmBuilder::add(const char* key, unsigned value)
</span><span class="cx"> {
</span><span class="cx">     VM&amp; vm = m_exec-&gt;vm();
</span><span class="lines">@@ -75,12 +70,11 @@
</span><span class="cx">     m_dictionary-&gt;putDirect(vm, identifier, arrayView-&gt;wrap(m_exec, vm.entryScope-&gt;globalObject()));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void JSCryptoAlgorithmBuilder::add(const char* key, const CryptoAlgorithmDescriptionBuilder&amp; nestedBuilder)
</del><ins>+void JSCryptoAlgorithmBuilder::add(const char* key, const JSCryptoAlgorithmBuilder&amp; nestedBuilder)
</ins><span class="cx"> {
</span><span class="cx">     VM&amp; vm = m_exec-&gt;vm();
</span><span class="cx">     Identifier identifier = Identifier::fromString(&amp;vm, key);
</span><del>-    const JSCryptoAlgorithmBuilder&amp; jsBuilder = static_cast&lt;const JSCryptoAlgorithmBuilder&amp;&gt;(nestedBuilder);
-    m_dictionary-&gt;putDirect(vm, identifier, jsBuilder.result());
</del><ins>+    m_dictionary-&gt;putDirect(vm, identifier, nestedBuilder.result());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSCryptoAlgorithmBuilderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmBuilder.h (205940 => 205941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmBuilder.h        2016-09-15 00:16:51 UTC (rev 205940)
+++ trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmBuilder.h        2016-09-15 00:19:12 UTC (rev 205941)
</span><span class="lines">@@ -26,7 +26,10 @@
</span><span class="cx"> #ifndef JSCryptoAlgorithmBuilder_h
</span><span class="cx"> #define JSCryptoAlgorithmBuilder_h
</span><span class="cx"> 
</span><del>-#include &quot;CryptoAlgorithmDescriptionBuilder.h&quot;
</del><ins>+#include &lt;wtf/Forward.h&gt;
+#include &lt;wtf/Noncopyable.h&gt;
+#include &lt;wtf/Vector.h&gt;
+#include &lt;wtf/text/WTFString.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(SUBTLE_CRYPTO)
</span><span class="cx"> 
</span><span class="lines">@@ -37,7 +40,8 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class JSCryptoAlgorithmBuilder final : public CryptoAlgorithmDescriptionBuilder {
</del><ins>+class JSCryptoAlgorithmBuilder {
+    WTF_MAKE_NONCOPYABLE(JSCryptoAlgorithmBuilder);
</ins><span class="cx"> public:
</span><span class="cx">     JSCryptoAlgorithmBuilder(JSC::ExecState*);
</span><span class="cx">     virtual ~JSCryptoAlgorithmBuilder();
</span><span class="lines">@@ -44,13 +48,11 @@
</span><span class="cx"> 
</span><span class="cx">     JSC::JSObject* result() const { return m_dictionary; }
</span><span class="cx"> 
</span><del>-    std::unique_ptr&lt;CryptoAlgorithmDescriptionBuilder&gt; createEmptyClone() const override;
</del><ins>+    void add(const char*, unsigned);
+    void add(const char*, const String&amp;);
+    void add(const char*, const Vector&lt;uint8_t&gt;&amp;);
+    void add(const char*, const JSCryptoAlgorithmBuilder&amp;);
</ins><span class="cx"> 
</span><del>-    void add(const char*, unsigned) override;
-    void add(const char*, const String&amp;) override;
-    void add(const char*, const Vector&lt;uint8_t&gt;&amp;) override;
-    void add(const char*, const CryptoAlgorithmDescriptionBuilder&amp;) override;
-
</del><span class="cx"> private:
</span><span class="cx">     JSC::ExecState* m_exec;
</span><span class="cx">     JSC::JSObject* m_dictionary;
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSCryptoKeyCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSCryptoKeyCustom.cpp (205940 => 205941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSCryptoKeyCustom.cpp        2016-09-15 00:16:51 UTC (rev 205940)
+++ trunk/Source/WebCore/bindings/js/JSCryptoKeyCustom.cpp        2016-09-15 00:19:12 UTC (rev 205941)
</span><span class="lines">@@ -28,7 +28,11 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(SUBTLE_CRYPTO)
</span><span class="cx"> 
</span><ins>+#include &quot;CryptoKeyAES.h&quot;
+#include &quot;CryptoKeyHMAC.h&quot;
+#include &quot;CryptoKeyRSA.h&quot;
</ins><span class="cx"> #include &quot;JSCryptoAlgorithmBuilder.h&quot;
</span><ins>+#include &lt;heap/HeapInlines.h&gt;
</ins><span class="cx"> #include &lt;runtime/JSCJSValueInlines.h&gt;
</span><span class="cx"> 
</span><span class="cx"> using namespace JSC;
</span><span class="lines">@@ -37,12 +41,51 @@
</span><span class="cx"> 
</span><span class="cx"> JSValue JSCryptoKey::algorithm(JSC::ExecState&amp; state) const
</span><span class="cx"> {
</span><ins>+    if (m_algorithm)
+        return m_algorithm.get();
+
</ins><span class="cx">     JSCryptoAlgorithmBuilder builder(&amp;state);
</span><del>-    wrapped().buildAlgorithmDescription(builder);
-    return builder.result();
</del><ins>+
+    std::unique_ptr&lt;KeyAlgorithm&gt; algorithm = wrapped().buildAlgorithm();
+    switch (algorithm-&gt;keyAlgorithmClass()) {
+    case KeyAlgorithmClass::AES: {
+        auto&amp; aesAlgorithm = downcast&lt;AesKeyAlgorithm&gt;(*algorithm);
+        builder.add(&quot;name&quot;, aesAlgorithm.name());
+        builder.add(&quot;length&quot;, aesAlgorithm.length());
+        break;
+    }
+    case KeyAlgorithmClass::HMAC: {
+        auto&amp; hmacAlgorithm = downcast&lt;HmacKeyAlgorithm&gt;(*algorithm);
+        builder.add(&quot;name&quot;, hmacAlgorithm.name());
+        JSCryptoAlgorithmBuilder hmacHash(&amp;state);
+        hmacHash.add(&quot;name&quot;, hmacAlgorithm.hash());
+        builder.add(&quot;hash&quot;, hmacHash);
+        builder.add(&quot;length&quot;, hmacAlgorithm.length());
+        break;
+    }
+    case KeyAlgorithmClass::HRSA: {
+        auto&amp; rsaAlgorithm = downcast&lt;RsaHashedKeyAlgorithm&gt;(*algorithm);
+        builder.add(&quot;name&quot;, rsaAlgorithm.name());
+        builder.add(&quot;modulusLength&quot;, rsaAlgorithm.modulusLength());
+        builder.add(&quot;publicExponent&quot;, rsaAlgorithm.publicExponent());
+        JSCryptoAlgorithmBuilder rsaHash(&amp;state);
+        rsaHash.add(&quot;name&quot;, rsaAlgorithm.hash());
+        builder.add(&quot;hash&quot;, rsaHash);
+        break;
+    }
+    case KeyAlgorithmClass::RSA: {
+        auto&amp; rsaAlgorithm = downcast&lt;RsaKeyAlgorithm&gt;(*algorithm);
+        builder.add(&quot;name&quot;, rsaAlgorithm.name());
+        builder.add(&quot;modulusLength&quot;, rsaAlgorithm.modulusLength());
+        builder.add(&quot;publicExponent&quot;, rsaAlgorithm.publicExponent());
+        break;
+    }
+    }
+
+    m_algorithm.set(state.vm(), this, builder.result());
+    return m_algorithm.get();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-
</del><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(SUBTLE_CRYPTO)
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoCryptoAlgorithmDescriptionBuildercpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/crypto/CryptoAlgorithmDescriptionBuilder.cpp (205940 => 205941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/CryptoAlgorithmDescriptionBuilder.cpp        2016-09-15 00:16:51 UTC (rev 205940)
+++ trunk/Source/WebCore/crypto/CryptoAlgorithmDescriptionBuilder.cpp        2016-09-15 00:19:12 UTC (rev 205941)
</span><span class="lines">@@ -1,43 +0,0 @@
</span><del>-/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include &quot;config.h&quot;
-#include &quot;CryptoAlgorithmDescriptionBuilder.h&quot;
-
-#if ENABLE(SUBTLE_CRYPTO)
-
-namespace WebCore {
-
-CryptoAlgorithmDescriptionBuilder::CryptoAlgorithmDescriptionBuilder()
-{
-}
-
-CryptoAlgorithmDescriptionBuilder::~CryptoAlgorithmDescriptionBuilder()
-{
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(SUBTLE_CRYPTO)
</del></span></pre></div>
<a id="trunkSourceWebCorecryptoCryptoAlgorithmDescriptionBuilderh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/crypto/CryptoAlgorithmDescriptionBuilder.h (205940 => 205941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/CryptoAlgorithmDescriptionBuilder.h        2016-09-15 00:16:51 UTC (rev 205940)
+++ trunk/Source/WebCore/crypto/CryptoAlgorithmDescriptionBuilder.h        2016-09-15 00:19:12 UTC (rev 205941)
</span><span class="lines">@@ -1,54 +0,0 @@
</span><del>-/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef CryptoAlgorithmDescriptionBuilder_h
-#define CryptoAlgorithmDescriptionBuilder_h
-
-#include &lt;wtf/Forward.h&gt;
-#include &lt;wtf/Noncopyable.h&gt;
-#include &lt;wtf/Vector.h&gt;
-
-#if ENABLE(SUBTLE_CRYPTO)
-
-namespace WebCore {
-
-class CryptoAlgorithmDescriptionBuilder {
-    WTF_MAKE_NONCOPYABLE(CryptoAlgorithmDescriptionBuilder);
-public:
-    CryptoAlgorithmDescriptionBuilder();
-    virtual ~CryptoAlgorithmDescriptionBuilder();
-
-    virtual std::unique_ptr&lt;CryptoAlgorithmDescriptionBuilder&gt; createEmptyClone() const = 0;
-
-    virtual void add(const char*, unsigned) = 0;
-    virtual void add(const char*, const String&amp;) = 0;
-    virtual void add(const char*, const Vector&lt;uint8_t&gt;&amp;) = 0;
-    virtual void add(const char*, const CryptoAlgorithmDescriptionBuilder&amp;) = 0;
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(SUBTLE_CRYPTO)
-#endif // CryptoAlgorithmDescriptionBuilder_h
</del></span></pre></div>
<a id="trunkSourceWebCorecryptoCryptoKeycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/CryptoKey.cpp (205940 => 205941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/CryptoKey.cpp        2016-09-15 00:16:51 UTC (rev 205940)
+++ trunk/Source/WebCore/crypto/CryptoKey.cpp        2016-09-15 00:19:12 UTC (rev 205941)
</span><span class="lines">@@ -28,15 +28,13 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(SUBTLE_CRYPTO)
</span><span class="cx"> 
</span><del>-#include &quot;CryptoAlgorithmDescriptionBuilder.h&quot;
</del><span class="cx"> #include &quot;CryptoAlgorithmRegistry.h&quot;
</span><span class="cx"> #include &lt;wtf/CryptographicallyRandomNumber.h&gt;
</span><del>-#include &lt;wtf/text/WTFString.h&gt;
</del><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-CryptoKey::CryptoKey(CryptoAlgorithmIdentifier algorithm, Type type, bool extractable, CryptoKeyUsage usages)
-    : m_algorithm(algorithm)
</del><ins>+CryptoKey::CryptoKey(CryptoAlgorithmIdentifier algorithmIdentifier, Type type, bool extractable, CryptoKeyUsage usages)
+    : m_algorithmIdentifier(algorithmIdentifier)
</ins><span class="cx">     , m_type(type)
</span><span class="cx">     , m_extractable(extractable)
</span><span class="cx">     , m_usages(usages)
</span><span class="lines">@@ -47,12 +45,6 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void CryptoKey::buildAlgorithmDescription(CryptoAlgorithmDescriptionBuilder&amp; builder) const
-{
-    builder.add(&quot;name&quot;, CryptoAlgorithmRegistry::singleton().nameForIdentifier(m_algorithm));
-    // Subclasses will add other keys.
-}
-
</del><span class="cx"> auto CryptoKey::usages() const -&gt; Vector&lt;Usage&gt;
</span><span class="cx"> {
</span><span class="cx">     // The result is ordered alphabetically.
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoCryptoKeyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/CryptoKey.h (205940 => 205941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/CryptoKey.h        2016-09-15 00:16:51 UTC (rev 205940)
+++ trunk/Source/WebCore/crypto/CryptoKey.h        2016-09-15 00:19:12 UTC (rev 205941)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> #include &lt;wtf/RefCounted.h&gt;
</span><span class="cx"> #include &lt;wtf/TypeCasts.h&gt;
</span><span class="cx"> #include &lt;wtf/Vector.h&gt;
</span><ins>+#include &lt;wtf/text/WTFString.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -42,11 +43,38 @@
</span><span class="cx"> class CryptoKeyData;
</span><span class="cx"> 
</span><span class="cx"> enum class CryptoKeyClass {
</span><ins>+    AES,
</ins><span class="cx">     HMAC,
</span><del>-    AES,
</del><span class="cx">     RSA
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+enum class KeyAlgorithmClass {
+    AES,
+    HMAC,
+    HRSA,
+    RSA,
+};
+
+class KeyAlgorithm {
+public:
+    virtual ~KeyAlgorithm()
+    {
+    }
+
+    virtual KeyAlgorithmClass keyAlgorithmClass() const = 0;
+
+    const String&amp; name() const { return m_name; }
+
+protected:
+    explicit KeyAlgorithm(const String&amp; name)
+        : m_name(name)
+    {
+    }
+
+private:
+    String m_name;
+};
+
</ins><span class="cx"> class CryptoKey : public RefCounted&lt;CryptoKey&gt; {
</span><span class="cx"> public:
</span><span class="cx">     using Type = CryptoKeyType;
</span><span class="lines">@@ -57,7 +85,7 @@
</span><span class="cx"> 
</span><span class="cx">     Type type() const;
</span><span class="cx">     bool extractable() const { return m_extractable; }
</span><del>-    virtual void buildAlgorithmDescription(CryptoAlgorithmDescriptionBuilder&amp;) const;
</del><ins>+    virtual std::unique_ptr&lt;KeyAlgorithm&gt; buildAlgorithm() const = 0;
</ins><span class="cx"> 
</span><span class="cx">     // FIXME: Confusing to have CryptoKeyUsage and CryptoKey::Usage named almost the same, but be slightly different.
</span><span class="cx">     // CryptoKeyUsage values are bit masks so they can be combined with &quot;or&quot;, while this is a normal enum that must
</span><span class="lines">@@ -65,7 +93,7 @@
</span><span class="cx">     enum class Usage { Encrypt, Decrypt, Sign, Verify, DeriveKey, DeriveBits, WrapKey, UnwrapKey };
</span><span class="cx">     Vector&lt;Usage&gt; usages() const;
</span><span class="cx"> 
</span><del>-    CryptoAlgorithmIdentifier algorithmIdentifier() const { return m_algorithm; }
</del><ins>+    CryptoAlgorithmIdentifier algorithmIdentifier() const { return m_algorithmIdentifier; }
</ins><span class="cx">     CryptoKeyUsage usagesBitmap() const { return m_usages; }
</span><span class="cx">     bool allows(CryptoKeyUsage usage) const { return usage == (m_usages &amp; usage); }
</span><span class="cx"> 
</span><span class="lines">@@ -74,7 +102,7 @@
</span><span class="cx">     static Vector&lt;uint8_t&gt; randomData(size_t);
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    CryptoAlgorithmIdentifier m_algorithm;
</del><ins>+    CryptoAlgorithmIdentifier m_algorithmIdentifier;
</ins><span class="cx">     Type m_type;
</span><span class="cx">     bool m_extractable;
</span><span class="cx">     CryptoKeyUsage m_usages;
</span><span class="lines">@@ -92,5 +120,10 @@
</span><span class="cx">     static bool isType(const WebCore::CryptoKey&amp; key) { return key.keyClass() == WebCore::KeyClass; } \
</span><span class="cx"> SPECIALIZE_TYPE_TRAITS_END()
</span><span class="cx"> 
</span><ins>+#define SPECIALIZE_TYPE_TRAITS_KEY_ALGORITHM(ToClassName, KeyAlgorithmClass) \
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToClassName) \
+    static bool isType(const WebCore::KeyAlgorithm&amp; algorithm) { return algorithm.keyAlgorithmClass() == WebCore::KeyAlgorithmClass; } \
+SPECIALIZE_TYPE_TRAITS_END()
+
</ins><span class="cx"> #endif // ENABLE(SUBTLE_CRYPTO)
</span><span class="cx"> #endif // CryptoKey_h
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoCryptoKeyidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/CryptoKey.idl (205940 => 205941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/CryptoKey.idl        2016-09-15 00:16:51 UTC (rev 205940)
+++ trunk/Source/WebCore/crypto/CryptoKey.idl        2016-09-15 00:19:12 UTC (rev 205941)
</span><span class="lines">@@ -47,6 +47,6 @@
</span><span class="cx"> ] interface CryptoKey {
</span><span class="cx">     readonly attribute KeyType type;
</span><span class="cx">     readonly attribute boolean extractable;
</span><del>-    [Custom] readonly attribute Algorithm algorithm;
-    readonly attribute sequence&lt;KeyUsage&gt; usages;
</del><ins>+    [CachedAttribute, CustomGetter] readonly attribute object algorithm;
+    [CachedAttribute] readonly attribute sequence&lt;KeyUsage&gt; usages;
</ins><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCorecryptognutlsCryptoKeyRSAGnuTLScpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/gnutls/CryptoKeyRSAGnuTLS.cpp (205940 => 205941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/gnutls/CryptoKeyRSAGnuTLS.cpp        2016-09-15 00:16:51 UTC (rev 205940)
+++ trunk/Source/WebCore/crypto/gnutls/CryptoKeyRSAGnuTLS.cpp        2016-09-15 00:19:12 UTC (rev 205941)
</span><span class="lines">@@ -28,7 +28,6 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(SUBTLE_CRYPTO)
</span><span class="cx"> 
</span><del>-#include &quot;CryptoAlgorithmDescriptionBuilder.h&quot;
</del><span class="cx"> #include &quot;CryptoAlgorithmRegistry.h&quot;
</span><span class="cx"> #include &quot;CryptoKeyDataRSAComponents.h&quot;
</span><span class="cx"> #include &quot;CryptoKeyPair.h&quot;
</span><span class="lines">@@ -81,10 +80,11 @@
</span><span class="cx">     return 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void CryptoKeyRSA::buildAlgorithmDescription(CryptoAlgorithmDescriptionBuilder&amp; builder) const
</del><ins>+std::unique_ptr&lt;KeyAlgorithm&gt; CryptoKeyRSA::buildAlgorithm() const
</ins><span class="cx"> {
</span><span class="cx">     notImplemented();
</span><del>-    UNUSED_PARAM(builder);
</del><ins>+    Vector&lt;uint8_t&gt; publicExponent;
+    return std::make_unique&lt;RsaKeyAlgorithm&gt;(emptyString(), 0, WTFMove(publicExponent));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> std::unique_ptr&lt;CryptoKeyData&gt; CryptoKeyRSA::exportData() const
</span></span></pre></div>
<a id="trunkSourceWebCorecryptokeysCryptoKeyAEScpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyAES.cpp (205940 => 205941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/keys/CryptoKeyAES.cpp        2016-09-15 00:16:51 UTC (rev 205940)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyAES.cpp        2016-09-15 00:19:12 UTC (rev 205941)
</span><span class="lines">@@ -28,7 +28,6 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(SUBTLE_CRYPTO)
</span><span class="cx"> 
</span><del>-#include &quot;CryptoAlgorithmDescriptionBuilder.h&quot;
</del><span class="cx"> #include &quot;CryptoAlgorithmRegistry.h&quot;
</span><span class="cx"> #include &quot;CryptoKeyDataOctetSequence.h&quot;
</span><span class="cx"> #include &lt;wtf/text/WTFString.h&gt;
</span><span class="lines">@@ -63,10 +62,9 @@
</span><span class="cx">     return adoptRef(new CryptoKeyAES(algorithm, randomData(lengthBits / 8), extractable, usages));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void CryptoKeyAES::buildAlgorithmDescription(CryptoAlgorithmDescriptionBuilder&amp; builder) const
</del><ins>+std::unique_ptr&lt;KeyAlgorithm&gt; CryptoKeyAES::buildAlgorithm() const
</ins><span class="cx"> {
</span><del>-    CryptoKey::buildAlgorithmDescription(builder);
-    builder.add(&quot;length&quot;, m_key.size() * 8);
</del><ins>+    return std::make_unique&lt;AesKeyAlgorithm&gt;(CryptoAlgorithmRegistry::singleton().nameForIdentifier(algorithmIdentifier()), m_key.size() * 8);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> std::unique_ptr&lt;CryptoKeyData&gt; CryptoKeyAES::exportData() const
</span></span></pre></div>
<a id="trunkSourceWebCorecryptokeysCryptoKeyAESh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyAES.h (205940 => 205941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/keys/CryptoKeyAES.h        2016-09-15 00:16:51 UTC (rev 205940)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyAES.h        2016-09-15 00:19:12 UTC (rev 205941)
</span><span class="lines">@@ -34,6 +34,22 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+class AesKeyAlgorithm final : public KeyAlgorithm {
+public:
+    AesKeyAlgorithm(const String&amp; name, size_t length)
+        : KeyAlgorithm(name)
+        , m_length(length)
+    {
+    }
+
+    KeyAlgorithmClass keyAlgorithmClass() const final { return KeyAlgorithmClass::AES; }
+
+    size_t length() const { return m_length; }
+
+private:
+    size_t m_length;
+};
+
</ins><span class="cx"> class CryptoKeyAES final : public CryptoKey {
</span><span class="cx"> public:
</span><span class="cx">     static Ref&lt;CryptoKeyAES&gt; create(CryptoAlgorithmIdentifier algorithm, const Vector&lt;uint8_t&gt;&amp; key, bool extractable, CryptoKeyUsage usage)
</span><span class="lines">@@ -46,7 +62,7 @@
</span><span class="cx"> 
</span><span class="cx">     static RefPtr&lt;CryptoKeyAES&gt; generate(CryptoAlgorithmIdentifier, size_t lengthBits, bool extractable, CryptoKeyUsage);
</span><span class="cx"> 
</span><del>-    CryptoKeyClass keyClass() const override { return CryptoKeyClass::AES; }
</del><ins>+    CryptoKeyClass keyClass() const final { return CryptoKeyClass::AES; }
</ins><span class="cx"> 
</span><span class="cx">     const Vector&lt;uint8_t&gt;&amp; key() const { return m_key; }
</span><span class="cx"> 
</span><span class="lines">@@ -53,8 +69,8 @@
</span><span class="cx"> private:
</span><span class="cx">     CryptoKeyAES(CryptoAlgorithmIdentifier, const Vector&lt;uint8_t&gt;&amp; key, bool extractable, CryptoKeyUsage);
</span><span class="cx"> 
</span><del>-    void buildAlgorithmDescription(CryptoAlgorithmDescriptionBuilder&amp;) const override;
-    std::unique_ptr&lt;CryptoKeyData&gt; exportData() const override;
</del><ins>+    std::unique_ptr&lt;KeyAlgorithm&gt; buildAlgorithm() const final;
+    std::unique_ptr&lt;CryptoKeyData&gt; exportData() const final;
</ins><span class="cx"> 
</span><span class="cx">     Vector&lt;uint8_t&gt; m_key;
</span><span class="cx"> };
</span><span class="lines">@@ -63,6 +79,8 @@
</span><span class="cx"> 
</span><span class="cx"> SPECIALIZE_TYPE_TRAITS_CRYPTO_KEY(CryptoKeyAES, CryptoKeyClass::AES)
</span><span class="cx"> 
</span><ins>+SPECIALIZE_TYPE_TRAITS_KEY_ALGORITHM(AesKeyAlgorithm, KeyAlgorithmClass::AES)
+
</ins><span class="cx"> #endif // ENABLE(SUBTLE_CRYPTO)
</span><span class="cx"> 
</span><span class="cx"> #endif // CryptoKeyAES_h
</span></span></pre></div>
<a id="trunkSourceWebCorecryptokeysCryptoKeyHMACcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.cpp (205940 => 205941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.cpp        2016-09-15 00:16:51 UTC (rev 205940)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.cpp        2016-09-15 00:19:12 UTC (rev 205941)
</span><span class="lines">@@ -28,7 +28,6 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(SUBTLE_CRYPTO)
</span><span class="cx"> 
</span><del>-#include &quot;CryptoAlgorithmDescriptionBuilder.h&quot;
</del><span class="cx"> #include &quot;CryptoAlgorithmRegistry.h&quot;
</span><span class="cx"> #include &quot;CryptoKeyDataOctetSequence.h&quot;
</span><span class="cx"> #include &lt;wtf/text/WTFString.h&gt;
</span><span class="lines">@@ -67,15 +66,10 @@
</span><span class="cx">     return adoptRef(new CryptoKeyHMAC(randomData(lengthBytes), hash, extractable, usages));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void CryptoKeyHMAC::buildAlgorithmDescription(CryptoAlgorithmDescriptionBuilder&amp; builder) const
</del><ins>+std::unique_ptr&lt;KeyAlgorithm&gt; CryptoKeyHMAC::buildAlgorithm() const
</ins><span class="cx"> {
</span><del>-    CryptoKey::buildAlgorithmDescription(builder);
-
-    auto hashDescriptionBuilder = builder.createEmptyClone();
-    hashDescriptionBuilder-&gt;add(&quot;name&quot;, CryptoAlgorithmRegistry::singleton().nameForIdentifier(m_hash));
-    builder.add(&quot;hash&quot;, *hashDescriptionBuilder);
-
-    builder.add(&quot;length&quot;, m_key.size());
</del><ins>+    return std::make_unique&lt;HmacKeyAlgorithm&gt;(CryptoAlgorithmRegistry::singleton().nameForIdentifier(algorithmIdentifier()),
+        CryptoAlgorithmRegistry::singleton().nameForIdentifier(m_hash), m_key.size());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> std::unique_ptr&lt;CryptoKeyData&gt; CryptoKeyHMAC::exportData() const
</span></span></pre></div>
<a id="trunkSourceWebCorecryptokeysCryptoKeyHMACh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.h (205940 => 205941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.h        2016-09-15 00:16:51 UTC (rev 205940)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.h        2016-09-15 00:19:12 UTC (rev 205941)
</span><span class="lines">@@ -33,6 +33,25 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+class HmacKeyAlgorithm final : public KeyAlgorithm {
+public:
+    HmacKeyAlgorithm(const String&amp; name, const String&amp; hash, size_t length)
+        : KeyAlgorithm(name)
+        , m_hash(hash)
+        , m_length(length)
+    {
+    }
+
+    KeyAlgorithmClass keyAlgorithmClass() const final { return KeyAlgorithmClass::HMAC; }
+
+    const String&amp; hash() const { return m_hash; }
+    size_t length() const { return m_length; }
+
+private:
+    String m_hash;
+    size_t m_length;
+};
+
</ins><span class="cx"> class CryptoKeyHMAC final : public CryptoKey {
</span><span class="cx"> public:
</span><span class="cx">     static Ref&lt;CryptoKeyHMAC&gt; create(const Vector&lt;uint8_t&gt;&amp; key, CryptoAlgorithmIdentifier hash, bool extractable, CryptoKeyUsage usage)
</span><span class="lines">@@ -44,7 +63,7 @@
</span><span class="cx">     // If lengthBytes is 0, a recommended length is used, which is the size of the associated hash function's block size.
</span><span class="cx">     static RefPtr&lt;CryptoKeyHMAC&gt; generate(size_t lengthBytes, CryptoAlgorithmIdentifier hash, bool extractable, CryptoKeyUsage);
</span><span class="cx"> 
</span><del>-    CryptoKeyClass keyClass() const override { return CryptoKeyClass::HMAC; }
</del><ins>+    CryptoKeyClass keyClass() const final { return CryptoKeyClass::HMAC; }
</ins><span class="cx"> 
</span><span class="cx">     const Vector&lt;uint8_t&gt;&amp; key() const { return m_key; }
</span><span class="cx"> 
</span><span class="lines">@@ -53,8 +72,8 @@
</span><span class="cx"> private:
</span><span class="cx">     CryptoKeyHMAC(const Vector&lt;uint8_t&gt;&amp; key, CryptoAlgorithmIdentifier hash, bool extractable, CryptoKeyUsage);
</span><span class="cx"> 
</span><del>-    void buildAlgorithmDescription(CryptoAlgorithmDescriptionBuilder&amp;) const override;
-    std::unique_ptr&lt;CryptoKeyData&gt; exportData() const override;
</del><ins>+    std::unique_ptr&lt;KeyAlgorithm&gt; buildAlgorithm() const final;
+    std::unique_ptr&lt;CryptoKeyData&gt; exportData() const final;
</ins><span class="cx"> 
</span><span class="cx">     CryptoAlgorithmIdentifier m_hash;
</span><span class="cx">     Vector&lt;uint8_t&gt; m_key;
</span><span class="lines">@@ -64,5 +83,7 @@
</span><span class="cx"> 
</span><span class="cx"> SPECIALIZE_TYPE_TRAITS_CRYPTO_KEY(CryptoKeyHMAC, CryptoKeyClass::HMAC)
</span><span class="cx"> 
</span><ins>+SPECIALIZE_TYPE_TRAITS_KEY_ALGORITHM(HmacKeyAlgorithm, KeyAlgorithmClass::HMAC)
+
</ins><span class="cx"> #endif // ENABLE(SUBTLE_CRYPTO)
</span><span class="cx"> #endif // CryptoKeyHMAC_h
</span></span></pre></div>
<a id="trunkSourceWebCorecryptokeysCryptoKeyRSAh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyRSA.h (205940 => 205941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/keys/CryptoKeyRSA.h        2016-09-15 00:16:51 UTC (rev 205940)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyRSA.h        2016-09-15 00:19:12 UTC (rev 205941)
</span><span class="lines">@@ -47,6 +47,41 @@
</span><span class="cx"> class CryptoKeyPair;
</span><span class="cx"> class PromiseWrapper;
</span><span class="cx"> 
</span><ins>+class RsaKeyAlgorithm : public KeyAlgorithm {
+public:
+    RsaKeyAlgorithm(const String&amp; name, size_t modulusLength, Vector&lt;uint8_t&gt;&amp;&amp; publicExponent)
+        : KeyAlgorithm(name)
+        , m_modulusLength(modulusLength)
+        , m_publicExponent(WTFMove(publicExponent))
+    {
+    }
+
+    KeyAlgorithmClass keyAlgorithmClass() const override { return KeyAlgorithmClass::RSA; }
+
+    size_t modulusLength() const { return m_modulusLength; }
+    const Vector&lt;uint8_t&gt;&amp; publicExponent() const { return m_publicExponent; }
+
+private:
+    size_t m_modulusLength;
+    Vector&lt;uint8_t&gt; m_publicExponent;
+};
+
+class RsaHashedKeyAlgorithm final : public RsaKeyAlgorithm {
+public:
+    RsaHashedKeyAlgorithm(const String&amp; name, size_t modulusLength, Vector&lt;uint8_t&gt;&amp;&amp; publicExponent, const String&amp; hash)
+        : RsaKeyAlgorithm(name, modulusLength, WTFMove(publicExponent))
+        , m_hash(hash)
+    {
+    }
+
+    KeyAlgorithmClass keyAlgorithmClass() const final { return KeyAlgorithmClass::HRSA; }
+
+    const String&amp; hash() const { return m_hash; }
+
+private:
+    String m_hash;
+};
+
</ins><span class="cx"> class CryptoKeyRSA final : public CryptoKey {
</span><span class="cx"> public:
</span><span class="cx">     static Ref&lt;CryptoKeyRSA&gt; create(CryptoAlgorithmIdentifier identifier, CryptoAlgorithmIdentifier hash, bool hasHash, CryptoKeyType type, PlatformRSAKey platformKey, bool extractable, CryptoKeyUsage usage)
</span><span class="lines">@@ -69,10 +104,10 @@
</span><span class="cx"> private:
</span><span class="cx">     CryptoKeyRSA(CryptoAlgorithmIdentifier, CryptoAlgorithmIdentifier hash, bool hasHash, CryptoKeyType, PlatformRSAKey, bool extractable, CryptoKeyUsage);
</span><span class="cx"> 
</span><del>-    CryptoKeyClass keyClass() const override { return CryptoKeyClass::RSA; }
</del><ins>+    CryptoKeyClass keyClass() const final { return CryptoKeyClass::RSA; }
</ins><span class="cx"> 
</span><del>-    void buildAlgorithmDescription(CryptoAlgorithmDescriptionBuilder&amp;) const override;
-    std::unique_ptr&lt;CryptoKeyData&gt; exportData() const override;
</del><ins>+    std::unique_ptr&lt;KeyAlgorithm&gt; buildAlgorithm() const final;
+    std::unique_ptr&lt;CryptoKeyData&gt; exportData() const final;
</ins><span class="cx"> 
</span><span class="cx">     PlatformRSAKey m_platformKey;
</span><span class="cx"> 
</span><span class="lines">@@ -84,5 +119,9 @@
</span><span class="cx"> 
</span><span class="cx"> SPECIALIZE_TYPE_TRAITS_CRYPTO_KEY(CryptoKeyRSA, CryptoKeyClass::RSA)
</span><span class="cx"> 
</span><ins>+SPECIALIZE_TYPE_TRAITS_KEY_ALGORITHM(RsaKeyAlgorithm, KeyAlgorithmClass::RSA)
+
+SPECIALIZE_TYPE_TRAITS_KEY_ALGORITHM(RsaHashedKeyAlgorithm, KeyAlgorithmClass::HRSA)
+
</ins><span class="cx"> #endif // ENABLE(SUBTLE_CRYPTO)
</span><span class="cx"> #endif // CryptoKeyRSA_h
</span></span></pre></div>
<a id="trunkSourceWebCorecryptomacCryptoKeyRSAMaccpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/mac/CryptoKeyRSAMac.cpp (205940 => 205941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/mac/CryptoKeyRSAMac.cpp        2016-09-15 00:16:51 UTC (rev 205940)
+++ trunk/Source/WebCore/crypto/mac/CryptoKeyRSAMac.cpp        2016-09-15 00:19:12 UTC (rev 205941)
</span><span class="lines">@@ -29,7 +29,6 @@
</span><span class="cx"> #if ENABLE(SUBTLE_CRYPTO)
</span><span class="cx"> 
</span><span class="cx"> #include &quot;CommonCryptoUtilities.h&quot;
</span><del>-#include &quot;CryptoAlgorithmDescriptionBuilder.h&quot;
</del><span class="cx"> #include &quot;CryptoAlgorithmRegistry.h&quot;
</span><span class="cx"> #include &quot;CryptoKeyDataRSAComponents.h&quot;
</span><span class="cx"> #include &quot;CryptoKeyPair.h&quot;
</span><span class="lines">@@ -160,26 +159,22 @@
</span><span class="cx">     return modulus.size() * 8;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void CryptoKeyRSA::buildAlgorithmDescription(CryptoAlgorithmDescriptionBuilder&amp; builder) const
</del><ins>+std::unique_ptr&lt;KeyAlgorithm&gt; CryptoKeyRSA::buildAlgorithm() const
</ins><span class="cx"> {
</span><del>-    CryptoKey::buildAlgorithmDescription(builder);
-
</del><ins>+    String name = CryptoAlgorithmRegistry::singleton().nameForIdentifier(algorithmIdentifier());
</ins><span class="cx">     Vector&lt;uint8_t&gt; modulus;
</span><span class="cx">     Vector&lt;uint8_t&gt; publicExponent;
</span><span class="cx">     CCCryptorStatus status = getPublicKeyComponents(m_platformKey, modulus, publicExponent);
</span><span class="cx">     if (status) {
</span><span class="cx">         WTFLogAlways(&quot;Couldn't get RSA key components, status %d&quot;, status);
</span><del>-        return;
</del><ins>+        publicExponent.clear();
+        return std::make_unique&lt;RsaKeyAlgorithm&gt;(name, 0, WTFMove(publicExponent));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    builder.add(&quot;modulusLength&quot;, modulus.size() * 8);
-    builder.add(&quot;publicExponent&quot;, publicExponent);
-
-    if (m_restrictedToSpecificHash) {
-        auto hashDescriptionBuilder = builder.createEmptyClone();
-        hashDescriptionBuilder-&gt;add(&quot;name&quot;, CryptoAlgorithmRegistry::singleton().nameForIdentifier(m_hash));
-        builder.add(&quot;hash&quot;, *hashDescriptionBuilder);
-    }
</del><ins>+    size_t modulusLength = modulus.size() * 8;
+    if (m_restrictedToSpecificHash)
+        return std::make_unique&lt;RsaHashedKeyAlgorithm&gt;(name, modulusLength, WTFMove(publicExponent), CryptoAlgorithmRegistry::singleton().nameForIdentifier(m_hash));
+    return std::make_unique&lt;RsaKeyAlgorithm&gt;(name, modulusLength, WTFMove(publicExponent));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> std::unique_ptr&lt;CryptoKeyData&gt; CryptoKeyRSA::exportData() const
</span></span></pre>
</div>
</div>

</body>
</html>