Title: [221665] trunk/Source/WebCore
Revision
221665
Author
[email protected]
Date
2017-09-05 23:48:49 -0700 (Tue, 05 Sep 2017)

Log Message

[WebCrypto] Downcast parameters and keys at the platform operation callsites
https://bugs.webkit.org/show_bug.cgi?id=176392

Reviewed by Sam Weinig.

Downcast to algorithm-specific parameter and key types in the shared
code that then invokes platform-specific operation implementations.
This reduces the duplicated downcasts across different implementations
that don't differ at all in this behavior.

Covered by existing tests.

* crypto/algorithms/CryptoAlgorithmAES_CBC.cpp:
(WebCore::CryptoAlgorithmAES_CBC::encrypt):
(WebCore::CryptoAlgorithmAES_CBC::decrypt):
* crypto/algorithms/CryptoAlgorithmAES_CBC.h:
* crypto/algorithms/CryptoAlgorithmAES_CFB.cpp:
(WebCore::CryptoAlgorithmAES_CFB::encrypt):
(WebCore::CryptoAlgorithmAES_CFB::decrypt):
* crypto/algorithms/CryptoAlgorithmAES_CFB.h:
* crypto/algorithms/CryptoAlgorithmAES_CTR.cpp:
(WebCore::CryptoAlgorithmAES_CTR::encrypt):
(WebCore::CryptoAlgorithmAES_CTR::decrypt):
* crypto/algorithms/CryptoAlgorithmAES_CTR.h:
* crypto/algorithms/CryptoAlgorithmAES_GCM.cpp:
(WebCore::CryptoAlgorithmAES_GCM::encrypt):
(WebCore::CryptoAlgorithmAES_GCM::decrypt):
* crypto/algorithms/CryptoAlgorithmAES_GCM.h:
* crypto/algorithms/CryptoAlgorithmAES_KW.cpp:
(WebCore::CryptoAlgorithmAES_KW::wrapKey):
(WebCore::CryptoAlgorithmAES_KW::unwrapKey):
* crypto/algorithms/CryptoAlgorithmAES_KW.h:
* crypto/algorithms/CryptoAlgorithmECDH.cpp:
(WebCore::CryptoAlgorithmECDH::deriveBits):
* crypto/algorithms/CryptoAlgorithmECDH.h:
* crypto/algorithms/CryptoAlgorithmECDSA.cpp:
(WebCore::CryptoAlgorithmECDSA::sign):
(WebCore::CryptoAlgorithmECDSA::verify):
* crypto/algorithms/CryptoAlgorithmECDSA.h:
* crypto/algorithms/CryptoAlgorithmHKDF.cpp:
(WebCore::CryptoAlgorithmHKDF::deriveBits):
* crypto/algorithms/CryptoAlgorithmHKDF.h:
* crypto/algorithms/CryptoAlgorithmHMAC.cpp:
(WebCore::CryptoAlgorithmHMAC::sign):
(WebCore::CryptoAlgorithmHMAC::verify):
* crypto/algorithms/CryptoAlgorithmHMAC.h:
* crypto/algorithms/CryptoAlgorithmPBKDF2.cpp:
(WebCore::CryptoAlgorithmPBKDF2::deriveBits):
* crypto/algorithms/CryptoAlgorithmPBKDF2.h:
* crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp:
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::encrypt):
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::decrypt):
* crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h:
* crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp:
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::sign):
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::verify):
* crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h:
* crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp:
(WebCore::CryptoAlgorithmRSA_OAEP::encrypt):
(WebCore::CryptoAlgorithmRSA_OAEP::decrypt):
* crypto/algorithms/CryptoAlgorithmRSA_OAEP.h:
* crypto/algorithms/CryptoAlgorithmRSA_PSS.cpp:
(WebCore::CryptoAlgorithmRSA_PSS::sign):
(WebCore::CryptoAlgorithmRSA_PSS::verify):
* crypto/algorithms/CryptoAlgorithmRSA_PSS.h:
* crypto/gcrypt/CryptoAlgorithmAES_CBCGCrypt.cpp:
(WebCore::CryptoAlgorithmAES_CBC::platformEncrypt):
(WebCore::CryptoAlgorithmAES_CBC::platformDecrypt):
* crypto/gcrypt/CryptoAlgorithmAES_CFBGCrypt.cpp:
(WebCore::CryptoAlgorithmAES_CFB::platformEncrypt):
(WebCore::CryptoAlgorithmAES_CFB::platformDecrypt):
* crypto/gcrypt/CryptoAlgorithmAES_CTRGCrypt.cpp:
(WebCore::CryptoAlgorithmAES_CTR::platformEncrypt):
(WebCore::CryptoAlgorithmAES_CTR::platformDecrypt):
* crypto/gcrypt/CryptoAlgorithmAES_GCMGCrypt.cpp:
(WebCore::CryptoAlgorithmAES_GCM::platformEncrypt):
(WebCore::CryptoAlgorithmAES_GCM::platformDecrypt):
* crypto/gcrypt/CryptoAlgorithmAES_KWGCrypt.cpp:
(WebCore::CryptoAlgorithmAES_KW::platformWrapKey):
(WebCore::CryptoAlgorithmAES_KW::platformUnwrapKey):
* crypto/gcrypt/CryptoAlgorithmECDHGCrypt.cpp:
(WebCore::CryptoAlgorithmECDH::platformDeriveBits):
* crypto/gcrypt/CryptoAlgorithmECDSAGCrypt.cpp:
(WebCore::CryptoAlgorithmECDSA::platformSign):
(WebCore::CryptoAlgorithmECDSA::platformVerify):
* crypto/gcrypt/CryptoAlgorithmHKDFGCrypt.cpp:
(WebCore::CryptoAlgorithmHKDF::platformDeriveBits):
* crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp:
(WebCore::CryptoAlgorithmHMAC::platformSign):
(WebCore::CryptoAlgorithmHMAC::platformVerify):
* crypto/gcrypt/CryptoAlgorithmPBKDF2GCrypt.cpp:
(WebCore::CryptoAlgorithmPBKDF2::platformDeriveBits):
* crypto/gcrypt/CryptoAlgorithmRSAES_PKCS1_v1_5GCrypt.cpp:
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt):
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::platformDecrypt):
* crypto/gcrypt/CryptoAlgorithmRSASSA_PKCS1_v1_5GCrypt.cpp:
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign):
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerify):
* crypto/gcrypt/CryptoAlgorithmRSA_OAEPGCrypt.cpp:
(WebCore::CryptoAlgorithmRSA_OAEP::platformEncrypt):
(WebCore::CryptoAlgorithmRSA_OAEP::platformDecrypt):
* crypto/gcrypt/CryptoAlgorithmRSA_PSSGCrypt.cpp:
(WebCore::CryptoAlgorithmRSA_PSS::platformSign):
(WebCore::CryptoAlgorithmRSA_PSS::platformVerify):
* crypto/mac/CryptoAlgorithmAES_CBCMac.cpp:
(WebCore::CryptoAlgorithmAES_CBC::platformEncrypt):
(WebCore::CryptoAlgorithmAES_CBC::platformDecrypt):
* crypto/mac/CryptoAlgorithmAES_CFBMac.cpp:
(WebCore::CryptoAlgorithmAES_CFB::platformEncrypt):
(WebCore::CryptoAlgorithmAES_CFB::platformDecrypt):
* crypto/mac/CryptoAlgorithmAES_CTRMac.cpp:
(WebCore::CryptoAlgorithmAES_CTR::platformEncrypt):
(WebCore::CryptoAlgorithmAES_CTR::platformDecrypt):
* crypto/mac/CryptoAlgorithmAES_GCMMac.cpp:
(WebCore::CryptoAlgorithmAES_GCM::platformEncrypt):
(WebCore::CryptoAlgorithmAES_GCM::platformDecrypt):
* crypto/mac/CryptoAlgorithmAES_KWMac.cpp:
(WebCore::CryptoAlgorithmAES_KW::platformWrapKey):
(WebCore::CryptoAlgorithmAES_KW::platformUnwrapKey):
* crypto/mac/CryptoAlgorithmECDHMac.cpp:
(WebCore::CryptoAlgorithmECDH::platformDeriveBits):
* crypto/mac/CryptoAlgorithmECDSAMac.cpp:
(WebCore::CryptoAlgorithmECDSA::platformSign):
(WebCore::CryptoAlgorithmECDSA::platformVerify):
* crypto/mac/CryptoAlgorithmHKDFMac.cpp:
(WebCore::CryptoAlgorithmHKDF::platformDeriveBits):
* crypto/mac/CryptoAlgorithmHMACMac.cpp:
(WebCore::CryptoAlgorithmHMAC::platformSign):
(WebCore::CryptoAlgorithmHMAC::platformVerify):
* crypto/mac/CryptoAlgorithmPBKDF2Mac.cpp:
(WebCore::CryptoAlgorithmPBKDF2::platformDeriveBits):
* crypto/mac/CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp:
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt):
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::platformDecrypt):
* crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp:
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign):
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerify):
* crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp:
(WebCore::CryptoAlgorithmRSA_OAEP::platformEncrypt):
(WebCore::CryptoAlgorithmRSA_OAEP::platformDecrypt):
* crypto/mac/CryptoAlgorithmRSA_PSSMac.cpp:
(WebCore::CryptoAlgorithmRSA_PSS::platformSign):
(WebCore::CryptoAlgorithmRSA_PSS::platformVerify):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (221664 => 221665)


--- trunk/Source/WebCore/ChangeLog	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/ChangeLog	2017-09-06 06:48:49 UTC (rev 221665)
@@ -1,3 +1,149 @@
+2017-09-05  Zan Dobersek  <[email protected]>
+
+        [WebCrypto] Downcast parameters and keys at the platform operation callsites
+        https://bugs.webkit.org/show_bug.cgi?id=176392
+
+        Reviewed by Sam Weinig.
+
+        Downcast to algorithm-specific parameter and key types in the shared
+        code that then invokes platform-specific operation implementations.
+        This reduces the duplicated downcasts across different implementations
+        that don't differ at all in this behavior.
+
+        Covered by existing tests.
+
+        * crypto/algorithms/CryptoAlgorithmAES_CBC.cpp:
+        (WebCore::CryptoAlgorithmAES_CBC::encrypt):
+        (WebCore::CryptoAlgorithmAES_CBC::decrypt):
+        * crypto/algorithms/CryptoAlgorithmAES_CBC.h:
+        * crypto/algorithms/CryptoAlgorithmAES_CFB.cpp:
+        (WebCore::CryptoAlgorithmAES_CFB::encrypt):
+        (WebCore::CryptoAlgorithmAES_CFB::decrypt):
+        * crypto/algorithms/CryptoAlgorithmAES_CFB.h:
+        * crypto/algorithms/CryptoAlgorithmAES_CTR.cpp:
+        (WebCore::CryptoAlgorithmAES_CTR::encrypt):
+        (WebCore::CryptoAlgorithmAES_CTR::decrypt):
+        * crypto/algorithms/CryptoAlgorithmAES_CTR.h:
+        * crypto/algorithms/CryptoAlgorithmAES_GCM.cpp:
+        (WebCore::CryptoAlgorithmAES_GCM::encrypt):
+        (WebCore::CryptoAlgorithmAES_GCM::decrypt):
+        * crypto/algorithms/CryptoAlgorithmAES_GCM.h:
+        * crypto/algorithms/CryptoAlgorithmAES_KW.cpp:
+        (WebCore::CryptoAlgorithmAES_KW::wrapKey):
+        (WebCore::CryptoAlgorithmAES_KW::unwrapKey):
+        * crypto/algorithms/CryptoAlgorithmAES_KW.h:
+        * crypto/algorithms/CryptoAlgorithmECDH.cpp:
+        (WebCore::CryptoAlgorithmECDH::deriveBits):
+        * crypto/algorithms/CryptoAlgorithmECDH.h:
+        * crypto/algorithms/CryptoAlgorithmECDSA.cpp:
+        (WebCore::CryptoAlgorithmECDSA::sign):
+        (WebCore::CryptoAlgorithmECDSA::verify):
+        * crypto/algorithms/CryptoAlgorithmECDSA.h:
+        * crypto/algorithms/CryptoAlgorithmHKDF.cpp:
+        (WebCore::CryptoAlgorithmHKDF::deriveBits):
+        * crypto/algorithms/CryptoAlgorithmHKDF.h:
+        * crypto/algorithms/CryptoAlgorithmHMAC.cpp:
+        (WebCore::CryptoAlgorithmHMAC::sign):
+        (WebCore::CryptoAlgorithmHMAC::verify):
+        * crypto/algorithms/CryptoAlgorithmHMAC.h:
+        * crypto/algorithms/CryptoAlgorithmPBKDF2.cpp:
+        (WebCore::CryptoAlgorithmPBKDF2::deriveBits):
+        * crypto/algorithms/CryptoAlgorithmPBKDF2.h:
+        * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp:
+        (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::encrypt):
+        (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::decrypt):
+        * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h:
+        * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp:
+        (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::sign):
+        (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::verify):
+        * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h:
+        * crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp:
+        (WebCore::CryptoAlgorithmRSA_OAEP::encrypt):
+        (WebCore::CryptoAlgorithmRSA_OAEP::decrypt):
+        * crypto/algorithms/CryptoAlgorithmRSA_OAEP.h:
+        * crypto/algorithms/CryptoAlgorithmRSA_PSS.cpp:
+        (WebCore::CryptoAlgorithmRSA_PSS::sign):
+        (WebCore::CryptoAlgorithmRSA_PSS::verify):
+        * crypto/algorithms/CryptoAlgorithmRSA_PSS.h:
+        * crypto/gcrypt/CryptoAlgorithmAES_CBCGCrypt.cpp:
+        (WebCore::CryptoAlgorithmAES_CBC::platformEncrypt):
+        (WebCore::CryptoAlgorithmAES_CBC::platformDecrypt):
+        * crypto/gcrypt/CryptoAlgorithmAES_CFBGCrypt.cpp:
+        (WebCore::CryptoAlgorithmAES_CFB::platformEncrypt):
+        (WebCore::CryptoAlgorithmAES_CFB::platformDecrypt):
+        * crypto/gcrypt/CryptoAlgorithmAES_CTRGCrypt.cpp:
+        (WebCore::CryptoAlgorithmAES_CTR::platformEncrypt):
+        (WebCore::CryptoAlgorithmAES_CTR::platformDecrypt):
+        * crypto/gcrypt/CryptoAlgorithmAES_GCMGCrypt.cpp:
+        (WebCore::CryptoAlgorithmAES_GCM::platformEncrypt):
+        (WebCore::CryptoAlgorithmAES_GCM::platformDecrypt):
+        * crypto/gcrypt/CryptoAlgorithmAES_KWGCrypt.cpp:
+        (WebCore::CryptoAlgorithmAES_KW::platformWrapKey):
+        (WebCore::CryptoAlgorithmAES_KW::platformUnwrapKey):
+        * crypto/gcrypt/CryptoAlgorithmECDHGCrypt.cpp:
+        (WebCore::CryptoAlgorithmECDH::platformDeriveBits):
+        * crypto/gcrypt/CryptoAlgorithmECDSAGCrypt.cpp:
+        (WebCore::CryptoAlgorithmECDSA::platformSign):
+        (WebCore::CryptoAlgorithmECDSA::platformVerify):
+        * crypto/gcrypt/CryptoAlgorithmHKDFGCrypt.cpp:
+        (WebCore::CryptoAlgorithmHKDF::platformDeriveBits):
+        * crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp:
+        (WebCore::CryptoAlgorithmHMAC::platformSign):
+        (WebCore::CryptoAlgorithmHMAC::platformVerify):
+        * crypto/gcrypt/CryptoAlgorithmPBKDF2GCrypt.cpp:
+        (WebCore::CryptoAlgorithmPBKDF2::platformDeriveBits):
+        * crypto/gcrypt/CryptoAlgorithmRSAES_PKCS1_v1_5GCrypt.cpp:
+        (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt):
+        (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::platformDecrypt):
+        * crypto/gcrypt/CryptoAlgorithmRSASSA_PKCS1_v1_5GCrypt.cpp:
+        (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign):
+        (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerify):
+        * crypto/gcrypt/CryptoAlgorithmRSA_OAEPGCrypt.cpp:
+        (WebCore::CryptoAlgorithmRSA_OAEP::platformEncrypt):
+        (WebCore::CryptoAlgorithmRSA_OAEP::platformDecrypt):
+        * crypto/gcrypt/CryptoAlgorithmRSA_PSSGCrypt.cpp:
+        (WebCore::CryptoAlgorithmRSA_PSS::platformSign):
+        (WebCore::CryptoAlgorithmRSA_PSS::platformVerify):
+        * crypto/mac/CryptoAlgorithmAES_CBCMac.cpp:
+        (WebCore::CryptoAlgorithmAES_CBC::platformEncrypt):
+        (WebCore::CryptoAlgorithmAES_CBC::platformDecrypt):
+        * crypto/mac/CryptoAlgorithmAES_CFBMac.cpp:
+        (WebCore::CryptoAlgorithmAES_CFB::platformEncrypt):
+        (WebCore::CryptoAlgorithmAES_CFB::platformDecrypt):
+        * crypto/mac/CryptoAlgorithmAES_CTRMac.cpp:
+        (WebCore::CryptoAlgorithmAES_CTR::platformEncrypt):
+        (WebCore::CryptoAlgorithmAES_CTR::platformDecrypt):
+        * crypto/mac/CryptoAlgorithmAES_GCMMac.cpp:
+        (WebCore::CryptoAlgorithmAES_GCM::platformEncrypt):
+        (WebCore::CryptoAlgorithmAES_GCM::platformDecrypt):
+        * crypto/mac/CryptoAlgorithmAES_KWMac.cpp:
+        (WebCore::CryptoAlgorithmAES_KW::platformWrapKey):
+        (WebCore::CryptoAlgorithmAES_KW::platformUnwrapKey):
+        * crypto/mac/CryptoAlgorithmECDHMac.cpp:
+        (WebCore::CryptoAlgorithmECDH::platformDeriveBits):
+        * crypto/mac/CryptoAlgorithmECDSAMac.cpp:
+        (WebCore::CryptoAlgorithmECDSA::platformSign):
+        (WebCore::CryptoAlgorithmECDSA::platformVerify):
+        * crypto/mac/CryptoAlgorithmHKDFMac.cpp:
+        (WebCore::CryptoAlgorithmHKDF::platformDeriveBits):
+        * crypto/mac/CryptoAlgorithmHMACMac.cpp:
+        (WebCore::CryptoAlgorithmHMAC::platformSign):
+        (WebCore::CryptoAlgorithmHMAC::platformVerify):
+        * crypto/mac/CryptoAlgorithmPBKDF2Mac.cpp:
+        (WebCore::CryptoAlgorithmPBKDF2::platformDeriveBits):
+        * crypto/mac/CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp:
+        (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt):
+        (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::platformDecrypt):
+        * crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp:
+        (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign):
+        (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerify):
+        * crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp:
+        (WebCore::CryptoAlgorithmRSA_OAEP::platformEncrypt):
+        (WebCore::CryptoAlgorithmRSA_OAEP::platformDecrypt):
+        * crypto/mac/CryptoAlgorithmRSA_PSSMac.cpp:
+        (WebCore::CryptoAlgorithmRSA_PSS::platformSign):
+        (WebCore::CryptoAlgorithmRSA_PSS::platformVerify):
+
 2017-09-05  Darin Adler  <[email protected]>
 
         Fix a few minor problems found while working toward removing unneeded calls to updateStyle

Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -65,7 +65,7 @@
 
     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
         [parameters = WTFMove(parameters), key = WTFMove(key), plainText = WTFMove(plainText)] {
-            return platformEncrypt(*parameters, key, plainText);
+            return platformEncrypt(downcast<CryptoAlgorithmAesCbcCfbParams>(*parameters), downcast<CryptoKeyAES>(key.get()), plainText);
         });
 }
 
@@ -80,7 +80,7 @@
 
     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
         [parameters = WTFMove(parameters), key = WTFMove(key), cipherText = WTFMove(cipherText)] {
-            return platformDecrypt(*parameters, key, cipherText);
+            return platformDecrypt(downcast<CryptoAlgorithmAesCbcCfbParams>(*parameters), downcast<CryptoKeyAES>(key.get()), cipherText);
         });
 }
 

Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.h (221664 => 221665)


--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.h	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.h	2017-09-06 06:48:49 UTC (rev 221665)
@@ -31,6 +31,7 @@
 
 namespace WebCore {
 
+class CryptoAlgorithmAesCbcCfbParams;
 class CryptoKeyAES;
 
 class CryptoAlgorithmAES_CBC final : public CryptoAlgorithm {
@@ -50,8 +51,8 @@
     void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
     ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&) final;
 
-    static ExceptionOr<Vector<uint8_t>> platformEncrypt(CryptoAlgorithmParameters&, const CryptoKey&, const Vector<uint8_t>&);
-    static ExceptionOr<Vector<uint8_t>> platformDecrypt(CryptoAlgorithmParameters&, const CryptoKey&, const Vector<uint8_t>&);
+    static ExceptionOr<Vector<uint8_t>> platformEncrypt(CryptoAlgorithmAesCbcCfbParams&, const CryptoKeyAES&, const Vector<uint8_t>&);
+    static ExceptionOr<Vector<uint8_t>> platformDecrypt(CryptoAlgorithmAesCbcCfbParams&, const CryptoKeyAES&, const Vector<uint8_t>&);
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CFB.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CFB.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CFB.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -65,7 +65,7 @@
 
     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
         [parameters = WTFMove(parameters), key = WTFMove(key), plainText = WTFMove(plainText)] {
-            return platformEncrypt(*parameters, key, plainText);
+            return platformEncrypt(downcast<CryptoAlgorithmAesCbcCfbParams>(*parameters), downcast<CryptoKeyAES>(key.get()), plainText);
         });
 }
 
@@ -80,7 +80,7 @@
 
     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
         [parameters = WTFMove(parameters), key = WTFMove(key), cipherText = WTFMove(cipherText)] {
-            return platformDecrypt(*parameters, key, cipherText);
+            return platformDecrypt(downcast<CryptoAlgorithmAesCbcCfbParams>(*parameters), downcast<CryptoKeyAES>(key.get()), cipherText);
         });
 }
 

Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CFB.h (221664 => 221665)


--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CFB.h	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CFB.h	2017-09-06 06:48:49 UTC (rev 221665)
@@ -31,6 +31,7 @@
 
 namespace WebCore {
 
+class CryptoAlgorithmAesCbcCfbParams;
 class CryptoKeyAES;
 
 class CryptoAlgorithmAES_CFB final : public CryptoAlgorithm {
@@ -50,8 +51,8 @@
     void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
     ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&) final;
 
-    static ExceptionOr<Vector<uint8_t>> platformEncrypt(CryptoAlgorithmParameters&, const CryptoKey&, const Vector<uint8_t>&);
-    static ExceptionOr<Vector<uint8_t>> platformDecrypt(CryptoAlgorithmParameters&, const CryptoKey&, const Vector<uint8_t>&);
+    static ExceptionOr<Vector<uint8_t>> platformEncrypt(CryptoAlgorithmAesCbcCfbParams&, const CryptoKeyAES&, const Vector<uint8_t>&);
+    static ExceptionOr<Vector<uint8_t>> platformDecrypt(CryptoAlgorithmAesCbcCfbParams&, const CryptoKeyAES&, const Vector<uint8_t>&);
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CTR.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CTR.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CTR.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -74,7 +74,7 @@
 
     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
         [parameters = WTFMove(parameters), key = WTFMove(key), plainText = WTFMove(plainText)] {
-            return platformEncrypt(*parameters, key, plainText);
+            return platformEncrypt(downcast<CryptoAlgorithmAesCtrParams>(*parameters), downcast<CryptoKeyAES>(key.get()), plainText);
         });
 }
 
@@ -89,7 +89,7 @@
 
     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
         [parameters = WTFMove(parameters), key = WTFMove(key), cipherText = WTFMove(cipherText)] {
-            return platformDecrypt(*parameters, key, cipherText);
+            return platformDecrypt(downcast<CryptoAlgorithmAesCtrParams>(*parameters), downcast<CryptoKeyAES>(key.get()), cipherText);
         });
 }
 

Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CTR.h (221664 => 221665)


--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CTR.h	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CTR.h	2017-09-06 06:48:49 UTC (rev 221665)
@@ -31,6 +31,7 @@
 
 namespace WebCore {
 
+class CryptoAlgorithmAesCtrParams;
 class CryptoKeyAES;
 
 class CryptoAlgorithmAES_CTR final : public CryptoAlgorithm {
@@ -50,8 +51,8 @@
     void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
     ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&) final;
 
-    static ExceptionOr<Vector<uint8_t>> platformEncrypt(CryptoAlgorithmParameters&, const CryptoKey&, const Vector<uint8_t>&);
-    static ExceptionOr<Vector<uint8_t>> platformDecrypt(CryptoAlgorithmParameters&, const CryptoKey&, const Vector<uint8_t>&);
+    static ExceptionOr<Vector<uint8_t>> platformEncrypt(CryptoAlgorithmAesCtrParams&, const CryptoKeyAES&, const Vector<uint8_t>&);
+    static ExceptionOr<Vector<uint8_t>> platformDecrypt(CryptoAlgorithmAesCtrParams&, const CryptoKeyAES&, const Vector<uint8_t>&);
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_GCM.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_GCM.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_GCM.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -95,7 +95,7 @@
 
     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
         [parameters = WTFMove(parameters), key = WTFMove(key), plainText = WTFMove(plainText)] {
-            return platformEncrypt(*parameters, key, plainText);
+            return platformEncrypt(downcast<CryptoAlgorithmAesGcmParams>(*parameters), downcast<CryptoKeyAES>(key.get()), plainText);
         });
 }
 
@@ -127,7 +127,7 @@
 
     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
         [parameters = WTFMove(parameters), key = WTFMove(key), cipherText = WTFMove(cipherText)] {
-            return platformDecrypt(*parameters, key, cipherText);
+            return platformDecrypt(downcast<CryptoAlgorithmAesGcmParams>(*parameters), downcast<CryptoKeyAES>(key.get()), cipherText);
         });
 }
 

Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_GCM.h (221664 => 221665)


--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_GCM.h	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_GCM.h	2017-09-06 06:48:49 UTC (rev 221665)
@@ -31,6 +31,7 @@
 
 namespace WebCore {
 
+class CryptoAlgorithmAesGcmParams;
 class CryptoKeyAES;
 
 class CryptoAlgorithmAES_GCM final : public CryptoAlgorithm {
@@ -50,8 +51,8 @@
     void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
     ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&) final;
 
-    static ExceptionOr<Vector<uint8_t>> platformEncrypt(CryptoAlgorithmParameters&, const CryptoKey&, const Vector<uint8_t>&);
-    static ExceptionOr<Vector<uint8_t>> platformDecrypt(CryptoAlgorithmParameters&, const CryptoKey&, const Vector<uint8_t>&);
+    static ExceptionOr<Vector<uint8_t>> platformEncrypt(CryptoAlgorithmAesGcmParams&, const CryptoKeyAES&, const Vector<uint8_t>&);
+    static ExceptionOr<Vector<uint8_t>> platformDecrypt(CryptoAlgorithmAesGcmParams&, const CryptoKeyAES&, const Vector<uint8_t>&);
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -155,7 +155,7 @@
         return;
     }
 
-    auto result = platformWrapKey(key, WTFMove(data));
+    auto result = platformWrapKey(downcast<CryptoKeyAES>(key.get()), WTFMove(data));
     if (result.hasException()) {
         exceptionCallback(result.releaseException().code());
         return;
@@ -166,7 +166,7 @@
 
 void CryptoAlgorithmAES_KW::unwrapKey(Ref<CryptoKey>&& key, Vector<uint8_t>&& data, VectorCallback&& callback, ExceptionCallback&& exceptionCallback)
 {
-    auto result = platformUnwrapKey(key, WTFMove(data));
+    auto result = platformUnwrapKey(downcast<CryptoKeyAES>(key.get()), WTFMove(data));
     if (result.hasException()) {
         exceptionCallback(result.releaseException().code());
         return;

Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.h (221664 => 221665)


--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.h	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.h	2017-09-06 06:48:49 UTC (rev 221665)
@@ -50,8 +50,8 @@
     void unwrapKey(Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&) final;
     ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&) final;
 
-    static ExceptionOr<Vector<uint8_t>> platformWrapKey(const CryptoKey&, const Vector<uint8_t>&);
-    static ExceptionOr<Vector<uint8_t>> platformUnwrapKey(const CryptoKey&, const Vector<uint8_t>&);
+    static ExceptionOr<Vector<uint8_t>> platformWrapKey(const CryptoKeyAES&, const Vector<uint8_t>&);
+    static ExceptionOr<Vector<uint8_t>> platformUnwrapKey(const CryptoKeyAES&, const Vector<uint8_t>&);
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDH.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDH.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDH.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -119,7 +119,7 @@
     context.ref();
     workQueue.dispatch(
         [baseKey = WTFMove(baseKey), publicKey = ecParameters.publicKey.releaseNonNull(), length, unifiedCallback = WTFMove(unifiedCallback), &context]() mutable {
-            auto derivedKey = platformDeriveBits(baseKey, publicKey);
+            auto derivedKey = platformDeriveBits(downcast<CryptoKeyEC>(baseKey.get()), downcast<CryptoKeyEC>(publicKey.get()));
             context.postTask(
                 [derivedKey = WTFMove(derivedKey), length, unifiedCallback = WTFMove(unifiedCallback)](ScriptExecutionContext& context) mutable {
                     unifiedCallback(WTFMove(derivedKey), length);

Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDH.h (221664 => 221665)


--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDH.h	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDH.h	2017-09-06 06:48:49 UTC (rev 221665)
@@ -31,6 +31,8 @@
 
 namespace WebCore {
 
+class CryptoKeyEC;
+
 class CryptoAlgorithmECDH final : public CryptoAlgorithm {
 public:
     static constexpr const char* s_name = "ECDH";
@@ -46,7 +48,7 @@
     void importKey(CryptoKeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
     void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
 
-    static std::optional<Vector<uint8_t>> platformDeriveBits(const CryptoKey&, const CryptoKey&);
+    static std::optional<Vector<uint8_t>> platformDeriveBits(const CryptoKeyEC&, const CryptoKeyEC&);
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDSA.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDSA.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDSA.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -29,6 +29,7 @@
 #if ENABLE(SUBTLE_CRYPTO)
 
 #include "CryptoAlgorithmEcKeyParams.h"
+#include "CryptoAlgorithmEcdsaParams.h"
 #include "CryptoKeyEC.h"
 
 namespace WebCore {
@@ -57,7 +58,7 @@
 
     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
         [parameters = WTFMove(parameters), key = WTFMove(key), data = "" {
-            return platformSign(*parameters, key, data);
+            return platformSign(downcast<CryptoAlgorithmEcdsaParams>(*parameters), downcast<CryptoKeyEC>(key.get()), data);
         });
 }
 
@@ -70,7 +71,7 @@
 
     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
         [parameters = WTFMove(parameters), key = WTFMove(key), signature = WTFMove(signature), data = "" {
-            return platformVerify(*parameters, key, signature, data);
+            return platformVerify(downcast<CryptoAlgorithmEcdsaParams>(*parameters), downcast<CryptoKeyEC>(key.get()), signature, data);
         });
 }
 

Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDSA.h (221664 => 221665)


--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDSA.h	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDSA.h	2017-09-06 06:48:49 UTC (rev 221665)
@@ -31,6 +31,9 @@
 
 namespace WebCore {
 
+class CryptoAlgorithmEcdsaParams;
+class CryptoKeyEC;
+
 class CryptoAlgorithmECDSA final : public CryptoAlgorithm {
 public:
     static constexpr const char* s_name = "ECDSA";
@@ -47,8 +50,8 @@
     void importKey(CryptoKeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
     void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
 
-    static ExceptionOr<Vector<uint8_t>> platformSign(const CryptoAlgorithmParameters&, const CryptoKey&, const Vector<uint8_t>&);
-    static ExceptionOr<bool> platformVerify(const CryptoAlgorithmParameters&, const CryptoKey&, const Vector<uint8_t>&, const Vector<uint8_t>&);
+    static ExceptionOr<Vector<uint8_t>> platformSign(const CryptoAlgorithmEcdsaParams&, const CryptoKeyEC&, const Vector<uint8_t>&);
+    static ExceptionOr<bool> platformVerify(const CryptoAlgorithmEcdsaParams&, const CryptoKeyEC&, const Vector<uint8_t>&, const Vector<uint8_t>&);
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHKDF.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHKDF.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHKDF.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -28,7 +28,7 @@
 
 #if ENABLE(SUBTLE_CRYPTO)
 
-#include "CryptoAlgorithmParameters.h"
+#include "CryptoAlgorithmHkdfParams.h"
 #include "CryptoKeyRaw.h"
 
 namespace WebCore {
@@ -52,7 +52,7 @@
 
     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
         [parameters = WTFMove(parameters), baseKey = WTFMove(baseKey), length] {
-            return platformDeriveBits(*parameters, baseKey, length);
+            return platformDeriveBits(downcast<CryptoAlgorithmHkdfParams>(*parameters), downcast<CryptoKeyRaw>(baseKey.get()), length);
         });
 }
 

Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHKDF.h (221664 => 221665)


--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHKDF.h	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHKDF.h	2017-09-06 06:48:49 UTC (rev 221665)
@@ -31,6 +31,9 @@
 
 namespace WebCore {
 
+class CryptoAlgorithmHkdfParams;
+class CryptoKeyRaw;
+
 class CryptoAlgorithmHKDF final : public CryptoAlgorithm {
 public:
     static constexpr const char* s_name = "HKDF";
@@ -45,7 +48,7 @@
     void importKey(CryptoKeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
     ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&) final;
 
-    static ExceptionOr<Vector<uint8_t>> platformDeriveBits(CryptoAlgorithmParameters&, const CryptoKey&, size_t);
+    static ExceptionOr<Vector<uint8_t>> platformDeriveBits(CryptoAlgorithmHkdfParams&, const CryptoKeyRaw&, size_t);
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -59,7 +59,7 @@
 {
     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
         [key = WTFMove(key), data = "" {
-            return platformSign(key, data);
+            return platformSign(downcast<CryptoKeyHMAC>(key.get()), data);
         });
 }
 
@@ -67,7 +67,7 @@
 {
     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
         [key = WTFMove(key), signature = WTFMove(signature), data = "" {
-            return platformVerify(key, signature, data);
+            return platformVerify(downcast<CryptoKeyHMAC>(key.get()), signature, data);
         });
 }
 

Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.h (221664 => 221665)


--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.h	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.h	2017-09-06 06:48:49 UTC (rev 221665)
@@ -50,8 +50,8 @@
     void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
     ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&) final;
 
-    static ExceptionOr<Vector<uint8_t>> platformSign(const CryptoKey&, const Vector<uint8_t>&);
-    static ExceptionOr<bool> platformVerify(const CryptoKey&, const Vector<uint8_t>&, const Vector<uint8_t>&);
+    static ExceptionOr<Vector<uint8_t>> platformSign(const CryptoKeyHMAC&, const Vector<uint8_t>&);
+    static ExceptionOr<bool> platformVerify(const CryptoKeyHMAC&, const Vector<uint8_t>&, const Vector<uint8_t>&);
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmPBKDF2.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmPBKDF2.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmPBKDF2.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -28,7 +28,7 @@
 
 #if ENABLE(SUBTLE_CRYPTO)
 
-#include "CryptoAlgorithmParameters.h"
+#include "CryptoAlgorithmPbkdf2Params.h"
 #include "CryptoKeyRaw.h"
 
 namespace WebCore {
@@ -52,7 +52,7 @@
 
     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
         [parameters = WTFMove(parameters), baseKey = WTFMove(baseKey), length] {
-            return platformDeriveBits(*parameters, baseKey, length);
+            return platformDeriveBits(downcast<CryptoAlgorithmPbkdf2Params>(*parameters), downcast<CryptoKeyRaw>(baseKey.get()), length);
         });
 }
 

Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmPBKDF2.h (221664 => 221665)


--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmPBKDF2.h	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmPBKDF2.h	2017-09-06 06:48:49 UTC (rev 221665)
@@ -31,6 +31,9 @@
 
 namespace WebCore {
 
+class CryptoAlgorithmPbkdf2Params;
+class CryptoKeyRaw;
+
 class CryptoAlgorithmPBKDF2 final : public CryptoAlgorithm {
 public:
     static constexpr const char* s_name = "PBKDF2";
@@ -45,7 +48,7 @@
     void importKey(CryptoKeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
     ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&) final;
 
-    static ExceptionOr<Vector<uint8_t>> platformDeriveBits(CryptoAlgorithmParameters&, const CryptoKey&, size_t);
+    static ExceptionOr<Vector<uint8_t>> platformDeriveBits(CryptoAlgorithmPbkdf2Params&, const CryptoKeyRaw&, size_t);
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -56,7 +56,7 @@
 
     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
         [key = WTFMove(key), plainText = WTFMove(plainText)] {
-            return platformEncrypt(key, plainText);
+            return platformEncrypt(downcast<CryptoKeyRSA>(key.get()), plainText);
         });
 }
 
@@ -69,7 +69,7 @@
 
     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
         [key = WTFMove(key), cipherText = WTFMove(cipherText)] {
-            return platformDecrypt(key, cipherText);
+            return platformDecrypt(downcast<CryptoKeyRSA>(key.get()), cipherText);
         });
 }
 

Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h (221664 => 221665)


--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h	2017-09-06 06:48:49 UTC (rev 221665)
@@ -31,7 +31,6 @@
 
 namespace WebCore {
 
-class CryptoAlgorithmRSAESParams;
 class CryptoKeyRSA;
 
 class CryptoAlgorithmRSAES_PKCS1_v1_5 final : public CryptoAlgorithm {
@@ -50,8 +49,8 @@
     void importKey(CryptoKeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
     void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
 
-    static ExceptionOr<Vector<uint8_t>> platformEncrypt(const CryptoKey&, const Vector<uint8_t>&);
-    static ExceptionOr<Vector<uint8_t>> platformDecrypt(const CryptoKey&, const Vector<uint8_t>&);
+    static ExceptionOr<Vector<uint8_t>> platformEncrypt(const CryptoKeyRSA&, const Vector<uint8_t>&);
+    static ExceptionOr<Vector<uint8_t>> platformDecrypt(const CryptoKeyRSA&, const Vector<uint8_t>&);
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -61,7 +61,7 @@
 
     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
         [key = WTFMove(key), data = "" {
-            return platformSign(key, data);
+            return platformSign(downcast<CryptoKeyRSA>(key.get()), data);
         });
 }
 
@@ -74,7 +74,7 @@
 
     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
         [key = WTFMove(key), signature = WTFMove(signature), data = "" {
-            return platformVerify(key, signature, data);
+            return platformVerify(downcast<CryptoKeyRSA>(key.get()), signature, data);
         });
 }
 

Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h (221664 => 221665)


--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h	2017-09-06 06:48:49 UTC (rev 221665)
@@ -49,8 +49,8 @@
     void importKey(CryptoKeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
     void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
 
-    static ExceptionOr<Vector<uint8_t>> platformSign(const CryptoKey&, const Vector<uint8_t>&);
-    static ExceptionOr<bool> platformVerify(const CryptoKey&, const Vector<uint8_t>&, const Vector<uint8_t>&);
+    static ExceptionOr<Vector<uint8_t>> platformSign(const CryptoKeyRSA&, const Vector<uint8_t>&);
+    static ExceptionOr<bool> platformVerify(const CryptoKeyRSA&, const Vector<uint8_t>&, const Vector<uint8_t>&);
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -30,6 +30,7 @@
 
 #include "CryptoAlgorithmRsaHashedImportParams.h"
 #include "CryptoAlgorithmRsaHashedKeyGenParams.h"
+#include "CryptoAlgorithmRsaOaepParams.h"
 #include "CryptoKeyPair.h"
 #include "CryptoKeyRSA.h"
 #include <wtf/Variant.h>
@@ -62,7 +63,7 @@
 
     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
         [parameters = WTFMove(parameters), key = WTFMove(key), plainText = WTFMove(plainText)] {
-            return platformEncrypt(*parameters, key, plainText);
+            return platformEncrypt(downcast<CryptoAlgorithmRsaOaepParams>(*parameters), downcast<CryptoKeyRSA>(key.get()), plainText);
         });
 }
 
@@ -76,7 +77,7 @@
 
     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
         [parameters = WTFMove(parameters), key = WTFMove(key), cipherText = WTFMove(cipherText)] {
-            return platformDecrypt(*parameters, key, cipherText);
+            return platformDecrypt(downcast<CryptoAlgorithmRsaOaepParams>(*parameters), downcast<CryptoKeyRSA>(key.get()), cipherText);
         });
 }
 

Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.h (221664 => 221665)


--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.h	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.h	2017-09-06 06:48:49 UTC (rev 221665)
@@ -31,6 +31,7 @@
 
 namespace WebCore {
 
+class CryptoAlgorithmRsaOaepParams;
 class CryptoKeyRSA;
 
 class CryptoAlgorithmRSA_OAEP final : public CryptoAlgorithm {
@@ -49,8 +50,8 @@
     void importKey(CryptoKeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
     void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
 
-    static ExceptionOr<Vector<uint8_t>> platformEncrypt(CryptoAlgorithmParameters&, const CryptoKey&, const Vector<uint8_t>&);
-    static ExceptionOr<Vector<uint8_t>> platformDecrypt(CryptoAlgorithmParameters&, const CryptoKey&, const Vector<uint8_t>&);
+    static ExceptionOr<Vector<uint8_t>> platformEncrypt(CryptoAlgorithmRsaOaepParams&, const CryptoKeyRSA&, const Vector<uint8_t>&);
+    static ExceptionOr<Vector<uint8_t>> platformDecrypt(CryptoAlgorithmRsaOaepParams&, const CryptoKeyRSA&, const Vector<uint8_t>&);
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_PSS.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_PSS.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_PSS.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -30,6 +30,7 @@
 
 #include "CryptoAlgorithmRsaHashedImportParams.h"
 #include "CryptoAlgorithmRsaHashedKeyGenParams.h"
+#include "CryptoAlgorithmRsaPssParams.h"
 #include "CryptoKeyPair.h"
 #include "CryptoKeyRSA.h"
 #include <wtf/Variant.h>
@@ -61,7 +62,7 @@
 
     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
         [parameters = WTFMove(parameters), key = WTFMove(key), data = "" {
-            return platformSign(*parameters, key, data);
+            return platformSign(downcast<CryptoAlgorithmRsaPssParams>(*parameters), downcast<CryptoKeyRSA>(key.get()), data);
         });
 }
 
@@ -74,7 +75,7 @@
 
     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
         [parameters = WTFMove(parameters), key = WTFMove(key), signature = WTFMove(signature), data = "" {
-            return platformVerify(*parameters, key, signature, data);
+            return platformVerify(downcast<CryptoAlgorithmRsaPssParams>(*parameters), downcast<CryptoKeyRSA>(key.get()), signature, data);
         });
 }
 

Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_PSS.h (221664 => 221665)


--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_PSS.h	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_PSS.h	2017-09-06 06:48:49 UTC (rev 221665)
@@ -31,6 +31,7 @@
 
 namespace WebCore {
 
+class CryptoAlgorithmRsaPssParams;
 class CryptoKeyRSA;
 
 class CryptoAlgorithmRSA_PSS final : public CryptoAlgorithm {
@@ -49,8 +50,8 @@
     void importKey(CryptoKeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
     void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
 
-    static ExceptionOr<Vector<uint8_t>> platformSign(CryptoAlgorithmParameters&, const CryptoKey&, const Vector<uint8_t>&);
-    static ExceptionOr<bool> platformVerify(CryptoAlgorithmParameters&, const CryptoKey&, const Vector<uint8_t>&, const Vector<uint8_t>&);
+    static ExceptionOr<Vector<uint8_t>> platformSign(CryptoAlgorithmRsaPssParams&, const CryptoKeyRSA&, const Vector<uint8_t>&);
+    static ExceptionOr<bool> platformVerify(CryptoAlgorithmRsaPssParams&, const CryptoKeyRSA&, const Vector<uint8_t>&, const Vector<uint8_t>&);
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmAES_CBCGCrypt.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmAES_CBCGCrypt.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmAES_CBCGCrypt.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -166,23 +166,17 @@
     return output;
 }
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CBC::platformEncrypt(CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& plainText)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CBC::platformEncrypt(CryptoAlgorithmAesCbcCfbParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& plainText)
 {
-    auto& aesParameters = downcast<CryptoAlgorithmAesCbcCfbParams>(parameters);
-    auto& aesKey = downcast<CryptoKeyAES>(key);
-
-    auto output = gcryptEncrypt(aesKey.key(), aesParameters.ivVector(), Vector<uint8_t>(plainText));
+    auto output = gcryptEncrypt(key.key(), parameters.ivVector(), Vector<uint8_t>(plainText));
     if (!output)
         return Exception { OperationError };
     return WTFMove(*output);
 }
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CBC::platformDecrypt(CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& cipherText)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CBC::platformDecrypt(CryptoAlgorithmAesCbcCfbParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& cipherText)
 {
-    auto& aesParameters = downcast<CryptoAlgorithmAesCbcCfbParams>(parameters);
-    auto& aesKey = downcast<CryptoKeyAES>(key);
-
-    auto output = gcryptDecrypt(aesKey.key(), aesParameters.ivVector(), cipherText);
+    auto output = gcryptDecrypt(key.key(), parameters.ivVector(), cipherText);
     if (!output)
         return Exception { OperationError };
     return WTFMove(*output);

Modified: trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmAES_CFBGCrypt.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmAES_CFBGCrypt.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmAES_CFBGCrypt.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -30,12 +30,12 @@
 
 namespace WebCore {
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CFB::platformEncrypt(CryptoAlgorithmParameters&, const CryptoKey&, const Vector<uint8_t>&)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CFB::platformEncrypt(CryptoAlgorithmAesCbcCfbParams&, const CryptoKeyAES&, const Vector<uint8_t>&)
 {
     return Exception { NotSupportedError };
 }
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CFB::platformDecrypt(CryptoAlgorithmParameters&, const CryptoKey&, const Vector<uint8_t>&)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CFB::platformDecrypt(CryptoAlgorithmAesCbcCfbParams&, const CryptoKeyAES&, const Vector<uint8_t>&)
 {
     return Exception { NotSupportedError };
 }

Modified: trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmAES_CTRGCrypt.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmAES_CTRGCrypt.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmAES_CTRGCrypt.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -195,23 +195,17 @@
     return output;
 }
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CTR::platformEncrypt(CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& plainText)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CTR::platformEncrypt(CryptoAlgorithmAesCtrParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& plainText)
 {
-    auto& aesParameters = downcast<CryptoAlgorithmAesCtrParams>(parameters);
-    auto& aesKey = downcast<CryptoKeyAES>(key);
-
-    auto output = gcryptAES_CTR(gcry_cipher_encrypt, aesKey.key(), aesParameters.counterVector(), aesParameters.length, plainText);
+    auto output = gcryptAES_CTR(gcry_cipher_encrypt, key.key(), parameters.counterVector(), parameters.length, plainText);
     if (!output)
         return Exception { OperationError };
     return WTFMove(*output);
 }
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CTR::platformDecrypt(CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& cipherText)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CTR::platformDecrypt(CryptoAlgorithmAesCtrParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& cipherText)
 {
-    auto& aesParameters = downcast<CryptoAlgorithmAesCtrParams>(parameters);
-    auto& aesKey = downcast<CryptoKeyAES>(key);
-
-    auto output = gcryptAES_CTR(gcry_cipher_decrypt, aesKey.key(), aesParameters.counterVector(), aesParameters.length, cipherText);
+    auto output = gcryptAES_CTR(gcry_cipher_decrypt, key.key(), parameters.counterVector(), parameters.length, cipherText);
     if (!output)
         return Exception { OperationError };
     return WTFMove(*output);

Modified: trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmAES_GCMGCrypt.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmAES_GCMGCrypt.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmAES_GCMGCrypt.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -179,23 +179,17 @@
     return output;
 }
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_GCM::platformEncrypt(CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& plainText)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_GCM::platformEncrypt(CryptoAlgorithmAesGcmParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& plainText)
 {
-    auto& aesParameters = downcast<CryptoAlgorithmAesGcmParams>(parameters);
-    auto& aesKey = downcast<CryptoKeyAES>(key);
-
-    auto output = gcryptEncrypt(aesKey.key(), aesParameters.ivVector(), plainText, aesParameters.additionalDataVector(), aesParameters.tagLength.value_or(0) / 8);
+    auto output = gcryptEncrypt(key.key(), parameters.ivVector(), plainText, parameters.additionalDataVector(), parameters.tagLength.value_or(0) / 8);
     if (!output)
         return Exception { OperationError };
     return WTFMove(*output);
 }
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_GCM::platformDecrypt(CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& cipherText)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_GCM::platformDecrypt(CryptoAlgorithmAesGcmParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& cipherText)
 {
-    auto& aesParameters = downcast<CryptoAlgorithmAesGcmParams>(parameters);
-    auto& aesKey = downcast<CryptoKeyAES>(key);
-
-    auto output = gcryptDecrypt(aesKey.key(), aesParameters.ivVector(), cipherText, aesParameters.additionalDataVector(), aesParameters.tagLength.value_or(0) / 8);
+    auto output = gcryptDecrypt(key.key(), parameters.ivVector(), cipherText, parameters.additionalDataVector(), parameters.tagLength.value_or(0) / 8);
     if (!output)
         return Exception { OperationError };
     return WTFMove(*output);

Modified: trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmAES_KWGCrypt.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmAES_KWGCrypt.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmAES_KWGCrypt.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -115,17 +115,17 @@
     return output;
 }
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_KW::platformWrapKey(const CryptoKey& key, const Vector<uint8_t>& data)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_KW::platformWrapKey(const CryptoKeyAES& key, const Vector<uint8_t>& data)
 {
-    auto output = gcryptWrapKey(downcast<CryptoKeyAES>(key).key(), data);
+    auto output = gcryptWrapKey(key.key(), data);
     if (!output)
         return Exception { OperationError };
     return WTFMove(*output);
 }
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_KW::platformUnwrapKey(const CryptoKey& key, const Vector<uint8_t>& data)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_KW::platformUnwrapKey(const CryptoKeyAES& key, const Vector<uint8_t>& data)
 {
-    auto output = gcryptUnwrapKey(downcast<CryptoKeyAES>(key).key(), data);
+    auto output = gcryptUnwrapKey(key.key(), data);
     if (!output)
         return Exception { OperationError };
     return WTFMove(*output);

Modified: trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmECDHGCrypt.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmECDHGCrypt.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmECDHGCrypt.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -115,9 +115,9 @@
     return output;
 }
 
-std::optional<Vector<uint8_t>> CryptoAlgorithmECDH::platformDeriveBits(const CryptoKey& baseKey, const CryptoKey& publicKey)
+std::optional<Vector<uint8_t>> CryptoAlgorithmECDH::platformDeriveBits(const CryptoKeyEC& baseKey, const CryptoKeyEC& publicKey)
 {
-    return gcryptDerive(downcast<CryptoKeyEC>(baseKey).platformKey(), downcast<CryptoKeyEC>(publicKey).platformKey());
+    return gcryptDerive(baseKey.platformKey(), publicKey.platformKey());
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmECDSAGCrypt.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmECDSAGCrypt.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmECDSAGCrypt.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -170,23 +170,17 @@
     return { error == GPG_ERR_NO_ERROR };
 }
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmECDSA::platformSign(const CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& data)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmECDSA::platformSign(const CryptoAlgorithmEcdsaParams& parameters, const CryptoKeyEC& key, const Vector<uint8_t>& data)
 {
-    auto& ecParameters = downcast<CryptoAlgorithmEcdsaParams>(parameters);
-    auto& ecKey = downcast<CryptoKeyEC>(key);
-
-    auto output = gcryptSign(ecKey.platformKey(), data, ecParameters.hashIdentifier, ecKey.keySizeInBits() / 8);
+    auto output = gcryptSign(key.platformKey(), data, parameters.hashIdentifier, key.keySizeInBits() / 8);
     if (!output)
         return Exception { OperationError };
     return WTFMove(*output);
 }
 
-ExceptionOr<bool> CryptoAlgorithmECDSA::platformVerify(const CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& signature, const Vector<uint8_t>& data)
+ExceptionOr<bool> CryptoAlgorithmECDSA::platformVerify(const CryptoAlgorithmEcdsaParams& parameters, const CryptoKeyEC& key, const Vector<uint8_t>& signature, const Vector<uint8_t>& data)
 {
-    auto& ecParameters = downcast<CryptoAlgorithmEcdsaParams>(parameters);
-    auto& ecKey = downcast<CryptoKeyEC>(key);
-
-    auto output = gcryptVerify(ecKey.platformKey(), signature, data, ecParameters.hashIdentifier, ecKey.keySizeInBits() / 8);
+    auto output = gcryptVerify(key.platformKey(), signature, data, parameters.hashIdentifier, key.keySizeInBits() / 8);
     if (!output)
         return Exception { OperationError };
     return WTFMove(*output);

Modified: trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmHKDFGCrypt.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmHKDFGCrypt.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmHKDFGCrypt.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -152,12 +152,9 @@
     return output;
 }
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmHKDF::platformDeriveBits(CryptoAlgorithmParameters& parameters, const CryptoKey& key, size_t length)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmHKDF::platformDeriveBits(CryptoAlgorithmHkdfParams& parameters, const CryptoKeyRaw& key, size_t length)
 {
-    auto& hkdfParameters = downcast<CryptoAlgorithmHkdfParams>(parameters);
-    auto& rawKey = downcast<CryptoKeyRaw>(key);
-
-    auto output = gcryptDeriveBits(rawKey.key(), hkdfParameters.saltVector(), hkdfParameters.infoVector(), length / 8, hkdfParameters.hashIdentifier);
+    auto output = gcryptDeriveBits(key.key(), parameters.saltVector(), parameters.infoVector(), length / 8, parameters.hashIdentifier);
     if (!output)
         return Exception { OperationError };
     return WTFMove(*output);

Modified: trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -82,29 +82,25 @@
     return WTFMove(signature);
 }
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmHMAC::platformSign(const CryptoKey& key, const Vector<uint8_t>& data)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmHMAC::platformSign(const CryptoKeyHMAC& key, const Vector<uint8_t>& data)
 {
-    auto& hmacKey = downcast<CryptoKeyHMAC>(key);
-
-    auto algorithm = getGCryptDigestAlgorithm(hmacKey.hashAlgorithmIdentifier());
+    auto algorithm = getGCryptDigestAlgorithm(key.hashAlgorithmIdentifier());
     if (algorithm == GCRY_MAC_NONE)
         return Exception { OperationError };
 
-    auto result = calculateSignature(algorithm, hmacKey.key(), data.data(), data.size());
+    auto result = calculateSignature(algorithm, key.key(), data.data(), data.size());
     if (!result)
         return Exception { OperationError };
     return WTFMove(*result);
 }
 
-ExceptionOr<bool> CryptoAlgorithmHMAC::platformVerify(const CryptoKey& key, const Vector<uint8_t>& signature, const Vector<uint8_t>& data)
+ExceptionOr<bool> CryptoAlgorithmHMAC::platformVerify(const CryptoKeyHMAC& key, const Vector<uint8_t>& signature, const Vector<uint8_t>& data)
 {
-    auto& hmacKey = downcast<CryptoKeyHMAC>(key);
-
-    auto algorithm = getGCryptDigestAlgorithm(hmacKey.hashAlgorithmIdentifier());
+    auto algorithm = getGCryptDigestAlgorithm(key.hashAlgorithmIdentifier());
     if (algorithm == GCRY_MAC_NONE)
         return Exception { OperationError };
 
-    auto expectedSignature = calculateSignature(algorithm, hmacKey.key(), data.data(), data.size());
+    auto expectedSignature = calculateSignature(algorithm, key.key(), data.data(), data.size());
     if (!expectedSignature)
         return Exception { OperationError };
     // Using a constant time comparison to prevent timing attacks.

Modified: trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmPBKDF2GCrypt.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmPBKDF2GCrypt.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmPBKDF2GCrypt.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -57,12 +57,9 @@
     return result;
 }
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmPBKDF2::platformDeriveBits(CryptoAlgorithmParameters& parameters, const CryptoKey& key, size_t length)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmPBKDF2::platformDeriveBits(CryptoAlgorithmPbkdf2Params& parameters, const CryptoKeyRaw& key, size_t length)
 {
-    auto& pbkdf2Parameters = downcast<CryptoAlgorithmPbkdf2Params>(parameters);
-    auto& rawKey = downcast<CryptoKeyRaw>(key);
-
-    auto output = gcryptDeriveBits(rawKey.key(), pbkdf2Parameters.saltVector(), pbkdf2Parameters.hashIdentifier, pbkdf2Parameters.iterations, length);
+    auto output = gcryptDeriveBits(key.key(), parameters.saltVector(), parameters.hashIdentifier, parameters.iterations, length);
     if (!output)
         return Exception { OperationError };
     return WTFMove(*output);

Modified: trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmRSAES_PKCS1_v1_5GCrypt.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmRSAES_PKCS1_v1_5GCrypt.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmRSAES_PKCS1_v1_5GCrypt.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -93,17 +93,17 @@
     return mpiData(valueSexp);
 }
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt(const CryptoKey& key, const Vector<uint8_t>& plainText)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt(const CryptoKeyRSA& key, const Vector<uint8_t>& plainText)
 {
-    auto output = gcryptEncrypt(downcast<CryptoKeyRSA>(key).platformKey(), plainText);
+    auto output = gcryptEncrypt(key.platformKey(), plainText);
     if (!output)
         return Exception { OperationError };
     return WTFMove(*output);
 }
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSAES_PKCS1_v1_5::platformDecrypt(const CryptoKey& key, const Vector<uint8_t>& cipherText)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSAES_PKCS1_v1_5::platformDecrypt(const CryptoKeyRSA& key, const Vector<uint8_t>& cipherText)
 {
-    auto output = gcryptDecrypt(downcast<CryptoKeyRSA>(key).platformKey(), cipherText);
+    auto output = gcryptDecrypt(key.platformKey(), cipherText);
     if (!output)
         return Exception { OperationError };
     return WTFMove(*output);

Modified: trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmRSASSA_PKCS1_v1_5GCrypt.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmRSASSA_PKCS1_v1_5GCrypt.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmRSASSA_PKCS1_v1_5GCrypt.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -134,19 +134,17 @@
     return { error == GPG_ERR_NO_ERROR };
 }
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign(const CryptoKey& key, const Vector<uint8_t>& data)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign(const CryptoKeyRSA& key, const Vector<uint8_t>& data)
 {
-    auto& rsaKey = downcast<CryptoKeyRSA>(key);
-    auto output = gcryptSign(rsaKey.platformKey(), data, rsaKey.hashAlgorithmIdentifier());
+    auto output = gcryptSign(key.platformKey(), data, key.hashAlgorithmIdentifier());
     if (!output)
         return Exception { OperationError };
     return WTFMove(*output);
 }
 
-ExceptionOr<bool> CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerify(const CryptoKey& key, const Vector<uint8_t>& signature, const Vector<uint8_t>& data)
+ExceptionOr<bool> CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerify(const CryptoKeyRSA& key, const Vector<uint8_t>& signature, const Vector<uint8_t>& data)
 {
-    auto& rsaKey = downcast<CryptoKeyRSA>(key);
-    auto output = gcryptVerify(rsaKey.platformKey(), signature, data, rsaKey.hashAlgorithmIdentifier());
+    auto output = gcryptVerify(key.platformKey(), signature, data, key.hashAlgorithmIdentifier());
     if (!output)
         return Exception { OperationError };
     return *output;

Modified: trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmRSA_OAEPGCrypt.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmRSA_OAEPGCrypt.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmRSA_OAEPGCrypt.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -110,23 +110,17 @@
     return mpiData(valueSexp);
 }
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_OAEP::platformEncrypt(CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& plainText)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_OAEP::platformEncrypt(CryptoAlgorithmRsaOaepParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& plainText)
 {
-    auto& rsaParameters = downcast<CryptoAlgorithmRsaOaepParams>(parameters);
-    auto& rsaKey = downcast<CryptoKeyRSA>(key);
-
-    auto output = gcryptEncrypt(rsaKey.hashAlgorithmIdentifier(), rsaKey.platformKey(), rsaParameters.labelVector(), plainText);
+    auto output = gcryptEncrypt(key.hashAlgorithmIdentifier(), key.platformKey(), parameters.labelVector(), plainText);
     if (!output)
         return Exception { OperationError };
     return WTFMove(*output);
 }
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_OAEP::platformDecrypt(CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& cipherText)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_OAEP::platformDecrypt(CryptoAlgorithmRsaOaepParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& cipherText)
 {
-    auto& rsaParameters = downcast<CryptoAlgorithmRsaOaepParams>(parameters);
-    auto& rsaKey = downcast<CryptoKeyRSA>(key);
-
-    auto output = gcryptDecrypt(rsaKey.hashAlgorithmIdentifier(), rsaKey.platformKey(), rsaParameters.labelVector(), cipherText);
+    auto output = gcryptDecrypt(key.hashAlgorithmIdentifier(), key.platformKey(), parameters.labelVector(), cipherText);
     if (!output)
         return Exception { OperationError };
     return WTFMove(*output);

Modified: trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmRSA_PSSGCrypt.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmRSA_PSSGCrypt.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmRSA_PSSGCrypt.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -140,23 +140,17 @@
     return { error == GPG_ERR_NO_ERROR };
 }
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_PSS::platformSign(CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& data)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_PSS::platformSign(CryptoAlgorithmRsaPssParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& data)
 {
-    auto& rsaKey = downcast<CryptoKeyRSA>(key);
-    auto& rsaParameters = downcast<CryptoAlgorithmRsaPssParams>(parameters);
-
-    auto output = gcryptSign(rsaKey.platformKey(), rsaKey.keySizeInBits(), data, rsaKey.hashAlgorithmIdentifier(), rsaParameters.saltLength);
+    auto output = gcryptSign(key.platformKey(), key.keySizeInBits(), data, key.hashAlgorithmIdentifier(), parameters.saltLength);
     if (!output)
         return Exception { OperationError };
     return WTFMove(*output);
 }
 
-ExceptionOr<bool> CryptoAlgorithmRSA_PSS::platformVerify(CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& signature, const Vector<uint8_t>& data)
+ExceptionOr<bool> CryptoAlgorithmRSA_PSS::platformVerify(CryptoAlgorithmRsaPssParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& signature, const Vector<uint8_t>& data)
 {
-    auto& rsaKey = downcast<CryptoKeyRSA>(key);
-    auto& rsaParameters = downcast<CryptoAlgorithmRsaPssParams>(parameters);
-
-    auto output = gcryptVerify(rsaKey.platformKey(), signature, data, rsaKey.hashAlgorithmIdentifier(), rsaParameters.saltLength);
+    auto output = gcryptVerify(key.platformKey(), signature, data, key.hashAlgorithmIdentifier(), parameters.saltLength);
     if (!output)
         return Exception { OperationError };
     return WTFMove(*output);

Modified: trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_CBCMac.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_CBCMac.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_CBCMac.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -62,20 +62,16 @@
     return WTFMove(result);
 }
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CBC::platformEncrypt(CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& plainText)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CBC::platformEncrypt(CryptoAlgorithmAesCbcCfbParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& plainText)
 {
-    auto& aesParameters = downcast<CryptoAlgorithmAesCbcCfbParams>(parameters);
-    auto& aesKey = downcast<CryptoKeyAES>(key);
-    ASSERT(aesParameters.ivVector().size() == kCCBlockSizeAES128);
-    return transformAES_CBC(kCCEncrypt, aesParameters.ivVector(), aesKey.key(), plainText);
+    ASSERT(parameters.ivVector().size() == kCCBlockSizeAES128);
+    return transformAES_CBC(kCCEncrypt, parameters.ivVector(), key.key(), plainText);
 }
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CBC::platformDecrypt(CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& cipherText)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CBC::platformDecrypt(CryptoAlgorithmAesCbcCfbParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& cipherText)
 {
-    auto& aesParameters = downcast<CryptoAlgorithmAesCbcCfbParams>(parameters);
-    auto& aesKey = downcast<CryptoKeyAES>(key);
-    ASSERT(aesParameters.ivVector().size() == kCCBlockSizeAES128);
-    return transformAES_CBC(kCCDecrypt, aesParameters.ivVector(), aesKey.key(), cipherText);
+    ASSERT(parameters.ivVector().size() == kCCBlockSizeAES128);
+    return transformAES_CBC(kCCDecrypt, parameters.ivVector(), key.key(), cipherText);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_CFBMac.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_CFBMac.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_CFBMac.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -62,20 +62,16 @@
     return WTFMove(result);
 }
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CFB::platformEncrypt(CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& plainText)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CFB::platformEncrypt(CryptoAlgorithmAesCbcCfbParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& plainText)
 {
-    auto& aesParameters = downcast<CryptoAlgorithmAesCbcCfbParams>(parameters);
-    auto& aesKey = downcast<CryptoKeyAES>(key);
-    ASSERT(aesParameters.ivVector().size() == kCCBlockSizeAES128);
-    return transformAES_CFB(kCCEncrypt, aesParameters.ivVector(), aesKey.key(), plainText);
+    ASSERT(parameters.ivVector().size() == kCCBlockSizeAES128);
+    return transformAES_CFB(kCCEncrypt, parameters.ivVector(), key.key(), plainText);
 }
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CFB::platformDecrypt(CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& cipherText)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CFB::platformDecrypt(CryptoAlgorithmAesCbcCfbParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& cipherText)
 {
-    auto& aesParameters = downcast<CryptoAlgorithmAesCbcCfbParams>(parameters);
-    auto& aesKey = downcast<CryptoKeyAES>(key);
-    ASSERT(aesParameters.ivVector().size() == kCCBlockSizeAES128);
-    return transformAES_CFB(kCCDecrypt, aesParameters.ivVector(), aesKey.key(), cipherText);
+    ASSERT(parameters.ivVector().size() == kCCBlockSizeAES128);
+    return transformAES_CFB(kCCDecrypt, parameters.ivVector(), key.key(), cipherText);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_CTRMac.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_CTRMac.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_CTRMac.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -138,20 +138,16 @@
     return WTFMove(head);
 }
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CTR::platformEncrypt(CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& plainText)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CTR::platformEncrypt(CryptoAlgorithmAesCtrParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& plainText)
 {
-    auto& aesParameters = downcast<CryptoAlgorithmAesCtrParams>(parameters);
-    auto& aesKey = downcast<CryptoKeyAES>(key);
-    ASSERT(aesParameters.counterVector().size() == kCCBlockSizeAES128);
-    return transformAES_CTR(kCCEncrypt, aesParameters.counterVector(), aesParameters.length, aesKey.key(), plainText);
+    ASSERT(parameters.counterVector().size() == kCCBlockSizeAES128);
+    return transformAES_CTR(kCCEncrypt, parameters.counterVector(), parameters.length, key.key(), plainText);
 }
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CTR::platformDecrypt(CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& cipherText)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CTR::platformDecrypt(CryptoAlgorithmAesCtrParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& cipherText)
 {
-    auto& aesParameters = downcast<CryptoAlgorithmAesCtrParams>(parameters);
-    auto& aesKey = downcast<CryptoKeyAES>(key);
-    ASSERT(aesParameters.counterVector().size() == kCCBlockSizeAES128);
-    return transformAES_CTR(kCCDecrypt, aesParameters.counterVector(), aesParameters.length, aesKey.key(), cipherText);
+      ASSERT(parameters.counterVector().size() == kCCBlockSizeAES128);
+    return transformAES_CTR(kCCDecrypt, parameters.counterVector(), parameters.length, key.key(), cipherText);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_GCMMac.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_GCMMac.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_GCMMac.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -72,18 +72,14 @@
     return WTFMove(plainText);
 }
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_GCM::platformEncrypt(CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& plainText)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_GCM::platformEncrypt(CryptoAlgorithmAesGcmParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& plainText)
 {
-    auto& aesParameters = downcast<CryptoAlgorithmAesGcmParams>(parameters);
-    auto& aesKey = downcast<CryptoKeyAES>(key);
-    return encryptAES_GCM(aesParameters.ivVector(), aesKey.key(), plainText, aesParameters.additionalDataVector(), aesParameters.tagLength.value_or(0) / 8);
+    return encryptAES_GCM(parameters.ivVector(), key.key(), plainText, parameters.additionalDataVector(), parameters.tagLength.value_or(0) / 8);
 }
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_GCM::platformDecrypt(CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& cipherText)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_GCM::platformDecrypt(CryptoAlgorithmAesGcmParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& cipherText)
 {
-    auto& aesParameters = downcast<CryptoAlgorithmAesGcmParams>(parameters);
-    auto& aesKey = downcast<CryptoKeyAES>(key);
-    return decyptAES_GCM(aesParameters.ivVector(), aesKey.key(), cipherText, aesParameters.additionalDataVector(), aesParameters.tagLength.value_or(0) / 8);
+    return decyptAES_GCM(parameters.ivVector(), key.key(), cipherText, parameters.additionalDataVector(), parameters.tagLength.value_or(0) / 8);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_KWMac.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_KWMac.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_KWMac.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -59,14 +59,14 @@
     return WTFMove(result);
 }
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_KW::platformWrapKey(const CryptoKey& key, const Vector<uint8_t>& data)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_KW::platformWrapKey(const CryptoKeyAES& key, const Vector<uint8_t>& data)
 {
-    return wrapKeyAES_KW(downcast<CryptoKeyAES>(key).key(), data);
+    return wrapKeyAES_KW(key.key(), data);
 }
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_KW::platformUnwrapKey(const CryptoKey& key, const Vector<uint8_t>& data)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_KW::platformUnwrapKey(const CryptoKeyAES& key, const Vector<uint8_t>& data)
 {
-    return unwrapKeyAES_KW(downcast<CryptoKeyAES>(key).key(), data);
+    return unwrapKeyAES_KW(key.key(), data);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/crypto/mac/CryptoAlgorithmECDHMac.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/mac/CryptoAlgorithmECDHMac.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/mac/CryptoAlgorithmECDHMac.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -33,15 +33,12 @@
 
 namespace WebCore {
 
-std::optional<Vector<uint8_t>> CryptoAlgorithmECDH::platformDeriveBits(const CryptoKey& baseKey, const CryptoKey& publicKey)
+std::optional<Vector<uint8_t>> CryptoAlgorithmECDH::platformDeriveBits(const CryptoKeyEC& baseKey, const CryptoKeyEC& publicKey)
 {
-    auto& ecBaseKey = downcast<CryptoKeyEC>(baseKey);
-    auto& ecPublicKey = downcast<CryptoKeyEC>(publicKey);
-
     std::optional<Vector<uint8_t>> result = std::nullopt;
-    Vector<uint8_t> derivedKey(ecBaseKey.keySizeInBits() / 8); // Per https://tools.ietf.org/html/rfc6090#section-4.
+    Vector<uint8_t> derivedKey(baseKey.keySizeInBits() / 8); // Per https://tools.ietf.org/html/rfc6090#section-4.
     size_t size = derivedKey.size();
-    if (!CCECCryptorComputeSharedSecret(ecBaseKey.platformKey(), ecPublicKey.platformKey(), derivedKey.data(), &size))
+    if (!CCECCryptorComputeSharedSecret(baseKey.platformKey(), publicKey.platformKey(), derivedKey.data(), &size))
         result = WTFMove(derivedKey);
     return result;
 }

Modified: trunk/Source/WebCore/crypto/mac/CryptoAlgorithmECDSAMac.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/mac/CryptoAlgorithmECDSAMac.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/mac/CryptoAlgorithmECDSAMac.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -151,18 +151,14 @@
     return valid;
 }
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmECDSA::platformSign(const CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& data)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmECDSA::platformSign(const CryptoAlgorithmEcdsaParams& parameters, const CryptoKeyEC& key, const Vector<uint8_t>& data)
 {
-    auto& ecKey = downcast<CryptoKeyEC>(key);
-    auto& ecParameters = downcast<CryptoAlgorithmEcdsaParams>(parameters);
-    return signECDSA(ecParameters.hashIdentifier, ecKey.platformKey(), ecKey.keySizeInBits() / 8, data);
+    return signECDSA(parameters.hashIdentifier, key.platformKey(), key.keySizeInBits() / 8, data);
 }
 
-ExceptionOr<bool> CryptoAlgorithmECDSA::platformVerify(const CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& signature, const Vector<uint8_t>& data)
+ExceptionOr<bool> CryptoAlgorithmECDSA::platformVerify(const CryptoAlgorithmEcdsaParams& parameters, const CryptoKeyEC& key, const Vector<uint8_t>& signature, const Vector<uint8_t>& data)
 {
-    auto& ecKey = downcast<CryptoKeyEC>(key);
-    auto& ecParameters = downcast<CryptoAlgorithmEcdsaParams>(parameters);
-    return verifyECDSA(ecParameters.hashIdentifier, ecKey.platformKey(), ecKey.keySizeInBits() / 8, signature, data);
+    return verifyECDSA(parameters.hashIdentifier, key.platformKey(), key.keySizeInBits() / 8, signature, data);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/crypto/mac/CryptoAlgorithmHKDFMac.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/mac/CryptoAlgorithmHKDFMac.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/mac/CryptoAlgorithmHKDFMac.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -34,17 +34,14 @@
 
 namespace WebCore {
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmHKDF::platformDeriveBits(CryptoAlgorithmParameters& parameters, const CryptoKey& key, size_t length)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmHKDF::platformDeriveBits(CryptoAlgorithmHkdfParams& parameters, const CryptoKeyRaw& key, size_t length)
 {
-    auto& hkdfParameters = downcast<CryptoAlgorithmHkdfParams>(parameters);
-    auto& rawKey = downcast<CryptoKeyRaw>(key);
-
     Vector<uint8_t> result(length / 8);
     CCDigestAlgorithm digestAlgorithm;
-    getCommonCryptoDigestAlgorithm(hkdfParameters.hashIdentifier, digestAlgorithm);
+    getCommonCryptoDigestAlgorithm(parameters.hashIdentifier, digestAlgorithm);
 
-    // <rdar://problem/32439455> Currently, when rawKey is null, CCKeyDerivationHMac will bail out.
-    if (CCKeyDerivationHMac(kCCKDFAlgorithmHKDF, digestAlgorithm, 0, rawKey.key().data(), rawKey.key().size(), 0, 0, hkdfParameters.infoVector().data(), hkdfParameters.infoVector().size(), 0, 0, hkdfParameters.saltVector().data(), hkdfParameters.saltVector().size(), result.data(), result.size()))
+    // <rdar://problem/32439455> Currently, when key data is empty, CCKeyDerivationHMac will bail out.
+    if (CCKeyDerivationHMac(kCCKDFAlgorithmHKDF, digestAlgorithm, 0, key.key().data(), key.key().size(), 0, 0, parameters.infoVector().data(), parameters.infoVector().size(), 0, 0, parameters.saltVector().data(), parameters.saltVector().size(), result.data(), result.size()))
         return Exception { OperationError };
     return WTFMove(result);
 }

Modified: trunk/Source/WebCore/crypto/mac/CryptoAlgorithmHMACMac.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/mac/CryptoAlgorithmHMACMac.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/mac/CryptoAlgorithmHMACMac.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -81,24 +81,22 @@
     return result;
 }
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmHMAC::platformSign(const CryptoKey& key, const Vector<uint8_t>& data)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmHMAC::platformSign(const CryptoKeyHMAC& key, const Vector<uint8_t>& data)
 {
-    auto& hmacKey = downcast<CryptoKeyHMAC>(key);
-    auto algorithm = commonCryptoHMACAlgorithm(hmacKey.hashAlgorithmIdentifier());
+    auto algorithm = commonCryptoHMACAlgorithm(key.hashAlgorithmIdentifier());
     if (!algorithm)
         return Exception { OperationError };
 
-    return calculateSignature(*algorithm, hmacKey.key(), data);
+    return calculateSignature(*algorithm, key.key(), data);
 }
 
-ExceptionOr<bool> CryptoAlgorithmHMAC::platformVerify(const CryptoKey& key, const Vector<uint8_t>& signature, const Vector<uint8_t>& data)
+ExceptionOr<bool> CryptoAlgorithmHMAC::platformVerify(const CryptoKeyHMAC& key, const Vector<uint8_t>& signature, const Vector<uint8_t>& data)
 {
-    auto& hmacKey = downcast<CryptoKeyHMAC>(key);
-    auto algorithm = commonCryptoHMACAlgorithm(hmacKey.hashAlgorithmIdentifier());
+    auto algorithm = commonCryptoHMACAlgorithm(key.hashAlgorithmIdentifier());
     if (!algorithm)
         return Exception { OperationError };
 
-    auto expectedSignature = calculateSignature(*algorithm, hmacKey.key(), data);
+    auto expectedSignature = calculateSignature(*algorithm, key.key(), data);
     // Using a constant time comparison to prevent timing attacks.
     return signature.size() == expectedSignature.size() && !constantTimeMemcmp(expectedSignature.data(), signature.data(), expectedSignature.size());
 }

Modified: trunk/Source/WebCore/crypto/mac/CryptoAlgorithmPBKDF2Mac.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/mac/CryptoAlgorithmPBKDF2Mac.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/mac/CryptoAlgorithmPBKDF2Mac.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -53,14 +53,11 @@
     }
 }
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmPBKDF2::platformDeriveBits(CryptoAlgorithmParameters& parameters, const CryptoKey& key, size_t length)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmPBKDF2::platformDeriveBits(CryptoAlgorithmPbkdf2Params& parameters, const CryptoKeyRaw& key, size_t length)
 {
-    auto& pbkdf2Parameters = downcast<CryptoAlgorithmPbkdf2Params>(parameters);
-    auto& rawKey = downcast<CryptoKeyRaw>(key);
-
     Vector<uint8_t> result(length / 8);
     // <rdar://problem/32439955> Currently, CCKeyDerivationPBKDF bails out when an empty password/salt is provided.
-    if (CCKeyDerivationPBKDF(kCCPBKDF2, reinterpret_cast<const char *>(rawKey.key().data()), rawKey.key().size(), pbkdf2Parameters.saltVector().data(), pbkdf2Parameters.saltVector().size(), commonCryptoHMACAlgorithm(pbkdf2Parameters.hashIdentifier), pbkdf2Parameters.iterations, result.data(), length / 8))
+    if (CCKeyDerivationPBKDF(kCCPBKDF2, reinterpret_cast<const char *>(key.key().data()), key.key().size(), parameters.saltVector().data(), parameters.saltVector().size(), commonCryptoHMACAlgorithm(parameters.hashIdentifier), parameters.iterations, result.data(), length / 8))
         return Exception { OperationError };
     return WTFMove(result);
 }

Modified: trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -54,16 +54,14 @@
     return WTFMove(plainText);
 }
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt(const CryptoKey& key, const Vector<uint8_t>& plainText)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt(const CryptoKeyRSA& key, const Vector<uint8_t>& plainText)
 {
-    auto& rsaKey = downcast<CryptoKeyRSA>(key);
-    return encryptRSAES_PKCS1_v1_5(rsaKey.platformKey(), rsaKey.keySizeInBits(), plainText);
+    return encryptRSAES_PKCS1_v1_5(key.platformKey(), key.keySizeInBits(), plainText);
 }
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSAES_PKCS1_v1_5::platformDecrypt(const CryptoKey& key, const Vector<uint8_t>& cipherText)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSAES_PKCS1_v1_5::platformDecrypt(const CryptoKeyRSA& key, const Vector<uint8_t>& cipherText)
 {
-    auto& rsaKey = downcast<CryptoKeyRSA>(key);
-    return decryptRSAES_PKCS1_v1_5(rsaKey.platformKey(), rsaKey.keySizeInBits(), cipherText);
+    return decryptRSAES_PKCS1_v1_5(key.platformKey(), key.keySizeInBits(), cipherText);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -83,16 +83,14 @@
     return Exception { OperationError };
 }
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign(const CryptoKey& key, const Vector<uint8_t>& data)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign(const CryptoKeyRSA& key, const Vector<uint8_t>& data)
 {
-    auto& rsaKey = downcast<CryptoKeyRSA>(key);
-    return signRSASSA_PKCS1_v1_5(rsaKey.hashAlgorithmIdentifier(), rsaKey.platformKey(), rsaKey.keySizeInBits(), data);
+    return signRSASSA_PKCS1_v1_5(key.hashAlgorithmIdentifier(), key.platformKey(), key.keySizeInBits(), data);
 }
 
-ExceptionOr<bool> CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerify(const CryptoKey& key, const Vector<uint8_t>& signature, const Vector<uint8_t>& data)
+ExceptionOr<bool> CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerify(const CryptoKeyRSA& key, const Vector<uint8_t>& signature, const Vector<uint8_t>& data)
 {
-    auto& rsaKey = downcast<CryptoKeyRSA>(key);
-    return verifyRSASSA_PKCS1_v1_5(rsaKey.hashAlgorithmIdentifier(), rsaKey.platformKey(), signature, data);
+    return verifyRSASSA_PKCS1_v1_5(key.hashAlgorithmIdentifier(), key.platformKey(), signature, data);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -63,18 +63,14 @@
     return WTFMove(plainText);
 }
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_OAEP::platformEncrypt(CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& plainText)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_OAEP::platformEncrypt(CryptoAlgorithmRsaOaepParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& plainText)
 {
-    auto& rsaParameters = downcast<CryptoAlgorithmRsaOaepParams>(parameters);
-    auto& rsaKey = downcast<CryptoKeyRSA>(key);
-    return encryptRSA_OAEP(rsaKey.hashAlgorithmIdentifier(), rsaParameters.labelVector(), rsaKey.platformKey(), rsaKey.keySizeInBits(), plainText);
+    return encryptRSA_OAEP(key.hashAlgorithmIdentifier(), parameters.labelVector(), key.platformKey(), key.keySizeInBits(), plainText);
 }
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_OAEP::platformDecrypt(CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& cipherText)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_OAEP::platformDecrypt(CryptoAlgorithmRsaOaepParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& cipherText)
 {
-    auto& rsaParameters = downcast<CryptoAlgorithmRsaOaepParams>(parameters);
-    auto& rsaKey = downcast<CryptoKeyRSA>(key);
-    return decryptRSA_OAEP(rsaKey.hashAlgorithmIdentifier(), rsaParameters.labelVector(), rsaKey.platformKey(), rsaKey.keySizeInBits(), cipherText);
+    return decryptRSA_OAEP(key.hashAlgorithmIdentifier(), parameters.labelVector(), key.platformKey(), key.keySizeInBits(), cipherText);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSA_PSSMac.cpp (221664 => 221665)


--- trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSA_PSSMac.cpp	2017-09-06 05:25:14 UTC (rev 221664)
+++ trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSA_PSSMac.cpp	2017-09-06 06:48:49 UTC (rev 221665)
@@ -81,18 +81,14 @@
     return false;
 }
 
-ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_PSS::platformSign(CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& data)
+ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_PSS::platformSign(CryptoAlgorithmRsaPssParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& data)
 {
-    auto& rsaKey = downcast<CryptoKeyRSA>(key);
-    auto& rsaParameters = downcast<CryptoAlgorithmRsaPssParams>(parameters);
-    return signRSA_PSS(rsaKey.hashAlgorithmIdentifier(), rsaKey.platformKey(), rsaKey.keySizeInBits(), data, rsaParameters.saltLength);
+    return signRSA_PSS(key.hashAlgorithmIdentifier(), key.platformKey(), key.keySizeInBits(), data, parameters.saltLength);
 }
 
-ExceptionOr<bool> CryptoAlgorithmRSA_PSS::platformVerify(CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& signature, const Vector<uint8_t>& data)
+ExceptionOr<bool> CryptoAlgorithmRSA_PSS::platformVerify(CryptoAlgorithmRsaPssParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& signature, const Vector<uint8_t>& data)
 {
-    auto& rsaKey = downcast<CryptoKeyRSA>(key);
-    auto& rsaParameters = downcast<CryptoAlgorithmRsaPssParams>(parameters);
-    return verifyRSA_PSS(rsaKey.hashAlgorithmIdentifier(), rsaKey.platformKey(), signature, data, rsaParameters.saltLength);
+    return verifyRSA_PSS(key.hashAlgorithmIdentifier(), key.platformKey(), signature, data, parameters.saltLength);
 }
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to