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

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

Issue 1100003006: Certificate Transparency: Fetching of Signed Tree Heads (DRAFT) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revised design, addressed some comments Created 5 years, 6 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
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"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 TEST_F(CTLogVerifierTest, VerifiesPrecertSCT) { 43 TEST_F(CTLogVerifierTest, VerifiesPrecertSCT) {
44 ct::LogEntry precert_entry; 44 ct::LogEntry precert_entry;
45 ct::GetPrecertLogEntry(&precert_entry); 45 ct::GetPrecertLogEntry(&precert_entry);
46 46
47 scoped_refptr<ct::SignedCertificateTimestamp> precert_sct; 47 scoped_refptr<ct::SignedCertificateTimestamp> precert_sct;
48 ct::GetPrecertSCT(&precert_sct); 48 ct::GetPrecertSCT(&precert_sct);
49 49
50 EXPECT_TRUE(log_->Verify(precert_entry, *precert_sct.get())); 50 EXPECT_TRUE(log_->Verify(precert_entry, *precert_sct.get()));
51 } 51 }
52 52
53 TEST_F(CTLogVerifierTest, CopyVerifiesCorrectly) {
54 ct::LogEntry cert_entry;
55 ct::GetX509CertLogEntry(&cert_entry);
56
57 scoped_refptr<ct::SignedCertificateTimestamp> cert_sct;
58 ct::GetX509CertSCT(&cert_sct);
59 CTLogVerifier verifier_copy(*log_.get());
60
61 EXPECT_TRUE(verifier_copy.Verify(cert_entry, *cert_sct));
62 }
63
53 TEST_F(CTLogVerifierTest, FailsInvalidTimestamp) { 64 TEST_F(CTLogVerifierTest, FailsInvalidTimestamp) {
54 ct::LogEntry cert_entry; 65 ct::LogEntry cert_entry;
55 ct::GetX509CertLogEntry(&cert_entry); 66 ct::GetX509CertLogEntry(&cert_entry);
56 67
57 scoped_refptr<ct::SignedCertificateTimestamp> cert_sct; 68 scoped_refptr<ct::SignedCertificateTimestamp> cert_sct;
58 ct::GetX509CertSCT(&cert_sct); 69 ct::GetX509CertSCT(&cert_sct);
59 70
60 // Mangle the timestamp, so that it should fail signature validation. 71 // Mangle the timestamp, so that it should fail signature validation.
61 cert_sct->timestamp = base::Time::Now(); 72 cert_sct->timestamp = base::Time::Now();
62 73
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 TEST_F(CTLogVerifierTest, ExcessDataInPublicKey) { 105 TEST_F(CTLogVerifierTest, ExcessDataInPublicKey) {
95 std::string key = ct::GetTestPublicKey(); 106 std::string key = ct::GetTestPublicKey();
96 key += "extra"; 107 key += "extra";
97 108
98 scoped_ptr<CTLogVerifier> log = 109 scoped_ptr<CTLogVerifier> log =
99 CTLogVerifier::Create(key, "testlog", "https://ct.example.com"); 110 CTLogVerifier::Create(key, "testlog", "https://ct.example.com");
100 EXPECT_FALSE(log); 111 EXPECT_FALSE(log);
101 } 112 }
102 113
103 } // namespace net 114 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698