Title: [159213] trunk/Source/WebCore
Revision
159213
Author
[email protected]
Date
2013-11-13 11:33:15 -0800 (Wed, 13 Nov 2013)

Log Message

Check WebCrypto parameter types when casting
https://bugs.webkit.org/show_bug.cgi?id=124297

Reviewed by Sam Weinig.

Also changed existing toCryptoXXX functions to use TYPE_CASTS_BASE mechanism.

* bindings/js/JSCryptoAlgorithmDictionary.cpp:
(WebCore::JSCryptoAlgorithmDictionary::createParametersForImportKey):
And sure enough, there was a bug caught by the added checks.

* bindings/js/JSCryptoKeySerializationJWK.cpp:
(WebCore::JSCryptoKeySerializationJWK::reconcileAlgorithm):
* crypto/CryptoAlgorithmParameters.h:
(WebCore::CryptoAlgorithmParameters::ENUM_CLASS):
(WebCore::CryptoAlgorithmParameters::parametersClass):
* crypto/CryptoKey.h:
* crypto/CryptoKeyData.h:
* crypto/CryptoKeySerialization.h:
* crypto/algorithms/CryptoAlgorithmAES_CBC.cpp:
(WebCore::CryptoAlgorithmAES_CBC::generateKey):
* crypto/algorithms/CryptoAlgorithmHMAC.cpp:
(WebCore::CryptoAlgorithmHMAC::generateKey):
(WebCore::CryptoAlgorithmHMAC::importKey):
* crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp:
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::importKey):
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::generateKey):
* crypto/keys/CryptoKeyAES.h:
* crypto/keys/CryptoKeyDataOctetSequence.h:
(WebCore::isCryptoKeyDataOctetSequence):
* crypto/keys/CryptoKeyDataRSAComponents.h:
(WebCore::isCryptoKeyDataRSAComponents):
* crypto/keys/CryptoKeyHMAC.h:
* crypto/keys/CryptoKeyRSA.h:
* crypto/keys/CryptoKeySerializationRaw.h:
* crypto/mac/CryptoAlgorithmAES_CBCMac.cpp:
(WebCore::CryptoAlgorithmAES_CBC::encrypt):
(WebCore::CryptoAlgorithmAES_CBC::decrypt):
* crypto/mac/CryptoAlgorithmHMACMac.cpp:
(WebCore::CryptoAlgorithmHMAC::sign):
(WebCore::CryptoAlgorithmHMAC::verify):
* crypto/parameters/CryptoAlgorithmAesCbcParams.h:
* crypto/parameters/CryptoAlgorithmAesKeyGenParams.h:
* crypto/parameters/CryptoAlgorithmHmacKeyParams.h:
* crypto/parameters/CryptoAlgorithmHmacParams.h:
* crypto/parameters/CryptoAlgorithmRsaKeyGenParams.h:
* crypto/parameters/CryptoAlgorithmRsaSsaKeyParams.h:
* crypto/parameters/CryptoAlgorithmRsaSsaParams.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (159212 => 159213)


--- trunk/Source/WebCore/ChangeLog	2013-11-13 19:23:01 UTC (rev 159212)
+++ trunk/Source/WebCore/ChangeLog	2013-11-13 19:33:15 UTC (rev 159213)
@@ -1,5 +1,56 @@
 2013-11-13  Alexey Proskuryakov  <[email protected]>
 
+        Check WebCrypto parameter types when casting
+        https://bugs.webkit.org/show_bug.cgi?id=124297
+
+        Reviewed by Sam Weinig.
+
+        Also changed existing toCryptoXXX functions to use TYPE_CASTS_BASE mechanism.
+
+        * bindings/js/JSCryptoAlgorithmDictionary.cpp:
+        (WebCore::JSCryptoAlgorithmDictionary::createParametersForImportKey):
+        And sure enough, there was a bug caught by the added checks.
+
+        * bindings/js/JSCryptoKeySerializationJWK.cpp:
+        (WebCore::JSCryptoKeySerializationJWK::reconcileAlgorithm):
+        * crypto/CryptoAlgorithmParameters.h:
+        (WebCore::CryptoAlgorithmParameters::ENUM_CLASS):
+        (WebCore::CryptoAlgorithmParameters::parametersClass):
+        * crypto/CryptoKey.h:
+        * crypto/CryptoKeyData.h:
+        * crypto/CryptoKeySerialization.h:
+        * crypto/algorithms/CryptoAlgorithmAES_CBC.cpp:
+        (WebCore::CryptoAlgorithmAES_CBC::generateKey):
+        * crypto/algorithms/CryptoAlgorithmHMAC.cpp:
+        (WebCore::CryptoAlgorithmHMAC::generateKey):
+        (WebCore::CryptoAlgorithmHMAC::importKey):
+        * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp:
+        (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::importKey):
+        (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::generateKey):
+        * crypto/keys/CryptoKeyAES.h:
+        * crypto/keys/CryptoKeyDataOctetSequence.h:
+        (WebCore::isCryptoKeyDataOctetSequence):
+        * crypto/keys/CryptoKeyDataRSAComponents.h:
+        (WebCore::isCryptoKeyDataRSAComponents):
+        * crypto/keys/CryptoKeyHMAC.h:
+        * crypto/keys/CryptoKeyRSA.h:
+        * crypto/keys/CryptoKeySerializationRaw.h:
+        * crypto/mac/CryptoAlgorithmAES_CBCMac.cpp:
+        (WebCore::CryptoAlgorithmAES_CBC::encrypt):
+        (WebCore::CryptoAlgorithmAES_CBC::decrypt):
+        * crypto/mac/CryptoAlgorithmHMACMac.cpp:
+        (WebCore::CryptoAlgorithmHMAC::sign):
+        (WebCore::CryptoAlgorithmHMAC::verify):
+        * crypto/parameters/CryptoAlgorithmAesCbcParams.h:
+        * crypto/parameters/CryptoAlgorithmAesKeyGenParams.h:
+        * crypto/parameters/CryptoAlgorithmHmacKeyParams.h:
+        * crypto/parameters/CryptoAlgorithmHmacParams.h:
+        * crypto/parameters/CryptoAlgorithmRsaKeyGenParams.h:
+        * crypto/parameters/CryptoAlgorithmRsaSsaKeyParams.h:
+        * crypto/parameters/CryptoAlgorithmRsaSsaParams.h:
+
+2013-11-13  Alexey Proskuryakov  <[email protected]>
+
         crypto/subtle/rsassa-pkcs1-v1_5-import-jwk.html is failing on Maverics release bot
         https://bugs.webkit.org/show_bug.cgi?id=124280
 

Modified: trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmDictionary.cpp (159212 => 159213)


--- trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmDictionary.cpp	2013-11-13 19:23:01 UTC (rev 159212)
+++ trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmDictionary.cpp	2013-11-13 19:33:15 UTC (rev 159213)
@@ -538,7 +538,7 @@
     case CryptoAlgorithmIdentifier::AES_CFB:
         return std::make_unique<CryptoAlgorithmParameters>();
     case CryptoAlgorithmIdentifier::HMAC:
-        return createHmacKeyParams(exec, value);
+        return createHmacParams(exec, value);
     case CryptoAlgorithmIdentifier::DH:
         return std::make_unique<CryptoAlgorithmParameters>();
     case CryptoAlgorithmIdentifier::SHA_1:

Modified: trunk/Source/WebCore/bindings/js/JSCryptoKeySerializationJWK.cpp (159212 => 159213)


--- trunk/Source/WebCore/bindings/js/JSCryptoKeySerializationJWK.cpp	2013-11-13 19:23:01 UTC (rev 159212)
+++ trunk/Source/WebCore/bindings/js/JSCryptoKeySerializationJWK.cpp	2013-11-13 19:33:15 UTC (rev 159213)
@@ -212,10 +212,10 @@
         return false;
 
     if (algorithm->identifier() == CryptoAlgorithmIdentifier::HMAC)
-        return static_cast<CryptoAlgorithmHmacParams&>(*parameters).hash == static_cast<CryptoAlgorithmHmacParams&>(*suggestedParameters).hash;
+        return toCryptoAlgorithmHmacParams(*parameters).hash == toCryptoAlgorithmHmacParams(*suggestedParameters).hash;
     if (algorithm->identifier() == CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5) {
-        CryptoAlgorithmRsaSsaKeyParams& rsaSSAParameters = static_cast<CryptoAlgorithmRsaSsaKeyParams&>(*parameters);
-        CryptoAlgorithmRsaSsaKeyParams& suggestedRSASSAParameters = static_cast<CryptoAlgorithmRsaSsaKeyParams&>(*suggestedParameters);
+        CryptoAlgorithmRsaSsaKeyParams& rsaSSAParameters = toCryptoAlgorithmRsaSsaKeyParams(*parameters);
+        CryptoAlgorithmRsaSsaKeyParams& suggestedRSASSAParameters = toCryptoAlgorithmRsaSsaKeyParams(*suggestedParameters);
         ASSERT(rsaSSAParameters.hasHash);
         if (suggestedRSASSAParameters.hasHash)
             return suggestedRSASSAParameters.hash == rsaSSAParameters.hash;

Modified: trunk/Source/WebCore/crypto/CryptoAlgorithmParameters.h (159212 => 159213)


--- trunk/Source/WebCore/crypto/CryptoAlgorithmParameters.h	2013-11-13 19:23:01 UTC (rev 159212)
+++ trunk/Source/WebCore/crypto/CryptoAlgorithmParameters.h	2013-11-13 19:33:15 UTC (rev 159213)
@@ -37,8 +37,23 @@
 public:
     CryptoAlgorithmParameters() { }
     virtual ~CryptoAlgorithmParameters() { }
+
+    ENUM_CLASS(Class) {
+        None,
+        AesCbcParams,
+        AesKeyGenParams,
+        HmacKeyParams,
+        HmacParams,
+        RsaKeyGenParams,
+        RsaSsaKeyParams,
+        RsaSsaParams
+    };
+    virtual Class parametersClass() const { return Class::None; }
 };
 
+#define CRYPTO_ALGORITHM_PARAMETERS_CASTS(ToClassName) \
+    TYPE_CASTS_BASE(CryptoAlgorithm##ToClassName, CryptoAlgorithmParameters, parameters, parameters->parametersClass() == CryptoAlgorithmParameters::Class::ToClassName, parameters.parametersClass() == CryptoAlgorithmParameters::Class::ToClassName)
+
 }
 
 #endif // ENABLE(SUBTLE_CRYPTO)

Modified: trunk/Source/WebCore/crypto/CryptoKey.h (159212 => 159213)


--- trunk/Source/WebCore/crypto/CryptoKey.h	2013-11-13 19:23:01 UTC (rev 159212)
+++ trunk/Source/WebCore/crypto/CryptoKey.h	2013-11-13 19:33:15 UTC (rev 159213)
@@ -68,6 +68,9 @@
     CryptoKeyUsage m_usages;
 };
 
+#define CRYPTO_KEY_TYPE_CASTS(ToClassName) \
+    TYPE_CASTS_BASE(ToClassName, CryptoKey, key, WebCore::is##ToClassName(*key), WebCore::is##ToClassName(key))
+
 } // namespace WebCore
 
 #endif // ENABLE(SUBTLE_CRYPTO)

Modified: trunk/Source/WebCore/crypto/CryptoKeyData.h (159212 => 159213)


--- trunk/Source/WebCore/crypto/CryptoKeyData.h	2013-11-13 19:23:01 UTC (rev 159212)
+++ trunk/Source/WebCore/crypto/CryptoKeyData.h	2013-11-13 19:33:15 UTC (rev 159213)
@@ -33,7 +33,7 @@
 namespace WebCore {
 
 class CryptoKeyData {
-WTF_MAKE_NONCOPYABLE(CryptoKeyData);
+    WTF_MAKE_NONCOPYABLE(CryptoKeyData);
 public:
     ENUM_CLASS(Format) {
         OctetSequence,
@@ -52,6 +52,9 @@
     Format m_format;
 };
 
+#define CRYPTO_KEY_DATA_CASTS(ToClassName) \
+    TYPE_CASTS_BASE(ToClassName, CryptoKeyData, keyData, WebCore::is##ToClassName(*keyData), WebCore::is##ToClassName(keyData))
+
 } // namespace WebCore
 
 #endif // ENABLE(SUBTLE_CRYPTO)

Modified: trunk/Source/WebCore/crypto/CryptoKeySerialization.h (159212 => 159213)


--- trunk/Source/WebCore/crypto/CryptoKeySerialization.h	2013-11-13 19:23:01 UTC (rev 159212)
+++ trunk/Source/WebCore/crypto/CryptoKeySerialization.h	2013-11-13 19:33:15 UTC (rev 159213)
@@ -40,7 +40,7 @@
 typedef std::pair<const char*, size_t> CryptoOperationData;
 
 class CryptoKeySerialization {
-WTF_MAKE_NONCOPYABLE(CryptoKeySerialization);
+    WTF_MAKE_NONCOPYABLE(CryptoKeySerialization);
 public:
     CryptoKeySerialization() { }
     virtual ~CryptoKeySerialization() { }

Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.cpp (159212 => 159213)


--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.cpp	2013-11-13 19:23:01 UTC (rev 159212)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.cpp	2013-11-13 19:33:15 UTC (rev 159213)
@@ -58,7 +58,7 @@
 
 void CryptoAlgorithmAES_CBC::generateKey(const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsage usages, std::unique_ptr<PromiseWrapper> promise, ExceptionCode&)
 {
-    const CryptoAlgorithmAesKeyGenParams& aesParameters = static_cast<const CryptoAlgorithmAesKeyGenParams&>(parameters);
+    const CryptoAlgorithmAesKeyGenParams& aesParameters = toCryptoAlgorithmAesKeyGenParams(parameters);
 
     RefPtr<CryptoKeyAES> result = CryptoKeyAES::generate(CryptoAlgorithmIdentifier::AES_CBC, aesParameters.length, extractable, usages);
     if (!result) {

Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp (159212 => 159213)


--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp	2013-11-13 19:23:01 UTC (rev 159212)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp	2013-11-13 19:33:15 UTC (rev 159213)
@@ -59,7 +59,7 @@
 
 void CryptoAlgorithmHMAC::generateKey(const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsage usages, std::unique_ptr<PromiseWrapper> promise, ExceptionCode&)
 {
-    const CryptoAlgorithmHmacKeyParams& hmacParameters = static_cast<const CryptoAlgorithmHmacKeyParams&>(parameters);
+    const CryptoAlgorithmHmacKeyParams& hmacParameters = toCryptoAlgorithmHmacKeyParams(parameters);
 
     RefPtr<CryptoKeyHMAC> result = CryptoKeyHMAC::generate(hmacParameters.hasLength ? hmacParameters.length : 0, hmacParameters.hash, extractable, usages);
     if (!result) {
@@ -78,7 +78,7 @@
     }
     const CryptoKeyDataOctetSequence& keyDataOctetSequence = toCryptoKeyDataOctetSequence(keyData);
 
-    const CryptoAlgorithmHmacParams& hmacParameters = static_cast<const CryptoAlgorithmHmacParams&>(parameters);
+    const CryptoAlgorithmHmacParams& hmacParameters = toCryptoAlgorithmHmacParams(parameters);
 
     RefPtr<CryptoKeyHMAC> result = CryptoKeyHMAC::create(keyDataOctetSequence.octetSequence(), hmacParameters.hash, extractable, usage);
     promise->fulfill(result.release());

Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp (159212 => 159213)


--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp	2013-11-13 19:23:01 UTC (rev 159212)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp	2013-11-13 19:33:15 UTC (rev 159213)
@@ -58,7 +58,7 @@
 
 void CryptoAlgorithmRSASSA_PKCS1_v1_5::importKey(const CryptoAlgorithmParameters& parameters, const CryptoKeyData& keyData, bool extractable, CryptoKeyUsage usage, std::unique_ptr<PromiseWrapper> promise, ExceptionCode&)
 {
-    const CryptoAlgorithmRsaSsaKeyParams& rsaSSAParameters = static_cast<const CryptoAlgorithmRsaSsaKeyParams&>(parameters);
+    const CryptoAlgorithmRsaSsaKeyParams& rsaSSAParameters = toCryptoAlgorithmRsaSsaKeyParams(parameters);
     const CryptoKeyDataRSAComponents& rsaComponents = toCryptoKeyDataRSAComponents(keyData);
 
     RefPtr<CryptoKeyRSA> result = CryptoKeyRSA::create(CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5, rsaComponents, extractable, usage);
@@ -75,7 +75,7 @@
 
 void CryptoAlgorithmRSASSA_PKCS1_v1_5::generateKey(const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsage usages, std::unique_ptr<PromiseWrapper> promise, ExceptionCode&)
 {
-    const CryptoAlgorithmRsaKeyGenParams& rsaParameters = static_cast<const CryptoAlgorithmRsaKeyGenParams&>(parameters);
+    const CryptoAlgorithmRsaKeyGenParams& rsaParameters = toCryptoAlgorithmRsaKeyGenParams(parameters);
 
     CryptoKeyRSA::generatePair(CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5, rsaParameters.modulusLength, rsaParameters.publicExponent, extractable, usages, std::move(promise));
 }

Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyAES.h (159212 => 159213)


--- trunk/Source/WebCore/crypto/keys/CryptoKeyAES.h	2013-11-13 19:23:01 UTC (rev 159212)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyAES.h	2013-11-13 19:33:15 UTC (rev 159213)
@@ -61,18 +61,8 @@
     return key.keyClass() == CryptoKeyClass::AES;
 }
 
-inline const CryptoKeyAES& toCryptoKeyAES(const CryptoKey& key)
-{
-    ASSERT_WITH_SECURITY_IMPLICATION(isCryptoKeyAES(key));
-    return static_cast<const CryptoKeyAES&>(key);
-}
+CRYPTO_KEY_TYPE_CASTS(CryptoKeyAES)
 
-inline CryptoKeyAES& toCryptoKeyAES(CryptoKey& key)
-{
-    ASSERT_WITH_SECURITY_IMPLICATION(isCryptoKeyAES(key));
-    return static_cast<CryptoKeyAES&>(key);
-}
-
 } // namespace WebCore
 
 #endif // ENABLE(SUBTLE_CRYPTO)

Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyDataOctetSequence.h (159212 => 159213)


--- trunk/Source/WebCore/crypto/keys/CryptoKeyDataOctetSequence.h	2013-11-13 19:23:01 UTC (rev 159212)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyDataOctetSequence.h	2013-11-13 19:33:15 UTC (rev 159213)
@@ -49,12 +49,13 @@
     Vector<char> m_keyData;
 };
 
-inline const CryptoKeyDataOctetSequence& toCryptoKeyDataOctetSequence(const CryptoKeyData& data)
+inline bool isCryptoKeyDataOctetSequence(const CryptoKeyData& data)
 {
-    ASSERT(data.format() == CryptoKeyData::Format::OctetSequence);
-    return static_cast<const CryptoKeyDataOctetSequence&>(data);
+    return data.format() == CryptoKeyData::Format::OctetSequence;
 }
 
+CRYPTO_KEY_DATA_CASTS(CryptoKeyDataOctetSequence)
+
 } // namespace WebCore
 
 #endif // ENABLE(SUBTLE_CRYPTO)

Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyDataRSAComponents.h (159212 => 159213)


--- trunk/Source/WebCore/crypto/keys/CryptoKeyDataRSAComponents.h	2013-11-13 19:23:01 UTC (rev 159212)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyDataRSAComponents.h	2013-11-13 19:33:15 UTC (rev 159213)
@@ -95,12 +95,13 @@
     Vector<PrimeInfo> m_otherPrimeInfos; // When three or more primes have been used, the number of array elements is be the number of primes used minus two.
 };
 
-inline const CryptoKeyDataRSAComponents& toCryptoKeyDataRSAComponents(const CryptoKeyData& data)
+inline bool isCryptoKeyDataRSAComponents(const CryptoKeyData& data)
 {
-    ASSERT(data.format() == CryptoKeyData::Format::RSAComponents);
-    return static_cast<const CryptoKeyDataRSAComponents&>(data);
+    return data.format() == CryptoKeyData::Format::RSAComponents;
 }
 
+CRYPTO_KEY_DATA_CASTS(CryptoKeyDataRSAComponents)
+
 } // namespace WebCore
 
 #endif // ENABLE(SUBTLE_CRYPTO)

Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.h (159212 => 159213)


--- trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.h	2013-11-13 19:23:01 UTC (rev 159212)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.h	2013-11-13 19:33:15 UTC (rev 159213)
@@ -62,18 +62,8 @@
     return key.keyClass() == CryptoKeyClass::HMAC;
 }
 
-inline const CryptoKeyHMAC& toCryptoKeyHMAC(const CryptoKey& key)
-{
-    ASSERT_WITH_SECURITY_IMPLICATION(isCryptoKeyHMAC(key));
-    return static_cast<const CryptoKeyHMAC&>(key);
-}
+CRYPTO_KEY_TYPE_CASTS(CryptoKeyHMAC)
 
-inline CryptoKeyHMAC& toCryptoKeyHMAC(CryptoKey& key)
-{
-    ASSERT_WITH_SECURITY_IMPLICATION(isCryptoKeyHMAC(key));
-    return static_cast<CryptoKeyHMAC&>(key);
-}
-
 } // namespace WebCore
 
 #endif // ENABLE(SUBTLE_CRYPTO)

Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyRSA.h (159212 => 159213)


--- trunk/Source/WebCore/crypto/keys/CryptoKeyRSA.h	2013-11-13 19:23:01 UTC (rev 159212)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyRSA.h	2013-11-13 19:33:15 UTC (rev 159213)
@@ -74,18 +74,8 @@
     return key.keyClass() == CryptoKeyClass::RSA;
 }
 
-inline const CryptoKeyRSA& toCryptoKeyRSA(const CryptoKey& key)
-{
-    ASSERT_WITH_SECURITY_IMPLICATION(isCryptoKeyRSA(key));
-    return static_cast<const CryptoKeyRSA&>(key);
-}
+CRYPTO_KEY_TYPE_CASTS(CryptoKeyRSA)
 
-inline CryptoKeyRSA& asCryptoKeyRSA(CryptoKey& key)
-{
-    ASSERT_WITH_SECURITY_IMPLICATION(isCryptoKeyRSA(key));
-    return static_cast<CryptoKeyRSA&>(key);
-}
-
 } // namespace WebCore
 
 #endif // ENABLE(SUBTLE_CRYPTO)

Modified: trunk/Source/WebCore/crypto/keys/CryptoKeySerializationRaw.h (159212 => 159213)


--- trunk/Source/WebCore/crypto/keys/CryptoKeySerializationRaw.h	2013-11-13 19:23:01 UTC (rev 159212)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeySerializationRaw.h	2013-11-13 19:33:15 UTC (rev 159213)
@@ -35,7 +35,7 @@
 namespace WebCore {
 
 class CryptoKeySerializationRaw FINAL : public CryptoKeySerialization {
-WTF_MAKE_NONCOPYABLE(CryptoKeySerializationRaw);
+    WTF_MAKE_NONCOPYABLE(CryptoKeySerializationRaw);
 public:
     static std::unique_ptr<CryptoKeySerializationRaw> create(const CryptoOperationData& data)
     {
@@ -44,6 +44,9 @@
 
     virtual ~CryptoKeySerializationRaw();
 
+private:
+    CryptoKeySerializationRaw(const CryptoOperationData&);
+
     virtual bool reconcileAlgorithm(std::unique_ptr<CryptoAlgorithm>&, std::unique_ptr<CryptoAlgorithmParameters>&) const OVERRIDE;
 
     virtual void reconcileUsages(CryptoKeyUsage&) const OVERRIDE;
@@ -51,9 +54,6 @@
 
     virtual std::unique_ptr<CryptoKeyData> keyData() const OVERRIDE;
 
-private:
-    CryptoKeySerializationRaw(const CryptoOperationData&);
-
     Vector<char> m_data;
 };
 

Modified: trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_CBCMac.cpp (159212 => 159213)


--- trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_CBCMac.cpp	2013-11-13 19:23:01 UTC (rev 159212)
+++ trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_CBCMac.cpp	2013-11-13 19:33:15 UTC (rev 159213)
@@ -91,7 +91,7 @@
 
 void CryptoAlgorithmAES_CBC::encrypt(const CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<CryptoOperationData>& data, std::unique_ptr<PromiseWrapper> promise, ExceptionCode& ec)
 {
-    const CryptoAlgorithmAesCbcParams& aesCBCParameters = static_cast<const CryptoAlgorithmAesCbcParams&>(parameters);
+    const CryptoAlgorithmAesCbcParams& aesCBCParameters = toCryptoAlgorithmAesCbcParams(parameters);
 
     if (!isCryptoKeyAES(key)) {
         ec = NOT_SUPPORTED_ERR;
@@ -104,7 +104,7 @@
 
 void CryptoAlgorithmAES_CBC::decrypt(const CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<CryptoOperationData>& data, std::unique_ptr<PromiseWrapper> promise, ExceptionCode& ec)
 {
-    const CryptoAlgorithmAesCbcParams& aesCBCParameters = static_cast<const CryptoAlgorithmAesCbcParams&>(parameters);
+    const CryptoAlgorithmAesCbcParams& aesCBCParameters = toCryptoAlgorithmAesCbcParams(parameters);
 
     if (!isCryptoKeyAES(key)) {
         ec = NOT_SUPPORTED_ERR;

Modified: trunk/Source/WebCore/crypto/mac/CryptoAlgorithmHMACMac.cpp (159212 => 159213)


--- trunk/Source/WebCore/crypto/mac/CryptoAlgorithmHMACMac.cpp	2013-11-13 19:23:01 UTC (rev 159212)
+++ trunk/Source/WebCore/crypto/mac/CryptoAlgorithmHMACMac.cpp	2013-11-13 19:33:15 UTC (rev 159213)
@@ -94,7 +94,7 @@
 
 void CryptoAlgorithmHMAC::sign(const CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<CryptoOperationData>& data, std::unique_ptr<PromiseWrapper> promise, ExceptionCode& ec)
 {
-    const CryptoAlgorithmHmacParams& hmacParameters = static_cast<const CryptoAlgorithmHmacParams&>(parameters);
+    const CryptoAlgorithmHmacParams& hmacParameters = toCryptoAlgorithmHmacParams(parameters);
 
     if (!isCryptoKeyHMAC(key)) {
         ec = NOT_SUPPORTED_ERR;
@@ -115,7 +115,7 @@
 
 void CryptoAlgorithmHMAC::verify(const CryptoAlgorithmParameters& parameters, const CryptoKey& key, const CryptoOperationData& expectedSignature, const Vector<CryptoOperationData>& data, std::unique_ptr<PromiseWrapper> promise, ExceptionCode& ec)
 {
-    const CryptoAlgorithmHmacParams& hmacParameters = static_cast<const CryptoAlgorithmHmacParams&>(parameters);
+    const CryptoAlgorithmHmacParams& hmacParameters = toCryptoAlgorithmHmacParams(parameters);
 
     if (!isCryptoKeyHMAC(key)) {
         ec = NOT_SUPPORTED_ERR;

Modified: trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmAesCbcParams.h (159212 => 159213)


--- trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmAesCbcParams.h	2013-11-13 19:23:01 UTC (rev 159212)
+++ trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmAesCbcParams.h	2013-11-13 19:33:15 UTC (rev 159213)
@@ -37,8 +37,12 @@
 public:
     // The initialization vector. MUST be 16 bytes.
     FixedArray<char, 16> iv;
+
+    virtual Class parametersClass() const OVERRIDE { return Class::AesCbcParams; }
 };
 
+CRYPTO_ALGORITHM_PARAMETERS_CASTS(AesCbcParams)
+
 }
 
 #endif // ENABLE(SUBTLE_CRYPTO)

Modified: trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmAesKeyGenParams.h (159212 => 159213)


--- trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmAesKeyGenParams.h	2013-11-13 19:23:01 UTC (rev 159212)
+++ trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmAesKeyGenParams.h	2013-11-13 19:33:15 UTC (rev 159213)
@@ -36,8 +36,12 @@
 public:
     // The length, in bits, of the key.
     unsigned length;
+
+    virtual Class parametersClass() const OVERRIDE { return Class::AesKeyGenParams; }
 };
 
+CRYPTO_ALGORITHM_PARAMETERS_CASTS(AesKeyGenParams)
+
 }
 
 #endif // ENABLE(SUBTLE_CRYPTO)

Modified: trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmHmacKeyParams.h (159212 => 159213)


--- trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmHmacKeyParams.h	2013-11-13 19:23:01 UTC (rev 159212)
+++ trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmHmacKeyParams.h	2013-11-13 19:33:15 UTC (rev 159213)
@@ -47,8 +47,12 @@
     // which is the size of the associated hash function's block size.
     bool hasLength;
     unsigned length;
+
+    virtual Class parametersClass() const OVERRIDE { return Class::HmacKeyParams; }
 };
 
+CRYPTO_ALGORITHM_PARAMETERS_CASTS(HmacKeyParams)
+
 }
 
 #endif // ENABLE(SUBTLE_CRYPTO)

Modified: trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmHmacParams.h (159212 => 159213)


--- trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmHmacParams.h	2013-11-13 19:23:01 UTC (rev 159212)
+++ trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmHmacParams.h	2013-11-13 19:33:15 UTC (rev 159213)
@@ -37,8 +37,12 @@
 public:
     // The inner hash function to use.
     CryptoAlgorithmIdentifier hash;
+
+    virtual Class parametersClass() const OVERRIDE { return Class::HmacParams; }
 };
 
+CRYPTO_ALGORITHM_PARAMETERS_CASTS(HmacParams)
+
 }
 
 #endif // ENABLE(SUBTLE_CRYPTO)

Modified: trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmRsaKeyGenParams.h (159212 => 159213)


--- trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmRsaKeyGenParams.h	2013-11-13 19:23:01 UTC (rev 159212)
+++ trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmRsaKeyGenParams.h	2013-11-13 19:33:15 UTC (rev 159213)
@@ -38,8 +38,12 @@
     unsigned modulusLength;
     // The RSA public exponent, encoded as BigInteger.
     Vector<char> publicExponent;
+
+    virtual Class parametersClass() const OVERRIDE { return Class::RsaKeyGenParams; }
 };
 
+CRYPTO_ALGORITHM_PARAMETERS_CASTS(RsaKeyGenParams)
+
 }
 
 #endif // ENABLE(SUBTLE_CRYPTO)

Modified: trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmRsaSsaKeyParams.h (159212 => 159213)


--- trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmRsaSsaKeyParams.h	2013-11-13 19:23:01 UTC (rev 159212)
+++ trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmRsaSsaKeyParams.h	2013-11-13 19:33:15 UTC (rev 159213)
@@ -46,8 +46,12 @@
     // The hash algorithm to use.
     bool hasHash;
     CryptoAlgorithmIdentifier hash;
+
+    virtual Class parametersClass() const OVERRIDE { return Class::RsaSsaKeyParams; }
 };
 
+CRYPTO_ALGORITHM_PARAMETERS_CASTS(RsaSsaKeyParams)
+
 }
 
 #endif // ENABLE(SUBTLE_CRYPTO)

Modified: trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmRsaSsaParams.h (159212 => 159213)


--- trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmRsaSsaParams.h	2013-11-13 19:23:01 UTC (rev 159212)
+++ trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmRsaSsaParams.h	2013-11-13 19:33:15 UTC (rev 159213)
@@ -37,8 +37,12 @@
 public:
     // The hash algorithm to use.
     CryptoAlgorithmIdentifier hash;
+
+    virtual Class parametersClass() const OVERRIDE { return Class::RsaSsaParams; }
 };
 
+CRYPTO_ALGORITHM_PARAMETERS_CASTS(RsaSsaParams)
+
 }
 
 #endif // ENABLE(SUBTLE_CRYPTO)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to