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

Side by Side Diff: net/base/hash_value.h

Issue 1432663002: Add type-safe constructors to net::HashValue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 | « no previous file | net/base/hash_value.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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_
OLDNEW
« no previous file with comments | « no previous file | net/base/hash_value.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698