Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(218)

Side by Side Diff: chrome/browser/net/packed_ct_ev_whitelist.h

Issue 782333002: Certificate Transparency: Adding finch and NetLog logging for EV certs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typo in log_view_painter, update params description in netlog Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 12 matching lines...) Expand all
23 // * First 8 bytes: First hash 23 // * First 8 bytes: First hash
24 // * Repeating Golomb-coded number which is the numeric difference of the 24 // * Repeating Golomb-coded number which is the numeric difference of the
25 // previous hash value from this one 25 // previous hash value from this one
26 // 26 //
27 // The resulting, unpacked list is a sorted list of hash values that can be 27 // The resulting, unpacked list is a sorted list of hash values that can be
28 // efficiently searched. 28 // efficiently searched.
29 class PackedEVCertsWhitelist : public net::ct::EVCertsWhitelist { 29 class PackedEVCertsWhitelist : public net::ct::EVCertsWhitelist {
30 public: 30 public:
31 // Unpacks the given |compressed_whitelist|. See the class documentation 31 // Unpacks the given |compressed_whitelist|. See the class documentation
32 // for description of the |compressed_whitelist| format. 32 // for description of the |compressed_whitelist| format.
33 explicit PackedEVCertsWhitelist(const std::string& compressed_whitelist); 33 PackedEVCertsWhitelist(const std::string& compressed_whitelist,
34 const base::Version& version);
34 35
35 // Returns true if the |certificate_hash| appears in the EV certificate hashes 36 // Returns true if the |certificate_hash| appears in the EV certificate hashes
36 // whitelist. Must not be called if IsValid for this instance returned false. 37 // whitelist. Must not be called if IsValid for this instance returned false.
37 bool ContainsCertificateHash( 38 bool ContainsCertificateHash(
38 const std::string& certificate_hash) const override; 39 const std::string& certificate_hash) const override;
39 40
40 // Returns true if the EV certificate hashes whitelist provided in the c'tor 41 // Returns true if the EV certificate hashes whitelist provided in the c'tor
41 // was valid, false otherwise. 42 // was valid, false otherwise.
42 bool IsValid() const override; 43 bool IsValid() const override;
43 44
45 // Returns the version of the whitelist in use, if available.
46 base::Version Version() const override;
47
44 protected: 48 protected:
45 ~PackedEVCertsWhitelist() override; 49 ~PackedEVCertsWhitelist() override;
46 50
47 private: 51 private:
48 FRIEND_TEST_ALL_PREFIXES(PackedEVCertsWhitelistTest, 52 FRIEND_TEST_ALL_PREFIXES(PackedEVCertsWhitelistTest,
49 UncompressFailsForTooShortList); 53 UncompressFailsForTooShortList);
50 FRIEND_TEST_ALL_PREFIXES(PackedEVCertsWhitelistTest, 54 FRIEND_TEST_ALL_PREFIXES(PackedEVCertsWhitelistTest,
51 UncompressFailsForTruncatedList); 55 UncompressFailsForTruncatedList);
52 FRIEND_TEST_ALL_PREFIXES(PackedEVCertsWhitelistTest, 56 FRIEND_TEST_ALL_PREFIXES(PackedEVCertsWhitelistTest,
53 UncompressFailsForInvalidValuesInList); 57 UncompressFailsForInvalidValuesInList);
54 FRIEND_TEST_ALL_PREFIXES(PackedEVCertsWhitelistTest, 58 FRIEND_TEST_ALL_PREFIXES(PackedEVCertsWhitelistTest,
55 UncompressesWhitelistCorrectly); 59 UncompressesWhitelistCorrectly);
56 60
57 // Given a Golomb-coded list of hashes in |compressed_whitelist|, unpack into 61 // Given a Golomb-coded list of hashes in |compressed_whitelist|, unpack into
58 // |uncompressed_list|. Returns true if the format of the compressed whitelist 62 // |uncompressed_list|. Returns true if the format of the compressed whitelist
59 // is valid, false otherwise. 63 // is valid, false otherwise.
60 static bool UncompressEVWhitelist(const std::string& compressed_whitelist, 64 static bool UncompressEVWhitelist(const std::string& compressed_whitelist,
61 std::vector<uint64_t>* uncompressed_list); 65 std::vector<uint64_t>* uncompressed_list);
62 66
63 // The whitelist is an array containing certificate hashes (truncated 67 // The whitelist is an array containing certificate hashes (truncated
64 // to a fixed size of 8 bytes), sorted. 68 // to a fixed size of 8 bytes), sorted.
65 // Binary search is used to locate hashes in the the array. 69 // Binary search is used to locate hashes in the the array.
66 // Benchmarking bsearch vs std::set (with 120K entries, doing 1.2M lookups) 70 // Benchmarking bsearch vs std::set (with 120K entries, doing 1.2M lookups)
67 // shows that bsearch is about twice as fast as std::set lookups (and std::set 71 // shows that bsearch is about twice as fast as std::set lookups (and std::set
68 // has additional memory overhead). 72 // has additional memory overhead).
69 std::vector<uint64_t> whitelist_; 73 std::vector<uint64_t> whitelist_;
74 base::Version version_;
70 75
71 DISALLOW_COPY_AND_ASSIGN(PackedEVCertsWhitelist); 76 DISALLOW_COPY_AND_ASSIGN(PackedEVCertsWhitelist);
72 }; 77 };
73 78
74 // Sets the EV certificate hashes whitelist in the SSLConfigService 79 // Sets the EV certificate hashes whitelist in the SSLConfigService
75 // to the provided |whitelist|, if valid. Otherwise, does nothing. 80 // to the provided |whitelist|, if valid. Otherwise, does nothing.
76 // To set the new whitelist, this function dispatches a task to the IO thread. 81 // To set the new whitelist, this function dispatches a task to the IO thread.
77 void SetEVCertsWhitelist(scoped_refptr<net::ct::EVCertsWhitelist> whitelist); 82 void SetEVCertsWhitelist(scoped_refptr<net::ct::EVCertsWhitelist> whitelist);
78 83
79 #endif // CHROME_BROWSER_NET_PACKED_CT_EV_WHITELIST_H_ 84 #endif // CHROME_BROWSER_NET_PACKED_CT_EV_WHITELIST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698