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 #include "chrome/browser/net/packed_ct_ev_whitelist.h" | 5 #include "chrome/browser/net/packed_ct_ev_whitelist.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
100 curr_hash += curr_diff; | 100 curr_hash += curr_diff; |
101 | 101 |
102 result.push_back(curr_hash); | 102 result.push_back(curr_hash); |
103 } | 103 } |
104 | 104 |
105 uncompressed_list->swap(result); | 105 uncompressed_list->swap(result); |
106 return true; | 106 return true; |
107 } | 107 } |
108 | 108 |
109 PackedEVCertsWhitelist::PackedEVCertsWhitelist( | 109 PackedEVCertsWhitelist::PackedEVCertsWhitelist( |
110 const std::string& compressed_whitelist) { | 110 const std::string& compressed_whitelist) |
111 : is_whitelist_valid_(false) { | |
111 if (!UncompressEVWhitelist(compressed_whitelist, &whitelist_)) { | 112 if (!UncompressEVWhitelist(compressed_whitelist, &whitelist_)) { |
112 whitelist_.clear(); | 113 whitelist_.clear(); |
113 return; | 114 return; |
114 } | 115 } |
116 | |
117 is_whitelist_valid_ = true; | |
Ryan Sleevi
2014/12/01 15:27:55
This doesn't seem used at all in this .cc; unneces
Eran Messeri
2014/12/01 17:29:54
My bad, this is a result of a bad merge. Removed.
| |
115 } | 118 } |
116 | 119 |
117 PackedEVCertsWhitelist::~PackedEVCertsWhitelist() { | 120 PackedEVCertsWhitelist::~PackedEVCertsWhitelist() { |
118 } | 121 } |
119 | 122 |
120 bool PackedEVCertsWhitelist::ContainsCertificateHash( | 123 bool PackedEVCertsWhitelist::ContainsCertificateHash( |
121 const std::string& certificate_hash) const { | 124 const std::string& certificate_hash) const { |
122 DCHECK(!whitelist_.empty()); | 125 DCHECK(!whitelist_.empty()); |
123 uint64_t hash_to_lookup; | 126 uint64_t hash_to_lookup; |
124 | 127 |
125 base::ReadBigEndian(certificate_hash.data(), &hash_to_lookup); | 128 base::ReadBigEndian(certificate_hash.data(), &hash_to_lookup); |
126 return bsearch(&hash_to_lookup, | 129 return bsearch(&hash_to_lookup, |
127 &whitelist_[0], | 130 &whitelist_[0], |
128 whitelist_.size(), | 131 whitelist_.size(), |
129 kCertHashLength, | 132 kCertHashLength, |
130 TruncatedHashesComparator) != NULL; | 133 TruncatedHashesComparator) != NULL; |
131 } | 134 } |
132 | 135 |
133 bool PackedEVCertsWhitelist::IsValid() const { | 136 bool PackedEVCertsWhitelist::IsValid() const { |
134 return whitelist_.size() > 0; | 137 return whitelist_.size() > 0; |
135 } | 138 } |
OLD | NEW |