OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef NET_BASE_HASH_VALUE_H_ | 5 #ifndef NET_BASE_HASH_VALUE_H_ |
6 #define NET_BASE_HASH_VALUE_H_ | 6 #define NET_BASE_HASH_VALUE_H_ |
7 | 7 |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 struct NET_EXPORT SHA256HashValue { | 26 struct NET_EXPORT SHA256HashValue { |
27 bool Equals(const SHA256HashValue& other) const; | 27 bool Equals(const SHA256HashValue& other) const; |
28 | 28 |
29 unsigned char data[32]; | 29 unsigned char data[32]; |
30 }; | 30 }; |
31 | 31 |
32 enum HashValueTag { | 32 enum HashValueTag { |
33 HASH_VALUE_SHA1, | 33 HASH_VALUE_SHA1, |
34 HASH_VALUE_SHA256, | 34 HASH_VALUE_SHA256, |
35 | |
36 // This must always be last. | |
37 HASH_VALUE_TAGS_COUNT | |
38 }; | 35 }; |
39 | 36 |
40 class NET_EXPORT HashValue { | 37 class NET_EXPORT HashValue { |
41 public: | 38 public: |
42 explicit HashValue(HashValueTag tag) : tag(tag) {} | 39 explicit HashValue(HashValueTag tag) : tag(tag) {} |
43 HashValue() : tag(HASH_VALUE_SHA1) {} | 40 HashValue() : tag(HASH_VALUE_SHA1) {} |
44 | 41 |
45 // Check for equality of hash values | 42 // Check for equality of hash values |
46 // This function may have VARIABLE timing which leaks information | 43 // This function may have VARIABLE timing which leaks information |
47 // about its inputs. For example it may exit early once a | 44 // about its inputs. For example it may exit early once a |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 | 113 |
117 // IsSHA1HashInSortedArray returns true iff |hash| is in |array|, a sorted | 114 // IsSHA1HashInSortedArray returns true iff |hash| is in |array|, a sorted |
118 // array of SHA1 hashes. | 115 // array of SHA1 hashes. |
119 bool IsSHA1HashInSortedArray(const SHA1HashValue& hash, | 116 bool IsSHA1HashInSortedArray(const SHA1HashValue& hash, |
120 const uint8_t* array, | 117 const uint8_t* array, |
121 size_t array_byte_len); | 118 size_t array_byte_len); |
122 | 119 |
123 } // namespace net | 120 } // namespace net |
124 | 121 |
125 #endif // NET_BASE_HASH_VALUE_H_ | 122 #endif // NET_BASE_HASH_VALUE_H_ |
OLD | NEW |