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

Side by Side Diff: net/base/transport_security_state_unittest.cc

Issue 10827104: Revert 149261 - Support SHA-256 in public key pins for HTTPS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "net/base/transport_security_state.h" 5 #include "net/base/transport_security_state.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
11 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "base/sha1.h" 12 #include "base/sha1.h"
13 #include "base/string_piece.h" 13 #include "base/string_piece.h"
14 #include "crypto/sha2.h"
15 #include "net/base/asn1_util.h" 14 #include "net/base/asn1_util.h"
16 #include "net/base/cert_test_util.h" 15 #include "net/base/cert_test_util.h"
17 #include "net/base/cert_verifier.h" 16 #include "net/base/cert_verifier.h"
18 #include "net/base/cert_verify_result.h" 17 #include "net/base/cert_verify_result.h"
19 #include "net/base/net_errors.h" 18 #include "net/base/net_errors.h"
20 #include "net/base/net_log.h" 19 #include "net/base/net_log.h"
21 #include "net/base/ssl_info.h" 20 #include "net/base/ssl_info.h"
22 #include "net/base/test_completion_callback.h" 21 #include "net/base/test_completion_callback.h"
23 #include "net/base/test_root_certs.h" 22 #include "net/base/test_root_certs.h"
24 #include "net/base/x509_cert_types.h"
25 #include "net/base/x509_certificate.h" 23 #include "net/base/x509_certificate.h"
26 #include "net/http/http_util.h" 24 #include "net/http/http_util.h"
27 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
28 26
29 #if defined(USE_OPENSSL) 27 #if defined(USE_OPENSSL)
30 #include "crypto/openssl_util.h" 28 #include "crypto/openssl_util.h"
31 #else 29 #else
32 #include "crypto/nss_util.h" 30 #include "crypto/nss_util.h"
33 #endif 31 #endif
34 32
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 EXPECT_FALSE(state.ParseSTSHeader(now, "max-age=34889 includesubdomains")); 84 EXPECT_FALSE(state.ParseSTSHeader(now, "max-age=34889 includesubdomains"));
87 85
88 // Check that |state| was not updated by expecting the default 86 // Check that |state| was not updated by expecting the default
89 // values for its predictable fields. 87 // values for its predictable fields.
90 EXPECT_EQ(state.upgrade_mode, 88 EXPECT_EQ(state.upgrade_mode,
91 TransportSecurityState::DomainState::MODE_FORCE_HTTPS); 89 TransportSecurityState::DomainState::MODE_FORCE_HTTPS);
92 EXPECT_FALSE(state.include_subdomains); 90 EXPECT_FALSE(state.include_subdomains);
93 } 91 }
94 92
95 static bool GetPublicKeyHash(const net::X509Certificate::OSCertHandle& cert, 93 static bool GetPublicKeyHash(const net::X509Certificate::OSCertHandle& cert,
96 HashValue* fingerprint, 94 SHA1Fingerprint* fingerprint) {
97 HashValueTag tag) {
98 std::string der_bytes; 95 std::string der_bytes;
99 if (!net::X509Certificate::GetDEREncoded(cert, &der_bytes)) 96 if (!net::X509Certificate::GetDEREncoded(cert, &der_bytes))
100 return false; 97 return false;
101 98
102 base::StringPiece spki; 99 base::StringPiece spki;
103 if (!asn1::ExtractSPKIFromDERCert(der_bytes, &spki)) 100 if (!asn1::ExtractSPKIFromDERCert(der_bytes, &spki))
104 return false; 101 return false;
105 102
106 fingerprint->tag = tag; 103 base::SHA1HashBytes(reinterpret_cast<const unsigned char*>(spki.data()),
107 switch (tag) { 104 spki.size(), fingerprint->data);
108 case HASH_VALUE_SHA1:
109 base::SHA1HashBytes(reinterpret_cast<const unsigned char*>(spki.data()),
110 spki.size(), fingerprint->data());
111 break;
112 case HASH_VALUE_SHA256:
113 crypto::SHA256HashString(spki, fingerprint->data(),
114 crypto::kSHA256Length);
115 break;
116 default:
117 NOTREACHED() << "Unknown HashValueTag " << tag;
118 }
119
120 return true; 105 return true;
121 } 106 }
122 107
123 static std::string GetPinFromCert(X509Certificate* cert, HashValueTag tag) { 108 static std::string GetPinFromCert(X509Certificate* cert) {
124 HashValue spki_hash; 109 SHA1Fingerprint spki_hash;
125 EXPECT_TRUE(GetPublicKeyHash(cert->os_cert_handle(), &spki_hash, tag)); 110 EXPECT_TRUE(GetPublicKeyHash(cert->os_cert_handle(), &spki_hash));
126 111
127 std::string base64; 112 std::string base64;
128 base::Base64Encode(base::StringPiece( 113 base::Base64Encode(base::StringPiece(reinterpret_cast<char*>(spki_hash.data),
129 reinterpret_cast<char*>(spki_hash.data()), spki_hash.size()), &base64); 114 sizeof(spki_hash.data)),
130 115 &base64);
131 std::string label; 116 return "pin-sha1=" + HttpUtil::Quote(base64);
132 switch (tag) {
133 case HASH_VALUE_SHA1:
134 label = "pin-sha1=";
135 break;
136 case HASH_VALUE_SHA256:
137 label = "pin-sha256=";
138 break;
139 default:
140 NOTREACHED() << "Unknown HashValueTag " << tag;
141 }
142
143 return label + HttpUtil::Quote(base64);
144 } 117 }
145 118
146 static void TestBogusPinsHeaders(HashValueTag tag) { 119 TEST_F(TransportSecurityStateTest, BogusPinsHeaders) {
147 TransportSecurityState::DomainState state; 120 TransportSecurityState::DomainState state;
148 SSLInfo ssl_info; 121 SSLInfo ssl_info;
149 ssl_info.cert = 122 ssl_info.cert =
150 ImportCertFromFile(GetTestCertsDirectory(), "test_mail_google_com.pem"); 123 ImportCertFromFile(GetTestCertsDirectory(), "test_mail_google_com.pem");
151 std::string good_pin = GetPinFromCert(ssl_info.cert, tag); 124 std::string good_pin = GetPinFromCert(ssl_info.cert);
152 base::Time now = base::Time::Now(); 125 base::Time now = base::Time::Now();
153 126
154 // The backup pin is fake --- it just has to not be in the chain. 127 // The backup pin is fake --- it just has to not be in the chain.
155 std::string backup_pin = "pin-sha1=" + 128 std::string backup_pin = "pin-sha1=" +
156 HttpUtil::Quote("6dcfXufJLW3J6S/9rRe4vUlBj5g="); 129 HttpUtil::Quote("6dcfXufJLW3J6S/9rRe4vUlBj5g=");
157 130
158 EXPECT_FALSE(state.ParsePinsHeader(now, "", ssl_info)); 131 EXPECT_FALSE(state.ParsePinsHeader(now, "", ssl_info));
159 EXPECT_FALSE(state.ParsePinsHeader(now, " ", ssl_info)); 132 EXPECT_FALSE(state.ParsePinsHeader(now, " ", ssl_info));
160 EXPECT_FALSE(state.ParsePinsHeader(now, "abc", ssl_info)); 133 EXPECT_FALSE(state.ParsePinsHeader(now, "abc", ssl_info));
161 EXPECT_FALSE(state.ParsePinsHeader(now, " abc", ssl_info)); 134 EXPECT_FALSE(state.ParsePinsHeader(now, " abc", ssl_info));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 ssl_info)); 173 ssl_info));
201 EXPECT_FALSE(state.ParsePinsHeader(now, "max-age=34889.23", ssl_info)); 174 EXPECT_FALSE(state.ParsePinsHeader(now, "max-age=34889.23", ssl_info));
202 175
203 // Check that |state| was not updated by expecting the default 176 // Check that |state| was not updated by expecting the default
204 // values for its predictable fields. 177 // values for its predictable fields.
205 EXPECT_EQ(state.upgrade_mode, 178 EXPECT_EQ(state.upgrade_mode,
206 TransportSecurityState::DomainState::MODE_FORCE_HTTPS); 179 TransportSecurityState::DomainState::MODE_FORCE_HTTPS);
207 EXPECT_FALSE(state.include_subdomains); 180 EXPECT_FALSE(state.include_subdomains);
208 } 181 }
209 182
210 TEST_F(TransportSecurityStateTest, BogusPinsHeadersSHA1) {
211 TestBogusPinsHeaders(HASH_VALUE_SHA1);
212 }
213
214 TEST_F(TransportSecurityStateTest, BogusPinsHeadersSHA256) {
215 TestBogusPinsHeaders(HASH_VALUE_SHA256);
216 }
217
218 TEST_F(TransportSecurityStateTest, ValidSTSHeaders) { 183 TEST_F(TransportSecurityStateTest, ValidSTSHeaders) {
219 TransportSecurityState::DomainState state; 184 TransportSecurityState::DomainState state;
220 base::Time expiry; 185 base::Time expiry;
221 base::Time now = base::Time::Now(); 186 base::Time now = base::Time::Now();
222 187
223 EXPECT_TRUE(state.ParseSTSHeader(now, "max-age=243")); 188 EXPECT_TRUE(state.ParseSTSHeader(now, "max-age=243"));
224 expiry = now + base::TimeDelta::FromSeconds(243); 189 expiry = now + base::TimeDelta::FromSeconds(243);
225 EXPECT_EQ(expiry, state.upgrade_expiry); 190 EXPECT_EQ(expiry, state.upgrade_expiry);
226 EXPECT_FALSE(state.include_subdomains); 191 EXPECT_FALSE(state.include_subdomains);
227 192
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 EXPECT_TRUE(state.ParseSTSHeader( 233 EXPECT_TRUE(state.ParseSTSHeader(
269 now, 234 now,
270 " max-age=999999999999999999999999999999999999999999999 ;" 235 " max-age=999999999999999999999999999999999999999999999 ;"
271 " incLudesUbdOmains ")); 236 " incLudesUbdOmains "));
272 expiry = now + base::TimeDelta::FromSeconds( 237 expiry = now + base::TimeDelta::FromSeconds(
273 TransportSecurityState::kMaxHSTSAgeSecs); 238 TransportSecurityState::kMaxHSTSAgeSecs);
274 EXPECT_EQ(expiry, state.upgrade_expiry); 239 EXPECT_EQ(expiry, state.upgrade_expiry);
275 EXPECT_TRUE(state.include_subdomains); 240 EXPECT_TRUE(state.include_subdomains);
276 } 241 }
277 242
278 static void TestValidPinsHeaders(HashValueTag tag) { 243 TEST_F(TransportSecurityStateTest, ValidPinsHeaders) {
279 TransportSecurityState::DomainState state; 244 TransportSecurityState::DomainState state;
280 base::Time expiry; 245 base::Time expiry;
281 base::Time now = base::Time::Now(); 246 base::Time now = base::Time::Now();
282 247
283 // Set up a realistic SSLInfo with a realistic cert chain. 248 // Set up a realistic SSLInfo with a realistic cert chain.
284 FilePath certs_dir = GetTestCertsDirectory(); 249 FilePath certs_dir = GetTestCertsDirectory();
285 scoped_refptr<X509Certificate> ee_cert = 250 scoped_refptr<X509Certificate> ee_cert =
286 ImportCertFromFile(certs_dir, "2048-rsa-ee-by-2048-rsa-intermediate.pem"); 251 ImportCertFromFile(certs_dir, "2048-rsa-ee-by-2048-rsa-intermediate.pem");
287 ASSERT_NE(static_cast<X509Certificate*>(NULL), ee_cert); 252 ASSERT_NE(static_cast<X509Certificate*>(NULL), ee_cert);
288 scoped_refptr<X509Certificate> intermediate = 253 scoped_refptr<X509Certificate> intermediate =
(...skipping 19 matching lines...) Expand all
308 scoped_ptr<CertVerifier> verifier(CertVerifier::CreateDefault()); 273 scoped_ptr<CertVerifier> verifier(CertVerifier::CreateDefault());
309 TestCompletionCallback callback; 274 TestCompletionCallback callback;
310 CertVerifier::RequestHandle handle = NULL; 275 CertVerifier::RequestHandle handle = NULL;
311 rv = verifier->Verify(ssl_info.cert, "127.0.0.1", 0, NULL, &result, 276 rv = verifier->Verify(ssl_info.cert, "127.0.0.1", 0, NULL, &result,
312 callback.callback(), &handle, BoundNetLog()); 277 callback.callback(), &handle, BoundNetLog());
313 rv = callback.GetResult(rv); 278 rv = callback.GetResult(rv);
314 ASSERT_EQ(OK, rv); 279 ASSERT_EQ(OK, rv);
315 // Normally, ssl_client_socket_nss would do this, but for a unit test we 280 // Normally, ssl_client_socket_nss would do this, but for a unit test we
316 // fake it. 281 // fake it.
317 ssl_info.public_key_hashes = result.public_key_hashes; 282 ssl_info.public_key_hashes = result.public_key_hashes;
318 std::string good_pin = GetPinFromCert(ssl_info.cert, /*tag*/HASH_VALUE_SHA1); 283 std::string good_pin = GetPinFromCert(ssl_info.cert);
319 DLOG(WARNING) << "good pin: " << good_pin;
320 284
321 // The backup pin is fake --- we just need an SPKI hash that does not match 285 // The backup pin is fake --- we just need an SPKI hash that does not match
322 // the hash of any SPKI in the certificate chain. 286 // the hash of any SPKI in the certificate chain.
323 std::string backup_pin = "pin-sha1=" + 287 std::string backup_pin = "pin-sha1=" +
324 HttpUtil::Quote("6dcfXufJLW3J6S/9rRe4vUlBj5g="); 288 HttpUtil::Quote("6dcfXufJLW3J6S/9rRe4vUlBj5g=");
325 289
326 EXPECT_TRUE(state.ParsePinsHeader( 290 EXPECT_TRUE(state.ParsePinsHeader(
327 now, 291 now,
328 "max-age=243; " + good_pin + ";" + backup_pin, 292 "max-age=243; " + good_pin + ";" + backup_pin,
329 ssl_info)); 293 ssl_info));
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 EXPECT_TRUE(state.ParsePinsHeader( 349 EXPECT_TRUE(state.ParsePinsHeader(
386 now, 350 now,
387 " max-age=999999999999999999999999999999999999999999999 ; " + 351 " max-age=999999999999999999999999999999999999999999999 ; " +
388 backup_pin + ";" + good_pin + "; ", 352 backup_pin + ";" + good_pin + "; ",
389 ssl_info)); 353 ssl_info));
390 expiry = now + 354 expiry = now +
391 base::TimeDelta::FromSeconds(TransportSecurityState::kMaxHSTSAgeSecs); 355 base::TimeDelta::FromSeconds(TransportSecurityState::kMaxHSTSAgeSecs);
392 EXPECT_EQ(expiry, state.dynamic_spki_hashes_expiry); 356 EXPECT_EQ(expiry, state.dynamic_spki_hashes_expiry);
393 } 357 }
394 358
395 TEST_F(TransportSecurityStateTest, ValidPinsHeadersSHA1) {
396 TestValidPinsHeaders(HASH_VALUE_SHA1);
397 }
398
399 TEST_F(TransportSecurityStateTest, ValidPinsHeadersSHA256) {
400 TestValidPinsHeaders(HASH_VALUE_SHA256);
401 }
402
403 TEST_F(TransportSecurityStateTest, SimpleMatches) { 359 TEST_F(TransportSecurityStateTest, SimpleMatches) {
404 TransportSecurityState state; 360 TransportSecurityState state;
405 TransportSecurityState::DomainState domain_state; 361 TransportSecurityState::DomainState domain_state;
406 const base::Time current_time(base::Time::Now()); 362 const base::Time current_time(base::Time::Now());
407 const base::Time expiry = current_time + base::TimeDelta::FromSeconds(1000); 363 const base::Time expiry = current_time + base::TimeDelta::FromSeconds(1000);
408 364
409 EXPECT_FALSE(state.GetDomainState("yahoo.com", true, &domain_state)); 365 EXPECT_FALSE(state.GetDomainState("yahoo.com", true, &domain_state));
410 domain_state.upgrade_expiry = expiry; 366 domain_state.upgrade_expiry = expiry;
411 state.EnableHost("yahoo.com", domain_state); 367 state.EnableHost("yahoo.com", domain_state);
412 EXPECT_TRUE(state.GetDomainState("yahoo.com", true, &domain_state)); 368 EXPECT_TRUE(state.GetDomainState("yahoo.com", true, &domain_state));
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 EXPECT_FALSE(state.GetDomainState(kLongName, true, &domain_state)); 776 EXPECT_FALSE(state.GetDomainState(kLongName, true, &domain_state));
821 } 777 }
822 778
823 TEST_F(TransportSecurityStateTest, BuiltinCertPins) { 779 TEST_F(TransportSecurityStateTest, BuiltinCertPins) {
824 TransportSecurityState state; 780 TransportSecurityState state;
825 TransportSecurityState::DomainState domain_state; 781 TransportSecurityState::DomainState domain_state;
826 782
827 EXPECT_TRUE(state.GetDomainState("chrome.google.com", true, &domain_state)); 783 EXPECT_TRUE(state.GetDomainState("chrome.google.com", true, &domain_state));
828 EXPECT_TRUE(HasPins("chrome.google.com")); 784 EXPECT_TRUE(HasPins("chrome.google.com"));
829 785
830 HashValueVector hashes; 786 FingerprintVector hashes;
831 // Checks that a built-in list does exist. 787 // Checks that a built-in list does exist.
832 EXPECT_FALSE(domain_state.IsChainOfPublicKeysPermitted(hashes)); 788 EXPECT_FALSE(domain_state.IsChainOfPublicKeysPermitted(hashes));
833 EXPECT_FALSE(HasPins("www.paypal.com")); 789 EXPECT_FALSE(HasPins("www.paypal.com"));
834 790
835 EXPECT_TRUE(HasPins("docs.google.com")); 791 EXPECT_TRUE(HasPins("docs.google.com"));
836 EXPECT_TRUE(HasPins("1.docs.google.com")); 792 EXPECT_TRUE(HasPins("1.docs.google.com"));
837 EXPECT_TRUE(HasPins("sites.google.com")); 793 EXPECT_TRUE(HasPins("sites.google.com"));
838 EXPECT_TRUE(HasPins("drive.google.com")); 794 EXPECT_TRUE(HasPins("drive.google.com"));
839 EXPECT_TRUE(HasPins("spreadsheets.google.com")); 795 EXPECT_TRUE(HasPins("spreadsheets.google.com"));
840 EXPECT_TRUE(HasPins("health.google.com")); 796 EXPECT_TRUE(HasPins("health.google.com"));
(...skipping 25 matching lines...) Expand all
866 EXPECT_TRUE(HasPins("oauth.twitter.com")); 822 EXPECT_TRUE(HasPins("oauth.twitter.com"));
867 EXPECT_TRUE(HasPins("mobile.twitter.com")); 823 EXPECT_TRUE(HasPins("mobile.twitter.com"));
868 EXPECT_TRUE(HasPins("dev.twitter.com")); 824 EXPECT_TRUE(HasPins("dev.twitter.com"));
869 EXPECT_TRUE(HasPins("business.twitter.com")); 825 EXPECT_TRUE(HasPins("business.twitter.com"));
870 EXPECT_TRUE(HasPins("platform.twitter.com")); 826 EXPECT_TRUE(HasPins("platform.twitter.com"));
871 EXPECT_TRUE(HasPins("si0.twimg.com")); 827 EXPECT_TRUE(HasPins("si0.twimg.com"));
872 EXPECT_TRUE(HasPins("twimg0-a.akamaihd.net")); 828 EXPECT_TRUE(HasPins("twimg0-a.akamaihd.net"));
873 } 829 }
874 830
875 static bool AddHash(const std::string& type_and_base64, 831 static bool AddHash(const std::string& type_and_base64,
876 HashValueVector* out) { 832 FingerprintVector* out) {
877 HashValue hash; 833 std::string hash_str;
878 834 if (type_and_base64.find("sha1/") == 0 &&
879 if (!TransportSecurityState::ParsePin(type_and_base64, &hash)) 835 base::Base64Decode(type_and_base64.substr(5, type_and_base64.size() - 5),
880 return false; 836 &hash_str) &&
881 837 hash_str.size() == base::kSHA1Length) {
882 out->push_back(hash); 838 SHA1Fingerprint hash;
883 return true; 839 memcpy(hash.data, hash_str.data(), sizeof(hash.data));
840 out->push_back(hash);
841 return true;
842 }
843 return false;
884 } 844 }
885 845
886
887 TEST_F(TransportSecurityStateTest, PinValidationWithRejectedCerts) { 846 TEST_F(TransportSecurityStateTest, PinValidationWithRejectedCerts) {
888 // kGoodPath is plus.google.com via Google Internet Authority. 847 // kGoodPath is plus.google.com via Google Internet Authority.
889 static const char* kGoodPath[] = { 848 static const char* kGoodPath[] = {
890 "sha1/4BjDjn8v2lWeUFQnqSs0BgbIcrU=", 849 "sha1/4BjDjn8v2lWeUFQnqSs0BgbIcrU=",
891 "sha1/QMVAHW+MuvCLAO3vse6H0AWzuc0=", 850 "sha1/QMVAHW+MuvCLAO3vse6H0AWzuc0=",
892 "sha1/SOZo+SvSspXXR9gjIBBPM5iQn9Q=", 851 "sha1/SOZo+SvSspXXR9gjIBBPM5iQn9Q=",
893 NULL, 852 NULL,
894 }; 853 };
895 854
896 // kBadPath is plus.google.com via Trustcenter, which contains a required 855 // kBadPath is plus.google.com via Trustcenter, which contains a required
897 // certificate (Equifax root), but also an excluded certificate 856 // certificate (Equifax root), but also an excluded certificate
898 // (Trustcenter). 857 // (Trustcenter).
899 static const char* kBadPath[] = { 858 static const char* kBadPath[] = {
900 "sha1/4BjDjn8v2lWeUFQnqSs0BgbIcrU=", 859 "sha1/4BjDjn8v2lWeUFQnqSs0BgbIcrU=",
901 "sha1/gzuEEAB/bkqdQS3EIjk2by7lW+k=", 860 "sha1/gzuEEAB/bkqdQS3EIjk2by7lW+k=",
902 "sha1/SOZo+SvSspXXR9gjIBBPM5iQn9Q=", 861 "sha1/SOZo+SvSspXXR9gjIBBPM5iQn9Q=",
903 NULL, 862 NULL,
904 }; 863 };
905 864
906 HashValueVector good_hashes, bad_hashes; 865 std::vector<net::SHA1Fingerprint> good_hashes, bad_hashes;
907 866
908 for (size_t i = 0; kGoodPath[i]; i++) { 867 for (size_t i = 0; kGoodPath[i]; i++) {
909 EXPECT_TRUE(AddHash(kGoodPath[i], &good_hashes)); 868 EXPECT_TRUE(AddHash(kGoodPath[i], &good_hashes));
910 } 869 }
911 for (size_t i = 0; kBadPath[i]; i++) { 870 for (size_t i = 0; kBadPath[i]; i++) {
912 EXPECT_TRUE(AddHash(kBadPath[i], &bad_hashes)); 871 EXPECT_TRUE(AddHash(kBadPath[i], &bad_hashes));
913 } 872 }
914 873
915 TransportSecurityState state; 874 TransportSecurityState state;
916 TransportSecurityState::DomainState domain_state; 875 TransportSecurityState::DomainState domain_state;
(...skipping 15 matching lines...) Expand all
932 891
933 // kBadPath is plus.google.com via Trustcenter, which is utterly wrong for 892 // kBadPath is plus.google.com via Trustcenter, which is utterly wrong for
934 // torproject.org. 893 // torproject.org.
935 static const char* kBadPath[] = { 894 static const char* kBadPath[] = {
936 "sha1/4BjDjn8v2lWeUFQnqSs0BgbIcrU=", 895 "sha1/4BjDjn8v2lWeUFQnqSs0BgbIcrU=",
937 "sha1/gzuEEAB/bkqdQS3EIjk2by7lW+k=", 896 "sha1/gzuEEAB/bkqdQS3EIjk2by7lW+k=",
938 "sha1/SOZo+SvSspXXR9gjIBBPM5iQn9Q=", 897 "sha1/SOZo+SvSspXXR9gjIBBPM5iQn9Q=",
939 NULL, 898 NULL,
940 }; 899 };
941 900
942 HashValueVector good_hashes, bad_hashes; 901 std::vector<net::SHA1Fingerprint> good_hashes, bad_hashes;
943 902
944 for (size_t i = 0; kGoodPath[i]; i++) { 903 for (size_t i = 0; kGoodPath[i]; i++) {
945 EXPECT_TRUE(AddHash(kGoodPath[i], &good_hashes)); 904 EXPECT_TRUE(AddHash(kGoodPath[i], &good_hashes));
946 } 905 }
947 for (size_t i = 0; kBadPath[i]; i++) { 906 for (size_t i = 0; kBadPath[i]; i++) {
948 EXPECT_TRUE(AddHash(kBadPath[i], &bad_hashes)); 907 EXPECT_TRUE(AddHash(kBadPath[i], &bad_hashes));
949 } 908 }
950 909
951 TransportSecurityState state; 910 TransportSecurityState state;
952 TransportSecurityState::DomainState domain_state; 911 TransportSecurityState::DomainState domain_state;
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 // Expect to fail for SNI hosts when not searching the SNI list: 1048 // Expect to fail for SNI hosts when not searching the SNI list:
1090 EXPECT_FALSE(TransportSecurityState::IsGooglePinnedProperty( 1049 EXPECT_FALSE(TransportSecurityState::IsGooglePinnedProperty(
1091 "gmail.com", false)); 1050 "gmail.com", false));
1092 EXPECT_FALSE(TransportSecurityState::IsGooglePinnedProperty( 1051 EXPECT_FALSE(TransportSecurityState::IsGooglePinnedProperty(
1093 "googlegroups.com", false)); 1052 "googlegroups.com", false));
1094 EXPECT_FALSE(TransportSecurityState::IsGooglePinnedProperty( 1053 EXPECT_FALSE(TransportSecurityState::IsGooglePinnedProperty(
1095 "www.googlegroups.com", false)); 1054 "www.googlegroups.com", false));
1096 } 1055 }
1097 1056
1098 } // namespace net 1057 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698