OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // TODO(jww) The original Blink-style header guard for this file conflicts with | 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 | 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 | 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 | 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 | 9 // to a similar style. Thus, whenever that is resolved, this header guard |
10 // should be changed to whatever style is agreed upon. | 10 // should be changed to whatever style is agreed upon. |
11 #ifndef SOURCE_PLATFORM_CRYPTO_H_ | 11 #ifndef SOURCE_PLATFORM_CRYPTO_H_ |
12 #define SOURCE_PLATFORM_CRYPTO_H_ | 12 #define SOURCE_PLATFORM_CRYPTO_H_ |
13 | 13 |
14 #include "platform/PlatformExport.h" | 14 #include "platform/PlatformExport.h" |
15 #include "public/platform/WebCrypto.h" | 15 #include "public/platform/WebCrypto.h" |
16 #include "wtf/Allocator.h" | 16 #include "wtf/Allocator.h" |
17 #include "wtf/HashSet.h" | 17 #include "wtf/HashSet.h" |
18 #include "wtf/StringHasher.h" | 18 #include "wtf/StringHasher.h" |
19 #include "wtf/Vector.h" | 19 #include "wtf/Vector.h" |
| 20 #include <memory> |
20 | 21 |
21 namespace blink { | 22 namespace blink { |
22 | 23 |
23 static const size_t kMaxDigestSize = 64; | 24 static const size_t kMaxDigestSize = 64; |
24 typedef Vector<uint8_t, kMaxDigestSize> DigestValue; | 25 typedef Vector<uint8_t, kMaxDigestSize> DigestValue; |
25 | 26 |
26 const size_t sha1HashSize = 20; | 27 const size_t sha1HashSize = 20; |
27 enum HashAlgorithm { | 28 enum HashAlgorithm { |
28 HashAlgorithmSha1, | 29 HashAlgorithmSha1, |
29 HashAlgorithmSha256, | 30 HashAlgorithmSha256, |
30 HashAlgorithmSha384, | 31 HashAlgorithmSha384, |
31 HashAlgorithmSha512 | 32 HashAlgorithmSha512 |
32 }; | 33 }; |
33 | 34 |
34 PLATFORM_EXPORT bool computeDigest(HashAlgorithm, const char* digestable, size_t
length, DigestValue& digestResult); | 35 PLATFORM_EXPORT bool computeDigest(HashAlgorithm, const char* digestable, size_t
length, DigestValue& digestResult); |
35 PLATFORM_EXPORT PassOwnPtr<WebCryptoDigestor> createDigestor(HashAlgorithm); | 36 PLATFORM_EXPORT std::unique_ptr<WebCryptoDigestor> createDigestor(HashAlgorithm)
; |
36 PLATFORM_EXPORT void finishDigestor(WebCryptoDigestor*, DigestValue& digestResul
t); | 37 PLATFORM_EXPORT void finishDigestor(WebCryptoDigestor*, DigestValue& digestResul
t); |
37 | 38 |
38 } // namespace blink | 39 } // namespace blink |
39 | 40 |
40 namespace WTF { | 41 namespace WTF { |
41 | 42 |
42 struct DigestValueHash { | 43 struct DigestValueHash { |
43 STATIC_ONLY(DigestValueHash); | 44 STATIC_ONLY(DigestValueHash); |
44 static unsigned hash(const blink::DigestValue& v) | 45 static unsigned hash(const blink::DigestValue& v) |
45 { | 46 { |
(...skipping 16 matching lines...) Expand all Loading... |
62 STATIC_ONLY(DefaultHash); | 63 STATIC_ONLY(DefaultHash); |
63 typedef IntHash<blink::HashAlgorithm> Hash; | 64 typedef IntHash<blink::HashAlgorithm> Hash; |
64 }; | 65 }; |
65 template <> | 66 template <> |
66 struct HashTraits<blink::HashAlgorithm> : UnsignedWithZeroKeyHashTraits<blink::H
ashAlgorithm> { | 67 struct HashTraits<blink::HashAlgorithm> : UnsignedWithZeroKeyHashTraits<blink::H
ashAlgorithm> { |
67 STATIC_ONLY(HashTraits); | 68 STATIC_ONLY(HashTraits); |
68 }; | 69 }; |
69 | 70 |
70 } // namespace WTF | 71 } // namespace WTF |
71 #endif // SOURCE_PLATFORM_CRYPTO_H_ | 72 #endif // SOURCE_PLATFORM_CRYPTO_H_ |
OLD | NEW |