Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (220948 => 220949)
--- trunk/Source/WebCore/CMakeLists.txt 2017-08-19 01:29:50 UTC (rev 220948)
+++ trunk/Source/WebCore/CMakeLists.txt 2017-08-19 01:40:54 UTC (rev 220949)
@@ -1334,11 +1334,10 @@
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
Modified: trunk/Source/WebCore/ChangeLog (220948 => 220949)
--- trunk/Source/WebCore/ChangeLog 2017-08-19 01:29:50 UTC (rev 220948)
+++ trunk/Source/WebCore/ChangeLog 2017-08-19 01:40:54 UTC (rev 220949)
@@ -1,3 +1,72 @@
+2017-08-18 Sam Weinig <[email protected]>
+
+ [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 <[email protected]>
[Cache API] Add support for being loaded responses
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (220948 => 220949)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-08-19 01:29:50 UTC (rev 220948)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-08-19 01:40:54 UTC (rev 220949)
@@ -6493,9 +6493,6 @@
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 */; };
@@ -6604,8 +6601,8 @@
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, ); }; };
@@ -15077,9 +15074,6 @@
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>"; };
@@ -15201,8 +15195,8 @@
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>"; };
@@ -24560,10 +24554,8 @@
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 */,
@@ -24741,7 +24733,6 @@
E157A8E218173A3A009F821D /* CryptoKey.cpp */,
E157A8E318173A3A009F821D /* CryptoKey.h */,
E157A8DC18172C2C009F821D /* CryptoKey.idl */,
- E125F85D182C2DF600D84CD9 /* CryptoKeyData.h */,
7C9ACAC91F40B96A00F3AA09 /* CryptoKeyFormat.h */,
E1F80B8618317252007885C3 /* CryptoKeyPair.h */,
E1F80B8418317247007885C3 /* CryptoKeyPair.idl */,
@@ -26886,9 +26877,7 @@
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 */,
@@ -30937,8 +30926,7 @@
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 */,
Modified: trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp (220948 => 220949)
--- trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp 2017-08-19 01:29:50 UTC (rev 220948)
+++ trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp 2017-08-19 01:40:54 UTC (rev 220949)
@@ -30,11 +30,10 @@
#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 @@
}
}
- 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 @@
write(isRestrictedToHash);
if (isRestrictedToHash)
write(hash);
- write(downcast<CryptoKeyDataRSAComponents>(*key->exportData()));
+ write(*downcast<CryptoKeyRSA>(*key).exportData());
break;
}
}
@@ -2293,7 +2292,7 @@
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 @@
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 @@
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 @@
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;
Modified: trunk/Source/WebCore/crypto/CryptoAlgorithm.h (220948 => 220949)
--- trunk/Source/WebCore/crypto/CryptoAlgorithm.h 2017-08-19 01:29:50 UTC (rev 220948)
+++ trunk/Source/WebCore/crypto/CryptoAlgorithm.h 2017-08-19 01:40:54 UTC (rev 220949)
@@ -43,7 +43,6 @@
class CryptoAlgorithmParameters;
class CryptoKey;
-class CryptoKeyData;
class ScriptExecutionContext;
using KeyData = Variant<Vector<uint8_t>, JsonWebKey>;
Modified: trunk/Source/WebCore/crypto/CryptoKey.h (220948 => 220949)
--- trunk/Source/WebCore/crypto/CryptoKey.h 2017-08-19 01:29:50 UTC (rev 220948)
+++ trunk/Source/WebCore/crypto/CryptoKey.h 2017-08-19 01:40:54 UTC (rev 220949)
@@ -46,7 +46,6 @@
namespace WebCore {
class CryptoAlgorithmDescriptionBuilder;
-class CryptoKeyData;
enum class CryptoKeyClass {
AES,
@@ -106,8 +105,6 @@
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:
Deleted: trunk/Source/WebCore/crypto/CryptoKeyData.h (220948 => 220949)
--- trunk/Source/WebCore/crypto/CryptoKeyData.h 2017-08-19 01:29:50 UTC (rev 220948)
+++ trunk/Source/WebCore/crypto/CryptoKeyData.h 2017-08-19 01:40:54 UTC (rev 220949)
@@ -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)
Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.cpp (220948 => 220949)
--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.cpp 2017-08-19 01:29:50 UTC (rev 220948)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.cpp 2017-08-19 01:40:54 UTC (rev 220949)
@@ -31,7 +31,6 @@
#include "CryptoAlgorithmAesCbcCfbParams.h"
#include "CryptoAlgorithmAesKeyParams.h"
#include "CryptoKeyAES.h"
-#include "CryptoKeyDataOctetSequence.h"
namespace WebCore {
Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.cpp (220948 => 220949)
--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.cpp 2017-08-19 01:29:50 UTC (rev 220948)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.cpp 2017-08-19 01:40:54 UTC (rev 220949)
@@ -30,7 +30,6 @@
#include "CryptoAlgorithmAesKeyParams.h"
#include "CryptoKeyAES.h"
-#include "CryptoKeyDataOctetSequence.h"
#include <wtf/Variant.h>
namespace WebCore {
Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp (220948 => 220949)
--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp 2017-08-19 01:29:50 UTC (rev 220948)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp 2017-08-19 01:40:54 UTC (rev 220949)
@@ -29,7 +29,6 @@
#if ENABLE(SUBTLE_CRYPTO)
#include "CryptoAlgorithmHmacKeyParams.h"
-#include "CryptoKeyDataOctetSequence.h"
#include "CryptoKeyHMAC.h"
#include <wtf/Variant.h>
Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp (220948 => 220949)
--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp 2017-08-19 01:29:50 UTC (rev 220948)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp 2017-08-19 01:40:54 UTC (rev 220949)
@@ -29,7 +29,6 @@
#if ENABLE(SUBTLE_CRYPTO)
#include "CryptoAlgorithmRsaKeyGenParams.h"
-#include "CryptoKeyDataRSAComponents.h"
#include "CryptoKeyPair.h"
#include "CryptoKeyRSA.h"
#include <wtf/Variant.h>
Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp (220948 => 220949)
--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp 2017-08-19 01:29:50 UTC (rev 220948)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp 2017-08-19 01:40:54 UTC (rev 220949)
@@ -30,7 +30,6 @@
#include "CryptoAlgorithmRsaHashedImportParams.h"
#include "CryptoAlgorithmRsaHashedKeyGenParams.h"
-#include "CryptoKeyDataRSAComponents.h"
#include "CryptoKeyPair.h"
#include "CryptoKeyRSA.h"
#include <wtf/Variant.h>
Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp (220948 => 220949)
--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp 2017-08-19 01:29:50 UTC (rev 220948)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp 2017-08-19 01:40:54 UTC (rev 220949)
@@ -30,7 +30,6 @@
#include "CryptoAlgorithmRsaHashedImportParams.h"
#include "CryptoAlgorithmRsaHashedKeyGenParams.h"
-#include "CryptoKeyDataRSAComponents.h"
#include "CryptoKeyPair.h"
#include "CryptoKeyRSA.h"
#include <wtf/Variant.h>
Modified: trunk/Source/WebCore/crypto/gcrypt/CryptoKeyRSAGCrypt.cpp (220948 => 220949)
--- trunk/Source/WebCore/crypto/gcrypt/CryptoKeyRSAGCrypt.cpp 2017-08-19 01:29:50 UTC (rev 220948)
+++ trunk/Source/WebCore/crypto/gcrypt/CryptoKeyRSAGCrypt.cpp 2017-08-19 01:40:54 UTC (rev 220949)
@@ -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 @@
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 @@
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 @@
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 @@
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 @@
if (!dMPI || !pMPI || !qMPI)
return nullptr;
- CryptoKeyDataRSAComponents::PrimeInfo firstPrimeInfo;
+ CryptoKeyRSAComponents::PrimeInfo firstPrimeInfo;
if (auto data = ""
firstPrimeInfo.primeFactor = WTFMove(data.value());
- CryptoKeyDataRSAComponents::PrimeInfo secondPrimeInfo;
+ CryptoKeyRSAComponents::PrimeInfo secondPrimeInfo;
if (auto data = ""
secondPrimeInfo.primeFactor = WTFMove(data.value());
@@ -697,9 +697,9 @@
if (auto data = ""
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();
Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyAES.cpp (220948 => 220949)
--- trunk/Source/WebCore/crypto/keys/CryptoKeyAES.cpp 2017-08-19 01:29:50 UTC (rev 220948)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyAES.cpp 2017-08-19 01:40:54 UTC (rev 220949)
@@ -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 @@
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)
Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyAES.h (220948 => 220949)
--- trunk/Source/WebCore/crypto/keys/CryptoKeyAES.h 2017-08-19 01:29:50 UTC (rev 220948)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyAES.h 2017-08-19 01:40:54 UTC (rev 220949)
@@ -88,7 +88,6 @@
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;
};
Deleted: trunk/Source/WebCore/crypto/keys/CryptoKeyDataOctetSequence.cpp (220948 => 220949)
--- trunk/Source/WebCore/crypto/keys/CryptoKeyDataOctetSequence.cpp 2017-08-19 01:29:50 UTC (rev 220948)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyDataOctetSequence.cpp 2017-08-19 01:40:54 UTC (rev 220949)
@@ -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)
Deleted: trunk/Source/WebCore/crypto/keys/CryptoKeyDataOctetSequence.h (220948 => 220949)
--- trunk/Source/WebCore/crypto/keys/CryptoKeyDataOctetSequence.h 2017-08-19 01:29:50 UTC (rev 220948)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyDataOctetSequence.h 2017-08-19 01:40:54 UTC (rev 220949)
@@ -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)
Deleted: trunk/Source/WebCore/crypto/keys/CryptoKeyDataRSAComponents.cpp (220948 => 220949)
--- trunk/Source/WebCore/crypto/keys/CryptoKeyDataRSAComponents.cpp 2017-08-19 01:29:50 UTC (rev 220948)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyDataRSAComponents.cpp 2017-08-19 01:40:54 UTC (rev 220949)
@@ -1,101 +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 "CryptoKeyDataRSAComponents.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)
- , m_modulus(modulus)
- , m_exponent(exponent)
-{
-}
-
-CryptoKeyDataRSAComponents::CryptoKeyDataRSAComponents(Vector<uint8_t>&& modulus, Vector<uint8_t>&& exponent)
- : CryptoKeyData(CryptoKeyData::Format::RSAComponents)
- , 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)
- , m_modulus(modulus)
- , m_exponent(exponent)
- , m_privateExponent(privateExponent)
- , m_hasAdditionalPrivateKeyParameters(false)
-{
-}
-
-CryptoKeyDataRSAComponents::CryptoKeyDataRSAComponents(Vector<uint8_t>&& modulus, Vector<uint8_t>&& exponent, Vector<uint8_t>&& privateExponent)
- : CryptoKeyData(CryptoKeyData::Format::RSAComponents)
- , m_type(Type::Private)
- , m_modulus(WTFMove(modulus))
- , m_exponent(WTFMove(exponent))
- , m_privateExponent(WTFMove(privateExponent))
- , m_hasAdditionalPrivateKeyParameters(false)
-{
-}
-
-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)
- , m_modulus(modulus)
- , m_exponent(exponent)
- , m_privateExponent(privateExponent)
- , m_hasAdditionalPrivateKeyParameters(true)
- , m_firstPrimeInfo(firstPrimeInfo)
- , m_secondPrimeInfo(secondPrimeInfo)
- , m_otherPrimeInfos(otherPrimeInfos)
-{
-}
-
-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)
- , m_modulus(WTFMove(modulus))
- , m_exponent(WTFMove(exponent))
- , m_privateExponent(WTFMove(privateExponent))
- , m_hasAdditionalPrivateKeyParameters(true)
- , m_firstPrimeInfo(WTFMove(firstPrimeInfo))
- , m_secondPrimeInfo(WTFMove(secondPrimeInfo))
- , m_otherPrimeInfos(WTFMove(otherPrimeInfos))
-{
-}
-
-CryptoKeyDataRSAComponents::~CryptoKeyDataRSAComponents()
-{
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(SUBTLE_CRYPTO)
Deleted: trunk/Source/WebCore/crypto/keys/CryptoKeyDataRSAComponents.h (220948 => 220949)
--- trunk/Source/WebCore/crypto/keys/CryptoKeyDataRSAComponents.h 2017-08-19 01:29:50 UTC (rev 220948)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyDataRSAComponents.h 2017-08-19 01:40:54 UTC (rev 220949)
@@ -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)
Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyEC.cpp (220948 => 220949)
--- trunk/Source/WebCore/crypto/keys/CryptoKeyEC.cpp 2017-08-19 01:29:50 UTC (rev 220948)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyEC.cpp 2017-08-19 01:40:54 UTC (rev 220949)
@@ -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 @@
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)
Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyEC.h (220948 => 220949)
--- trunk/Source/WebCore/crypto/keys/CryptoKeyEC.h 2017-08-19 01:29:50 UTC (rev 220948)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyEC.h 2017-08-19 01:40:54 UTC (rev 220949)
@@ -102,7 +102,6 @@
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);
Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.cpp (220948 => 220949)
--- trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.cpp 2017-08-19 01:29:50 UTC (rev 220948)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.cpp 2017-08-19 01:40:54 UTC (rev 220949)
@@ -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 @@
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)
Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.h (220948 => 220949)
--- trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.h 2017-08-19 01:29:50 UTC (rev 220948)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.h 2017-08-19 01:40:54 UTC (rev 220949)
@@ -86,7 +86,6 @@
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;
Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyRSA.cpp (220948 => 220949)
--- trunk/Source/WebCore/crypto/keys/CryptoKeyRSA.cpp 2017-08-19 01:29:50 UTC (rev 220948)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyRSA.cpp 2017-08-19 01:40:54 UTC (rev 220949)
@@ -26,7 +26,7 @@
#include "config.h"
#include "CryptoKeyRSA.h"
-#include "CryptoKeyDataRSAComponents.h"
+#include "CryptoKeyRSAComponents.h"
#include "JsonWebKey.h"
#include <_javascript_Core/GenericTypedArrayViewInlines.h>
#include <_javascript_Core/JSGenericTypedArrayViewInlines.h>
@@ -78,7 +78,7 @@
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,7 +88,7 @@
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);
}
@@ -95,8 +95,8 @@
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 @@
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 @@
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 @@
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);
Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyRSA.h (220948 => 220949)
--- trunk/Source/WebCore/crypto/keys/CryptoKeyRSA.h 2017-08-19 01:29:50 UTC (rev 220948)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyRSA.h 2017-08-19 01:40:54 UTC (rev 220949)
@@ -44,7 +44,7 @@
namespace WebCore {
-class CryptoKeyDataRSAComponents;
+class CryptoKeyRSAComponents;
class PromiseWrapper;
class ScriptExecutionContext;
@@ -96,7 +96,7 @@
{
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 @@
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 @@
CryptoKeyClass keyClass() const final { return CryptoKeyClass::RSA; }
std::unique_ptr<KeyAlgorithm> buildAlgorithm() const final;
- std::unique_ptr<CryptoKeyData> exportData() const final;
PlatformRSAKey m_platformKey;
Copied: trunk/Source/WebCore/crypto/keys/CryptoKeyRSAComponents.cpp (from rev 220948, trunk/Source/WebCore/crypto/keys/CryptoKeyDataRSAComponents.cpp) (0 => 220949)
--- trunk/Source/WebCore/crypto/keys/CryptoKeyRSAComponents.cpp (rev 0)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyRSAComponents.cpp 2017-08-19 01:40:54 UTC (rev 220949)
@@ -0,0 +1,95 @@
+/*
+ * 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 "CryptoKeyRSAComponents.h"
+
+#if ENABLE(SUBTLE_CRYPTO)
+
+namespace WebCore {
+
+CryptoKeyRSAComponents::CryptoKeyRSAComponents(const Vector<uint8_t>& modulus, const Vector<uint8_t>& exponent)
+ : m_type(Type::Public)
+ , m_modulus(modulus)
+ , m_exponent(exponent)
+{
+}
+
+CryptoKeyRSAComponents::CryptoKeyRSAComponents(Vector<uint8_t>&& modulus, Vector<uint8_t>&& exponent)
+ : m_type(Type::Public)
+ , m_modulus(WTFMove(modulus))
+ , m_exponent(WTFMove(exponent))
+{
+}
+
+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)
+ , m_hasAdditionalPrivateKeyParameters(false)
+{
+}
+
+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))
+ , m_hasAdditionalPrivateKeyParameters(false)
+{
+}
+
+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)
+ , m_hasAdditionalPrivateKeyParameters(true)
+ , m_firstPrimeInfo(firstPrimeInfo)
+ , m_secondPrimeInfo(secondPrimeInfo)
+ , m_otherPrimeInfos(otherPrimeInfos)
+{
+}
+
+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))
+ , m_hasAdditionalPrivateKeyParameters(true)
+ , m_firstPrimeInfo(WTFMove(firstPrimeInfo))
+ , m_secondPrimeInfo(WTFMove(secondPrimeInfo))
+ , m_otherPrimeInfos(WTFMove(otherPrimeInfos))
+{
+}
+
+CryptoKeyRSAComponents::~CryptoKeyRSAComponents()
+{
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SUBTLE_CRYPTO)
Copied: trunk/Source/WebCore/crypto/keys/CryptoKeyRSAComponents.h (from rev 220948, trunk/Source/WebCore/crypto/keys/CryptoKeyDataRSAComponents.h) (0 => 220949)
--- trunk/Source/WebCore/crypto/keys/CryptoKeyRSAComponents.h (rev 0)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyRSAComponents.h 2017-08-19 01:40:54 UTC (rev 220949)
@@ -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)
Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyRaw.cpp (220948 => 220949)
--- trunk/Source/WebCore/crypto/keys/CryptoKeyRaw.cpp 2017-08-19 01:29:50 UTC (rev 220948)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyRaw.cpp 2017-08-19 01:40:54 UTC (rev 220949)
@@ -29,7 +29,6 @@
#if ENABLE(SUBTLE_CRYPTO)
#include "CryptoAlgorithmRegistry.h"
-#include "CryptoKeyDataOctetSequence.h"
namespace WebCore {
@@ -51,12 +50,6 @@
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)
Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyRaw.h (220948 => 220949)
--- trunk/Source/WebCore/crypto/keys/CryptoKeyRaw.h 2017-08-19 01:29:50 UTC (rev 220948)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyRaw.h 2017-08-19 01:40:54 UTC (rev 220949)
@@ -58,7 +58,6 @@
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;
};
Modified: trunk/Source/WebCore/crypto/mac/CryptoKeyRSAMac.cpp (220948 => 220949)
--- trunk/Source/WebCore/crypto/mac/CryptoKeyRSAMac.cpp 2017-08-19 01:29:50 UTC (rev 220948)
+++ trunk/Source/WebCore/crypto/mac/CryptoKeyRSAMac.cpp 2017-08-19 01:40:54 UTC (rev 220949)
@@ -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 @@
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 @@
{
}
-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 @@
}
// 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 @@
// 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 @@
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 @@
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 @@
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 @@
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;