<!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>[174358] trunk/Source/WebCore</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/174358">174358</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2014-10-06 12:20:19 -0700 (Mon, 06 Oct 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Use is&lt;&gt;() / downcast&lt;&gt;() for CryptoKey subclasses
https://bugs.webkit.org/show_bug.cgi?id=137436

Reviewed by Ryosuke Niwa.

Use is&lt;&gt;() / downcast&lt;&gt;() for CryptoKey subclasses.

No new tests, no behavior change.

* bindings/js/JSCryptoKeySerializationJWK.cpp:
(WebCore::addJWKAlgorithmToJSON):
* bindings/js/SerializedScriptValue.cpp:
(WebCore::CloneSerializer::write):
* crypto/CryptoKey.h:
* crypto/algorithms/CryptoAlgorithmAES_CBC.cpp:
(WebCore::CryptoAlgorithmAES_CBC::keyAlgorithmMatches):
(WebCore::CryptoAlgorithmAES_CBC::encrypt):
(WebCore::CryptoAlgorithmAES_CBC::decrypt):
* crypto/algorithms/CryptoAlgorithmAES_KW.cpp:
(WebCore::CryptoAlgorithmAES_KW::keyAlgorithmMatches):
(WebCore::CryptoAlgorithmAES_KW::encryptForWrapKey):
(WebCore::CryptoAlgorithmAES_KW::decryptForUnwrapKey):
* crypto/algorithms/CryptoAlgorithmHMAC.cpp:
(WebCore::CryptoAlgorithmHMAC::keyAlgorithmMatches):
(WebCore::CryptoAlgorithmHMAC::sign):
(WebCore::CryptoAlgorithmHMAC::verify):
* crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp:
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::keyAlgorithmMatches):
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::encrypt):
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::decrypt):
* crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp:
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::keyAlgorithmMatches):
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::sign):
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::verify):
* crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp:
(WebCore::CryptoAlgorithmRSA_OAEP::keyAlgorithmMatches):
(WebCore::CryptoAlgorithmRSA_OAEP::encrypt):
(WebCore::CryptoAlgorithmRSA_OAEP::decrypt):
* crypto/keys/CryptoKeyAES.h:
(WebCore::isCryptoKeyAES): Deleted.
* crypto/keys/CryptoKeyHMAC.h:
(WebCore::isCryptoKeyHMAC): Deleted.
* crypto/keys/CryptoKeyRSA.h:
(WebCore::isCryptoKeyRSA): Deleted.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSCryptoKeySerializationJWKcpp">trunk/Source/WebCore/bindings/js/JSCryptoKeySerializationJWK.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsSerializedScriptValuecpp">trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoCryptoKeyh">trunk/Source/WebCore/crypto/CryptoKey.h</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmAES_CBCcpp">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmAES_KWcpp">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmHMACcpp">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSAES_PKCS1_v1_5cpp">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSASSA_PKCS1_v1_5cpp">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSA_OAEPcpp">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptokeysCryptoKeyAESh">trunk/Source/WebCore/crypto/keys/CryptoKeyAES.h</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>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (174357 => 174358)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-10-06 19:09:55 UTC (rev 174357)
+++ trunk/Source/WebCore/ChangeLog        2014-10-06 19:20:19 UTC (rev 174358)
</span><span class="lines">@@ -1,3 +1,50 @@
</span><ins>+2014-10-06  Christophe Dumez  &lt;cdumez@apple.com&gt;
+
+        Use is&lt;&gt;() / downcast&lt;&gt;() for CryptoKey subclasses
+        https://bugs.webkit.org/show_bug.cgi?id=137436
+
+        Reviewed by Ryosuke Niwa.
+
+        Use is&lt;&gt;() / downcast&lt;&gt;() for CryptoKey subclasses.
+
+        No new tests, no behavior change.
+
+        * bindings/js/JSCryptoKeySerializationJWK.cpp:
+        (WebCore::addJWKAlgorithmToJSON):
+        * bindings/js/SerializedScriptValue.cpp:
+        (WebCore::CloneSerializer::write):
+        * crypto/CryptoKey.h:
+        * crypto/algorithms/CryptoAlgorithmAES_CBC.cpp:
+        (WebCore::CryptoAlgorithmAES_CBC::keyAlgorithmMatches):
+        (WebCore::CryptoAlgorithmAES_CBC::encrypt):
+        (WebCore::CryptoAlgorithmAES_CBC::decrypt):
+        * crypto/algorithms/CryptoAlgorithmAES_KW.cpp:
+        (WebCore::CryptoAlgorithmAES_KW::keyAlgorithmMatches):
+        (WebCore::CryptoAlgorithmAES_KW::encryptForWrapKey):
+        (WebCore::CryptoAlgorithmAES_KW::decryptForUnwrapKey):
+        * crypto/algorithms/CryptoAlgorithmHMAC.cpp:
+        (WebCore::CryptoAlgorithmHMAC::keyAlgorithmMatches):
+        (WebCore::CryptoAlgorithmHMAC::sign):
+        (WebCore::CryptoAlgorithmHMAC::verify):
+        * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp:
+        (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::keyAlgorithmMatches):
+        (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::encrypt):
+        (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::decrypt):
+        * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp:
+        (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::keyAlgorithmMatches):
+        (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::sign):
+        (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::verify):
+        * crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp:
+        (WebCore::CryptoAlgorithmRSA_OAEP::keyAlgorithmMatches):
+        (WebCore::CryptoAlgorithmRSA_OAEP::encrypt):
+        (WebCore::CryptoAlgorithmRSA_OAEP::decrypt):
+        * crypto/keys/CryptoKeyAES.h:
+        (WebCore::isCryptoKeyAES): Deleted.
+        * crypto/keys/CryptoKeyHMAC.h:
+        (WebCore::isCryptoKeyHMAC): Deleted.
+        * crypto/keys/CryptoKeyRSA.h:
+        (WebCore::isCryptoKeyRSA): Deleted.
+
</ins><span class="cx"> 2014-10-06  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Some compositing logic cleanup
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSCryptoKeySerializationJWKcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSCryptoKeySerializationJWK.cpp (174357 => 174358)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSCryptoKeySerializationJWK.cpp        2014-10-06 19:09:55 UTC (rev 174357)
+++ trunk/Source/WebCore/bindings/js/JSCryptoKeySerializationJWK.cpp        2014-10-06 19:20:19 UTC (rev 174358)
</span><span class="lines">@@ -556,17 +556,17 @@
</span><span class="cx">     String jwkAlgorithm;
</span><span class="cx">     switch (key.algorithmIdentifier()) {
</span><span class="cx">     case CryptoAlgorithmIdentifier::HMAC:
</span><del>-        switch (toCryptoKeyHMAC(key).hashAlgorithmIdentifier()) {
</del><ins>+        switch (downcast&lt;CryptoKeyHMAC&gt;(key).hashAlgorithmIdentifier()) {
</ins><span class="cx">         case CryptoAlgorithmIdentifier::SHA_256:
</span><del>-            if (toCryptoKeyHMAC(key).key().size() * 8 &gt;= 256)
</del><ins>+            if (downcast&lt;CryptoKeyHMAC&gt;(key).key().size() * 8 &gt;= 256)
</ins><span class="cx">                 jwkAlgorithm = &quot;HS256&quot;;
</span><span class="cx">             break;
</span><span class="cx">         case CryptoAlgorithmIdentifier::SHA_384:
</span><del>-            if (toCryptoKeyHMAC(key).key().size() * 8 &gt;= 384)
</del><ins>+            if (downcast&lt;CryptoKeyHMAC&gt;(key).key().size() * 8 &gt;= 384)
</ins><span class="cx">                 jwkAlgorithm = &quot;HS384&quot;;
</span><span class="cx">             break;
</span><span class="cx">         case CryptoAlgorithmIdentifier::SHA_512:
</span><del>-            if (toCryptoKeyHMAC(key).key().size() * 8 &gt;= 512)
</del><ins>+            if (downcast&lt;CryptoKeyHMAC&gt;(key).key().size() * 8 &gt;= 512)
</ins><span class="cx">                 jwkAlgorithm = &quot;HS512&quot;;
</span><span class="cx">             break;
</span><span class="cx">         default:
</span><span class="lines">@@ -574,7 +574,7 @@
</span><span class="cx">         }
</span><span class="cx">         break;
</span><span class="cx">     case CryptoAlgorithmIdentifier::AES_CBC:
</span><del>-        switch (toCryptoKeyAES(key).key().size() * 8) {
</del><ins>+        switch (downcast&lt;CryptoKeyAES&gt;(key).key().size() * 8) {
</ins><span class="cx">         case 128:
</span><span class="cx">             jwkAlgorithm = &quot;A128CBC&quot;;
</span><span class="cx">             break;
</span><span class="lines">@@ -587,7 +587,7 @@
</span><span class="cx">         }
</span><span class="cx">         break;
</span><span class="cx">     case CryptoAlgorithmIdentifier::AES_KW:
</span><del>-        switch (toCryptoKeyAES(key).key().size() * 8) {
</del><ins>+        switch (downcast&lt;CryptoKeyAES&gt;(key).key().size() * 8) {
</ins><span class="cx">         case 128:
</span><span class="cx">             jwkAlgorithm = &quot;A128KW&quot;;
</span><span class="cx">             break;
</span><span class="lines">@@ -600,7 +600,7 @@
</span><span class="cx">         }
</span><span class="cx">         break;
</span><span class="cx">     case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5: {
</span><del>-        const CryptoKeyRSA&amp; rsaKey = toCryptoKeyRSA(key);
</del><ins>+        const CryptoKeyRSA&amp; rsaKey = downcast&lt;CryptoKeyRSA&gt;(key);
</ins><span class="cx">         CryptoAlgorithmIdentifier hash;
</span><span class="cx">         if (!rsaKey.isRestrictedToHash(hash))
</span><span class="cx">             break;
</span><span class="lines">@@ -622,14 +622,14 @@
</span><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx">     case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5: {
</span><del>-        const CryptoKeyRSA&amp; rsaKey = toCryptoKeyRSA(key);
</del><ins>+        const CryptoKeyRSA&amp; rsaKey = downcast&lt;CryptoKeyRSA&gt;(key);
</ins><span class="cx">         if (rsaKey.keySizeInBits() &lt; 2048)
</span><span class="cx">             break;
</span><span class="cx">         jwkAlgorithm = &quot;RSA1_5&quot;;
</span><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx">     case CryptoAlgorithmIdentifier::RSA_OAEP: {
</span><del>-        const CryptoKeyRSA&amp; rsaKey = toCryptoKeyRSA(key);
</del><ins>+        const CryptoKeyRSA&amp; rsaKey = downcast&lt;CryptoKeyRSA&gt;(key);
</ins><span class="cx">         CryptoAlgorithmIdentifier hash;
</span><span class="cx">         // WebCrypto RSA-OAEP keys are not tied to any particular hash, unless previously imported from JWK, which only supports SHA-1.
</span><span class="cx">         if (rsaKey.isRestrictedToHash(hash) &amp;&amp; hash != CryptoAlgorithmIdentifier::SHA_1)
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsSerializedScriptValuecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp (174357 => 174358)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp        2014-10-06 19:09:55 UTC (rev 174357)
+++ trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp        2014-10-06 19:20:19 UTC (rev 174358)
</span><span class="lines">@@ -1173,19 +1173,19 @@
</span><span class="cx">         switch (key-&gt;keyClass()) {
</span><span class="cx">         case CryptoKeyClass::HMAC:
</span><span class="cx">             write(CryptoKeyClassSubtag::HMAC);
</span><del>-            write(toCryptoKeyHMAC(key)-&gt;key());
-            write(toCryptoKeyHMAC(key)-&gt;hashAlgorithmIdentifier());
</del><ins>+            write(downcast&lt;CryptoKeyHMAC&gt;(*key).key());
+            write(downcast&lt;CryptoKeyHMAC&gt;(*key).hashAlgorithmIdentifier());
</ins><span class="cx">             break;
</span><span class="cx">         case CryptoKeyClass::AES:
</span><span class="cx">             write(CryptoKeyClassSubtag::AES);
</span><span class="cx">             write(key-&gt;algorithmIdentifier());
</span><del>-            write(toCryptoKeyAES(key)-&gt;key());
</del><ins>+            write(downcast&lt;CryptoKeyAES&gt;(*key).key());
</ins><span class="cx">             break;
</span><span class="cx">         case CryptoKeyClass::RSA:
</span><span class="cx">             write(CryptoKeyClassSubtag::RSA);
</span><span class="cx">             write(key-&gt;algorithmIdentifier());
</span><span class="cx">             CryptoAlgorithmIdentifier hash;
</span><del>-            bool isRestrictedToHash = toCryptoKeyRSA(key)-&gt;isRestrictedToHash(hash);
</del><ins>+            bool isRestrictedToHash = downcast&lt;CryptoKeyRSA&gt;(*key).isRestrictedToHash(hash);
</ins><span class="cx">             write(isRestrictedToHash);
</span><span class="cx">             if (isRestrictedToHash)
</span><span class="cx">                 write(hash);
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoCryptoKeyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/CryptoKey.h (174357 => 174358)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/CryptoKey.h        2014-10-06 19:09:55 UTC (rev 174357)
+++ trunk/Source/WebCore/crypto/CryptoKey.h        2014-10-06 19:20:19 UTC (rev 174358)
</span><span class="lines">@@ -26,15 +26,16 @@
</span><span class="cx"> #ifndef CryptoKey_h
</span><span class="cx"> #define CryptoKey_h
</span><span class="cx"> 
</span><ins>+#if ENABLE(SUBTLE_CRYPTO)
+
</ins><span class="cx"> #include &quot;CryptoAlgorithmIdentifier.h&quot;
</span><span class="cx"> #include &quot;CryptoKeyType.h&quot;
</span><span class="cx"> #include &quot;CryptoKeyUsage.h&quot;
</span><span class="cx"> #include &lt;wtf/Forward.h&gt;
</span><span class="cx"> #include &lt;wtf/RefCounted.h&gt;
</span><ins>+#include &lt;wtf/TypeCasts.h&gt;
</ins><span class="cx"> #include &lt;wtf/Vector.h&gt;
</span><span class="cx"> 
</span><del>-#if ENABLE(SUBTLE_CRYPTO)
-
</del><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> class CryptoAlgorithmDescriptionBuilder;
</span><span class="lines">@@ -73,10 +74,12 @@
</span><span class="cx">     CryptoKeyUsage m_usages;
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-#define CRYPTO_KEY_TYPE_CASTS(ToClassName) \
-    TYPE_CASTS_BASE(ToClassName, CryptoKey, key, WebCore::is##ToClassName(*key), WebCore::is##ToClassName(key))
-
</del><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><ins>+#define SPECIALIZE_TYPE_TRAITS_CRYPTO_KEY(ToClassName, KeyClass) \
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToClassName) \
+    static bool isType(const WebCore::CryptoKey&amp; key) { return key.keyClass() == WebCore::KeyClass; } \
+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="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmAES_CBCcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.cpp (174357 => 174358)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.cpp        2014-10-06 19:09:55 UTC (rev 174357)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.cpp        2014-10-06 19:20:19 UTC (rev 174358)
</span><span class="lines">@@ -60,7 +60,7 @@
</span><span class="cx"> {
</span><span class="cx">     if (key.algorithmIdentifier() != s_identifier)
</span><span class="cx">         return false;
</span><del>-    ASSERT(isCryptoKeyAES(key));
</del><ins>+    ASSERT(is&lt;CryptoKeyAES&gt;(key));
</ins><span class="cx"> 
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="lines">@@ -74,7 +74,7 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    platformEncrypt(aesCBCParameters, toCryptoKeyAES(key), data, WTF::move(callback), WTF::move(failureCallback), ec);
</del><ins>+    platformEncrypt(aesCBCParameters, downcast&lt;CryptoKeyAES&gt;(key), data, WTF::move(callback), WTF::move(failureCallback), ec);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CryptoAlgorithmAES_CBC::decrypt(const CryptoAlgorithmParameters&amp; parameters, const CryptoKey&amp; key, const CryptoOperationData&amp; data, VectorCallback callback, VoidCallback failureCallback, ExceptionCode&amp; ec)
</span><span class="lines">@@ -86,7 +86,7 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    platformDecrypt(aesCBCParameters, toCryptoKeyAES(key), data, WTF::move(callback), WTF::move(failureCallback), ec);
</del><ins>+    platformDecrypt(aesCBCParameters, downcast&lt;CryptoKeyAES&gt;(key), data, WTF::move(callback), WTF::move(failureCallback), ec);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CryptoAlgorithmAES_CBC::generateKey(const CryptoAlgorithmParameters&amp; parameters, bool extractable, CryptoKeyUsage usages, KeyOrKeyPairCallback callback, VoidCallback failureCallback, ExceptionCode&amp;)
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmAES_KWcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.cpp (174357 => 174358)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.cpp        2014-10-06 19:09:55 UTC (rev 174357)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.cpp        2014-10-06 19:20:19 UTC (rev 174358)
</span><span class="lines">@@ -59,7 +59,7 @@
</span><span class="cx"> {
</span><span class="cx">     if (key.algorithmIdentifier() != s_identifier)
</span><span class="cx">         return false;
</span><del>-    ASSERT(isCryptoKeyAES(key));
</del><ins>+    ASSERT(is&lt;CryptoKeyAES&gt;(key));
</ins><span class="cx"> 
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="lines">@@ -71,7 +71,7 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    platformEncrypt(toCryptoKeyAES(key), data, WTF::move(callback), WTF::move(failureCallback), ec);
</del><ins>+    platformEncrypt(downcast&lt;CryptoKeyAES&gt;(key), data, WTF::move(callback), WTF::move(failureCallback), ec);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CryptoAlgorithmAES_KW::decryptForUnwrapKey(const CryptoAlgorithmParameters&amp;, const CryptoKey&amp; key, const CryptoOperationData&amp; data, VectorCallback callback, VoidCallback failureCallback, ExceptionCode&amp; ec)
</span><span class="lines">@@ -81,7 +81,7 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    platformDecrypt(toCryptoKeyAES(key), data, WTF::move(callback), WTF::move(failureCallback), ec);
</del><ins>+    platformDecrypt(downcast&lt;CryptoKeyAES&gt;(key), data, WTF::move(callback), WTF::move(failureCallback), ec);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CryptoAlgorithmAES_KW::generateKey(const CryptoAlgorithmParameters&amp; parameters, bool extractable, CryptoKeyUsage usages, KeyOrKeyPairCallback callback, VoidCallback failureCallback, ExceptionCode&amp;)
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmHMACcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp (174357 => 174358)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp        2014-10-06 19:09:55 UTC (rev 174357)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp        2014-10-06 19:20:19 UTC (rev 174358)
</span><span class="lines">@@ -60,9 +60,8 @@
</span><span class="cx"> {
</span><span class="cx">     if (key.algorithmIdentifier() != s_identifier)
</span><span class="cx">         return false;
</span><del>-    ASSERT(isCryptoKeyHMAC(key));
</del><span class="cx"> 
</span><del>-    if (toCryptoKeyHMAC(key).hashAlgorithmIdentifier() != parameters.hash)
</del><ins>+    if (downcast&lt;CryptoKeyHMAC&gt;(key).hashAlgorithmIdentifier() != parameters.hash)
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     return true;
</span><span class="lines">@@ -77,7 +76,7 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    platformSign(hmacParameters, toCryptoKeyHMAC(key), data, WTF::move(callback), WTF::move(failureCallback), ec);
</del><ins>+    platformSign(hmacParameters, downcast&lt;CryptoKeyHMAC&gt;(key), data, WTF::move(callback), WTF::move(failureCallback), ec);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CryptoAlgorithmHMAC::verify(const CryptoAlgorithmParameters&amp; parameters, const CryptoKey&amp; key, const CryptoOperationData&amp; expectedSignature, const CryptoOperationData&amp; data, BoolCallback callback, VoidCallback failureCallback, ExceptionCode&amp; ec)
</span><span class="lines">@@ -89,7 +88,7 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    platformVerify(hmacParameters, toCryptoKeyHMAC(key), expectedSignature, data, WTF::move(callback), WTF::move(failureCallback), ec);
</del><ins>+    platformVerify(hmacParameters, downcast&lt;CryptoKeyHMAC&gt;(key), expectedSignature, data, WTF::move(callback), WTF::move(failureCallback), ec);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CryptoAlgorithmHMAC::generateKey(const CryptoAlgorithmParameters&amp; parameters, bool extractable, CryptoKeyUsage usages, KeyOrKeyPairCallback callback, VoidCallback failureCallback, ExceptionCode&amp;)
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSAES_PKCS1_v1_5cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp (174357 => 174358)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp        2014-10-06 19:09:55 UTC (rev 174357)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp        2014-10-06 19:20:19 UTC (rev 174358)
</span><span class="lines">@@ -59,7 +59,7 @@
</span><span class="cx"> {
</span><span class="cx">     if (key.algorithmIdentifier() != s_identifier)
</span><span class="cx">         return false;
</span><del>-    ASSERT(isCryptoKeyRSA(key));
</del><ins>+    ASSERT(is&lt;CryptoKeyRSA&gt;(key));
</ins><span class="cx"> 
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="lines">@@ -71,7 +71,7 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    platformEncrypt(toCryptoKeyRSA(key), data, WTF::move(callback), WTF::move(failureCallback), ec);
</del><ins>+    platformEncrypt(downcast&lt;CryptoKeyRSA&gt;(key), data, WTF::move(callback), WTF::move(failureCallback), ec);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CryptoAlgorithmRSAES_PKCS1_v1_5::decrypt(const CryptoAlgorithmParameters&amp;, const CryptoKey&amp; key, const CryptoOperationData&amp; data, VectorCallback callback, VoidCallback failureCallback, ExceptionCode&amp; ec)
</span><span class="lines">@@ -81,7 +81,7 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    platformDecrypt(toCryptoKeyRSA(key), data, WTF::move(callback), WTF::move(failureCallback), ec);
</del><ins>+    platformDecrypt(downcast&lt;CryptoKeyRSA&gt;(key), data, WTF::move(callback), WTF::move(failureCallback), ec);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CryptoAlgorithmRSAES_PKCS1_v1_5::generateKey(const CryptoAlgorithmParameters&amp; parameters, bool extractable, CryptoKeyUsage usages, KeyOrKeyPairCallback callback, VoidCallback failureCallback, ExceptionCode&amp;)
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSASSA_PKCS1_v1_5cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp (174357 => 174358)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp        2014-10-06 19:09:55 UTC (rev 174357)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp        2014-10-06 19:20:19 UTC (rev 174358)
</span><span class="lines">@@ -61,10 +61,9 @@
</span><span class="cx"> {
</span><span class="cx">     if (key.algorithmIdentifier() != s_identifier)
</span><span class="cx">         return false;
</span><del>-    ASSERT(isCryptoKeyRSA(key));
</del><span class="cx"> 
</span><span class="cx">     CryptoAlgorithmIdentifier keyHash;
</span><del>-    if (toCryptoKeyRSA(key).isRestrictedToHash(keyHash) &amp;&amp; keyHash != algorithmParameters.hash)
</del><ins>+    if (downcast&lt;CryptoKeyRSA&gt;(key).isRestrictedToHash(keyHash) &amp;&amp; keyHash != algorithmParameters.hash)
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     return true;
</span><span class="lines">@@ -79,7 +78,7 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    platformSign(rsaSSAParameters, toCryptoKeyRSA(key), data, WTF::move(callback), WTF::move(failureCallback), ec);
</del><ins>+    platformSign(rsaSSAParameters, downcast&lt;CryptoKeyRSA&gt;(key), data, WTF::move(callback), WTF::move(failureCallback), ec);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CryptoAlgorithmRSASSA_PKCS1_v1_5::verify(const CryptoAlgorithmParameters&amp; parameters, const CryptoKey&amp; key, const CryptoOperationData&amp; signature, const CryptoOperationData&amp; data, BoolCallback callback, VoidCallback failureCallback, ExceptionCode&amp; ec)
</span><span class="lines">@@ -91,7 +90,7 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    platformVerify(rsaSSAParameters, toCryptoKeyRSA(key), signature, data, WTF::move(callback), WTF::move(failureCallback), ec);
</del><ins>+    platformVerify(rsaSSAParameters,  downcast&lt;CryptoKeyRSA&gt;(key), signature, data, WTF::move(callback), WTF::move(failureCallback), ec);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CryptoAlgorithmRSASSA_PKCS1_v1_5::generateKey(const CryptoAlgorithmParameters&amp; parameters, bool extractable, CryptoKeyUsage usages, KeyOrKeyPairCallback callback, VoidCallback failureCallback, ExceptionCode&amp;)
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSA_OAEPcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp (174357 => 174358)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp        2014-10-06 19:09:55 UTC (rev 174357)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp        2014-10-06 19:20:19 UTC (rev 174358)
</span><span class="lines">@@ -61,10 +61,9 @@
</span><span class="cx"> {
</span><span class="cx">     if (key.algorithmIdentifier() != s_identifier)
</span><span class="cx">         return false;
</span><del>-    ASSERT(isCryptoKeyRSA(key));
</del><span class="cx"> 
</span><span class="cx">     CryptoAlgorithmIdentifier keyHash;
</span><del>-    if (toCryptoKeyRSA(key).isRestrictedToHash(keyHash) &amp;&amp; keyHash != algorithmParameters.hash)
</del><ins>+    if (downcast&lt;CryptoKeyRSA&gt;(key).isRestrictedToHash(keyHash) &amp;&amp; keyHash != algorithmParameters.hash)
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     return true;
</span><span class="lines">@@ -79,7 +78,7 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    platformEncrypt(rsaOAEPParameters, toCryptoKeyRSA(key), data, WTF::move(callback), WTF::move(failureCallback), ec);
</del><ins>+    platformEncrypt(rsaOAEPParameters, downcast&lt;CryptoKeyRSA&gt;(key), data, WTF::move(callback), WTF::move(failureCallback), ec);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CryptoAlgorithmRSA_OAEP::decrypt(const CryptoAlgorithmParameters&amp; parameters, const CryptoKey&amp; key, const CryptoOperationData&amp; data, VectorCallback callback, VoidCallback failureCallback, ExceptionCode&amp; ec)
</span><span class="lines">@@ -91,7 +90,7 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    platformDecrypt(rsaOAEPParameters, toCryptoKeyRSA(key), data, WTF::move(callback), WTF::move(failureCallback), ec);
</del><ins>+    platformDecrypt(rsaOAEPParameters, downcast&lt;CryptoKeyRSA&gt;(key), data, WTF::move(callback), WTF::move(failureCallback), ec);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CryptoAlgorithmRSA_OAEP::generateKey(const CryptoAlgorithmParameters&amp; parameters, bool extractable, CryptoKeyUsage usages, KeyOrKeyPairCallback callback, VoidCallback failureCallback, ExceptionCode&amp;)
</span></span></pre></div>
<a id="trunkSourceWebCorecryptokeysCryptoKeyAESh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyAES.h (174357 => 174358)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/keys/CryptoKeyAES.h        2014-10-06 19:09:55 UTC (rev 174357)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyAES.h        2014-10-06 19:20:19 UTC (rev 174358)
</span><span class="lines">@@ -59,16 +59,10 @@
</span><span class="cx">     Vector&lt;uint8_t&gt; m_key;
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-inline bool isCryptoKeyAES(const CryptoKey&amp; key)
-{
-    return key.keyClass() == CryptoKeyClass::AES;
-}
-
-CRYPTO_KEY_TYPE_CASTS(CryptoKeyAES)
-
</del><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><ins>+SPECIALIZE_TYPE_TRAITS_CRYPTO_KEY(CryptoKeyAES, CryptoKeyClass::AES)
+
</ins><span class="cx"> #endif // ENABLE(SUBTLE_CRYPTO)
</span><span class="cx"> 
</span><del>-
</del><span class="cx"> #endif // CryptoKeyAES_h
</span></span></pre></div>
<a id="trunkSourceWebCorecryptokeysCryptoKeyHMACh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.h (174357 => 174358)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.h        2014-10-06 19:09:55 UTC (rev 174357)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.h        2014-10-06 19:20:19 UTC (rev 174358)
</span><span class="lines">@@ -60,14 +60,9 @@
</span><span class="cx">     Vector&lt;uint8_t&gt; m_key;
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-inline bool isCryptoKeyHMAC(const CryptoKey&amp; key)
-{
-    return key.keyClass() == CryptoKeyClass::HMAC;
-}
-
-CRYPTO_KEY_TYPE_CASTS(CryptoKeyHMAC)
-
</del><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><ins>+SPECIALIZE_TYPE_TRAITS_CRYPTO_KEY(CryptoKeyHMAC, CryptoKeyClass::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 (174357 => 174358)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/keys/CryptoKeyRSA.h        2014-10-06 19:09:55 UTC (rev 174357)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyRSA.h        2014-10-06 19:20:19 UTC (rev 174358)
</span><span class="lines">@@ -81,14 +81,9 @@
</span><span class="cx">     CryptoAlgorithmIdentifier m_hash;
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-inline bool isCryptoKeyRSA(const CryptoKey&amp; key)
-{
-    return key.keyClass() == CryptoKeyClass::RSA;
-}
-
-CRYPTO_KEY_TYPE_CASTS(CryptoKeyRSA)
-
</del><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><ins>+SPECIALIZE_TYPE_TRAITS_CRYPTO_KEY(CryptoKeyRSA, CryptoKeyClass::RSA)
+
</ins><span class="cx"> #endif // ENABLE(SUBTLE_CRYPTO)
</span><span class="cx"> #endif // CryptoKeyRSA_h
</span></span></pre>
</div>
</div>

</body>
</html>