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_objects_extractor_nss.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: rebase and wire extracted SCTs to the CT verifier 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 <cert.h> 7 #include <cert.h>
8 #include <secasn1.h> 8 #include <secasn1.h>
9 #include <secitem.h> 9 #include <secitem.h>
10 #include <secoid.h> 10 #include <secoid.h>
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 std::string encoded; 262 std::string encoded;
263 if (!X509Certificate::GetDEREncoded(leaf, &encoded)) 263 if (!X509Certificate::GetDEREncoded(leaf, &encoded))
264 return false; 264 return false;
265 265
266 result->Reset(); 266 result->Reset();
267 result->type = ct::LogEntry::LOG_ENTRY_TYPE_X509; 267 result->type = ct::LogEntry::LOG_ENTRY_TYPE_X509;
268 result->leaf_certificate.swap(encoded); 268 result->leaf_certificate.swap(encoded);
269 return true; 269 return true;
270 } 270 }
271 271
272 bool ExtractSCTListFromOCSPResponse(X509Certificate::OSCertHandle leaf,
273 const std::string& ocsp_response,
274 std::string* sct_list) {
275 DCHECK(leaf);
276 NSSCertWrapper leaf_cert(leaf);
277 sct_list->clear();
278 base::StringPiece serial_number = base::StringPiece(
279 reinterpret_cast<char*>(leaf_cert.cert->serialNumber.data),
280 leaf_cert.cert->serialNumber.len);
281 base::StringPiece ocsp_resp(ocsp_response);
wtc 2013/12/03 01:18:06 Nit: it should be OK to just pass |ocsp_response|.
ekasper 2013/12/03 13:50:51 Done.
282 base::StringPiece sct_list_out;
283 if (!asn1::ExtractSCTExtensionFromOCSPResponse(ocsp_resp,
284 serial_number,
285 &sct_list_out))
286 return false;
287
288 *sct_list = std::string(sct_list_out.data(), sct_list_out.size());
wtc 2013/12/03 01:18:06 Nit: you can use the as_string() method: *sct_li
ekasper 2013/12/03 13:50:51 Done.
289 return true;
290 }
291
272 } // namespace ct 292 } // namespace ct
273 293
274 } // namespace net 294 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698