| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <string.h> | 10 #include <string.h> |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 inline bool operator==(const SHA256HashValue& lhs, const SHA256HashValue& rhs) { | 37 inline bool operator==(const SHA256HashValue& lhs, const SHA256HashValue& rhs) { |
| 38 return memcmp(lhs.data, rhs.data, sizeof(lhs.data)) == 0; | 38 return memcmp(lhs.data, rhs.data, sizeof(lhs.data)) == 0; |
| 39 } | 39 } |
| 40 | 40 |
| 41 inline bool operator!=(const SHA256HashValue& lhs, const SHA256HashValue& rhs) { | 41 inline bool operator!=(const SHA256HashValue& lhs, const SHA256HashValue& rhs) { |
| 42 return !(lhs == rhs); | 42 return !(lhs == rhs); |
| 43 } | 43 } |
| 44 | 44 |
| 45 enum HashValueTag { | 45 enum HashValueTag { |
| 46 HASH_VALUE_SHA1, | |
| 47 HASH_VALUE_SHA256, | 46 HASH_VALUE_SHA256, |
| 48 }; | 47 }; |
| 49 | 48 |
| 50 class NET_EXPORT HashValue { | 49 class NET_EXPORT HashValue { |
| 51 public: | 50 public: |
| 52 explicit HashValue(const SHA1HashValue& hash); | |
| 53 explicit HashValue(const SHA256HashValue& hash); | 51 explicit HashValue(const SHA256HashValue& hash); |
| 54 explicit HashValue(HashValueTag tag) : tag(tag) {} | 52 explicit HashValue(HashValueTag tag) : tag(tag) {} |
| 55 HashValue() : tag(HASH_VALUE_SHA1) {} | 53 HashValue() : tag(HASH_VALUE_SHA256) {} |
| 56 | 54 |
| 57 // Serializes/Deserializes hashes in the form of | 55 // Serializes/Deserializes hashes in the form of |
| 58 // <hash-name>"/"<base64-hash-value> | 56 // <hash-name>"/"<base64-hash-value> |
| 59 // (eg: "sha1/...") | 57 // (eg: "sha1/...") |
| 60 // This format may be persisted to permanent storage, so | 58 // This format may be persisted to permanent storage, so |
| 61 // care should be taken before changing the serialization. | 59 // care should be taken before changing the serialization. |
| 62 // | 60 // |
| 63 // This format is used for: | 61 // This format is used for: |
| 64 // - net_internals display/setting public-key pins | 62 // - net_internals display/setting public-key pins |
| 65 // - logging public-key pins | 63 // - logging public-key pins |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 | 113 |
| 116 // IsSHA256HashInSortedArray returns true iff |hash| is in |array|, a sorted | 114 // IsSHA256HashInSortedArray returns true iff |hash| is in |array|, a sorted |
| 117 // array of SHA256 hashes. | 115 // array of SHA256 hashes. |
| 118 bool IsSHA256HashInSortedArray(const SHA256HashValue& hash, | 116 bool IsSHA256HashInSortedArray(const SHA256HashValue& hash, |
| 119 const uint8_t* array, | 117 const uint8_t* array, |
| 120 size_t array_byte_len); | 118 size_t array_byte_len); |
| 121 | 119 |
| 122 } // namespace net | 120 } // namespace net |
| 123 | 121 |
| 124 #endif // NET_BASE_HASH_VALUE_H_ | 122 #endif // NET_BASE_HASH_VALUE_H_ |
| OLD | NEW |