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

Unified Diff: chrome/browser/net/transport_security_persister_unittest.cc

Issue 10545166: Support SHA-256 in public key pins for HTTPS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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
Index: chrome/browser/net/transport_security_persister_unittest.cc
===================================================================
--- chrome/browser/net/transport_security_persister_unittest.cc (revision 148967)
+++ chrome/browser/net/transport_security_persister_unittest.cc (working copy)
@@ -96,10 +96,12 @@
TEST_F(TransportSecurityPersisterTest, SerializeData3) {
// Add an entry.
- net::SHA1Fingerprint fp1;
- memset(fp1.data, 0, sizeof(fp1.data));
- net::SHA1Fingerprint fp2;
- memset(fp2.data, 1, sizeof(fp2.data));
+ net::HashValue fp1;
+ fp1.tag = net::HASH_VALUE_SHA1;
+ memset(fp1.data(), 0, fp1.size());
+ net::HashValue fp2;
+ fp2.tag = net::HASH_VALUE_SHA1;
+ memset(fp2.data(), 1, fp2.size());
TransportSecurityState::DomainState example_state;
example_state.upgrade_expiry =
base::Time::Now() + base::TimeDelta::FromSeconds(1000);
@@ -111,8 +113,8 @@
state_.EnableHost("www.example.com", example_state);
// Add another entry.
- memset(fp1.data, 2, sizeof(fp1.data));
- memset(fp2.data, 3, sizeof(fp2.data));
+ memset(fp1.data(), 2, fp1.size());
+ memset(fp2.data(), 3, fp2.size());
example_state.upgrade_expiry =
base::Time::Now() + base::TimeDelta::FromSeconds(3000);
example_state.upgrade_mode =
@@ -181,17 +183,18 @@
TransportSecurityState::DomainState domain_state;
static const char kTestDomain[] = "example.com";
EXPECT_FALSE(state_.GetDomainState(kTestDomain, false, &domain_state));
- net::FingerprintVector hashes;
+ net::HashValueVector hashes;
EXPECT_TRUE(domain_state.IsChainOfPublicKeysPermitted(hashes));
- net::SHA1Fingerprint hash;
- memset(hash.data, '1', sizeof(hash.data));
+ net::HashValue hash;
+ hash.tag = net::HASH_VALUE_SHA1;
+ memset(hash.data(), '1', hash.size());
domain_state.static_spki_hashes.push_back(hash);
EXPECT_FALSE(domain_state.IsChainOfPublicKeysPermitted(hashes));
hashes.push_back(hash);
EXPECT_TRUE(domain_state.IsChainOfPublicKeysPermitted(hashes));
- hashes[0].data[0] = '2';
+ hashes[0].data()[0] = '2';
EXPECT_FALSE(domain_state.IsChainOfPublicKeysPermitted(hashes));
const base::Time current_time(base::Time::Now());
@@ -204,8 +207,9 @@
EXPECT_TRUE(persister_->LoadEntries(ser, &dirty));
EXPECT_TRUE(state_.GetDomainState(kTestDomain, false, &domain_state));
EXPECT_EQ(1u, domain_state.static_spki_hashes.size());
- EXPECT_EQ(0, memcmp(domain_state.static_spki_hashes[0].data, hash.data,
- sizeof(hash.data)));
+ EXPECT_EQ(hash.tag, domain_state.static_spki_hashes[0].tag);
+ EXPECT_EQ(0, memcmp(domain_state.static_spki_hashes[0].data(), hash.data(),
+ hash.size()));
}
TEST_F(TransportSecurityPersisterTest, ForcePreloads) {
« no previous file with comments | « chrome/browser/net/transport_security_persister.cc ('k') | chrome/browser/ui/webui/net_internals/net_internals_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698