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

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

Issue 2824983002: Rename net::ct::LogEntry to SignedEntryData and clarify the comment. (Closed)
Patch Set: sort forward decls Created 3 years, 8 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_objects_extractor.h ('k') | net/cert/ct_objects_extractor_unittest.cc » ('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_objects_extractor.h" 5 #include "net/cert/ct_objects_extractor.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/sha1.h" 10 #include "base/sha1.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 if (!x509) 166 if (!x509)
167 return false; 167 return false;
168 X509_EXTENSIONS* x509_exts = x509->cert_info->extensions; 168 X509_EXTENSIONS* x509_exts = x509->cert_info->extensions;
169 if (!x509_exts) 169 if (!x509_exts)
170 return false; 170 return false;
171 return GetSCTListFromX509_EXTENSIONS(x509->cert_info->extensions, 171 return GetSCTListFromX509_EXTENSIONS(x509->cert_info->extensions,
172 kEmbeddedSCTOid, sizeof(kEmbeddedSCTOid), 172 kEmbeddedSCTOid, sizeof(kEmbeddedSCTOid),
173 sct_list); 173 sct_list);
174 } 174 }
175 175
176 bool GetPrecertLogEntry(X509Certificate::OSCertHandle leaf, 176 bool GetPrecertSignedEntry(X509Certificate::OSCertHandle leaf,
177 X509Certificate::OSCertHandle issuer, 177 X509Certificate::OSCertHandle issuer,
178 LogEntry* result) { 178 SignedEntryData* result) {
179 result->Reset(); 179 result->Reset();
180 180
181 bssl::UniquePtr<X509> leaf_x509(OSCertHandleToOpenSSL(leaf)); 181 bssl::UniquePtr<X509> leaf_x509(OSCertHandleToOpenSSL(leaf));
182 if (!leaf_x509) 182 if (!leaf_x509)
183 return false; 183 return false;
184 184
185 // XXX(rsleevi): This check may be overkill, since we should be able to 185 // XXX(rsleevi): This check may be overkill, since we should be able to
186 // generate precerts for certs without the extension. For now, just a sanity 186 // generate precerts for certs without the extension. For now, just a sanity
187 // check to match the reference implementation. 187 // check to match the reference implementation.
188 if (!leaf_x509->cert_info->extensions || 188 if (!leaf_x509->cert_info->extensions ||
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 return false; 221 return false;
222 222
223 // Extract the issuer's public key. 223 // Extract the issuer's public key.
224 std::string issuer_der; 224 std::string issuer_der;
225 if (!X509Certificate::GetDEREncoded(issuer, &issuer_der)) 225 if (!X509Certificate::GetDEREncoded(issuer, &issuer_der))
226 return false; 226 return false;
227 base::StringPiece issuer_key; 227 base::StringPiece issuer_key;
228 if (!asn1::ExtractSPKIFromDERCert(issuer_der, &issuer_key)) 228 if (!asn1::ExtractSPKIFromDERCert(issuer_der, &issuer_key))
229 return false; 229 return false;
230 230
231 // Fill in the LogEntry. 231 // Fill in the SignedEntryData.
232 result->type = ct::LogEntry::LOG_ENTRY_TYPE_PRECERT; 232 result->type = ct::SignedEntryData::LOG_ENTRY_TYPE_PRECERT;
233 result->tbs_certificate.swap(to_be_signed); 233 result->tbs_certificate.swap(to_be_signed);
234 crypto::SHA256HashString(issuer_key, result->issuer_key_hash.data, 234 crypto::SHA256HashString(issuer_key, result->issuer_key_hash.data,
235 sizeof(result->issuer_key_hash.data)); 235 sizeof(result->issuer_key_hash.data));
236 236
237 return true; 237 return true;
238 } 238 }
239 239
240 bool GetX509LogEntry(X509Certificate::OSCertHandle leaf, LogEntry* result) { 240 bool GetX509SignedEntry(X509Certificate::OSCertHandle leaf,
241 SignedEntryData* result) {
241 DCHECK(leaf); 242 DCHECK(leaf);
242 243
243 std::string encoded; 244 std::string encoded;
244 if (!X509Certificate::GetDEREncoded(leaf, &encoded)) 245 if (!X509Certificate::GetDEREncoded(leaf, &encoded))
245 return false; 246 return false;
246 247
247 result->Reset(); 248 result->Reset();
248 result->type = ct::LogEntry::LOG_ENTRY_TYPE_X509; 249 result->type = ct::SignedEntryData::LOG_ENTRY_TYPE_X509;
249 result->leaf_certificate.swap(encoded); 250 result->leaf_certificate.swap(encoded);
250 return true; 251 return true;
251 } 252 }
252 253
253 bool ExtractSCTListFromOCSPResponse(X509Certificate::OSCertHandle issuer, 254 bool ExtractSCTListFromOCSPResponse(X509Certificate::OSCertHandle issuer,
254 const std::string& cert_serial_number, 255 const std::string& cert_serial_number,
255 base::StringPiece ocsp_response, 256 base::StringPiece ocsp_response,
256 std::string* sct_list) { 257 std::string* sct_list) {
257 // The input is an OCSPResponse. See RFC2560, section 4.2.1. The SCT list is 258 // The input is an OCSPResponse. See RFC2560, section 4.2.1. The SCT list is
258 // in the extensions field of the SingleResponse which matches the input 259 // in the extensions field of the SingleResponse which matches the input
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 if (!x509_exts || ptr != CBS_data(&extensions) + CBS_len(&extensions)) 343 if (!x509_exts || ptr != CBS_data(&extensions) + CBS_len(&extensions))
343 return false; 344 return false;
344 345
345 return GetSCTListFromX509_EXTENSIONS(x509_exts.get(), kOCSPExtensionOid, 346 return GetSCTListFromX509_EXTENSIONS(x509_exts.get(), kOCSPExtensionOid,
346 sizeof(kOCSPExtensionOid), sct_list); 347 sizeof(kOCSPExtensionOid), sct_list);
347 } 348 }
348 349
349 } // namespace ct 350 } // namespace ct
350 351
351 } // namespace net 352 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/ct_objects_extractor.h ('k') | net/cert/ct_objects_extractor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698