Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: Source/platform/Crypto.h

Issue 189373010: Get rid of WTF::SHA1. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase on ToT and fixed header guard collision. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/modules/websockets/WebSocketHandshake.cpp ('k') | Source/platform/Crypto.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // TODO(jww) The original Blink-style header guard for this file conflicts with
6 // the header guard in Source/modules/crypto/Crypto.h, so this is a
7 // Chromium-style header guard instead. There is now a bug
8 // (https://crbug.com/360121) to track a proposal to change all header guards
9 // to a similar style. Thus, whenever that is resolved, this header guard
10 // should be changed to whatever style is agreed upon.
11 #ifndef SOURCE_PLATFORM_CRYPTO_H_
12 #define SOURCE_PLATFORM_CRYPTO_H_
13
14 #include "platform/PlatformExport.h"
15 #include "public/platform/WebCrypto.h"
16 #include "wtf/HashSet.h"
17 #include "wtf/StringHasher.h"
18 #include "wtf/Vector.h"
19 #include "wtf/text/CString.h"
20
21 namespace WebCore {
22
23 static const size_t kMaxDigestSize = 64;
24 typedef Vector<uint8_t, kMaxDigestSize> DigestValue;
25
26 const size_t sha1HashSize = 20;
27 enum HashAlgorithm {
28 HashAlgorithmSha1,
29 HashAlgorithmSha256,
30 HashAlgorithmSha384,
31 HashAlgorithmSha512
32 };
33
34 PLATFORM_EXPORT void computeDigest(HashAlgorithm, const char* digestable, size_t length, DigestValue& digestResult);
35 PLATFORM_EXPORT PassOwnPtr<blink::WebCryptoDigestor> createDigestor(HashAlgorith m);
36 PLATFORM_EXPORT void finishDigestor(blink::WebCryptoDigestor*, DigestValue& dige stResult);
37
38 } // namespace WebCore
39
40 namespace WTF {
41
42 struct DigestValueHash {
43 static unsigned hash(const WebCore::DigestValue& v)
44 {
45 return StringHasher::computeHash(v.data(), v.size());
46 }
47 static bool equal(const WebCore::DigestValue& a, const WebCore::DigestValue& b)
48 {
49 return a == b;
50 };
51 static const bool safeToCompareToEmptyOrDeleted = true;
52 };
53 template <>
54 struct DefaultHash<WebCore::DigestValue> {
55 typedef DigestValueHash Hash;
56 };
57
58 template <>
59 struct DefaultHash<WebCore::HashAlgorithm> {
60 typedef IntHash<WebCore::HashAlgorithm> Hash;
61 };
62 template <>
63 struct HashTraits<WebCore::HashAlgorithm> : UnsignedWithZeroKeyHashTraits<WebCor e::HashAlgorithm> {
64 };
65
66 } // namespace WTF
67 #endif // SOURCE_PLATFORM_CRYPTO_H_
OLDNEW
« no previous file with comments | « Source/modules/websockets/WebSocketHandshake.cpp ('k') | Source/platform/Crypto.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698