[WebCrypto] Get rid of CryptoKeyData class and all its subclasses
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 19 Aug 2017 01:40:54 +0000 (01:40 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 19 Aug 2017 01:40:54 +0000 (01:40 +0000)
https://bugs.webkit.org/show_bug.cgi?id=169806

Reviewed by Chris Dumez.

- Replaces the CryptoKeyData type hierarchy

    CryptoKeyData
      - CryptoKeyDataOctetSequence
      - CryptoKeyDataRSAComponents

  with the renamed CryptoKeyRSAComponents.

- Removes pure virtual exportData function on CryptoKey, and all
  the implementations except the one on CryptoKeyRSA, which now is
  non-virtual, and returns a CryptoKeyRSAComponents. Update the one
  external caller, SerializedScriptValue, to handle this.

* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/SerializedScriptValue.cpp:
* crypto/CryptoAlgorithm.h:
* crypto/CryptoKey.h:
* crypto/CryptoKeyData.h: Removed.
* crypto/algorithms/CryptoAlgorithmAES_CBC.cpp:
* crypto/algorithms/CryptoAlgorithmAES_KW.cpp:
* crypto/algorithms/CryptoAlgorithmHMAC.cpp:
* crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp:
* crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp:
* crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp:
* crypto/gcrypt/CryptoKeyRSAGCrypt.cpp:
(WebCore::CryptoKeyRSA::create):
(WebCore::CryptoKeyRSA::exportData const):
* crypto/keys/CryptoKeyAES.cpp:
(WebCore::CryptoKeyAES::exportData const): Deleted.
* crypto/keys/CryptoKeyAES.h:
* crypto/keys/CryptoKeyDataOctetSequence.cpp: Removed.
* crypto/keys/CryptoKeyDataOctetSequence.h: Removed.
* crypto/keys/CryptoKeyDataRSAComponents.cpp: Removed.
* crypto/keys/CryptoKeyDataRSAComponents.h: Removed.
* crypto/keys/CryptoKeyEC.cpp:
(WebCore::CryptoKeyEC::exportData const): Deleted.
* crypto/keys/CryptoKeyEC.h:
* crypto/keys/CryptoKeyHMAC.cpp:
(WebCore::CryptoKeyHMAC::exportData const): Deleted.
* crypto/keys/CryptoKeyHMAC.h:
* crypto/keys/CryptoKeyRSA.cpp:
(WebCore::CryptoKeyRSA::importJwk):
(WebCore::CryptoKeyRSA::exportJwk const):
* crypto/keys/CryptoKeyRSA.h:
* crypto/keys/CryptoKeyRSAComponents.cpp: Copied from crypto/keys/CryptoKeyDataRSAComponents.cpp.
(WebCore::CryptoKeyRSAComponents::CryptoKeyRSAComponents):
(WebCore::CryptoKeyRSAComponents::~CryptoKeyRSAComponents):
(WebCore::CryptoKeyDataRSAComponents::CryptoKeyDataRSAComponents): Deleted.
(WebCore::CryptoKeyDataRSAComponents::~CryptoKeyDataRSAComponents): Deleted.
* crypto/keys/CryptoKeyRSAComponents.h: Copied from crypto/keys/CryptoKeyDataRSAComponents.h.
(WebCore::CryptoKeyRSAComponents::createPublic):
(WebCore::CryptoKeyRSAComponents::createPrivate):
(WebCore::CryptoKeyRSAComponents::createPrivateWithAdditionalData):
* crypto/keys/CryptoKeyRaw.cpp:
(WebCore::CryptoKeyRaw::exportData const): Deleted.
* crypto/keys/CryptoKeyRaw.h:
* crypto/mac/CryptoKeyRSAMac.cpp:
(WebCore::getPrivateKeyComponents):
(WebCore::CryptoKeyRSA::create):
(WebCore::CryptoKeyRSA::exportData const):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220949 268f45cc-cd09-0410-ab3c-d52691b4dbfc

30 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/SerializedScriptValue.cpp
Source/WebCore/crypto/CryptoAlgorithm.h
Source/WebCore/crypto/CryptoKey.h
Source/WebCore/crypto/CryptoKeyData.h [deleted file]
Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.cpp
Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.cpp
Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp
Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp
Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp
Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp
Source/WebCore/crypto/gcrypt/CryptoKeyRSAGCrypt.cpp
Source/WebCore/crypto/keys/CryptoKeyAES.cpp
Source/WebCore/crypto/keys/CryptoKeyAES.h
Source/WebCore/crypto/keys/CryptoKeyDataOctetSequence.cpp [deleted file]
Source/WebCore/crypto/keys/CryptoKeyDataOctetSequence.h [deleted file]
Source/WebCore/crypto/keys/CryptoKeyDataRSAComponents.h [deleted file]
Source/WebCore/crypto/keys/CryptoKeyEC.cpp
Source/WebCore/crypto/keys/CryptoKeyEC.h
Source/WebCore/crypto/keys/CryptoKeyHMAC.cpp
Source/WebCore/crypto/keys/CryptoKeyHMAC.h
Source/WebCore/crypto/keys/CryptoKeyRSA.cpp
Source/WebCore/crypto/keys/CryptoKeyRSA.h
Source/WebCore/crypto/keys/CryptoKeyRSAComponents.cpp [moved from Source/WebCore/crypto/keys/CryptoKeyDataRSAComponents.cpp with 60% similarity]
Source/WebCore/crypto/keys/CryptoKeyRSAComponents.h [new file with mode: 0644]
Source/WebCore/crypto/keys/CryptoKeyRaw.cpp
Source/WebCore/crypto/keys/CryptoKeyRaw.h
Source/WebCore/crypto/mac/CryptoKeyRSAMac.cpp

index aa8b4c5..a416911 100644 (file)
@@ -1334,11 +1334,10 @@ set(WebCore_SOURCES
     crypto/algorithms/CryptoAlgorithmSHA512.cpp
 
     crypto/keys/CryptoKeyAES.cpp
-    crypto/keys/CryptoKeyDataOctetSequence.cpp
-    crypto/keys/CryptoKeyDataRSAComponents.cpp
     crypto/keys/CryptoKeyEC.cpp
     crypto/keys/CryptoKeyHMAC.cpp
     crypto/keys/CryptoKeyRSA.cpp
+    crypto/keys/CryptoKeyRSAComponents.cpp
     crypto/keys/CryptoKeyRaw.cpp
 
     css/BasicShapeFunctions.cpp
index a40d121..88e3a58 100644 (file)
@@ -1,3 +1,72 @@
+2017-08-18  Sam Weinig  <sam@webkit.org>
+
+        [WebCrypto] Get rid of CryptoKeyData class and all its subclasses
+        https://bugs.webkit.org/show_bug.cgi?id=169806
+
+        Reviewed by Chris Dumez.
+
+        - Replaces the CryptoKeyData type hierarchy 
+
+            CryptoKeyData
+              - CryptoKeyDataOctetSequence
+              - CryptoKeyDataRSAComponents
+
+          with the renamed CryptoKeyRSAComponents.
+
+        - Removes pure virtual exportData function on CryptoKey, and all
+          the implementations except the one on CryptoKeyRSA, which now is
+          non-virtual, and returns a CryptoKeyRSAComponents. Update the one
+          external caller, SerializedScriptValue, to handle this.
+
+        * CMakeLists.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/SerializedScriptValue.cpp:
+        * crypto/CryptoAlgorithm.h:
+        * crypto/CryptoKey.h:
+        * crypto/CryptoKeyData.h: Removed.
+        * crypto/algorithms/CryptoAlgorithmAES_CBC.cpp:
+        * crypto/algorithms/CryptoAlgorithmAES_KW.cpp:
+        * crypto/algorithms/CryptoAlgorithmHMAC.cpp:
+        * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp:
+        * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp:
+        * crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp:
+        * crypto/gcrypt/CryptoKeyRSAGCrypt.cpp:
+        (WebCore::CryptoKeyRSA::create):
+        (WebCore::CryptoKeyRSA::exportData const):
+        * crypto/keys/CryptoKeyAES.cpp:
+        (WebCore::CryptoKeyAES::exportData const): Deleted.
+        * crypto/keys/CryptoKeyAES.h:
+        * crypto/keys/CryptoKeyDataOctetSequence.cpp: Removed.
+        * crypto/keys/CryptoKeyDataOctetSequence.h: Removed.
+        * crypto/keys/CryptoKeyDataRSAComponents.cpp: Removed.
+        * crypto/keys/CryptoKeyDataRSAComponents.h: Removed.
+        * crypto/keys/CryptoKeyEC.cpp:
+        (WebCore::CryptoKeyEC::exportData const): Deleted.
+        * crypto/keys/CryptoKeyEC.h:
+        * crypto/keys/CryptoKeyHMAC.cpp:
+        (WebCore::CryptoKeyHMAC::exportData const): Deleted.
+        * crypto/keys/CryptoKeyHMAC.h:
+        * crypto/keys/CryptoKeyRSA.cpp:
+        (WebCore::CryptoKeyRSA::importJwk):
+        (WebCore::CryptoKeyRSA::exportJwk const):
+        * crypto/keys/CryptoKeyRSA.h:
+        * crypto/keys/CryptoKeyRSAComponents.cpp: Copied from crypto/keys/CryptoKeyDataRSAComponents.cpp.
+        (WebCore::CryptoKeyRSAComponents::CryptoKeyRSAComponents):
+        (WebCore::CryptoKeyRSAComponents::~CryptoKeyRSAComponents):
+        (WebCore::CryptoKeyDataRSAComponents::CryptoKeyDataRSAComponents): Deleted.
+        (WebCore::CryptoKeyDataRSAComponents::~CryptoKeyDataRSAComponents): Deleted.
+        * crypto/keys/CryptoKeyRSAComponents.h: Copied from crypto/keys/CryptoKeyDataRSAComponents.h.
+        (WebCore::CryptoKeyRSAComponents::createPublic):
+        (WebCore::CryptoKeyRSAComponents::createPrivate):
+        (WebCore::CryptoKeyRSAComponents::createPrivateWithAdditionalData):
+        * crypto/keys/CryptoKeyRaw.cpp:
+        (WebCore::CryptoKeyRaw::exportData const): Deleted.
+        * crypto/keys/CryptoKeyRaw.h:
+        * crypto/mac/CryptoKeyRSAMac.cpp:
+        (WebCore::getPrivateKeyComponents):
+        (WebCore::CryptoKeyRSA::create):
+        (WebCore::CryptoKeyRSA::exportData const):
+
 2017-08-18  Youenn Fablet  <youenn@apple.com>
 
         [Cache API] Add support for being loaded responses
index e2e517a..6950c05 100644 (file)
                E125F845182425C900D84CD9 /* CryptoAlgorithmAES_CBCMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E125F843182425C900D84CD9 /* CryptoAlgorithmAES_CBCMac.cpp */; };
                E125F84D1824289D00D84CD9 /* CryptoKeyAES.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E125F84B1824289D00D84CD9 /* CryptoKeyAES.cpp */; };
                E125F84E1824289D00D84CD9 /* CryptoKeyAES.h in Headers */ = {isa = PBXBuildFile; fileRef = E125F84C1824289D00D84CD9 /* CryptoKeyAES.h */; };
-               E125F85E182C2DF600D84CD9 /* CryptoKeyData.h in Headers */ = {isa = PBXBuildFile; fileRef = E125F85D182C2DF600D84CD9 /* CryptoKeyData.h */; };
-               E125F863182C303A00D84CD9 /* CryptoKeyDataOctetSequence.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E125F861182C303A00D84CD9 /* CryptoKeyDataOctetSequence.cpp */; };
-               E125F864182C303A00D84CD9 /* CryptoKeyDataOctetSequence.h in Headers */ = {isa = PBXBuildFile; fileRef = E125F862182C303A00D84CD9 /* CryptoKeyDataOctetSequence.h */; };
                E12719C70EEEC16800F61213 /* NavigatorBase.h in Headers */ = {isa = PBXBuildFile; fileRef = E12719C60EEEC16800F61213 /* NavigatorBase.h */; };
                E12719CA0EEEC21300F61213 /* NavigatorBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E12719C90EEEC21300F61213 /* NavigatorBase.cpp */; };
                E1271A0B0EEEC77A00F61213 /* WorkerNavigator.h in Headers */ = {isa = PBXBuildFile; fileRef = E1271A0A0EEEC77A00F61213 /* WorkerNavigator.h */; };
                E1BE512D0CF6C512002EA959 /* XSLTUnicodeSort.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1BE512B0CF6C512002EA959 /* XSLTUnicodeSort.cpp */; };
                E1BE512E0CF6C512002EA959 /* XSLTUnicodeSort.h in Headers */ = {isa = PBXBuildFile; fileRef = E1BE512C0CF6C512002EA959 /* XSLTUnicodeSort.h */; };
                E1C266D818317AB4003F8B33 /* CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1C266D618317AB4003F8B33 /* CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp */; };
-               E1C266DE18319F31003F8B33 /* CryptoKeyDataRSAComponents.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1C266DC18319F31003F8B33 /* CryptoKeyDataRSAComponents.cpp */; };
-               E1C266DF18319F31003F8B33 /* CryptoKeyDataRSAComponents.h in Headers */ = {isa = PBXBuildFile; fileRef = E1C266DD18319F31003F8B33 /* CryptoKeyDataRSAComponents.h */; };
+               E1C266DE18319F31003F8B33 /* CryptoKeyRSAComponents.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1C266DC18319F31003F8B33 /* CryptoKeyRSAComponents.cpp */; };
+               E1C266DF18319F31003F8B33 /* CryptoKeyRSAComponents.h in Headers */ = {isa = PBXBuildFile; fileRef = E1C266DD18319F31003F8B33 /* CryptoKeyRSAComponents.h */; };
                E1C362EF0EAF2AA9007410BC /* JSWorkerLocation.h in Headers */ = {isa = PBXBuildFile; fileRef = E1C362ED0EAF2AA9007410BC /* JSWorkerLocation.h */; };
                E1C362F00EAF2AA9007410BC /* JSWorkerLocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1C362EE0EAF2AA9007410BC /* JSWorkerLocation.cpp */; };
                E1C36C030EB076D6007410BC /* JSDOMGlobalObject.h in Headers */ = {isa = PBXBuildFile; fileRef = E1C36C020EB076D6007410BC /* JSDOMGlobalObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E125F843182425C900D84CD9 /* CryptoAlgorithmAES_CBCMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoAlgorithmAES_CBCMac.cpp; sourceTree = "<group>"; };
                E125F84B1824289D00D84CD9 /* CryptoKeyAES.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoKeyAES.cpp; sourceTree = "<group>"; };
                E125F84C1824289D00D84CD9 /* CryptoKeyAES.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoKeyAES.h; sourceTree = "<group>"; };
-               E125F85D182C2DF600D84CD9 /* CryptoKeyData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoKeyData.h; sourceTree = "<group>"; };
-               E125F861182C303A00D84CD9 /* CryptoKeyDataOctetSequence.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoKeyDataOctetSequence.cpp; sourceTree = "<group>"; };
-               E125F862182C303A00D84CD9 /* CryptoKeyDataOctetSequence.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoKeyDataOctetSequence.h; sourceTree = "<group>"; };
                E12719C60EEEC16800F61213 /* NavigatorBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NavigatorBase.h; sourceTree = "<group>"; };
                E12719C90EEEC21300F61213 /* NavigatorBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NavigatorBase.cpp; sourceTree = "<group>"; };
                E1271A0A0EEEC77A00F61213 /* WorkerNavigator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WorkerNavigator.h; sourceTree = "<group>"; };
                E1BE512B0CF6C512002EA959 /* XSLTUnicodeSort.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XSLTUnicodeSort.cpp; sourceTree = "<group>"; };
                E1BE512C0CF6C512002EA959 /* XSLTUnicodeSort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XSLTUnicodeSort.h; sourceTree = "<group>"; };
                E1C266D618317AB4003F8B33 /* CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp; sourceTree = "<group>"; };
-               E1C266DC18319F31003F8B33 /* CryptoKeyDataRSAComponents.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoKeyDataRSAComponents.cpp; sourceTree = "<group>"; };
-               E1C266DD18319F31003F8B33 /* CryptoKeyDataRSAComponents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoKeyDataRSAComponents.h; sourceTree = "<group>"; };
+               E1C266DC18319F31003F8B33 /* CryptoKeyRSAComponents.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoKeyRSAComponents.cpp; sourceTree = "<group>"; };
+               E1C266DD18319F31003F8B33 /* CryptoKeyRSAComponents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoKeyRSAComponents.h; sourceTree = "<group>"; };
                E1C362ED0EAF2AA9007410BC /* JSWorkerLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWorkerLocation.h; sourceTree = "<group>"; };
                E1C362EE0EAF2AA9007410BC /* JSWorkerLocation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWorkerLocation.cpp; sourceTree = "<group>"; };
                E1C36C020EB076D6007410BC /* JSDOMGlobalObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMGlobalObject.h; sourceTree = "<group>"; };
                                E125F84C1824289D00D84CD9 /* CryptoKeyAES.h */,
                                7C9ACA8F1F3CC0AA00F3AA09 /* CryptoKeyAlgorithm.h */,
                                7C9ACA911F3CC0AA00F3AA09 /* CryptoKeyAlgorithm.idl */,
-                               E125F861182C303A00D84CD9 /* CryptoKeyDataOctetSequence.cpp */,
-                               E125F862182C303A00D84CD9 /* CryptoKeyDataOctetSequence.h */,
-                               E1C266DC18319F31003F8B33 /* CryptoKeyDataRSAComponents.cpp */,
-                               E1C266DD18319F31003F8B33 /* CryptoKeyDataRSAComponents.h */,
+                               E1C266DC18319F31003F8B33 /* CryptoKeyRSAComponents.cpp */,
+                               E1C266DD18319F31003F8B33 /* CryptoKeyRSAComponents.h */,
                                5750A9721E68D00000705C4A /* CryptoKeyEC.cpp */,
                                5750A9731E68D00000705C4A /* CryptoKeyEC.h */,
                                E125F8331822F18A00D84CD9 /* CryptoKeyHMAC.cpp */,
                                E157A8E218173A3A009F821D /* CryptoKey.cpp */,
                                E157A8E318173A3A009F821D /* CryptoKey.h */,
                                E157A8DC18172C2C009F821D /* CryptoKey.idl */,
-                               E125F85D182C2DF600D84CD9 /* CryptoKeyData.h */,
                                7C9ACAC91F40B96A00F3AA09 /* CryptoKeyFormat.h */,
                                E1F80B8618317252007885C3 /* CryptoKeyPair.h */,
                                E1F80B8418317247007885C3 /* CryptoKeyPair.idl */,
                                E157A8E518173A3A009F821D /* CryptoKey.h in Headers */,
                                E125F84E1824289D00D84CD9 /* CryptoKeyAES.h in Headers */,
                                7C9ACA921F3CC0AA00F3AA09 /* CryptoKeyAlgorithm.h in Headers */,
-                               E125F85E182C2DF600D84CD9 /* CryptoKeyData.h in Headers */,
-                               E125F864182C303A00D84CD9 /* CryptoKeyDataOctetSequence.h in Headers */,
-                               E1C266DF18319F31003F8B33 /* CryptoKeyDataRSAComponents.h in Headers */,
+                               E1C266DF18319F31003F8B33 /* CryptoKeyRSAComponents.h in Headers */,
                                5750A9751E68D00000705C4A /* CryptoKeyEC.h in Headers */,
                                E125F8361822F18A00D84CD9 /* CryptoKeyHMAC.h in Headers */,
                                E1F80B8818317252007885C3 /* CryptoKeyPair.h in Headers */,
                                E19AC3F41824DC7900349426 /* CryptoAlgorithmSHA512.cpp in Sources */,
                                E157A8E418173A3A009F821D /* CryptoKey.cpp in Sources */,
                                E125F84D1824289D00D84CD9 /* CryptoKeyAES.cpp in Sources */,
-                               E125F863182C303A00D84CD9 /* CryptoKeyDataOctetSequence.cpp in Sources */,
-                               E1C266DE18319F31003F8B33 /* CryptoKeyDataRSAComponents.cpp in Sources */,
+                               E1C266DE18319F31003F8B33 /* CryptoKeyRSAComponents.cpp in Sources */,
                                5750A9741E68D00000705C4A /* CryptoKeyEC.cpp in Sources */,
                                5750A97B1E69161600705C4A /* CryptoKeyECMac.cpp in Sources */,
                                E125F8351822F18A00D84CD9 /* CryptoKeyHMAC.cpp in Sources */,
index 92caa20..6fd8382 100644 (file)
 #include "Blob.h"
 #include "BlobRegistry.h"
 #include "CryptoKeyAES.h"
-#include "CryptoKeyDataOctetSequence.h"
-#include "CryptoKeyDataRSAComponents.h"
 #include "CryptoKeyEC.h"
 #include "CryptoKeyHMAC.h"
 #include "CryptoKeyRSA.h"
+#include "CryptoKeyRSAComponents.h"
 #include "CryptoKeyRaw.h"
 #include "File.h"
 #include "FileList.h"
@@ -1315,24 +1314,24 @@ private:
         }
     }
 
-    void write(CryptoKeyDataRSAComponents::Type type)
+    void write(CryptoKeyRSAComponents::Type type)
     {
         switch (type) {
-        case CryptoKeyDataRSAComponents::Type::Public:
+        case CryptoKeyRSAComponents::Type::Public:
             write(CryptoKeyAsymmetricTypeSubtag::Public);
             return;
-        case CryptoKeyDataRSAComponents::Type::Private:
+        case CryptoKeyRSAComponents::Type::Private:
             write(CryptoKeyAsymmetricTypeSubtag::Private);
             return;
         }
     }
 
-    void write(const CryptoKeyDataRSAComponents& key)
+    void write(const CryptoKeyRSAComponents& key)
     {
         write(key.type());
         write(key.modulus());
         write(key.exponent());
-        if (key.type() == CryptoKeyDataRSAComponents::Type::Public)
+        if (key.type() == CryptoKeyRSAComponents::Type::Public)
             return;
 
         write(key.privateExponent());
@@ -1427,7 +1426,7 @@ private:
             write(isRestrictedToHash);
             if (isRestrictedToHash)
                 write(hash);
-            write(downcast<CryptoKeyDataRSAComponents>(*key->exportData()));
+            write(*downcast<CryptoKeyRSA>(*key).exportData());
             break;
         }
     }
@@ -2293,7 +2292,7 @@ private:
             return false;
 
         if (type == CryptoKeyAsymmetricTypeSubtag::Public) {
-            auto keyData = CryptoKeyDataRSAComponents::createPublic(modulus, exponent);
+            auto keyData = CryptoKeyRSAComponents::createPublic(modulus, exponent);
             auto key = CryptoKeyRSA::create(algorithm, hash, isRestrictedToHash, *keyData, extractable, usages);
             result = WTFMove(key);
             return true;
@@ -2308,7 +2307,7 @@ private:
             return false;
 
         if (!primeCount) {
-            auto keyData = CryptoKeyDataRSAComponents::createPrivate(modulus, exponent, privateExponent);
+            auto keyData = CryptoKeyRSAComponents::createPrivate(modulus, exponent, privateExponent);
             auto key = CryptoKeyRSA::create(algorithm, hash, isRestrictedToHash, *keyData, extractable, usages);
             result = WTFMove(key);
             return true;
@@ -2317,9 +2316,9 @@ private:
         if (primeCount < 2)
             return false;
 
-        CryptoKeyDataRSAComponents::PrimeInfo firstPrimeInfo;
-        CryptoKeyDataRSAComponents::PrimeInfo secondPrimeInfo;
-        Vector<CryptoKeyDataRSAComponents::PrimeInfo> otherPrimeInfos(primeCount - 2);
+        CryptoKeyRSAComponents::PrimeInfo firstPrimeInfo;
+        CryptoKeyRSAComponents::PrimeInfo secondPrimeInfo;
+        Vector<CryptoKeyRSAComponents::PrimeInfo> otherPrimeInfos(primeCount - 2);
 
         if (!read(firstPrimeInfo.primeFactor))
             return false;
@@ -2340,7 +2339,7 @@ private:
                 return false;
         }
 
-        auto keyData = CryptoKeyDataRSAComponents::createPrivateWithAdditionalData(modulus, exponent, privateExponent, firstPrimeInfo, secondPrimeInfo, otherPrimeInfos);
+        auto keyData = CryptoKeyRSAComponents::createPrivateWithAdditionalData(modulus, exponent, privateExponent, firstPrimeInfo, secondPrimeInfo, otherPrimeInfos);
         auto key = CryptoKeyRSA::create(algorithm, hash, isRestrictedToHash, *keyData, extractable, usages);
         result = WTFMove(key);
         return true;
index 78bcac4..eba7c5d 100644 (file)
@@ -43,7 +43,6 @@ namespace WebCore {
 
 class CryptoAlgorithmParameters;
 class CryptoKey;
-class CryptoKeyData;
 class ScriptExecutionContext;
 
 using KeyData = Variant<Vector<uint8_t>, JsonWebKey>;
index 9a5bc80..b14f4a5 100644 (file)
@@ -46,7 +46,6 @@
 namespace WebCore {
 
 class CryptoAlgorithmDescriptionBuilder;
-class CryptoKeyData;
 
 enum class CryptoKeyClass {
     AES,
@@ -106,8 +105,6 @@ public:
     void setUsagesBitmap(CryptoKeyUsageBitmap usage) { m_usages = usage; };
     bool allows(CryptoKeyUsageBitmap usage) const { return usage == (m_usages & usage); }
 
-    virtual std::unique_ptr<CryptoKeyData> exportData() const = 0;
-
     static Vector<uint8_t> randomData(size_t);
 
 private:
diff --git a/Source/WebCore/crypto/CryptoKeyData.h b/Source/WebCore/crypto/CryptoKeyData.h
deleted file mode 100644 (file)
index 2c2adbc..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#if ENABLE(SUBTLE_CRYPTO)
-
-#include <wtf/Noncopyable.h>
-#include <wtf/TypeCasts.h>
-
-namespace WebCore {
-
-class CryptoKeyData {
-    WTF_MAKE_NONCOPYABLE(CryptoKeyData);
-public:
-    enum class Format {
-        OctetSequence,
-        RSAComponents
-    };
-
-    CryptoKeyData(Format format)
-        : m_format(format)
-    {
-    }
-    virtual ~CryptoKeyData() { }
-
-    Format format() const { return m_format; }
-
-private:
-    Format m_format;
-};
-
-} // namespace WebCore
-
-#define SPECIALIZE_TYPE_TRAITS_CRYPTO_KEY_DATA(ToClassName, Format) \
-SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToClassName) \
-    static bool isType(const WebCore::CryptoKeyData& keyData) { return keyData.format() == WebCore::Format; } \
-SPECIALIZE_TYPE_TRAITS_END()
-
-#endif // ENABLE(SUBTLE_CRYPTO)
index f1c97b7..ce6077d 100644 (file)
@@ -31,7 +31,6 @@
 #include "CryptoAlgorithmAesCbcCfbParams.h"
 #include "CryptoAlgorithmAesKeyParams.h"
 #include "CryptoKeyAES.h"
-#include "CryptoKeyDataOctetSequence.h"
 
 namespace WebCore {
 
index dbf34e9..780a586 100644 (file)
@@ -30,7 +30,6 @@
 
 #include "CryptoAlgorithmAesKeyParams.h"
 #include "CryptoKeyAES.h"
-#include "CryptoKeyDataOctetSequence.h"
 #include <wtf/Variant.h>
 
 namespace WebCore {
index 731ea3e..af6521c 100644 (file)
@@ -29,7 +29,6 @@
 #if ENABLE(SUBTLE_CRYPTO)
 
 #include "CryptoAlgorithmHmacKeyParams.h"
-#include "CryptoKeyDataOctetSequence.h"
 #include "CryptoKeyHMAC.h"
 #include <wtf/Variant.h>
 
index b9df0ec..e4db593 100644 (file)
@@ -29,7 +29,6 @@
 #if ENABLE(SUBTLE_CRYPTO)
 
 #include "CryptoAlgorithmRsaKeyGenParams.h"
-#include "CryptoKeyDataRSAComponents.h"
 #include "CryptoKeyPair.h"
 #include "CryptoKeyRSA.h"
 #include <wtf/Variant.h>
index 75323d8..293b8ef 100644 (file)
@@ -30,7 +30,6 @@
 
 #include "CryptoAlgorithmRsaHashedImportParams.h"
 #include "CryptoAlgorithmRsaHashedKeyGenParams.h"
-#include "CryptoKeyDataRSAComponents.h"
 #include "CryptoKeyPair.h"
 #include "CryptoKeyRSA.h"
 #include <wtf/Variant.h>
index 980c22d..4debff0 100644 (file)
@@ -30,7 +30,6 @@
 
 #include "CryptoAlgorithmRsaHashedImportParams.h"
 #include "CryptoAlgorithmRsaHashedKeyGenParams.h"
-#include "CryptoKeyDataRSAComponents.h"
 #include "CryptoKeyPair.h"
 #include "CryptoKeyRSA.h"
 #include <wtf/Variant.h>
index 73c0190..c3737b9 100644 (file)
@@ -29,8 +29,8 @@
 #if ENABLE(SUBTLE_CRYPTO)
 
 #include "CryptoAlgorithmRegistry.h"
-#include "CryptoKeyDataRSAComponents.h"
 #include "CryptoKeyPair.h"
+#include "CryptoKeyRSAComponents.h"
 #include "GCryptUtilities.h"
 #include "ScriptExecutionContext.h"
 #include <pal/crypto/gcrypt/Handle.h>
@@ -69,10 +69,10 @@ static Vector<uint8_t> getRSAKeyParameter(gcry_sexp_t keySexp, const char* name)
     return WTFMove(data.value());
 }
 
-RefPtr<CryptoKeyRSA> CryptoKeyRSA::create(CryptoAlgorithmIdentifier identifier, CryptoAlgorithmIdentifier hash, bool hasHash, const CryptoKeyDataRSAComponents& keyData, bool extractable, CryptoKeyUsageBitmap usages)
+RefPtr<CryptoKeyRSA> CryptoKeyRSA::create(CryptoAlgorithmIdentifier identifier, CryptoAlgorithmIdentifier hash, bool hasHash, const CryptoKeyRSAComponents& keyData, bool extractable, CryptoKeyUsageBitmap usages)
 {
     // When creating a private key, we require the p and q prime information.
-    if (keyData.type() == CryptoKeyDataRSAComponents::Type::Private && !keyData.hasAdditionalPrivateKeyParameters())
+    if (keyData.type() == CryptoKeyRSAComponents::Type::Private && !keyData.hasAdditionalPrivateKeyParameters())
         return nullptr;
 
     // But we don't currently support creating keys with any additional prime information.
@@ -87,7 +87,7 @@ RefPtr<CryptoKeyRSA> CryptoKeyRSA::create(CryptoAlgorithmIdentifier identifier,
         valid &= !keyData.modulus().isEmpty() && !keyData.exponent().isEmpty();
 
         // For private keys, we require the private exponent, as well as p and q prime information.
-        if (keyData.type() == CryptoKeyDataRSAComponents::Type::Private)
+        if (keyData.type() == CryptoKeyRSAComponents::Type::Private)
             valid &= !keyData.privateExponent().isEmpty() && !keyData.firstPrimeInfo().primeFactor.isEmpty() && !keyData.secondPrimeInfo().primeFactor.isEmpty();
 
         if (!valid)
@@ -96,10 +96,10 @@ RefPtr<CryptoKeyRSA> CryptoKeyRSA::create(CryptoAlgorithmIdentifier identifier,
 
     CryptoKeyType keyType;
     switch (keyData.type()) {
-    case CryptoKeyDataRSAComponents::Type::Public:
+    case CryptoKeyRSAComponents::Type::Public:
         keyType = CryptoKeyType::Public;
         break;
-    case CryptoKeyDataRSAComponents::Type::Private:
+    case CryptoKeyRSAComponents::Type::Private:
         keyType = CryptoKeyType::Private;
         break;
     }
@@ -630,13 +630,13 @@ std::unique_ptr<KeyAlgorithm> CryptoKeyRSA::buildAlgorithm() const
     return std::make_unique<RsaKeyAlgorithm>(name, modulusLength, WTFMove(publicExponent));
 }
 
-std::unique_ptr<CryptoKeyData> CryptoKeyRSA::exportData() const
+std::unique_ptr<CryptoKeyRSAComponents> CryptoKeyRSA::exportData() const
 {
     ASSERT(extractable());
 
     switch (type()) {
     case CryptoKeyType::Public:
-        return CryptoKeyDataRSAComponents::createPublic(getRSAKeyParameter(m_platformKey, "n"), getRSAKeyParameter(m_platformKey, "e"));
+        return CryptoKeyRSAComponents::createPublic(getRSAKeyParameter(m_platformKey, "n"), getRSAKeyParameter(m_platformKey, "e"));
     case CryptoKeyType::Private: {
         auto parameterMPI =
             [](gcry_sexp_t sexp, const char* name) -> gcry_mpi_t {
@@ -654,11 +654,11 @@ std::unique_ptr<CryptoKeyData> CryptoKeyRSA::exportData() const
         if (!dMPI || !pMPI || !qMPI)
             return nullptr;
 
-        CryptoKeyDataRSAComponents::PrimeInfo firstPrimeInfo;
+        CryptoKeyRSAComponents::PrimeInfo firstPrimeInfo;
         if (auto data = mpiData(pMPI))
             firstPrimeInfo.primeFactor = WTFMove(data.value());
 
-        CryptoKeyDataRSAComponents::PrimeInfo secondPrimeInfo;
+        CryptoKeyRSAComponents::PrimeInfo secondPrimeInfo;
         if (auto data = mpiData(qMPI))
             secondPrimeInfo.primeFactor = WTFMove(data.value());
 
@@ -697,9 +697,9 @@ std::unique_ptr<CryptoKeyData> CryptoKeyRSA::exportData() const
         if (auto data = mpiData(dMPI))
             privateExponent = WTFMove(data.value());
 
-        return CryptoKeyDataRSAComponents::createPrivateWithAdditionalData(
+        return CryptoKeyRSAComponents::createPrivateWithAdditionalData(
             getRSAKeyParameter(m_platformKey, "n"), getRSAKeyParameter(m_platformKey, "e"), WTFMove(privateExponent),
-            WTFMove(firstPrimeInfo), WTFMove(secondPrimeInfo), Vector<CryptoKeyDataRSAComponents::PrimeInfo> { });
+            WTFMove(firstPrimeInfo), WTFMove(secondPrimeInfo), Vector<CryptoKeyRSAComponents::PrimeInfo> { });
     }
     default:
         ASSERT_NOT_REACHED();
index 7af6828..6f77a09 100644 (file)
@@ -30,7 +30,6 @@
 
 #include "CryptoAlgorithmAesKeyParams.h"
 #include "CryptoAlgorithmRegistry.h"
-#include "CryptoKeyDataOctetSequence.h"
 #include "ExceptionOr.h"
 #include "JsonWebKey.h"
 #include <wtf/text/Base64.h>
@@ -136,11 +135,6 @@ std::unique_ptr<KeyAlgorithm> CryptoKeyAES::buildAlgorithm() const
     return std::make_unique<AesKeyAlgorithm>(CryptoAlgorithmRegistry::singleton().name(algorithmIdentifier()), m_key.size() * 8);
 }
 
-std::unique_ptr<CryptoKeyData> CryptoKeyAES::exportData() const
-{
-    return std::make_unique<CryptoKeyDataOctetSequence>(m_key);
-}
-
 } // namespace WebCore
 
 #endif // ENABLE(SUBTLE_CRYPTO)
index eb5c9d1..7a1a8c1 100644 (file)
@@ -88,7 +88,6 @@ private:
     CryptoKeyAES(CryptoAlgorithmIdentifier, Vector<uint8_t>&& key, bool extractable, CryptoKeyUsageBitmap);
 
     std::unique_ptr<KeyAlgorithm> buildAlgorithm() const final;
-    std::unique_ptr<CryptoKeyData> exportData() const final;
 
     Vector<uint8_t> m_key;
 };
diff --git a/Source/WebCore/crypto/keys/CryptoKeyDataOctetSequence.cpp b/Source/WebCore/crypto/keys/CryptoKeyDataOctetSequence.cpp
deleted file mode 100644 (file)
index 27a4e6c..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "CryptoKeyDataOctetSequence.h"
-
-#if ENABLE(SUBTLE_CRYPTO)
-
-namespace WebCore {
-
-CryptoKeyDataOctetSequence::CryptoKeyDataOctetSequence(const Vector<uint8_t>& data)
-    : CryptoKeyData(CryptoKeyData::Format::OctetSequence)
-    , m_keyData(data)
-{
-}
-
-CryptoKeyDataOctetSequence::~CryptoKeyDataOctetSequence()
-{
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(SUBTLE_CRYPTO)
diff --git a/Source/WebCore/crypto/keys/CryptoKeyDataOctetSequence.h b/Source/WebCore/crypto/keys/CryptoKeyDataOctetSequence.h
deleted file mode 100644 (file)
index 645f8ee..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#include "CryptoKeyData.h"
-#include <wtf/Vector.h>
-
-#if ENABLE(SUBTLE_CRYPTO)
-
-namespace WebCore {
-
-class CryptoKeyDataOctetSequence final : public CryptoKeyData {
-public:
-    explicit CryptoKeyDataOctetSequence(const Vector<uint8_t>&);
-    virtual ~CryptoKeyDataOctetSequence();
-
-    const Vector<uint8_t>& octetSequence() const { return m_keyData; }
-
-private:
-    Vector<uint8_t> m_keyData;
-};
-
-} // namespace WebCore
-
-SPECIALIZE_TYPE_TRAITS_CRYPTO_KEY_DATA(CryptoKeyDataOctetSequence, CryptoKeyData::Format::OctetSequence)
-
-#endif // ENABLE(SUBTLE_CRYPTO)
diff --git a/Source/WebCore/crypto/keys/CryptoKeyDataRSAComponents.h b/Source/WebCore/crypto/keys/CryptoKeyDataRSAComponents.h
deleted file mode 100644 (file)
index 294b912..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#include "CryptoKeyData.h"
-#include <wtf/Vector.h>
-
-#if ENABLE(SUBTLE_CRYPTO)
-
-namespace WebCore {
-
-class CryptoKeyDataRSAComponents final : public CryptoKeyData {
-public:
-    enum class Type {
-        Public,
-        Private
-    };
-
-    struct PrimeInfo {
-        Vector<uint8_t> primeFactor;
-        Vector<uint8_t> factorCRTExponent;
-        Vector<uint8_t> factorCRTCoefficient;
-    };
-
-    static std::unique_ptr<CryptoKeyDataRSAComponents> createPublic(const Vector<uint8_t>& modulus, const Vector<uint8_t>& exponent)
-    {
-        return std::unique_ptr<CryptoKeyDataRSAComponents>(new CryptoKeyDataRSAComponents(modulus, exponent));
-    }
-    static std::unique_ptr<CryptoKeyDataRSAComponents> createPublic(Vector<uint8_t>&& modulus, Vector<uint8_t>&& exponent)
-    {
-        return std::unique_ptr<CryptoKeyDataRSAComponents>(new CryptoKeyDataRSAComponents(WTFMove(modulus), WTFMove(exponent)));
-    }
-
-    static std::unique_ptr<CryptoKeyDataRSAComponents> createPrivate(const Vector<uint8_t>& modulus, const Vector<uint8_t>& exponent, const Vector<uint8_t>& privateExponent)
-    {
-        return std::unique_ptr<CryptoKeyDataRSAComponents>(new CryptoKeyDataRSAComponents(modulus, exponent, privateExponent));
-    }
-    static std::unique_ptr<CryptoKeyDataRSAComponents> createPrivate(Vector<uint8_t>&& modulus, Vector<uint8_t>&& exponent, Vector<uint8_t>&& privateExponent)
-    {
-        return std::unique_ptr<CryptoKeyDataRSAComponents>(new CryptoKeyDataRSAComponents(WTFMove(modulus), WTFMove(exponent), WTFMove(privateExponent)));
-    }
-
-    static std::unique_ptr<CryptoKeyDataRSAComponents> createPrivateWithAdditionalData(const Vector<uint8_t>& modulus, const Vector<uint8_t>& exponent, const Vector<uint8_t>& privateExponent, const PrimeInfo& firstPrimeInfo, const PrimeInfo& secondPrimeInfo, const Vector<PrimeInfo>& otherPrimeInfos)
-    {
-        return std::unique_ptr<CryptoKeyDataRSAComponents>(new CryptoKeyDataRSAComponents(modulus, exponent, privateExponent, firstPrimeInfo, secondPrimeInfo, otherPrimeInfos));
-    }
-    static std::unique_ptr<CryptoKeyDataRSAComponents> createPrivateWithAdditionalData(Vector<uint8_t>&& modulus, Vector<uint8_t>&& exponent, Vector<uint8_t>&& privateExponent, PrimeInfo&& firstPrimeInfo, PrimeInfo&& secondPrimeInfo, Vector<PrimeInfo>&& otherPrimeInfos)
-    {
-        return std::unique_ptr<CryptoKeyDataRSAComponents>(new CryptoKeyDataRSAComponents(WTFMove(modulus), WTFMove(exponent), WTFMove(privateExponent), WTFMove(firstPrimeInfo), WTFMove(secondPrimeInfo), WTFMove(otherPrimeInfos)));
-    }
-
-    virtual ~CryptoKeyDataRSAComponents();
-
-    Type type() const { return m_type; }
-
-    // Private and public keys.
-    const Vector<uint8_t>& modulus() const { return m_modulus; }
-    const Vector<uint8_t>& exponent() const { return m_exponent; }
-
-    // Only private keys.
-    const Vector<uint8_t>& privateExponent() const { return m_privateExponent; }
-    bool hasAdditionalPrivateKeyParameters() const { return m_hasAdditionalPrivateKeyParameters; }
-    const PrimeInfo& firstPrimeInfo() const { return m_firstPrimeInfo; }
-    const PrimeInfo& secondPrimeInfo() const { return m_secondPrimeInfo; }
-    const Vector<PrimeInfo>& otherPrimeInfos() const { return m_otherPrimeInfos; }
-
-private:
-    CryptoKeyDataRSAComponents(const Vector<uint8_t>& modulus, const Vector<uint8_t>& exponent);
-    CryptoKeyDataRSAComponents(Vector<uint8_t>&& modulus, Vector<uint8_t>&& exponent);
-
-    CryptoKeyDataRSAComponents(const Vector<uint8_t>& modulus, const Vector<uint8_t>& exponent, const Vector<uint8_t>& privateExponent);
-    CryptoKeyDataRSAComponents(Vector<uint8_t>&& modulus, Vector<uint8_t>&& exponent, Vector<uint8_t>&& privateExponent);
-
-    CryptoKeyDataRSAComponents(const Vector<uint8_t>& modulus, const Vector<uint8_t>& exponent, const Vector<uint8_t>& privateExponent, const PrimeInfo& firstPrimeInfo, const PrimeInfo& secondPrimeInfo, const Vector<PrimeInfo>& otherPrimeInfos);
-    CryptoKeyDataRSAComponents(Vector<uint8_t>&& modulus, Vector<uint8_t>&& exponent, Vector<uint8_t>&& privateExponent, PrimeInfo&& firstPrimeInfo, PrimeInfo&& secondPrimeInfo, Vector<PrimeInfo>&& otherPrimeInfos);
-
-    Type m_type;
-
-    // Private and public keys.
-    Vector<uint8_t> m_modulus;
-    Vector<uint8_t> m_exponent;
-
-    // Only private keys.
-    Vector<uint8_t> m_privateExponent;
-    bool m_hasAdditionalPrivateKeyParameters;
-    PrimeInfo m_firstPrimeInfo;
-    PrimeInfo m_secondPrimeInfo;
-    Vector<PrimeInfo> m_otherPrimeInfos; // When three or more primes have been used, the number of array elements is be the number of primes used minus two.
-};
-
-} // namespace WebCore
-
-SPECIALIZE_TYPE_TRAITS_CRYPTO_KEY_DATA(CryptoKeyDataRSAComponents, CryptoKeyData::Format::RSAComponents)
-
-#endif // ENABLE(SUBTLE_CRYPTO)
index 8b1cd08..ecd269b 100644 (file)
@@ -29,7 +29,6 @@
 #if ENABLE(SUBTLE_CRYPTO)
 
 #include "CryptoAlgorithmRegistry.h"
-#include "CryptoKeyData.h"
 #include "JsonWebKey.h"
 #include <wtf/text/Base64.h>
 
@@ -222,12 +221,6 @@ std::unique_ptr<KeyAlgorithm> CryptoKeyEC::buildAlgorithm() const
     return nullptr;
 }
 
-std::unique_ptr<CryptoKeyData> CryptoKeyEC::exportData() const
-{
-    // A dummy implementation for now.
-    return std::make_unique<CryptoKeyData>(CryptoKeyData::Format::OctetSequence);
-}
-
 } // namespace WebCore
 
 #endif // ENABLE(SUBTLE_CRYPTO)
index a0e488b..526903e 100644 (file)
@@ -102,7 +102,6 @@ private:
     CryptoKeyClass keyClass() const final { return CryptoKeyClass::EC; }
 
     std::unique_ptr<KeyAlgorithm> buildAlgorithm() const final;
-    std::unique_ptr<CryptoKeyData> exportData() const final;
 
     static std::optional<CryptoKeyPair> platformGeneratePair(CryptoAlgorithmIdentifier, NamedCurve, bool extractable, CryptoKeyUsageBitmap);
     static RefPtr<CryptoKeyEC> platformImportRaw(CryptoAlgorithmIdentifier, NamedCurve, Vector<uint8_t>&& keyData, bool extractable, CryptoKeyUsageBitmap);
index bb38b37..ee5dc01 100644 (file)
@@ -30,7 +30,6 @@
 
 #include "CryptoAlgorithmHmacKeyParams.h"
 #include "CryptoAlgorithmRegistry.h"
-#include "CryptoKeyDataOctetSequence.h"
 #include "ExceptionOr.h"
 #include "JsonWebKey.h"
 #include <wtf/text/Base64.h>
@@ -157,11 +156,6 @@ std::unique_ptr<KeyAlgorithm> CryptoKeyHMAC::buildAlgorithm() const
         CryptoAlgorithmRegistry::singleton().name(m_hash), m_key.size() * 8);
 }
 
-std::unique_ptr<CryptoKeyData> CryptoKeyHMAC::exportData() const
-{
-    return std::make_unique<CryptoKeyDataOctetSequence>(m_key);
-}
-
 } // namespace WebCore
 
 #endif // ENABLE(SUBTLE_CRYPTO)
index 9a9d5b4..6c81e5a 100644 (file)
@@ -86,7 +86,6 @@ private:
     CryptoKeyHMAC(Vector<uint8_t>&& key, CryptoAlgorithmIdentifier hash, bool extractable, CryptoKeyUsageBitmap);
 
     std::unique_ptr<KeyAlgorithm> buildAlgorithm() const final;
-    std::unique_ptr<CryptoKeyData> exportData() const final;
 
     CryptoAlgorithmIdentifier m_hash;
     Vector<uint8_t> m_key;
index 0d97559..24826ec 100644 (file)
@@ -26,7 +26,7 @@
 #include "config.h"
 #include "CryptoKeyRSA.h"
 
-#include "CryptoKeyDataRSAComponents.h"
+#include "CryptoKeyRSAComponents.h"
 #include "JsonWebKey.h"
 #include <JavaScriptCore/GenericTypedArrayViewInlines.h>
 #include <JavaScriptCore/JSGenericTypedArrayViewInlines.h>
@@ -78,7 +78,7 @@ RefPtr<CryptoKeyRSA> CryptoKeyRSA::importJwk(CryptoAlgorithmIdentifier algorithm
         return nullptr;
     if (keyData.d.isNull()) {
         // import public key
-        auto publicKeyComponents = CryptoKeyDataRSAComponents::createPublic(WTFMove(modulus), WTFMove(exponent));
+        auto publicKeyComponents = CryptoKeyRSAComponents::createPublic(WTFMove(modulus), WTFMove(exponent));
         // Notice: CryptoAlgorithmIdentifier::SHA_1 is just a placeholder. It should not have any effect if hash is std::nullopt.
         return CryptoKeyRSA::create(algorithm, hash.value_or(CryptoAlgorithmIdentifier::SHA_1), !!hash, *publicKeyComponents, extractable, usages);
     }
@@ -88,15 +88,15 @@ RefPtr<CryptoKeyRSA> CryptoKeyRSA::importJwk(CryptoAlgorithmIdentifier algorithm
     if (!WTF::base64URLDecode(keyData.d, privateExponent))
         return nullptr;
     if (keyData.p.isNull() && keyData.q.isNull() && keyData.dp.isNull() && keyData.dp.isNull() && keyData.qi.isNull()) {
-        auto privateKeyComponents = CryptoKeyDataRSAComponents::createPrivate(WTFMove(modulus), WTFMove(exponent), WTFMove(privateExponent));
+        auto privateKeyComponents = CryptoKeyRSAComponents::createPrivate(WTFMove(modulus), WTFMove(exponent), WTFMove(privateExponent));
         // Notice: CryptoAlgorithmIdentifier::SHA_1 is just a placeholder. It should not have any effect if hash is std::nullopt.
         return CryptoKeyRSA::create(algorithm, hash.value_or(CryptoAlgorithmIdentifier::SHA_1), !!hash, *privateKeyComponents, extractable, usages);
     }
 
     if (keyData.p.isNull() || keyData.q.isNull() || keyData.dp.isNull() || keyData.dq.isNull() || keyData.qi.isNull())
         return nullptr;
-    CryptoKeyDataRSAComponents::PrimeInfo firstPrimeInfo;
-    CryptoKeyDataRSAComponents::PrimeInfo secondPrimeInfo;
+    CryptoKeyRSAComponents::PrimeInfo firstPrimeInfo;
+    CryptoKeyRSAComponents::PrimeInfo secondPrimeInfo;
     if (!WTF::base64URLDecode(keyData.p, firstPrimeInfo.primeFactor))
         return nullptr;
     if (!WTF::base64URLDecode(keyData.dp, firstPrimeInfo.factorCRTExponent))
@@ -108,14 +108,14 @@ RefPtr<CryptoKeyRSA> CryptoKeyRSA::importJwk(CryptoAlgorithmIdentifier algorithm
     if (!WTF::base64URLDecode(keyData.qi, secondPrimeInfo.factorCRTCoefficient))
         return nullptr;
     if (!keyData.oth) {
-        auto privateKeyComponents = CryptoKeyDataRSAComponents::createPrivateWithAdditionalData(WTFMove(modulus), WTFMove(exponent), WTFMove(privateExponent), WTFMove(firstPrimeInfo), WTFMove(secondPrimeInfo), { });
+        auto privateKeyComponents = CryptoKeyRSAComponents::createPrivateWithAdditionalData(WTFMove(modulus), WTFMove(exponent), WTFMove(privateExponent), WTFMove(firstPrimeInfo), WTFMove(secondPrimeInfo), { });
         // Notice: CryptoAlgorithmIdentifier::SHA_1 is just a placeholder. It should not have any effect if hash is std::nullopt.
         return CryptoKeyRSA::create(algorithm, hash.value_or(CryptoAlgorithmIdentifier::SHA_1), !!hash, *privateKeyComponents, extractable, usages);
     }
 
-    Vector<CryptoKeyDataRSAComponents::PrimeInfo> otherPrimeInfos;
+    Vector<CryptoKeyRSAComponents::PrimeInfo> otherPrimeInfos;
     for (auto value : keyData.oth.value()) {
-        CryptoKeyDataRSAComponents::PrimeInfo info;
+        CryptoKeyRSAComponents::PrimeInfo info;
         if (!WTF::base64URLDecode(value.r, info.primeFactor))
             return nullptr;
         if (!WTF::base64URLDecode(value.d, info.factorCRTExponent))
@@ -125,7 +125,7 @@ RefPtr<CryptoKeyRSA> CryptoKeyRSA::importJwk(CryptoAlgorithmIdentifier algorithm
         otherPrimeInfos.append(info);
     }
 
-    auto privateKeyComponents = CryptoKeyDataRSAComponents::createPrivateWithAdditionalData(WTFMove(modulus), WTFMove(exponent), WTFMove(privateExponent), WTFMove(firstPrimeInfo), WTFMove(secondPrimeInfo), WTFMove(otherPrimeInfos));
+    auto privateKeyComponents = CryptoKeyRSAComponents::createPrivateWithAdditionalData(WTFMove(modulus), WTFMove(exponent), WTFMove(privateExponent), WTFMove(firstPrimeInfo), WTFMove(secondPrimeInfo), WTFMove(otherPrimeInfos));
     // Notice: CryptoAlgorithmIdentifier::SHA_1 is just a placeholder. It should not have any effect if hash is std::nullopt.
     return CryptoKeyRSA::create(algorithm, hash.value_or(CryptoAlgorithmIdentifier::SHA_1), !!hash, *privateKeyComponents, extractable, usages);
 }
@@ -137,29 +137,29 @@ JsonWebKey CryptoKeyRSA::exportJwk() const
     result.key_ops = usages();
     result.ext = extractable();
 
-    auto keyData = exportData();
-    const auto& rsaKeyData = downcast<CryptoKeyDataRSAComponents>(*keyData);
+    auto rsaComponents = exportData();
+
     // public key
-    result.n = base64URLEncode(rsaKeyData.modulus());
-    result.e = base64URLEncode(rsaKeyData.exponent());
-    if (rsaKeyData.type() == CryptoKeyDataRSAComponents::Type::Public)
+    result.n = base64URLEncode(rsaComponents->modulus());
+    result.e = base64URLEncode(rsaComponents->exponent());
+    if (rsaComponents->type() == CryptoKeyRSAComponents::Type::Public)
         return result;
 
     // private key
-    result.d = base64URLEncode(rsaKeyData.privateExponent());
-    if (!rsaKeyData.hasAdditionalPrivateKeyParameters())
+    result.d = base64URLEncode(rsaComponents->privateExponent());
+    if (!rsaComponents->hasAdditionalPrivateKeyParameters())
         return result;
 
-    result.p = base64URLEncode(rsaKeyData.firstPrimeInfo().primeFactor);
-    result.q = base64URLEncode(rsaKeyData.secondPrimeInfo().primeFactor);
-    result.dp = base64URLEncode(rsaKeyData.firstPrimeInfo().factorCRTExponent);
-    result.dq = base64URLEncode(rsaKeyData.secondPrimeInfo().factorCRTExponent);
-    result.qi = base64URLEncode(rsaKeyData.secondPrimeInfo().factorCRTCoefficient);
-    if (rsaKeyData.otherPrimeInfos().isEmpty())
+    result.p = base64URLEncode(rsaComponents->firstPrimeInfo().primeFactor);
+    result.q = base64URLEncode(rsaComponents->secondPrimeInfo().primeFactor);
+    result.dp = base64URLEncode(rsaComponents->firstPrimeInfo().factorCRTExponent);
+    result.dq = base64URLEncode(rsaComponents->secondPrimeInfo().factorCRTExponent);
+    result.qi = base64URLEncode(rsaComponents->secondPrimeInfo().factorCRTCoefficient);
+    if (rsaComponents->otherPrimeInfos().isEmpty())
         return result;
 
     Vector<RsaOtherPrimesInfo> oth;
-    for (auto info : rsaKeyData.otherPrimeInfos()) {
+    for (auto info : rsaComponents->otherPrimeInfos()) {
         RsaOtherPrimesInfo otherInfo;
         otherInfo.r = base64URLEncode(info.primeFactor);
         otherInfo.d = base64URLEncode(info.factorCRTExponent);
index c7f9d04..9a8ed92 100644 (file)
@@ -44,7 +44,7 @@ typedef gcry_sexp* PlatformRSAKey;
 
 namespace WebCore {
 
-class CryptoKeyDataRSAComponents;
+class CryptoKeyRSAComponents;
 class PromiseWrapper;
 class ScriptExecutionContext;
 
@@ -96,7 +96,7 @@ public:
     {
         return adoptRef(*new CryptoKeyRSA(identifier, hash, hasHash, type, platformKey, extractable, usage));
     }
-    static RefPtr<CryptoKeyRSA> create(CryptoAlgorithmIdentifier, CryptoAlgorithmIdentifier hash, bool hasHash, const CryptoKeyDataRSAComponents&, bool extractable, CryptoKeyUsageBitmap);
+    static RefPtr<CryptoKeyRSA> create(CryptoAlgorithmIdentifier, CryptoAlgorithmIdentifier hash, bool hasHash, const CryptoKeyRSAComponents&, bool extractable, CryptoKeyUsageBitmap);
     virtual ~CryptoKeyRSA();
 
     bool isRestrictedToHash(CryptoAlgorithmIdentifier&) const;
@@ -115,6 +115,8 @@ public:
     ExceptionOr<Vector<uint8_t>> exportSpki() const;
     ExceptionOr<Vector<uint8_t>> exportPkcs8() const;
 
+    std::unique_ptr<CryptoKeyRSAComponents> exportData() const;
+
     CryptoAlgorithmIdentifier hashAlgorithmIdentifier() const { return m_hash; }
 
 private:
@@ -123,7 +125,6 @@ private:
     CryptoKeyClass keyClass() const final { return CryptoKeyClass::RSA; }
 
     std::unique_ptr<KeyAlgorithm> buildAlgorithm() const final;
-    std::unique_ptr<CryptoKeyData> exportData() const final;
 
     PlatformRSAKey m_platformKey;
 
  */
 
 #include "config.h"
-#include "CryptoKeyDataRSAComponents.h"
+#include "CryptoKeyRSAComponents.h"
 
 #if ENABLE(SUBTLE_CRYPTO)
 
 namespace WebCore {
 
-CryptoKeyDataRSAComponents::CryptoKeyDataRSAComponents(const Vector<uint8_t>& modulus, const Vector<uint8_t>& exponent)
-    : CryptoKeyData(CryptoKeyData::Format::RSAComponents)
-    , m_type(Type::Public)
+CryptoKeyRSAComponents::CryptoKeyRSAComponents(const Vector<uint8_t>& modulus, const Vector<uint8_t>& exponent)
+    : m_type(Type::Public)
     , m_modulus(modulus)
     , m_exponent(exponent)
 {
 }
 
-CryptoKeyDataRSAComponents::CryptoKeyDataRSAComponents(Vector<uint8_t>&& modulus, Vector<uint8_t>&& exponent)
-    : CryptoKeyData(CryptoKeyData::Format::RSAComponents)
-    , m_type(Type::Public)
+CryptoKeyRSAComponents::CryptoKeyRSAComponents(Vector<uint8_t>&& modulus, Vector<uint8_t>&& exponent)
+    : m_type(Type::Public)
     , m_modulus(WTFMove(modulus))
     , m_exponent(WTFMove(exponent))
 {
 }
 
-CryptoKeyDataRSAComponents::CryptoKeyDataRSAComponents(const Vector<uint8_t>& modulus, const Vector<uint8_t>& exponent, const Vector<uint8_t>& privateExponent)
-    : CryptoKeyData(CryptoKeyData::Format::RSAComponents)
-    , m_type(Type::Private)
+CryptoKeyRSAComponents::CryptoKeyRSAComponents(const Vector<uint8_t>& modulus, const Vector<uint8_t>& exponent, const Vector<uint8_t>& privateExponent)
+    : m_type(Type::Private)
     , m_modulus(modulus)
     , m_exponent(exponent)
     , m_privateExponent(privateExponent)
@@ -56,9 +53,8 @@ CryptoKeyDataRSAComponents::CryptoKeyDataRSAComponents(const Vector<uint8_t>& mo
 {
 }
 
-CryptoKeyDataRSAComponents::CryptoKeyDataRSAComponents(Vector<uint8_t>&& modulus, Vector<uint8_t>&& exponent, Vector<uint8_t>&& privateExponent)
-    : CryptoKeyData(CryptoKeyData::Format::RSAComponents)
-    , m_type(Type::Private)
+CryptoKeyRSAComponents::CryptoKeyRSAComponents(Vector<uint8_t>&& modulus, Vector<uint8_t>&& exponent, Vector<uint8_t>&& privateExponent)
+    : m_type(Type::Private)
     , m_modulus(WTFMove(modulus))
     , m_exponent(WTFMove(exponent))
     , m_privateExponent(WTFMove(privateExponent))
@@ -66,9 +62,8 @@ CryptoKeyDataRSAComponents::CryptoKeyDataRSAComponents(Vector<uint8_t>&& modulus
 {
 }
 
-CryptoKeyDataRSAComponents::CryptoKeyDataRSAComponents(const Vector<uint8_t>& modulus, const Vector<uint8_t>& exponent, const Vector<uint8_t>& privateExponent, const PrimeInfo& firstPrimeInfo, const PrimeInfo& secondPrimeInfo, const Vector<PrimeInfo>& otherPrimeInfos)
-    : CryptoKeyData(CryptoKeyData::Format::RSAComponents)
-    , m_type(Type::Private)
+CryptoKeyRSAComponents::CryptoKeyRSAComponents(const Vector<uint8_t>& modulus, const Vector<uint8_t>& exponent, const Vector<uint8_t>& privateExponent, const PrimeInfo& firstPrimeInfo, const PrimeInfo& secondPrimeInfo, const Vector<PrimeInfo>& otherPrimeInfos)
+    : m_type(Type::Private)
     , m_modulus(modulus)
     , m_exponent(exponent)
     , m_privateExponent(privateExponent)
@@ -79,9 +74,8 @@ CryptoKeyDataRSAComponents::CryptoKeyDataRSAComponents(const Vector<uint8_t>& mo
 {
 }
 
-CryptoKeyDataRSAComponents::CryptoKeyDataRSAComponents(Vector<uint8_t>&& modulus, Vector<uint8_t>&& exponent, Vector<uint8_t>&& privateExponent, PrimeInfo&& firstPrimeInfo, PrimeInfo&& secondPrimeInfo, Vector<PrimeInfo>&& otherPrimeInfos)
-    : CryptoKeyData(CryptoKeyData::Format::RSAComponents)
-    , m_type(Type::Private)
+CryptoKeyRSAComponents::CryptoKeyRSAComponents(Vector<uint8_t>&& modulus, Vector<uint8_t>&& exponent, Vector<uint8_t>&& privateExponent, PrimeInfo&& firstPrimeInfo, PrimeInfo&& secondPrimeInfo, Vector<PrimeInfo>&& otherPrimeInfos)
+    : m_type(Type::Private)
     , m_modulus(WTFMove(modulus))
     , m_exponent(WTFMove(exponent))
     , m_privateExponent(WTFMove(privateExponent))
@@ -92,7 +86,7 @@ CryptoKeyDataRSAComponents::CryptoKeyDataRSAComponents(Vector<uint8_t>&& modulus
 {
 }
 
-CryptoKeyDataRSAComponents::~CryptoKeyDataRSAComponents()
+CryptoKeyRSAComponents::~CryptoKeyRSAComponents()
 {
 }
 
diff --git a/Source/WebCore/crypto/keys/CryptoKeyRSAComponents.h b/Source/WebCore/crypto/keys/CryptoKeyRSAComponents.h
new file mode 100644 (file)
index 0000000..a4c411c
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/Vector.h>
+
+#if ENABLE(SUBTLE_CRYPTO)
+
+namespace WebCore {
+
+class CryptoKeyRSAComponents {
+public:
+    enum class Type {
+        Public,
+        Private
+    };
+
+    struct PrimeInfo {
+        Vector<uint8_t> primeFactor;
+        Vector<uint8_t> factorCRTExponent;
+        Vector<uint8_t> factorCRTCoefficient;
+    };
+
+    static std::unique_ptr<CryptoKeyRSAComponents> createPublic(const Vector<uint8_t>& modulus, const Vector<uint8_t>& exponent)
+    {
+        return std::unique_ptr<CryptoKeyRSAComponents>(new CryptoKeyRSAComponents(modulus, exponent));
+    }
+    static std::unique_ptr<CryptoKeyRSAComponents> createPublic(Vector<uint8_t>&& modulus, Vector<uint8_t>&& exponent)
+    {
+        return std::unique_ptr<CryptoKeyRSAComponents>(new CryptoKeyRSAComponents(WTFMove(modulus), WTFMove(exponent)));
+    }
+
+    static std::unique_ptr<CryptoKeyRSAComponents> createPrivate(const Vector<uint8_t>& modulus, const Vector<uint8_t>& exponent, const Vector<uint8_t>& privateExponent)
+    {
+        return std::unique_ptr<CryptoKeyRSAComponents>(new CryptoKeyRSAComponents(modulus, exponent, privateExponent));
+    }
+    static std::unique_ptr<CryptoKeyRSAComponents> createPrivate(Vector<uint8_t>&& modulus, Vector<uint8_t>&& exponent, Vector<uint8_t>&& privateExponent)
+    {
+        return std::unique_ptr<CryptoKeyRSAComponents>(new CryptoKeyRSAComponents(WTFMove(modulus), WTFMove(exponent), WTFMove(privateExponent)));
+    }
+
+    static std::unique_ptr<CryptoKeyRSAComponents> createPrivateWithAdditionalData(const Vector<uint8_t>& modulus, const Vector<uint8_t>& exponent, const Vector<uint8_t>& privateExponent, const PrimeInfo& firstPrimeInfo, const PrimeInfo& secondPrimeInfo, const Vector<PrimeInfo>& otherPrimeInfos)
+    {
+        return std::unique_ptr<CryptoKeyRSAComponents>(new CryptoKeyRSAComponents(modulus, exponent, privateExponent, firstPrimeInfo, secondPrimeInfo, otherPrimeInfos));
+    }
+    static std::unique_ptr<CryptoKeyRSAComponents> createPrivateWithAdditionalData(Vector<uint8_t>&& modulus, Vector<uint8_t>&& exponent, Vector<uint8_t>&& privateExponent, PrimeInfo&& firstPrimeInfo, PrimeInfo&& secondPrimeInfo, Vector<PrimeInfo>&& otherPrimeInfos)
+    {
+        return std::unique_ptr<CryptoKeyRSAComponents>(new CryptoKeyRSAComponents(WTFMove(modulus), WTFMove(exponent), WTFMove(privateExponent), WTFMove(firstPrimeInfo), WTFMove(secondPrimeInfo), WTFMove(otherPrimeInfos)));
+    }
+
+    virtual ~CryptoKeyRSAComponents();
+
+    Type type() const { return m_type; }
+
+    // Private and public keys.
+    const Vector<uint8_t>& modulus() const { return m_modulus; }
+    const Vector<uint8_t>& exponent() const { return m_exponent; }
+
+    // Only private keys.
+    const Vector<uint8_t>& privateExponent() const { return m_privateExponent; }
+    bool hasAdditionalPrivateKeyParameters() const { return m_hasAdditionalPrivateKeyParameters; }
+    const PrimeInfo& firstPrimeInfo() const { return m_firstPrimeInfo; }
+    const PrimeInfo& secondPrimeInfo() const { return m_secondPrimeInfo; }
+    const Vector<PrimeInfo>& otherPrimeInfos() const { return m_otherPrimeInfos; }
+
+private:
+    CryptoKeyRSAComponents(const Vector<uint8_t>& modulus, const Vector<uint8_t>& exponent);
+    CryptoKeyRSAComponents(Vector<uint8_t>&& modulus, Vector<uint8_t>&& exponent);
+
+    CryptoKeyRSAComponents(const Vector<uint8_t>& modulus, const Vector<uint8_t>& exponent, const Vector<uint8_t>& privateExponent);
+    CryptoKeyRSAComponents(Vector<uint8_t>&& modulus, Vector<uint8_t>&& exponent, Vector<uint8_t>&& privateExponent);
+
+    CryptoKeyRSAComponents(const Vector<uint8_t>& modulus, const Vector<uint8_t>& exponent, const Vector<uint8_t>& privateExponent, const PrimeInfo& firstPrimeInfo, const PrimeInfo& secondPrimeInfo, const Vector<PrimeInfo>& otherPrimeInfos);
+    CryptoKeyRSAComponents(Vector<uint8_t>&& modulus, Vector<uint8_t>&& exponent, Vector<uint8_t>&& privateExponent, PrimeInfo&& firstPrimeInfo, PrimeInfo&& secondPrimeInfo, Vector<PrimeInfo>&& otherPrimeInfos);
+
+    Type m_type;
+
+    // Private and public keys.
+    Vector<uint8_t> m_modulus;
+    Vector<uint8_t> m_exponent;
+
+    // Only private keys.
+    Vector<uint8_t> m_privateExponent;
+    bool m_hasAdditionalPrivateKeyParameters;
+    PrimeInfo m_firstPrimeInfo;
+    PrimeInfo m_secondPrimeInfo;
+    Vector<PrimeInfo> m_otherPrimeInfos; // When three or more primes have been used, the number of array elements is be the number of primes used minus two.
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SUBTLE_CRYPTO)
index 48263c2..aa853ea 100644 (file)
@@ -29,7 +29,6 @@
 #if ENABLE(SUBTLE_CRYPTO)
 
 #include "CryptoAlgorithmRegistry.h"
-#include "CryptoKeyDataOctetSequence.h"
 
 namespace WebCore {
 
@@ -51,12 +50,6 @@ std::unique_ptr<KeyAlgorithm> CryptoKeyRaw::buildAlgorithm() const
     return std::make_unique<RawKeyAlgorithm>(CryptoAlgorithmRegistry::singleton().name(algorithmIdentifier()));
 }
 
-std::unique_ptr<CryptoKeyData> CryptoKeyRaw::exportData() const
-{
-
-    return std::make_unique<CryptoKeyDataOctetSequence>(m_key);
-}
-
 } // namespace WebCore
 
 #endif // ENABLE(SUBTLE_CRYPTO)
index 575c366..344777a 100644 (file)
@@ -58,7 +58,6 @@ private:
     CryptoKeyClass keyClass() const final { return CryptoKeyClass::Raw; }
 
     std::unique_ptr<KeyAlgorithm> buildAlgorithm() const final;
-    std::unique_ptr<CryptoKeyData> exportData() const final;
 
     Vector<uint8_t> m_key;
 };
index 5f81fe1..e1cd550 100644 (file)
@@ -31,8 +31,8 @@
 #include "CommonCryptoDERUtilities.h"
 #include "CommonCryptoUtilities.h"
 #include "CryptoAlgorithmRegistry.h"
-#include "CryptoKeyDataRSAComponents.h"
 #include "CryptoKeyPair.h"
+#include "CryptoKeyRSAComponents.h"
 #include "ScriptExecutionContext.h"
 #include <wtf/MainThread.h>
 
@@ -66,7 +66,7 @@ static CCCryptorStatus getPublicKeyComponents(CCRSACryptorRef rsaKey, Vector<uin
     return status;
 }
 
-static CCCryptorStatus getPrivateKeyComponents(CCRSACryptorRef rsaKey, Vector<uint8_t>& privateExponent, CryptoKeyDataRSAComponents::PrimeInfo& firstPrimeInfo, CryptoKeyDataRSAComponents::PrimeInfo& secondPrimeInfo)
+static CCCryptorStatus getPrivateKeyComponents(CCRSACryptorRef rsaKey, Vector<uint8_t>& privateExponent, CryptoKeyRSAComponents::PrimeInfo& firstPrimeInfo, CryptoKeyRSAComponents::PrimeInfo& secondPrimeInfo)
 {
     ASSERT(CCRSAGetKeyType(rsaKey) == ccRSAKeyPrivate);
 
@@ -110,9 +110,9 @@ CryptoKeyRSA::CryptoKeyRSA(CryptoAlgorithmIdentifier identifier, CryptoAlgorithm
 {
 }
 
-RefPtr<CryptoKeyRSA> CryptoKeyRSA::create(CryptoAlgorithmIdentifier identifier, CryptoAlgorithmIdentifier hash, bool hasHash, const CryptoKeyDataRSAComponents& keyData, bool extractable, CryptoKeyUsageBitmap usage)
+RefPtr<CryptoKeyRSA> CryptoKeyRSA::create(CryptoAlgorithmIdentifier identifier, CryptoAlgorithmIdentifier hash, bool hasHash, const CryptoKeyRSAComponents& keyData, bool extractable, CryptoKeyUsageBitmap usage)
 {
-    if (keyData.type() == CryptoKeyDataRSAComponents::Type::Private && !keyData.hasAdditionalPrivateKeyParameters()) {
+    if (keyData.type() == CryptoKeyRSAComponents::Type::Private && !keyData.hasAdditionalPrivateKeyParameters()) {
         // <rdar://problem/15452324> tracks adding support.
         WTFLogAlways("Private keys without additional data are not supported");
         return nullptr;
@@ -124,7 +124,7 @@ RefPtr<CryptoKeyRSA> CryptoKeyRSA::create(CryptoAlgorithmIdentifier identifier,
     }
     // When an empty vector p is provided to CCRSACryptorCreateFromData to create a private key, it crashes.
     // <rdar://problem/30550228> tracks the issue.
-    if (keyData.type() == CryptoKeyDataRSAComponents::Type::Private && keyData.firstPrimeInfo().primeFactor.isEmpty())
+    if (keyData.type() == CryptoKeyRSAComponents::Type::Private && keyData.firstPrimeInfo().primeFactor.isEmpty())
         return nullptr;
 
     CCRSACryptorRef cryptor;
@@ -132,7 +132,7 @@ RefPtr<CryptoKeyRSA> CryptoKeyRSA::create(CryptoAlgorithmIdentifier identifier,
     // given the fact that we have already had it. Also, the re-caculated private exponent may not match the given one.
     // See <rdar://problem/15452324>.
     CCCryptorStatus status = CCRSACryptorCreateFromData(
-        keyData.type() == CryptoKeyDataRSAComponents::Type::Public ? ccRSAKeyPublic : ccRSAKeyPrivate,
+        keyData.type() == CryptoKeyRSAComponents::Type::Public ? ccRSAKeyPublic : ccRSAKeyPrivate,
         (uint8_t*)keyData.modulus().data(), keyData.modulus().size(),
         (uint8_t*)keyData.exponent().data(), keyData.exponent().size(),
         (uint8_t*)keyData.firstPrimeInfo().primeFactor.data(), keyData.firstPrimeInfo().primeFactor.size(),
@@ -144,7 +144,7 @@ RefPtr<CryptoKeyRSA> CryptoKeyRSA::create(CryptoAlgorithmIdentifier identifier,
         return nullptr;
     }
 
-    return adoptRef(new CryptoKeyRSA(identifier, hash, hasHash, keyData.type() == CryptoKeyDataRSAComponents::Type::Public ? CryptoKeyType::Public : CryptoKeyType::Private, cryptor, extractable, usage));
+    return adoptRef(new CryptoKeyRSA(identifier, hash, hasHash, keyData.type() == CryptoKeyRSAComponents::Type::Public ? CryptoKeyType::Public : CryptoKeyType::Private, cryptor, extractable, usage));
 }
 
 CryptoKeyRSA::~CryptoKeyRSA()
@@ -192,7 +192,7 @@ std::unique_ptr<KeyAlgorithm> CryptoKeyRSA::buildAlgorithm() const
     return std::make_unique<RsaKeyAlgorithm>(name, modulusLength, WTFMove(publicExponent));
 }
 
-std::unique_ptr<CryptoKeyData> CryptoKeyRSA::exportData() const
+std::unique_ptr<CryptoKeyRSAComponents> CryptoKeyRSA::exportData() const
 {
     switch (CCRSAGetKeyType(m_platformKey)) {
     case ccRSAKeyPublic: {
@@ -203,7 +203,7 @@ std::unique_ptr<CryptoKeyData> CryptoKeyRSA::exportData() const
             WTFLogAlways("Couldn't get RSA key components, status %d", status);
             return nullptr;
         }
-        return CryptoKeyDataRSAComponents::createPublic(modulus, publicExponent);
+        return CryptoKeyRSAComponents::createPublic(modulus, publicExponent);
     }
     case ccRSAKeyPrivate: {
         Vector<uint8_t> modulus;
@@ -214,15 +214,15 @@ std::unique_ptr<CryptoKeyData> CryptoKeyRSA::exportData() const
             return nullptr;
         }
         Vector<uint8_t> privateExponent;
-        CryptoKeyDataRSAComponents::PrimeInfo firstPrimeInfo;
-        CryptoKeyDataRSAComponents::PrimeInfo secondPrimeInfo;
-        Vector<CryptoKeyDataRSAComponents::PrimeInfo> otherPrimeInfos; // Always empty, CommonCrypto only supports two primes (cf. <rdar://problem/15444074>).
+        CryptoKeyRSAComponents::PrimeInfo firstPrimeInfo;
+        CryptoKeyRSAComponents::PrimeInfo secondPrimeInfo;
+        Vector<CryptoKeyRSAComponents::PrimeInfo> otherPrimeInfos; // Always empty, CommonCrypto only supports two primes (cf. <rdar://problem/15444074>).
         status = getPrivateKeyComponents(m_platformKey, privateExponent, firstPrimeInfo, secondPrimeInfo);
         if (status) {
             WTFLogAlways("Couldn't get RSA key components, status %d", status);
             return nullptr;
         }
-        return CryptoKeyDataRSAComponents::createPrivateWithAdditionalData(modulus, publicExponent, privateExponent, firstPrimeInfo, secondPrimeInfo, otherPrimeInfos);
+        return CryptoKeyRSAComponents::createPrivateWithAdditionalData(modulus, publicExponent, privateExponent, firstPrimeInfo, secondPrimeInfo, otherPrimeInfos);
     }
     default:
         return nullptr;