| 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 #ifndef CHROME_BROWSER_NET_PACKED_CT_EV_WHITELIST_H_ | 5 #ifndef CHROME_BROWSER_NET_PACKED_CT_EV_WHITELIST_H_ |
| 6 #define CHROME_BROWSER_NET_PACKED_CT_EV_WHITELIST_H_ | 6 #define CHROME_BROWSER_NET_PACKED_CT_EV_WHITELIST_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 UncompressFailsForInvalidValuesInList); | 53 UncompressFailsForInvalidValuesInList); |
| 54 FRIEND_TEST_ALL_PREFIXES(PackedEVCertsWhitelistTest, | 54 FRIEND_TEST_ALL_PREFIXES(PackedEVCertsWhitelistTest, |
| 55 UncompressesWhitelistCorrectly); | 55 UncompressesWhitelistCorrectly); |
| 56 | 56 |
| 57 // Given a Golomb-coded list of hashes in |compressed_whitelist|, unpack into | 57 // Given a Golomb-coded list of hashes in |compressed_whitelist|, unpack into |
| 58 // |uncompressed_list|. Returns true if the format of the compressed whitelist | 58 // |uncompressed_list|. Returns true if the format of the compressed whitelist |
| 59 // is valid, false otherwise. | 59 // is valid, false otherwise. |
| 60 static bool UncompressEVWhitelist(const std::string& compressed_whitelist, | 60 static bool UncompressEVWhitelist(const std::string& compressed_whitelist, |
| 61 std::vector<uint64_t>* uncompressed_list); | 61 std::vector<uint64_t>* uncompressed_list); |
| 62 | 62 |
| 63 bool is_whitelist_valid_; | |
| 64 | |
| 65 // The whitelist is an array containing certificate hashes (truncated | 63 // The whitelist is an array containing certificate hashes (truncated |
| 66 // to a fixed size of 8 bytes), sorted. | 64 // to a fixed size of 8 bytes), sorted. |
| 67 // Binary search is used to locate hashes in the the array. | 65 // Binary search is used to locate hashes in the the array. |
| 68 // Benchmarking bsearch vs std::set (with 120K entries, doing 1.2M lookups) | 66 // Benchmarking bsearch vs std::set (with 120K entries, doing 1.2M lookups) |
| 69 // shows that bsearch is about twice as fast as std::set lookups (and std::set | 67 // shows that bsearch is about twice as fast as std::set lookups (and std::set |
| 70 // has additional memory overhead). | 68 // has additional memory overhead). |
| 71 std::vector<uint64_t> whitelist_; | 69 std::vector<uint64_t> whitelist_; |
| 72 | 70 |
| 73 DISALLOW_COPY_AND_ASSIGN(PackedEVCertsWhitelist); | 71 DISALLOW_COPY_AND_ASSIGN(PackedEVCertsWhitelist); |
| 74 }; | 72 }; |
| 75 | 73 |
| 76 // Sets the EV certificate hashes whitelist from |compressed_whitelist_file| | 74 // Sets the EV certificate hashes whitelist from |compressed_whitelist_file| |
| 77 // in |ssl_config_service|, after uncompressing it. | 75 // in |ssl_config_service|, after uncompressing it. |
| 78 // If the data in |compressed_whitelist_file| is not a valid compressed | 76 // If the data in |compressed_whitelist_file| is not a valid compressed |
| 79 // whitelist, does nothing. | 77 // whitelist, does nothing. |
| 80 // As this function performs file operations, it should be called from a | 78 // As this function performs file operations, it should be called from a |
| 81 // blocking pool worker or a file worker. | 79 // blocking pool worker or a file worker. |
| 82 // To set the new whitelist, this function dispatches a task to the IO thread. | 80 // To set the new whitelist, this function dispatches a task to the IO thread. |
| 83 void SetEVWhitelistFromFile(const base::FilePath& compressed_whitelist_file); | 81 void SetEVWhitelistFromFile(const base::FilePath& compressed_whitelist_file); |
| 84 | 82 |
| 85 #endif // CHROME_BROWSER_NET_PACKED_CT_EV_WHITELIST_H_ | 83 #endif // CHROME_BROWSER_NET_PACKED_CT_EV_WHITELIST_H_ |
| OLD | NEW |