OLD | NEW |
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 Loading... |
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 WriteEncodedBytes( | |
438 base::StringPiece(reinterpret_cast<const char*>(input->log_id.data()), | |
439 kLogIdLength), | |
440 output); | |
441 WriteTimeSinceEpoch(input->timestamp, output); | |
442 WriteVariableBytes(kExtensionsLengthBytes, input->extensions, output); | |
443 EncodeDigitallySigned(input->signature, output); | |
444 } | |
445 | |
446 bool EncodeSCTListForTesting(const base::StringPiece& sct, | 431 bool EncodeSCTListForTesting(const base::StringPiece& sct, |
447 std::string* output) { | 432 std::string* output) { |
448 std::string encoded_sct; | 433 std::string encoded_sct; |
449 return WriteVariableBytes(kSerializedSCTLengthBytes, sct, &encoded_sct) && | 434 return WriteVariableBytes(kSerializedSCTLengthBytes, sct, &encoded_sct) && |
450 WriteVariableBytes(kSCTListLengthBytes, encoded_sct, output); | 435 WriteVariableBytes(kSCTListLengthBytes, encoded_sct, output); |
451 } | 436 } |
452 | 437 |
453 } // namespace ct | 438 } // namespace ct |
454 | 439 |
455 } // namespace net | 440 } // namespace net |
OLD | NEW |