OLD | NEW |
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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 // Mangle the log ID, which should cause it to match a different log before | 73 // Mangle the log ID, which should cause it to match a different log before |
74 // attempting signature validation. | 74 // attempting signature validation. |
75 cert_sct->log_id.assign(cert_sct->log_id.size(), '\0'); | 75 cert_sct->log_id.assign(cert_sct->log_id.size(), '\0'); |
76 | 76 |
77 EXPECT_FALSE(log_->Verify(cert_entry, *cert_sct.get())); | 77 EXPECT_FALSE(log_->Verify(cert_entry, *cert_sct.get())); |
78 } | 78 } |
79 | 79 |
80 TEST_F(CTLogVerifierTest, SetsValidSTH) { | 80 TEST_F(CTLogVerifierTest, SetsValidSTH) { |
81 scoped_ptr<ct::SignedTreeHead> sth(new ct::SignedTreeHead()); | 81 scoped_ptr<ct::SignedTreeHead> sth(new ct::SignedTreeHead()); |
82 ct::GetSignedTreeHead(sth.get()); | 82 ct::GetSignedTreeHead(sth.get()); |
83 ASSERT_TRUE(log_->SetSignedTreeHead(sth.Pass())); | 83 ASSERT_TRUE(log_->VerifySignedTreeHead(sth.get())); |
84 } | 84 } |
85 | 85 |
86 TEST_F(CTLogVerifierTest, DoesNotSetInvalidSTH) { | 86 TEST_F(CTLogVerifierTest, DoesNotSetInvalidSTH) { |
87 scoped_ptr<ct::SignedTreeHead> sth(new ct::SignedTreeHead()); | 87 scoped_ptr<ct::SignedTreeHead> sth(new ct::SignedTreeHead()); |
88 ct::GetSignedTreeHead(sth.get()); | 88 ct::GetSignedTreeHead(sth.get()); |
89 sth->sha256_root_hash[0] = '\x0'; | 89 sth->sha256_root_hash[0] = '\x0'; |
90 ASSERT_FALSE(log_->SetSignedTreeHead(sth.Pass())); | 90 ASSERT_FALSE(log_->VerifySignedTreeHead(sth.get())); |
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_ptr<CTLogVerifier> log = | 98 scoped_ptr<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 |
OLD | NEW |