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

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

Issue 2957063005: Reland of Update SCT serialization format in Expect-CT reports (Closed)
Patch Set: fix reinterpret_cast Created 3 years, 5 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_serialization.h ('k') | net/cert/ct_serialization_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_serialization.h" 5 #include "net/cert/ct_serialization.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <limits> 10 #include <limits>
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 !DecodeDigitallySigned(input, &result->signature)) { 421 !DecodeDigitallySigned(input, &result->signature)) {
422 return false; 422 return false;
423 } 423 }
424 424
425 log_id.CopyToString(&result->log_id); 425 log_id.CopyToString(&result->log_id);
426 extensions.CopyToString(&result->extensions); 426 extensions.CopyToString(&result->extensions);
427 output->swap(result); 427 output->swap(result);
428 return true; 428 return true;
429 } 429 }
430 430
431 void EncodeSignedCertificateTimestamp(
432 const scoped_refptr<ct::SignedCertificateTimestamp>& input,
433 std::string* output) {
434 // This function only supports serialization of V1 SCTs.
435 DCHECK_EQ(SignedCertificateTimestamp::V1, input->version);
436 WriteUint(kVersionLength, input->version, output);
437 DCHECK_EQ(kLogIdLength, input->log_id.size());
438 WriteEncodedBytes(
439 base::StringPiece(reinterpret_cast<const char*>(input->log_id.data()),
440 kLogIdLength),
441 output);
442 WriteTimeSinceEpoch(input->timestamp, output);
443 WriteVariableBytes(kExtensionsLengthBytes, input->extensions, output);
444 EncodeDigitallySigned(input->signature, output);
445 }
446
431 bool EncodeSCTListForTesting(const base::StringPiece& sct, 447 bool EncodeSCTListForTesting(const base::StringPiece& sct,
432 std::string* output) { 448 std::string* output) {
433 std::string encoded_sct; 449 std::string encoded_sct;
434 return WriteVariableBytes(kSerializedSCTLengthBytes, sct, &encoded_sct) && 450 return WriteVariableBytes(kSerializedSCTLengthBytes, sct, &encoded_sct) &&
435 WriteVariableBytes(kSCTListLengthBytes, encoded_sct, output); 451 WriteVariableBytes(kSCTListLengthBytes, encoded_sct, output);
436 } 452 }
437 453
438 } // namespace ct 454 } // namespace ct
439 455
440 } // namespace net 456 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/ct_serialization.h ('k') | net/cert/ct_serialization_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698