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

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

Issue 230713002: Certificate Transparency: Parse Signed Tree Heads and validate them (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing more of Ryan's comments Created 6 years, 7 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
« no previous file with comments | « net/cert/ct_log_verifier_openssl.cc ('k') | net/cert/ct_serialization.h » ('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/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
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
OLDNEW
« no previous file with comments | « net/cert/ct_log_verifier_openssl.cc ('k') | net/cert/ct_serialization.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698