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

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

Issue 71633002: Convert SignedCertificateClass to be ref_counted, and add an SCTStore in which to store them. Add S… Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: few lint fixes Created 7 years, 1 month 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_serialization.h ('k') | net/cert/ct_verify_result.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_serialization.h" 5 #include "net/cert/ct_serialization.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 9
10 namespace net { 10 namespace net {
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 return false; 310 return false;
311 } 311 }
312 312
313 if (!input->empty() || result.empty()) 313 if (!input->empty() || result.empty())
314 return false; 314 return false;
315 output->swap(result); 315 output->swap(result);
316 return true; 316 return true;
317 } 317 }
318 318
319 bool DecodeSignedCertificateTimestamp(base::StringPiece* input, 319 bool DecodeSignedCertificateTimestamp(base::StringPiece* input,
320 SignedCertificateTimestamp* output) { 320 scoped_refptr<SignedCertificateTimestamp>* output) {
321 SignedCertificateTimestamp result; 321 scoped_refptr<SignedCertificateTimestamp> result(
322 new SignedCertificateTimestamp());
322 unsigned version; 323 unsigned version;
323 if (!ReadUint(kVersionLength, input, &version)) 324 if (!ReadUint(kVersionLength, input, &version))
324 return false; 325 return false;
325 if (version != SignedCertificateTimestamp::SCT_VERSION_1) { 326 if (version != SignedCertificateTimestamp::SCT_VERSION_1) {
326 DVLOG(1) << "Unsupported/invalid version " << version; 327 DVLOG(1) << "Unsupported/invalid version " << version;
327 return false; 328 return false;
328 } 329 }
329 330
330 result.version = SignedCertificateTimestamp::SCT_VERSION_1; 331 result->version = SignedCertificateTimestamp::SCT_VERSION_1;
331 uint64 timestamp; 332 uint64 timestamp;
332 base::StringPiece log_id; 333 base::StringPiece log_id;
333 base::StringPiece extensions; 334 base::StringPiece extensions;
334 if (!ReadFixedBytes(kLogIdLength, input, &log_id) || 335 if (!ReadFixedBytes(kLogIdLength, input, &log_id) ||
335 !ReadUint(kTimestampLength, input, &timestamp) || 336 !ReadUint(kTimestampLength, input, &timestamp) ||
336 !ReadVariableBytes(kExtensionsLengthBytes, input, 337 !ReadVariableBytes(kExtensionsLengthBytes, input,
337 &extensions) || 338 &extensions) ||
338 !DecodeDigitallySigned(input, &result.signature)) { 339 !DecodeDigitallySigned(input, &result->signature)) {
339 return false; 340 return false;
340 } 341 }
341 342
342 if (timestamp > static_cast<uint64>(kint64max)) { 343 if (timestamp > static_cast<uint64>(kint64max)) {
343 DVLOG(1) << "Timestamp value too big to cast to int64: " << timestamp; 344 DVLOG(1) << "Timestamp value too big to cast to int64: " << timestamp;
344 return false; 345 return false;
345 } 346 }
346 347
347 log_id.CopyToString(&result.log_id); 348 log_id.CopyToString(&result->log_id);
348 extensions.CopyToString(&result.extensions); 349 extensions.CopyToString(&result->extensions);
349 result.timestamp = 350 result->timestamp =
350 base::Time::UnixEpoch() + 351 base::Time::UnixEpoch() +
351 base::TimeDelta::FromMilliseconds(static_cast<int64>(timestamp)); 352 base::TimeDelta::FromMilliseconds(static_cast<int64>(timestamp));
352 353
353 *output = result; 354 output->swap(result);
354 return true; 355 return true;
355 } 356 }
356 357
357 } // namespace ct 358 } // namespace ct
358 359
359 } // namespace net 360 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/ct_serialization.h ('k') | net/cert/ct_verify_result.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698