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

Side by Side Diff: net/cert/ct_log_verifier_unittest.cc

Issue 1440643002: Certificate Transparency: Per-profile CT verification (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing iOS compilation Created 5 years, 1 month 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
« no previous file with comments | « net/cert/ct_log_verifier_openssl.cc ('k') | net/cert/ct_objects_extractor_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/cert/ct_log_verifier.h" 5 #include "net/cert/ct_log_verifier.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "net/cert/signed_certificate_timestamp.h" 10 #include "net/cert/signed_certificate_timestamp.h"
11 #include "net/cert/signed_tree_head.h" 11 #include "net/cert/signed_tree_head.h"
12 #include "net/test/ct_test_util.h" 12 #include "net/test/ct_test_util.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 namespace net { 15 namespace net {
16 16
17 class CTLogVerifierTest : public ::testing::Test { 17 class CTLogVerifierTest : public ::testing::Test {
18 public: 18 public:
19 CTLogVerifierTest() {} 19 CTLogVerifierTest() {}
20 20
21 void SetUp() override { 21 void SetUp() override {
22 log_ = CTLogVerifier::Create(ct::GetTestPublicKey(), "testlog", 22 log_ = CTLogVerifier::Create(ct::GetTestPublicKey(), "testlog",
23 "https://ct.example.com").Pass(); 23 "https://ct.example.com").Pass();
24 24
25 ASSERT_TRUE(log_); 25 ASSERT_TRUE(log_);
26 ASSERT_EQ(log_->key_id(), ct::GetTestPublicKeyId()); 26 ASSERT_EQ(log_->key_id(), ct::GetTestPublicKeyId());
27 } 27 }
28 28
29 protected: 29 protected:
30 scoped_refptr<CTLogVerifier> log_; 30 scoped_refptr<const CTLogVerifier> log_;
31 }; 31 };
32 32
33 TEST_F(CTLogVerifierTest, VerifiesCertSCT) { 33 TEST_F(CTLogVerifierTest, VerifiesCertSCT) {
34 ct::LogEntry cert_entry; 34 ct::LogEntry cert_entry;
35 ct::GetX509CertLogEntry(&cert_entry); 35 ct::GetX509CertLogEntry(&cert_entry);
36 36
37 scoped_refptr<ct::SignedCertificateTimestamp> cert_sct; 37 scoped_refptr<ct::SignedCertificateTimestamp> cert_sct;
38 ct::GetX509CertSCT(&cert_sct); 38 ct::GetX509CertSCT(&cert_sct);
39 39
40 EXPECT_TRUE(log_->Verify(cert_entry, *cert_sct.get())); 40 EXPECT_TRUE(log_->Verify(cert_entry, *cert_sct.get()));
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 ct::GetSampleSignedTreeHead(&sth); 88 ct::GetSampleSignedTreeHead(&sth);
89 sth.sha256_root_hash[0] = '\x0'; 89 sth.sha256_root_hash[0] = '\x0';
90 ASSERT_FALSE(log_->VerifySignedTreeHead(sth)); 90 ASSERT_FALSE(log_->VerifySignedTreeHead(sth));
91 } 91 }
92 92
93 // Test that excess data after the public key is rejected. 93 // Test that excess data after the public key is rejected.
94 TEST_F(CTLogVerifierTest, ExcessDataInPublicKey) { 94 TEST_F(CTLogVerifierTest, ExcessDataInPublicKey) {
95 std::string key = ct::GetTestPublicKey(); 95 std::string key = ct::GetTestPublicKey();
96 key += "extra"; 96 key += "extra";
97 97
98 scoped_refptr<CTLogVerifier> log = 98 scoped_refptr<const CTLogVerifier> log =
99 CTLogVerifier::Create(key, "testlog", "https://ct.example.com"); 99 CTLogVerifier::Create(key, "testlog", "https://ct.example.com");
100 EXPECT_FALSE(log); 100 EXPECT_FALSE(log);
101 } 101 }
102 102
103 } // namespace net 103 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/ct_log_verifier_openssl.cc ('k') | net/cert/ct_objects_extractor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698