| 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" |
| 11 #include "net/cert/signed_tree_head.h" |
| 11 #include "net/test/ct_test_util.h" | 12 #include "net/test/ct_test_util.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 14 |
| 14 namespace net { | 15 namespace net { |
| 15 | 16 |
| 16 class CTLogVerifierTest : public ::testing::Test { | 17 class CTLogVerifierTest : public ::testing::Test { |
| 17 public: | 18 public: |
| 18 CTLogVerifierTest() {} | 19 CTLogVerifierTest() {} |
| 19 | 20 |
| 20 virtual void SetUp() OVERRIDE { | 21 virtual void SetUp() OVERRIDE { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 scoped_refptr<ct::SignedCertificateTimestamp> cert_sct; | 69 scoped_refptr<ct::SignedCertificateTimestamp> cert_sct; |
| 69 ct::GetX509CertSCT(&cert_sct); | 70 ct::GetX509CertSCT(&cert_sct); |
| 70 | 71 |
| 71 // Mangle the log ID, which should cause it to match a different log before | 72 // Mangle the log ID, which should cause it to match a different log before |
| 72 // attempting signature validation. | 73 // attempting signature validation. |
| 73 cert_sct->log_id.assign(cert_sct->log_id.size(), '\0'); | 74 cert_sct->log_id.assign(cert_sct->log_id.size(), '\0'); |
| 74 | 75 |
| 75 EXPECT_FALSE(log_->Verify(cert_entry, *cert_sct)); | 76 EXPECT_FALSE(log_->Verify(cert_entry, *cert_sct)); |
| 76 } | 77 } |
| 77 | 78 |
| 79 TEST_F(CTLogVerifierTest, SetsValidSTH) { |
| 80 scoped_ptr<ct::SignedTreeHead> sth(new ct::SignedTreeHead()); |
| 81 ct::GetSignedTreeHead(sth.get()); |
| 82 ASSERT_TRUE(log_->SetSignedTreeHead(sth.Pass())); |
| 83 } |
| 84 |
| 85 TEST_F(CTLogVerifierTest, DoesNotSetInvalidSTH) { |
| 86 scoped_ptr<ct::SignedTreeHead> sth(new ct::SignedTreeHead()); |
| 87 ct::GetSignedTreeHead(sth.get()); |
| 88 sth->sha256_root_hash[0] = '\x0'; |
| 89 ASSERT_FALSE(log_->SetSignedTreeHead(sth.Pass())); |
| 90 } |
| 91 |
| 78 } // namespace net | 92 } // namespace net |
| OLD | NEW |