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

Unified Diff: net/http/transport_security_state.cc

Issue 2726873003: Make transport security state data source configurable. (Closed)
Patch Set: ternary Created 3 years, 9 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/transport_security_state.h ('k') | net/http/transport_security_state_source.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/transport_security_state.cc
diff --git a/net/http/transport_security_state.cc b/net/http/transport_security_state.cc
index 14979c2d7c2ced94028406045939a2ab44cb4191..2e829ad4a9e101fbc669934991b8bfe82a194849 100644
--- a/net/http/transport_security_state.cc
+++ b/net/http/transport_security_state.cc
@@ -47,6 +47,9 @@ const size_t kMaxHPKPReportCacheEntries = 50;
const int kTimeToRememberHPKPReportsMins = 60;
const size_t kReportCacheKeyLength = 16;
+// Points to the active transport security state source.
+const TransportSecurityStateSource* g_hsts_source = &kHSTSSource;
+
// Override for ShouldRequireCT() for unit tests. Possible values:
// -1: Unless a delegate says otherwise, do not require CT.
// 0: Use the default implementation (e.g. production)
@@ -434,9 +437,11 @@ struct PreloadResult {
bool DecodeHSTSPreloadRaw(const std::string& search_hostname,
bool* out_found,
PreloadResult* out) {
- HuffmanDecoder huffman(kHSTSHuffmanTree, sizeof(kHSTSHuffmanTree));
- BitReader reader(kPreloadedHSTSData, kPreloadedHSTSBits);
- size_t bit_offset = kHSTSRootPosition;
+ HuffmanDecoder huffman(g_hsts_source->huffman_tree,
+ g_hsts_source->huffman_tree_size);
+ BitReader reader(g_hsts_source->preloaded_data,
+ g_hsts_source->preloaded_bits);
+ size_t bit_offset = g_hsts_source->root_position;
static const char kEndOfString = 0;
static const char kEndOfTable = 127;
@@ -721,6 +726,11 @@ bool SerializeExpectStapleReport(const HostPortPair& host_port_pair,
} // namespace
+void SetTransportSecurityStateSourceForTesting(
+ const TransportSecurityStateSource* source) {
+ g_hsts_source = source ? source : &kHSTSSource;
+}
+
TransportSecurityState::TransportSecurityState()
: enable_static_pins_(true),
enable_static_expect_ct_(true),
@@ -1104,8 +1114,8 @@ bool TransportSecurityState::GetStaticExpectCTState(
return false;
expect_ct_state->domain = host.substr(result.hostname_offset);
- expect_ct_state->report_uri =
- GURL(kExpectCTReportURIs[result.expect_ct_report_uri_id]);
+ expect_ct_state->report_uri = GURL(
+ g_hsts_source->expect_ct_report_uris[result.expect_ct_report_uri_id]);
return true;
}
@@ -1128,7 +1138,8 @@ bool TransportSecurityState::GetStaticExpectStapleState(
expect_staple_state->include_subdomains =
result.expect_staple_include_subdomains;
expect_staple_state->report_uri =
- GURL(kExpectStapleReportURIs[result.expect_staple_report_uri_id]);
+ GURL(g_hsts_source
+ ->expect_staple_report_uris[result.expect_staple_report_uri_id]);
return true;
}
@@ -1432,9 +1443,10 @@ bool TransportSecurityState::GetStaticDomainState(const std::string& host,
pkp_state->include_subdomains = result.pkp_include_subdomains;
pkp_state->last_observed = base::GetBuildTime();
- if (result.pinset_id >= arraysize(kPinsets))
+ if (result.pinset_id >= g_hsts_source->pinsets_count)
return false;
- const Pinset *pinset = &kPinsets[result.pinset_id];
+ const TransportSecurityStateSource::Pinset* pinset =
+ &g_hsts_source->pinsets[result.pinset_id];
if (pinset->report_uri != kNoReportURI)
pkp_state->report_uri = GURL(pinset->report_uri);
« no previous file with comments | « net/http/transport_security_state.h ('k') | net/http/transport_security_state_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698