Changeset 197575 in webkit
- Timestamp:
- Mar 4, 2016 11:26:23 AM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 added
- 12 edited
- 3 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r197468 r197575 70 70 "${WEBCORE_DIR}/platform/animation" 71 71 "${WEBCORE_DIR}/platform/audio" 72 "${WEBCORE_DIR}/platform/crypto" 72 73 "${WEBCORE_DIR}/platform/graphics" 73 74 "${WEBCORE_DIR}/platform/graphics/cpu/arm" -
trunk/Source/WebCore/ChangeLog
r197573 r197575 1 2016-03-04 Daniel Bates <dabates@apple.com> 2 3 Move CryptoDigest to WebCore/platform 4 https://bugs.webkit.org/show_bug.cgi?id=155008 5 <rdar://problem/24969787> 6 7 Reviewed by Brent Fulgham. 8 9 CryptoDigest provides a platform-independent interface for interacting with platform- 10 specific cryptographic hashing services. We currently make use of this code as part 11 of the implementation of Web Crypto. This code will also be beneficial as part of 12 implementing support for Content Security Policy inline script and inline stylesheet 13 hashes. We should move CryptoDigest to WebCore/platform to convey that it a general 14 purpose platform abstraction. 15 16 * CMakeLists.txt: Add include directory WebCore/platform/crypto. 17 * PlatformEfl.cmake: Add file platform/crypto/gnutls/CryptoDigestGnuTLS.cpp and 18 remove file crypto/gnutls/CryptoDigestGnuTLS.cpp. 19 * PlatformGTK.cmake: Ditto. 20 * PlatformMac.cmake: Add file platform/crypto/mac/CryptoDigestMac.cpp and 21 remove file crypto/mac/CryptoDigestMac.cpp. 22 * WebCore.xcodeproj/project.pbxproj: 23 * crypto/algorithms/CryptoAlgorithmSHA1.cpp: 24 (WebCore::CryptoAlgorithmSHA1::digest): Substitute "CryptoDigest::Algorithm" for "CryptoAlgorithmIdentifier". 25 * crypto/algorithms/CryptoAlgorithmSHA224.cpp: 26 (WebCore::CryptoAlgorithmSHA224::digest): Ditto. 27 * crypto/algorithms/CryptoAlgorithmSHA256.cpp: 28 (WebCore::CryptoAlgorithmSHA256::digest): Ditto. 29 * crypto/algorithms/CryptoAlgorithmSHA384.cpp: 30 (WebCore::CryptoAlgorithmSHA384::digest): Ditto. 31 * crypto/algorithms/CryptoAlgorithmSHA512.cpp: 32 (WebCore::CryptoAlgorithmSHA512::digest): Ditto. 33 * crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp: 34 (WebCore::getCryptoDigestAlgorithm): Converts a CryptoAlgorithmIdentifier enumerator to a 35 CryptoDigest::Algorithm enumerator, if applicable. 36 (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign): Write in terms of WebCore::getCryptoDigestAlgorithm(). 37 (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerify): Ditto. 38 * platform/crypto/CryptoDigest.h: Renamed from Source/WebCore/crypto/CryptoDigest.h. Also added enum CryptoDigest::Algorithm 39 and changed constructor to take this enum. 40 * platform/crypto/gnutls/CryptoDigestGnuTLS.cpp: Renamed from Source/WebCore/crypto/gnutls/CryptoDigestGnuTLS.cpp. 41 (WebCore::CryptoDigest::CryptoDigest): Substitute "CryptoDigest::Algorithm" for "CryptoAlgorithmIdentifier". 42 (WebCore::CryptoDigest::~CryptoDigest): Ditto. 43 (WebCore::CryptoDigest::create): Ditto. 44 (WebCore::CryptoDigest::addBytes): Ditto. 45 (WebCore::CryptoDigest::computeHash): Ditto. 46 * platform/crypto/mac/CryptoDigestMac.cpp: Renamed from Source/WebCore/crypto/mac/CryptoDigestMac.cpp. 47 (WebCore::toSHA1Context): Ditto. 48 (WebCore::toSHA224Context): Ditto. 49 (WebCore::toSHA256Context): Ditto. 50 (WebCore::toSHA384Context): Ditto. 51 (WebCore::toSHA512Context): Ditto. 52 (WebCore::CryptoDigest::CryptoDigest): Ditto. 53 (WebCore::CryptoDigest::~CryptoDigest): Ditto. 54 (WebCore::CryptoDigest::create): Ditto. 55 (WebCore::CryptoDigest::addBytes): Ditto. 56 (WebCore::CryptoDigest::computeHash): Ditto. 57 1 58 2016-03-04 Myles C. Maxfield <mmaxfield@apple.com> 2 59 -
trunk/Source/WebCore/PlatformEfl.cmake
r196578 r197575 89 89 platform/audio/efl/AudioBusEfl.cpp 90 90 91 platform/crypto/gnutls/CryptoDigestGnuTLS.cpp 92 91 93 platform/efl/BatteryProviderEfl.cpp 92 94 platform/efl/CursorEfl.cpp … … 433 435 crypto/gnutls/CryptoAlgorithmRSA_OAEPGnuTLS.cpp 434 436 crypto/gnutls/CryptoAlgorithmRegistryGnuTLS.cpp 435 crypto/gnutls/CryptoDigestGnuTLS.cpp436 437 crypto/gnutls/CryptoKeyRSAGnuTLS.cpp 437 438 crypto/gnutls/SerializedCryptoKeyWrapGnuTLS.cpp -
trunk/Source/WebCore/PlatformGTK.cmake
r197142 r197575 82 82 83 83 platform/audio/glib/AudioBusGLib.cpp 84 85 platform/crypto/gnutls/CryptoDigestGnuTLS.cpp 84 86 85 87 platform/geoclue/GeolocationProviderGeoclue1.cpp … … 808 810 crypto/gnutls/CryptoAlgorithmRSA_OAEPGnuTLS.cpp 809 811 crypto/gnutls/CryptoAlgorithmRegistryGnuTLS.cpp 810 crypto/gnutls/CryptoDigestGnuTLS.cpp811 812 crypto/gnutls/CryptoKeyRSAGnuTLS.cpp 812 813 crypto/gnutls/SerializedCryptoKeyWrapGnuTLS.cpp -
trunk/Source/WebCore/PlatformMac.cmake
r197398 r197575 219 219 crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp 220 220 crypto/mac/CryptoAlgorithmRegistryMac.cpp 221 crypto/mac/CryptoDigestMac.cpp222 221 crypto/mac/CryptoKeyMac.cpp 223 222 crypto/mac/CryptoKeyRSAMac.cpp … … 340 339 platform/cocoa/VNodeTrackerCocoa.cpp 341 340 platform/cocoa/WebCoreNSErrorExtras.mm 341 342 platform/crypto/mac/CryptoDigestMac.cpp 342 343 343 344 platform/graphics/DisplayRefreshMonitor.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r197550 r197575 14551 14551 E1F80B8B183172B5007885C3 /* JSCryptoKeyPair.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCryptoKeyPair.cpp; sourceTree = "<group>"; }; 14552 14552 E1F80B8C183172B5007885C3 /* JSCryptoKeyPair.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCryptoKeyPair.h; sourceTree = "<group>"; }; 14553 E1FE13621834351100892F13 /* CryptoDigestMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path =CryptoDigestMac.cpp; sourceTree = "<group>"; };14554 E1FE136618343A1000892F13 /* CryptoDigest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path =CryptoDigest.h; sourceTree = "<group>"; };14553 E1FE13621834351100892F13 /* CryptoDigestMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CryptoDigestMac.cpp; path = crypto/mac/CryptoDigestMac.cpp; sourceTree = "<group>"; }; 14554 E1FE136618343A1000892F13 /* CryptoDigest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CryptoDigest.h; path = crypto/CryptoDigest.h; sourceTree = "<group>"; }; 14555 14555 E1FE1368183FE1AB00892F13 /* CryptoAlgorithmRSA_OAEP.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoAlgorithmRSA_OAEP.cpp; sourceTree = "<group>"; }; 14556 14556 E1FE1369183FE1AB00892F13 /* CryptoAlgorithmRSA_OAEP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmRSA_OAEP.h; sourceTree = "<group>"; }; … … 22792 22792 1AE42F670AA4B8CB00C8612D /* cf */, 22793 22793 A5C974CE11485FDA0066F2AB /* cocoa */, 22794 CE50D8CE1C8932ED0072EA5A /* crypto */, 22794 22795 B2A015910AF6CD53006BCE0E /* graphics */, 22795 22796 A59E3C1B11580F340072928E /* ios */, … … 23177 23178 sourceTree = "<group>"; 23178 23179 }; 23180 CE50D8CE1C8932ED0072EA5A /* crypto */ = { 23181 isa = PBXGroup; 23182 children = ( 23183 CE50D8CF1C8932FB0072EA5A /* mac */, 23184 E1FE136618343A1000892F13 /* CryptoDigest.h */, 23185 ); 23186 name = crypto; 23187 sourceTree = "<group>"; 23188 }; 23189 CE50D8CF1C8932FB0072EA5A /* mac */ = { 23190 isa = PBXGroup; 23191 children = ( 23192 E1FE13621834351100892F13 /* CryptoDigestMac.cpp */, 23193 ); 23194 name = mac; 23195 sourceTree = "<group>"; 23196 }; 23179 23197 DF9AFD6F13FC31B00015FEB7 /* objc */ = { 23180 23198 isa = PBXGroup; … … 23231 23249 E1233F0E185A4130008DFAF5 /* CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp */, 23232 23250 E1C266D618317AB4003F8B33 /* CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp */, 23233 E1FE13621834351100892F13 /* CryptoDigestMac.cpp */,23234 23251 E19AC3F8182566F700349426 /* CryptoKeyMac.cpp */, 23235 23252 E164FAA418315E1A00DB4E61 /* CryptoKeyRSAMac.cpp */, … … 23422 23439 E1FF8F6A180DB5BE00132674 /* CryptoAlgorithmRegistry.cpp */, 23423 23440 E1FF8F6B180DB5BE00132674 /* CryptoAlgorithmRegistry.h */, 23424 E1FE136618343A1000892F13 /* CryptoDigest.h */,23425 23441 E157A8E218173A3A009F821D /* CryptoKey.cpp */, 23426 23442 E157A8E318173A3A009F821D /* CryptoKey.h */, -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA1.cpp
r188118 r197575 55 55 void CryptoAlgorithmSHA1::digest(const CryptoAlgorithmParameters&, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback, ExceptionCode&) 56 56 { 57 std::unique_ptr<CryptoDigest> digest = CryptoDigest::create(Crypto AlgorithmIdentifier::SHA_1);57 std::unique_ptr<CryptoDigest> digest = CryptoDigest::create(CryptoDigest::Algorithm::SHA_1); 58 58 if (!digest) { 59 59 failureCallback(); -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA224.cpp
r188118 r197575 55 55 void CryptoAlgorithmSHA224::digest(const CryptoAlgorithmParameters&, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback, ExceptionCode&) 56 56 { 57 std::unique_ptr<CryptoDigest> digest = CryptoDigest::create(Crypto AlgorithmIdentifier::SHA_224);57 std::unique_ptr<CryptoDigest> digest = CryptoDigest::create(CryptoDigest::Algorithm::SHA_224); 58 58 if (!digest) { 59 59 failureCallback(); -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA256.cpp
r188118 r197575 55 55 void CryptoAlgorithmSHA256::digest(const CryptoAlgorithmParameters&, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback, ExceptionCode&) 56 56 { 57 std::unique_ptr<CryptoDigest> digest = CryptoDigest::create(Crypto AlgorithmIdentifier::SHA_256);57 std::unique_ptr<CryptoDigest> digest = CryptoDigest::create(CryptoDigest::Algorithm::SHA_256); 58 58 if (!digest) { 59 59 failureCallback(); -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA384.cpp
r188118 r197575 55 55 void CryptoAlgorithmSHA384::digest(const CryptoAlgorithmParameters&, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback, ExceptionCode&) 56 56 { 57 std::unique_ptr<CryptoDigest> digest = CryptoDigest::create(Crypto AlgorithmIdentifier::SHA_384);57 std::unique_ptr<CryptoDigest> digest = CryptoDigest::create(CryptoDigest::Algorithm::SHA_384); 58 58 if (!digest) { 59 59 failureCallback(); -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA512.cpp
r188118 r197575 55 55 void CryptoAlgorithmSHA512::digest(const CryptoAlgorithmParameters&, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback, ExceptionCode&) 56 56 { 57 std::unique_ptr<CryptoDigest> digest = CryptoDigest::create(Crypto AlgorithmIdentifier::SHA_512);57 std::unique_ptr<CryptoDigest> digest = CryptoDigest::create(CryptoDigest::Algorithm::SHA_512); 58 58 if (!digest) { 59 59 failureCallback(); -
trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp
r188118 r197575 37 37 namespace WebCore { 38 38 39 inline bool getCryptoDigestAlgorithm(CryptoAlgorithmIdentifier hashFunction, CryptoDigest::Algorithm& algorithm) 40 { 41 switch (hashFunction) { 42 case CryptoAlgorithmIdentifier::SHA_1: 43 algorithm = CryptoDigest::Algorithm::SHA_1; 44 return true; 45 case CryptoAlgorithmIdentifier::SHA_224: 46 algorithm = CryptoDigest::Algorithm::SHA_224; 47 return true; 48 case CryptoAlgorithmIdentifier::SHA_256: 49 algorithm = CryptoDigest::Algorithm::SHA_256; 50 return true; 51 case CryptoAlgorithmIdentifier::SHA_384: 52 algorithm = CryptoDigest::Algorithm::SHA_384; 53 return true; 54 case CryptoAlgorithmIdentifier::SHA_512: 55 algorithm = CryptoDigest::Algorithm::SHA_512; 56 return true; 57 default: 58 return false; 59 } 60 } 61 39 62 void CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign(const CryptoAlgorithmRsaSsaParams& parameters, const CryptoKeyRSA& key, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback, ExceptionCode& ec) 40 63 { … … 45 68 } 46 69 47 std::unique_ptr<CryptoDigest> digest = CryptoDigest::create(parameters.hash); 70 CryptoDigest::Algorithm cryptoDigestAlgorithm; 71 if (!getCryptoDigestAlgorithm(parameters.hash, cryptoDigestAlgorithm)) { 72 ec = NOT_SUPPORTED_ERR; 73 return; 74 } 75 76 std::unique_ptr<CryptoDigest> digest = CryptoDigest::create(cryptoDigestAlgorithm); 48 77 if (!digest) { 49 78 ec = NOT_SUPPORTED_ERR; … … 76 105 } 77 106 78 std::unique_ptr<CryptoDigest> digest = CryptoDigest::create(parameters.hash); 107 CryptoDigest::Algorithm cryptoDigestAlgorithm; 108 if (!getCryptoDigestAlgorithm(parameters.hash, cryptoDigestAlgorithm)) { 109 ec = NOT_SUPPORTED_ERR; 110 return; 111 } 112 113 std::unique_ptr<CryptoDigest> digest = CryptoDigest::create(cryptoDigestAlgorithm); 79 114 if (!digest) { 80 115 ec = NOT_SUPPORTED_ERR; -
trunk/Source/WebCore/platform/crypto/CryptoDigest.h
r197574 r197575 1 1 /* 2 * Copyright (C) 2013 Apple Inc. All rights reserved.2 * Copyright (C) 2013, 2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 27 27 #define CryptoDigest_h 28 28 29 #include "CryptoAlgorithmIdentifier.h"30 29 #include <wtf/Noncopyable.h> 31 30 #include <wtf/Vector.h> 32 33 #if ENABLE(SUBTLE_CRYPTO)34 31 35 32 namespace WebCore { … … 40 37 WTF_MAKE_NONCOPYABLE(CryptoDigest); 41 38 public: 42 static std::unique_ptr<CryptoDigest> create(CryptoAlgorithmIdentifier); 39 enum class Algorithm { 40 SHA_1, 41 SHA_224, 42 SHA_256, 43 SHA_384, 44 SHA_512, 45 }; 46 static std::unique_ptr<CryptoDigest> create(Algorithm); 43 47 ~CryptoDigest(); 44 48 … … 54 58 } // namespace WebCore 55 59 56 #endif // ENABLE(SUBTLE_CRYPTO)57 60 #endif // CryptoDigest_h -
trunk/Source/WebCore/platform/crypto/gnutls/CryptoDigestGnuTLS.cpp
r197574 r197575 27 27 #include "CryptoDigest.h" 28 28 29 #if ENABLE(SUBTLE_CRYPTO)30 31 29 #include <gnutls/gnutls.h> 32 30 #include <gnutls/crypto.h> … … 49 47 } 50 48 51 std::unique_ptr<CryptoDigest> CryptoDigest::create(Crypto AlgorithmIdentifieralgorithm)49 std::unique_ptr<CryptoDigest> CryptoDigest::create(CryptoDigest::Algorithm algorithm) 52 50 { 53 51 gnutls_digest_algorithm_t gnutlsAlgorithm; 54 52 55 53 switch (algorithm) { 56 case Crypto AlgorithmIdentifier::SHA_1: {54 case CryptoDigest::Algorithm::SHA_1: { 57 55 gnutlsAlgorithm = GNUTLS_DIG_SHA1; 58 56 break; 59 57 } 60 case Crypto AlgorithmIdentifier::SHA_224: {58 case CryptoDigest::Algorithm::SHA_224: { 61 59 gnutlsAlgorithm = GNUTLS_DIG_SHA224; 62 60 break; 63 61 } 64 case Crypto AlgorithmIdentifier::SHA_256: {62 case CryptoDigest::Algorithm::SHA_256: { 65 63 gnutlsAlgorithm = GNUTLS_DIG_SHA256; 66 64 break; 67 65 } 68 case Crypto AlgorithmIdentifier::SHA_384: {66 case CryptoDigest::Algorithm::SHA_384: { 69 67 gnutlsAlgorithm = GNUTLS_DIG_SHA384; 70 68 break; 71 69 } 72 case Crypto AlgorithmIdentifier::SHA_512: {70 case CryptoDigest::Algorithm::SHA_512: { 73 71 gnutlsAlgorithm = GNUTLS_DIG_SHA512; 74 72 break; 75 73 } 76 default:77 return nullptr;78 74 } 79 75 … … 105 101 106 102 } // namespace WebCore 107 108 #endif // ENABLE(SUBTLE_CRYPTO) -
trunk/Source/WebCore/platform/crypto/mac/CryptoDigestMac.cpp
r197574 r197575 27 27 #include "CryptoDigest.h" 28 28 29 #if ENABLE(SUBTLE_CRYPTO)30 31 29 #include <CommonCrypto/CommonCrypto.h> 32 30 … … 34 32 35 33 struct CryptoDigestContext { 36 Crypto AlgorithmIdentifieralgorithm;34 CryptoDigest::Algorithm algorithm; 37 35 void* ccContext; 38 36 }; … … 40 38 inline CC_SHA1_CTX* toSHA1Context(CryptoDigestContext* context) 41 39 { 42 ASSERT(context->algorithm == Crypto AlgorithmIdentifier::SHA_1);40 ASSERT(context->algorithm == CryptoDigest::Algorithm::SHA_1); 43 41 return static_cast<CC_SHA1_CTX*>(context->ccContext); 44 42 } 45 43 inline CC_SHA256_CTX* toSHA224Context(CryptoDigestContext* context) 46 44 { 47 ASSERT(context->algorithm == Crypto AlgorithmIdentifier::SHA_224);45 ASSERT(context->algorithm == CryptoDigest::Algorithm::SHA_224); 48 46 return static_cast<CC_SHA256_CTX*>(context->ccContext); 49 47 } 50 48 inline CC_SHA256_CTX* toSHA256Context(CryptoDigestContext* context) 51 49 { 52 ASSERT(context->algorithm == Crypto AlgorithmIdentifier::SHA_256);50 ASSERT(context->algorithm == CryptoDigest::Algorithm::SHA_256); 53 51 return static_cast<CC_SHA256_CTX*>(context->ccContext); 54 52 } 55 53 inline CC_SHA512_CTX* toSHA384Context(CryptoDigestContext* context) 56 54 { 57 ASSERT(context->algorithm == Crypto AlgorithmIdentifier::SHA_384);55 ASSERT(context->algorithm == CryptoDigest::Algorithm::SHA_384); 58 56 return static_cast<CC_SHA512_CTX*>(context->ccContext); 59 57 } 60 58 inline CC_SHA512_CTX* toSHA512Context(CryptoDigestContext* context) 61 59 { 62 ASSERT(context->algorithm == Crypto AlgorithmIdentifier::SHA_512);60 ASSERT(context->algorithm == CryptoDigest::Algorithm::SHA_512); 63 61 return static_cast<CC_SHA512_CTX*>(context->ccContext); 64 62 } … … 72 70 { 73 71 switch (m_context->algorithm) { 74 case Crypto AlgorithmIdentifier::SHA_1:72 case CryptoDigest::Algorithm::SHA_1: 75 73 delete toSHA1Context(m_context.get()); 76 74 return; 77 case Crypto AlgorithmIdentifier::SHA_224:75 case CryptoDigest::Algorithm::SHA_224: 78 76 delete toSHA224Context(m_context.get()); 79 77 return; 80 case Crypto AlgorithmIdentifier::SHA_256:78 case CryptoDigest::Algorithm::SHA_256: 81 79 delete toSHA256Context(m_context.get()); 82 80 return; 83 case Crypto AlgorithmIdentifier::SHA_384:81 case CryptoDigest::Algorithm::SHA_384: 84 82 delete toSHA384Context(m_context.get()); 85 83 return; 86 case Crypto AlgorithmIdentifier::SHA_512:84 case CryptoDigest::Algorithm::SHA_512: 87 85 delete toSHA512Context(m_context.get()); 88 86 return; 89 default:90 ASSERT_NOT_REACHED();91 87 } 92 88 } 93 89 94 90 95 std::unique_ptr<CryptoDigest> CryptoDigest::create(Crypto AlgorithmIdentifieralgorithm)91 std::unique_ptr<CryptoDigest> CryptoDigest::create(CryptoDigest::Algorithm algorithm) 96 92 { 97 93 std::unique_ptr<CryptoDigest> digest(new CryptoDigest); … … 99 95 100 96 switch (algorithm) { 101 case Crypto AlgorithmIdentifier::SHA_1: {97 case CryptoDigest::Algorithm::SHA_1: { 102 98 CC_SHA1_CTX* context = new CC_SHA1_CTX; 103 99 digest->m_context->ccContext = context; … … 105 101 return digest; 106 102 } 107 case Crypto AlgorithmIdentifier::SHA_224: {103 case CryptoDigest::Algorithm::SHA_224: { 108 104 CC_SHA256_CTX* context = new CC_SHA256_CTX; 109 105 digest->m_context->ccContext = context; … … 111 107 return digest; 112 108 } 113 case Crypto AlgorithmIdentifier::SHA_256: {109 case CryptoDigest::Algorithm::SHA_256: { 114 110 CC_SHA256_CTX* context = new CC_SHA256_CTX; 115 111 digest->m_context->ccContext = context; … … 117 113 return digest; 118 114 } 119 case Crypto AlgorithmIdentifier::SHA_384: {115 case CryptoDigest::Algorithm::SHA_384: { 120 116 CC_SHA512_CTX* context = new CC_SHA512_CTX; 121 117 digest->m_context->ccContext = context; … … 123 119 return digest; 124 120 } 125 case Crypto AlgorithmIdentifier::SHA_512: {121 case CryptoDigest::Algorithm::SHA_512: { 126 122 CC_SHA512_CTX* context = new CC_SHA512_CTX; 127 123 digest->m_context->ccContext = context; … … 129 125 return digest; 130 126 } 131 default:132 return nullptr;133 127 } 134 128 } … … 137 131 { 138 132 switch (m_context->algorithm) { 139 case Crypto AlgorithmIdentifier::SHA_1:133 case CryptoDigest::Algorithm::SHA_1: 140 134 CC_SHA1_Update(toSHA1Context(m_context.get()), input, length); 141 135 return; 142 case Crypto AlgorithmIdentifier::SHA_224:136 case CryptoDigest::Algorithm::SHA_224: 143 137 CC_SHA224_Update(toSHA224Context(m_context.get()), input, length); 144 138 return; 145 case Crypto AlgorithmIdentifier::SHA_256:139 case CryptoDigest::Algorithm::SHA_256: 146 140 CC_SHA256_Update(toSHA256Context(m_context.get()), input, length); 147 141 return; 148 case Crypto AlgorithmIdentifier::SHA_384:142 case CryptoDigest::Algorithm::SHA_384: 149 143 CC_SHA384_Update(toSHA384Context(m_context.get()), input, length); 150 144 return; 151 case Crypto AlgorithmIdentifier::SHA_512:145 case CryptoDigest::Algorithm::SHA_512: 152 146 CC_SHA512_Update(toSHA512Context(m_context.get()), input, length); 153 147 return; 154 default:155 ASSERT_NOT_REACHED();156 148 } 157 149 } … … 161 153 Vector<uint8_t> result; 162 154 switch (m_context->algorithm) { 163 case Crypto AlgorithmIdentifier::SHA_1:155 case CryptoDigest::Algorithm::SHA_1: 164 156 result.resize(CC_SHA1_DIGEST_LENGTH); 165 157 CC_SHA1_Final(result.data(), toSHA1Context(m_context.get())); 166 158 break; 167 case Crypto AlgorithmIdentifier::SHA_224:159 case CryptoDigest::Algorithm::SHA_224: 168 160 result.resize(CC_SHA224_DIGEST_LENGTH); 169 161 CC_SHA224_Final(result.data(), toSHA224Context(m_context.get())); 170 162 break; 171 case Crypto AlgorithmIdentifier::SHA_256:163 case CryptoDigest::Algorithm::SHA_256: 172 164 result.resize(CC_SHA256_DIGEST_LENGTH); 173 165 CC_SHA256_Final(result.data(), toSHA256Context(m_context.get())); 174 166 break; 175 case Crypto AlgorithmIdentifier::SHA_384:167 case CryptoDigest::Algorithm::SHA_384: 176 168 result.resize(CC_SHA384_DIGEST_LENGTH); 177 169 CC_SHA384_Final(result.data(), toSHA384Context(m_context.get())); 178 170 break; 179 case Crypto AlgorithmIdentifier::SHA_512:171 case CryptoDigest::Algorithm::SHA_512: 180 172 result.resize(CC_SHA512_DIGEST_LENGTH); 181 173 CC_SHA512_Final(result.data(), toSHA512Context(m_context.get())); 182 174 break; 183 default:184 ASSERT_NOT_REACHED();185 175 } 186 176 return result; … … 188 178 189 179 } // namespace WebCore 190 191 #endif // ENABLE(SUBTLE_CRYPTO)
Note: See TracChangeset
for help on using the changeset viewer.