| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 curr_hash += curr_diff; | 91 curr_hash += curr_diff; |
| 92 | 92 |
| 93 result.push_back(curr_hash); | 93 result.push_back(curr_hash); |
| 94 } | 94 } |
| 95 | 95 |
| 96 uncompressed_list->swap(result); | 96 uncompressed_list->swap(result); |
| 97 return true; | 97 return true; |
| 98 } | 98 } |
| 99 | 99 |
| 100 PackedEVCertsWhitelist::PackedEVCertsWhitelist( | 100 PackedEVCertsWhitelist::PackedEVCertsWhitelist( |
| 101 const std::string& compressed_whitelist) { | 101 const std::string& compressed_whitelist, |
| 102 const base::Version& version) |
| 103 : version_(version) { |
| 102 if (!UncompressEVWhitelist(compressed_whitelist, &whitelist_)) { | 104 if (!UncompressEVWhitelist(compressed_whitelist, &whitelist_)) { |
| 103 whitelist_.clear(); | 105 whitelist_.clear(); |
| 104 return; | 106 return; |
| 105 } | 107 } |
| 106 } | 108 } |
| 107 | 109 |
| 108 PackedEVCertsWhitelist::~PackedEVCertsWhitelist() { | 110 PackedEVCertsWhitelist::~PackedEVCertsWhitelist() { |
| 109 } | 111 } |
| 110 | 112 |
| 111 bool PackedEVCertsWhitelist::ContainsCertificateHash( | 113 bool PackedEVCertsWhitelist::ContainsCertificateHash( |
| 112 const std::string& certificate_hash) const { | 114 const std::string& certificate_hash) const { |
| 113 DCHECK(!whitelist_.empty()); | 115 DCHECK(!whitelist_.empty()); |
| 114 uint64_t hash_to_lookup; | 116 uint64_t hash_to_lookup; |
| 115 | 117 |
| 116 base::ReadBigEndian(certificate_hash.data(), &hash_to_lookup); | 118 base::ReadBigEndian(certificate_hash.data(), &hash_to_lookup); |
| 117 return bsearch(&hash_to_lookup, | 119 return bsearch(&hash_to_lookup, |
| 118 &whitelist_[0], | 120 &whitelist_[0], |
| 119 whitelist_.size(), | 121 whitelist_.size(), |
| 120 kCertHashLength, | 122 kCertHashLength, |
| 121 TruncatedHashesComparator) != NULL; | 123 TruncatedHashesComparator) != NULL; |
| 122 } | 124 } |
| 123 | 125 |
| 124 bool PackedEVCertsWhitelist::IsValid() const { | 126 bool PackedEVCertsWhitelist::IsValid() const { |
| 125 return whitelist_.size() > 0; | 127 return whitelist_.size() > 0; |
| 126 } | 128 } |
| 129 |
| 130 base::Version PackedEVCertsWhitelist::Version() const { |
| 131 return version_; |
| 132 } |
| OLD | NEW |