Modified: trunk/Source/WebCore/ChangeLog (197870 => 197871)
--- trunk/Source/WebCore/ChangeLog 2016-03-09 20:22:28 UTC (rev 197870)
+++ trunk/Source/WebCore/ChangeLog 2016-03-09 20:25:25 UTC (rev 197871)
@@ -1,3 +1,17 @@
+2016-03-09 Daniel Bates <[email protected]>
+
+ Rename WebCore/platform/crypto/mac/CryptoDigestMac.cpp to WebCore/platform/crypto/commoncrypto/CryptoDigestCommonCrypto.cpp
+ https://bugs.webkit.org/show_bug.cgi?id=155244
+
+ Reviewed by Alexey Proskuryakov.
+
+ The file WebCore/platform/crypto/mac/CryptoDigestMac.cpp is applicable to both iOS and OS X.
+ We should move and rename this file to reflect that is applicable to both of these platforms.
+
+ * PlatformMac.cmake:
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/crypto/commoncrypto/CryptoDigestCommonCrypto.cpp: Renamed from Source/WebCore/platform/crypto/mac/CryptoDigestMac.cpp.
+
2016-03-09 Tim Horton <[email protected]>
Removing and re-adding a script message handler with the same name results in an unusable message handler
Modified: trunk/Source/WebCore/PlatformMac.cmake (197870 => 197871)
--- trunk/Source/WebCore/PlatformMac.cmake 2016-03-09 20:22:28 UTC (rev 197870)
+++ trunk/Source/WebCore/PlatformMac.cmake 2016-03-09 20:25:25 UTC (rev 197871)
@@ -339,7 +339,7 @@
platform/cocoa/VNodeTrackerCocoa.cpp
platform/cocoa/WebCoreNSErrorExtras.mm
- platform/crypto/mac/CryptoDigestMac.cpp
+ platform/crypto/commoncrypto/CryptoDigestCommonCrypto.cpp
platform/graphics/DisplayRefreshMonitor.cpp
platform/graphics/DisplayRefreshMonitorManager.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (197870 => 197871)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-03-09 20:22:28 UTC (rev 197870)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-03-09 20:25:25 UTC (rev 197871)
@@ -6542,7 +6542,7 @@
E1F80B8A183172A2007885C3 /* JSCryptoKeyPairCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1F80B89183172A2007885C3 /* JSCryptoKeyPairCustom.cpp */; };
E1F80B8D183172B5007885C3 /* JSCryptoKeyPair.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1F80B8B183172B5007885C3 /* JSCryptoKeyPair.cpp */; };
E1F80B8E183172B5007885C3 /* JSCryptoKeyPair.h in Headers */ = {isa = PBXBuildFile; fileRef = E1F80B8C183172B5007885C3 /* JSCryptoKeyPair.h */; };
- E1FE13641834351100892F13 /* CryptoDigestMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FE13621834351100892F13 /* CryptoDigestMac.cpp */; };
+ E1FE13641834351100892F13 /* CryptoDigestCommonCrypto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FE13621834351100892F13 /* CryptoDigestCommonCrypto.cpp */; };
E1FE136718343A1000892F13 /* CryptoDigest.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FE136618343A1000892F13 /* CryptoDigest.h */; };
E1FE136A183FE1AB00892F13 /* CryptoAlgorithmRSA_OAEP.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FE1368183FE1AB00892F13 /* CryptoAlgorithmRSA_OAEP.cpp */; };
E1FE136B183FE1AB00892F13 /* CryptoAlgorithmRSA_OAEP.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FE1369183FE1AB00892F13 /* CryptoAlgorithmRSA_OAEP.h */; };
@@ -14586,8 +14586,8 @@
E1F80B89183172A2007885C3 /* JSCryptoKeyPairCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCryptoKeyPairCustom.cpp; sourceTree = "<group>"; };
E1F80B8B183172B5007885C3 /* JSCryptoKeyPair.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCryptoKeyPair.cpp; sourceTree = "<group>"; };
E1F80B8C183172B5007885C3 /* JSCryptoKeyPair.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCryptoKeyPair.h; sourceTree = "<group>"; };
- E1FE13621834351100892F13 /* CryptoDigestMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CryptoDigestMac.cpp; path = crypto/mac/CryptoDigestMac.cpp; sourceTree = "<group>"; };
- E1FE136618343A1000892F13 /* CryptoDigest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CryptoDigest.h; path = crypto/CryptoDigest.h; sourceTree = "<group>"; };
+ E1FE13621834351100892F13 /* CryptoDigestCommonCrypto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoDigestCommonCrypto.cpp; sourceTree = "<group>"; };
+ E1FE136618343A1000892F13 /* CryptoDigest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoDigest.h; sourceTree = "<group>"; };
E1FE1368183FE1AB00892F13 /* CryptoAlgorithmRSA_OAEP.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoAlgorithmRSA_OAEP.cpp; sourceTree = "<group>"; };
E1FE1369183FE1AB00892F13 /* CryptoAlgorithmRSA_OAEP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmRSA_OAEP.h; sourceTree = "<group>"; };
E1FE136E183FECF000892F13 /* CryptoAlgorithmRSA_OAEPMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoAlgorithmRSA_OAEPMac.cpp; sourceTree = "<group>"; };
@@ -23236,18 +23236,18 @@
CE50D8CE1C8932ED0072EA5A /* crypto */ = {
isa = PBXGroup;
children = (
- CE50D8CF1C8932FB0072EA5A /* mac */,
+ CE50D8CF1C8932FB0072EA5A /* commoncrypto */,
E1FE136618343A1000892F13 /* CryptoDigest.h */,
);
- name = crypto;
+ path = crypto;
sourceTree = "<group>";
};
- CE50D8CF1C8932FB0072EA5A /* mac */ = {
+ CE50D8CF1C8932FB0072EA5A /* commoncrypto */ = {
isa = PBXGroup;
children = (
- E1FE13621834351100892F13 /* CryptoDigestMac.cpp */,
+ E1FE13621834351100892F13 /* CryptoDigestCommonCrypto.cpp */,
);
- name = mac;
+ path = commoncrypto;
sourceTree = "<group>";
};
DF9AFD6F13FC31B00015FEB7 /* objc */ = {
@@ -29274,7 +29274,7 @@
E19AC3F01824DC7900349426 /* CryptoAlgorithmSHA256.cpp in Sources */,
E19AC3F21824DC7900349426 /* CryptoAlgorithmSHA384.cpp in Sources */,
E19AC3F41824DC7900349426 /* CryptoAlgorithmSHA512.cpp in Sources */,
- E1FE13641834351100892F13 /* CryptoDigestMac.cpp in Sources */,
+ E1FE13641834351100892F13 /* CryptoDigestCommonCrypto.cpp in Sources */,
E157A8E418173A3A009F821D /* CryptoKey.cpp in Sources */,
E125F84D1824289D00D84CD9 /* CryptoKeyAES.cpp in Sources */,
E125F863182C303A00D84CD9 /* CryptoKeyDataOctetSequence.cpp in Sources */,
Copied: trunk/Source/WebCore/platform/crypto/commoncrypto/CryptoDigestCommonCrypto.cpp (from rev 197870, trunk/Source/WebCore/platform/crypto/mac/CryptoDigestMac.cpp) (0 => 197871)
--- trunk/Source/WebCore/platform/crypto/commoncrypto/CryptoDigestCommonCrypto.cpp (rev 0)
+++ trunk/Source/WebCore/platform/crypto/commoncrypto/CryptoDigestCommonCrypto.cpp 2016-03-09 20:25:25 UTC (rev 197871)
@@ -0,0 +1,179 @@
+/*
+ * 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 "CryptoDigest.h"
+
+#include <CommonCrypto/CommonCrypto.h>
+
+namespace WebCore {
+
+struct CryptoDigestContext {
+ CryptoDigest::Algorithm algorithm;
+ void* ccContext;
+};
+
+inline CC_SHA1_CTX* toSHA1Context(CryptoDigestContext* context)
+{
+ ASSERT(context->algorithm == CryptoDigest::Algorithm::SHA_1);
+ return static_cast<CC_SHA1_CTX*>(context->ccContext);
+}
+inline CC_SHA256_CTX* toSHA224Context(CryptoDigestContext* context)
+{
+ ASSERT(context->algorithm == CryptoDigest::Algorithm::SHA_224);
+ return static_cast<CC_SHA256_CTX*>(context->ccContext);
+}
+inline CC_SHA256_CTX* toSHA256Context(CryptoDigestContext* context)
+{
+ ASSERT(context->algorithm == CryptoDigest::Algorithm::SHA_256);
+ return static_cast<CC_SHA256_CTX*>(context->ccContext);
+}
+inline CC_SHA512_CTX* toSHA384Context(CryptoDigestContext* context)
+{
+ ASSERT(context->algorithm == CryptoDigest::Algorithm::SHA_384);
+ return static_cast<CC_SHA512_CTX*>(context->ccContext);
+}
+inline CC_SHA512_CTX* toSHA512Context(CryptoDigestContext* context)
+{
+ ASSERT(context->algorithm == CryptoDigest::Algorithm::SHA_512);
+ return static_cast<CC_SHA512_CTX*>(context->ccContext);
+}
+
+CryptoDigest::CryptoDigest()
+ : m_context(new CryptoDigestContext)
+{
+}
+
+CryptoDigest::~CryptoDigest()
+{
+ switch (m_context->algorithm) {
+ case CryptoDigest::Algorithm::SHA_1:
+ delete toSHA1Context(m_context.get());
+ return;
+ case CryptoDigest::Algorithm::SHA_224:
+ delete toSHA224Context(m_context.get());
+ return;
+ case CryptoDigest::Algorithm::SHA_256:
+ delete toSHA256Context(m_context.get());
+ return;
+ case CryptoDigest::Algorithm::SHA_384:
+ delete toSHA384Context(m_context.get());
+ return;
+ case CryptoDigest::Algorithm::SHA_512:
+ delete toSHA512Context(m_context.get());
+ return;
+ }
+}
+
+
+std::unique_ptr<CryptoDigest> CryptoDigest::create(CryptoDigest::Algorithm algorithm)
+{
+ std::unique_ptr<CryptoDigest> digest(new CryptoDigest);
+ digest->m_context->algorithm = algorithm;
+
+ switch (algorithm) {
+ case CryptoDigest::Algorithm::SHA_1: {
+ CC_SHA1_CTX* context = new CC_SHA1_CTX;
+ digest->m_context->ccContext = context;
+ CC_SHA1_Init(context);
+ return digest;
+ }
+ case CryptoDigest::Algorithm::SHA_224: {
+ CC_SHA256_CTX* context = new CC_SHA256_CTX;
+ digest->m_context->ccContext = context;
+ CC_SHA224_Init(context);
+ return digest;
+ }
+ case CryptoDigest::Algorithm::SHA_256: {
+ CC_SHA256_CTX* context = new CC_SHA256_CTX;
+ digest->m_context->ccContext = context;
+ CC_SHA256_Init(context);
+ return digest;
+ }
+ case CryptoDigest::Algorithm::SHA_384: {
+ CC_SHA512_CTX* context = new CC_SHA512_CTX;
+ digest->m_context->ccContext = context;
+ CC_SHA384_Init(context);
+ return digest;
+ }
+ case CryptoDigest::Algorithm::SHA_512: {
+ CC_SHA512_CTX* context = new CC_SHA512_CTX;
+ digest->m_context->ccContext = context;
+ CC_SHA512_Init(context);
+ return digest;
+ }
+ }
+}
+
+void CryptoDigest::addBytes(const void* input, size_t length)
+{
+ switch (m_context->algorithm) {
+ case CryptoDigest::Algorithm::SHA_1:
+ CC_SHA1_Update(toSHA1Context(m_context.get()), input, length);
+ return;
+ case CryptoDigest::Algorithm::SHA_224:
+ CC_SHA224_Update(toSHA224Context(m_context.get()), input, length);
+ return;
+ case CryptoDigest::Algorithm::SHA_256:
+ CC_SHA256_Update(toSHA256Context(m_context.get()), input, length);
+ return;
+ case CryptoDigest::Algorithm::SHA_384:
+ CC_SHA384_Update(toSHA384Context(m_context.get()), input, length);
+ return;
+ case CryptoDigest::Algorithm::SHA_512:
+ CC_SHA512_Update(toSHA512Context(m_context.get()), input, length);
+ return;
+ }
+}
+
+Vector<uint8_t> CryptoDigest::computeHash()
+{
+ Vector<uint8_t> result;
+ switch (m_context->algorithm) {
+ case CryptoDigest::Algorithm::SHA_1:
+ result.resize(CC_SHA1_DIGEST_LENGTH);
+ CC_SHA1_Final(result.data(), toSHA1Context(m_context.get()));
+ break;
+ case CryptoDigest::Algorithm::SHA_224:
+ result.resize(CC_SHA224_DIGEST_LENGTH);
+ CC_SHA224_Final(result.data(), toSHA224Context(m_context.get()));
+ break;
+ case CryptoDigest::Algorithm::SHA_256:
+ result.resize(CC_SHA256_DIGEST_LENGTH);
+ CC_SHA256_Final(result.data(), toSHA256Context(m_context.get()));
+ break;
+ case CryptoDigest::Algorithm::SHA_384:
+ result.resize(CC_SHA384_DIGEST_LENGTH);
+ CC_SHA384_Final(result.data(), toSHA384Context(m_context.get()));
+ break;
+ case CryptoDigest::Algorithm::SHA_512:
+ result.resize(CC_SHA512_DIGEST_LENGTH);
+ CC_SHA512_Final(result.data(), toSHA512Context(m_context.get()));
+ break;
+ }
+ return result;
+}
+
+} // namespace WebCore