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 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 | |
447 bool EncodeSCTListForTesting(const base::StringPiece& sct, | 431 bool EncodeSCTListForTesting(const base::StringPiece& sct, |
448 std::string* output) { | 432 std::string* output) { |
449 std::string encoded_sct; | 433 std::string encoded_sct; |
450 return WriteVariableBytes(kSerializedSCTLengthBytes, sct, &encoded_sct) && | 434 return WriteVariableBytes(kSerializedSCTLengthBytes, sct, &encoded_sct) && |
451 WriteVariableBytes(kSCTListLengthBytes, encoded_sct, output); | 435 WriteVariableBytes(kSCTListLengthBytes, encoded_sct, output); |
452 } | 436 } |
453 | 437 |
454 } // namespace ct | 438 } // namespace ct |
455 | 439 |
456 } // namespace net | 440 } // namespace net |
OLD | NEW |