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 18 matching lines...) Expand all Loading... |
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 }; | 35 }; |
36 | 36 |
37 class NET_EXPORT HashValue { | 37 class NET_EXPORT HashValue { |
38 public: | 38 public: |
| 39 explicit HashValue(const SHA1HashValue& hash); |
| 40 explicit HashValue(const SHA256HashValue& hash); |
39 explicit HashValue(HashValueTag tag) : tag(tag) {} | 41 explicit HashValue(HashValueTag tag) : tag(tag) {} |
40 HashValue() : tag(HASH_VALUE_SHA1) {} | 42 HashValue() : tag(HASH_VALUE_SHA1) {} |
41 | 43 |
42 // Check for equality of hash values | 44 // Check for equality of hash values |
43 // This function may have VARIABLE timing which leaks information | 45 // This function may have VARIABLE timing which leaks information |
44 // about its inputs. For example it may exit early once a | 46 // about its inputs. For example it may exit early once a |
45 // nonequal character is discovered. Thus, for security reasons | 47 // nonequal character is discovered. Thus, for security reasons |
46 // this function MUST NOT be used with secret values (such as | 48 // this function MUST NOT be used with secret values (such as |
47 // password hashes, MAC tags, etc.) | 49 // password hashes, MAC tags, etc.) |
48 bool Equals(const HashValue& other) const; | 50 bool Equals(const HashValue& other) const; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 | 115 |
114 // IsSHA1HashInSortedArray returns true iff |hash| is in |array|, a sorted | 116 // IsSHA1HashInSortedArray returns true iff |hash| is in |array|, a sorted |
115 // array of SHA1 hashes. | 117 // array of SHA1 hashes. |
116 bool IsSHA1HashInSortedArray(const SHA1HashValue& hash, | 118 bool IsSHA1HashInSortedArray(const SHA1HashValue& hash, |
117 const uint8_t* array, | 119 const uint8_t* array, |
118 size_t array_byte_len); | 120 size_t array_byte_len); |
119 | 121 |
120 } // namespace net | 122 } // namespace net |
121 | 123 |
122 #endif // NET_BASE_HASH_VALUE_H_ | 124 #endif // NET_BASE_HASH_VALUE_H_ |
OLD | NEW |