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

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

Issue 92443002: Extract Certificate Transparency SCTs from stapled OCSP responses (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@extract_scts
Patch Set: clean up subs Created 7 years 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_objects_extractor.h" 5 #include "net/cert/ct_objects_extractor.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "net/base/test_data_directory.h" 8 #include "net/base/test_data_directory.h"
9 #include "net/cert/ct_log_verifier.h" 9 #include "net/cert/ct_log_verifier.h"
10 #include "net/cert/ct_serialization.h" 10 #include "net/cert/ct_serialization.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 scoped_refptr<ct::SignedCertificateTimestamp> sct( 116 scoped_refptr<ct::SignedCertificateTimestamp> sct(
117 new ct::SignedCertificateTimestamp()); 117 new ct::SignedCertificateTimestamp());
118 GetX509CertSCT(&sct); 118 GetX509CertSCT(&sct);
119 119
120 LogEntry entry; 120 LogEntry entry;
121 ASSERT_TRUE(GetX509LogEntry(test_cert_->os_cert_handle(), &entry)); 121 ASSERT_TRUE(GetX509LogEntry(test_cert_->os_cert_handle(), &entry));
122 122
123 EXPECT_TRUE(log_->Verify(entry, *sct)); 123 EXPECT_TRUE(log_->Verify(entry, *sct));
124 } 124 }
125 125
126 // Test that the extractor can parse OCSP responses.
127 TEST_F(CTObjectsExtractorTest, ExtractSCTListFromOCSPResponse) {
128 std::string der_test_cert(ct::GetDerEncodedFakeOCSPResponseCert());
129 scoped_refptr<X509Certificate> test_cert =
130 X509Certificate::CreateFromBytes(der_test_cert.data(),
131 der_test_cert.length());
132 std::string der_issuer_cert(ct::GetDerEncodedFakeOCSPResponseIssuerCert());
133 scoped_refptr<X509Certificate> issuer_cert =
134 X509Certificate::CreateFromBytes(der_issuer_cert.data(),
135 der_issuer_cert.length());
136
137 std::string fake_sct_list = ct::GetFakeOCSPExtensionValue();
138 ASSERT_FALSE(fake_sct_list.empty());
139 std::string ocsp_response = ct::GetDerEncodedFakeOCSPResponse();
140
141 std::string extracted_sct_list;
142 EXPECT_TRUE(ct::ExtractSCTListFromOCSPResponse(
143 test_cert->serial_number(),
144 issuer_cert->os_cert_handle(),
145 ocsp_response, &extracted_sct_list));
146 EXPECT_EQ(extracted_sct_list, fake_sct_list);
147 }
148
149 // Test that the extractor honours serial number.
150 TEST_F(CTObjectsExtractorTest, ExtractSCTListFromOCSPResponseMatchesSerial) {
151 std::string der_test_cert(ct::GetDerEncodedFakeOCSPResponseCert());
152 scoped_refptr<X509Certificate> test_cert =
153 X509Certificate::CreateFromBytes(der_test_cert.data(),
154 der_test_cert.length());
155 std::string der_issuer_cert(ct::GetDerEncodedFakeOCSPResponseIssuerCert());
156 scoped_refptr<X509Certificate> issuer_cert =
157 X509Certificate::CreateFromBytes(der_issuer_cert.data(),
158 der_issuer_cert.length());
159
160 std::string ocsp_response = ct::GetDerEncodedFakeOCSPResponse();
161
162 std::string extracted_sct_list;
163 EXPECT_FALSE(ct::ExtractSCTListFromOCSPResponse(
164 test_cert_->serial_number(), issuer_cert->os_cert_handle(),
165 ocsp_response, &extracted_sct_list));
166 }
167
168 // Test that the extractor honours issuer ID.
169 TEST_F(CTObjectsExtractorTest, ExtractSCTListFromOCSPResponseMatchesIssuer) {
170 std::string der_test_cert(ct::GetDerEncodedFakeOCSPResponseCert());
171 scoped_refptr<X509Certificate> test_cert =
172 X509Certificate::CreateFromBytes(der_test_cert.data(),
173 der_test_cert.length());
174
175 std::string ocsp_response = ct::GetDerEncodedFakeOCSPResponse();
176
177 std::string extracted_sct_list;
178 EXPECT_FALSE(ct::ExtractSCTListFromOCSPResponse(
179 test_cert->serial_number(), test_cert_->os_cert_handle(),
180 ocsp_response, &extracted_sct_list));
181 }
182
126 } // namespace ct 183 } // namespace ct
127 184
128 } // namespace net 185 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698