| 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 "components/packed_ct_ev_whitelist/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 |
| 11 #include "base/big_endian.h" | 11 #include "base/big_endian.h" |
| 12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
| 13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "chrome/browser/net/bit_stream_reader.h" | 15 #include "components/packed_ct_ev_whitelist/bit_stream_reader.h" |
| 16 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 17 #include "net/ssl/ssl_config_service.h" | 17 #include "net/ssl/ssl_config_service.h" |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 const uint8_t kCertHashLengthBits = 64; // 8 bytes | 20 const uint8_t kCertHashLengthBits = 64; // 8 bytes |
| 21 const uint8_t kCertHashLength = kCertHashLengthBits / 8; | 21 const uint8_t kCertHashLength = kCertHashLengthBits / 8; |
| 22 const uint64_t kGolombMParameterBits = 47; // 2^47 | 22 const uint64_t kGolombMParameterBits = 47; // 2^47 |
| 23 | 23 |
| 24 void SetEVWhitelistInSSLConfigService( | 24 void SetEVWhitelistInSSLConfigService( |
| 25 const scoped_refptr<net::ct::EVCertsWhitelist>& new_whitelist) { | 25 const scoped_refptr<net::ct::EVCertsWhitelist>& new_whitelist) { |
| 26 VLOG(1) << "Setting new EV Certs whitelist."; | 26 VLOG(1) << "Setting new EV Certs whitelist."; |
| 27 net::SSLConfigService::SetEVCertsWhitelist(new_whitelist); | 27 net::SSLConfigService::SetEVCertsWhitelist(new_whitelist); |
| 28 } | 28 } |
| 29 | 29 |
| 30 int TruncatedHashesComparator(const void* v1, const void* v2) { | 30 int TruncatedHashesComparator(const void* v1, const void* v2) { |
| 31 const uint64_t& h1(*(static_cast<const uint64_t*>(v1))); | 31 const uint64_t& h1(*(static_cast<const uint64_t*>(v1))); |
| 32 const uint64_t& h2(*(static_cast<const uint64_t*>(v2))); | 32 const uint64_t& h2(*(static_cast<const uint64_t*>(v2))); |
| 33 if (h1 < h2) | 33 if (h1 < h2) |
| 34 return -1; | 34 return -1; |
| 35 else if (h1 > h2) | 35 else if (h1 > h2) |
| 36 return 1; | 36 return 1; |
| 37 return 0; | 37 return 0; |
| 38 } | 38 } |
| 39 } // namespace | 39 } // namespace |
| 40 | 40 |
| 41 namespace packed_ct_ev_whitelist { |
| 42 |
| 41 void SetEVCertsWhitelist(scoped_refptr<net::ct::EVCertsWhitelist> whitelist) { | 43 void SetEVCertsWhitelist(scoped_refptr<net::ct::EVCertsWhitelist> whitelist) { |
| 42 if (!whitelist->IsValid()) { | 44 if (!whitelist->IsValid()) { |
| 43 VLOG(1) << "EV Certs whitelist is not valid, not setting."; | 45 VLOG(1) << "EV Certs whitelist is not valid, not setting."; |
| 44 return; | 46 return; |
| 45 } | 47 } |
| 46 | 48 |
| 47 base::Closure assign_cb = | 49 base::Closure assign_cb = |
| 48 base::Bind(SetEVWhitelistInSSLConfigService, whitelist); | 50 base::Bind(SetEVWhitelistInSSLConfigService, whitelist); |
| 49 content::BrowserThread::PostTask( | 51 content::BrowserThread::PostTask( |
| 50 content::BrowserThread::IO, FROM_HERE, assign_cb); | 52 content::BrowserThread::IO, FROM_HERE, assign_cb); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 TruncatedHashesComparator) != NULL; | 125 TruncatedHashesComparator) != NULL; |
| 124 } | 126 } |
| 125 | 127 |
| 126 bool PackedEVCertsWhitelist::IsValid() const { | 128 bool PackedEVCertsWhitelist::IsValid() const { |
| 127 return whitelist_.size() > 0; | 129 return whitelist_.size() > 0; |
| 128 } | 130 } |
| 129 | 131 |
| 130 base::Version PackedEVCertsWhitelist::Version() const { | 132 base::Version PackedEVCertsWhitelist::Version() const { |
| 131 return version_; | 133 return version_; |
| 132 } | 134 } |
| 135 |
| 136 } // namespace packed_ct_ev_whitelist |
| OLD | NEW |