| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/signed_tree_head.h" | 5 #include "net/cert/signed_tree_head.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include <iostream> | |
| 10 | |
| 11 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 12 | 10 |
| 13 namespace net { | 11 namespace net { |
| 14 namespace ct { | 12 namespace ct { |
| 15 | 13 |
| 16 SignedTreeHead::SignedTreeHead() {} | 14 SignedTreeHead::SignedTreeHead() {} |
| 17 | 15 |
| 18 SignedTreeHead::SignedTreeHead(Version version, | 16 SignedTreeHead::SignedTreeHead(Version version, |
| 19 const base::Time& timestamp, | 17 const base::Time& timestamp, |
| 20 uint64_t tree_size, | 18 uint64_t tree_size, |
| 21 const char sha256_root_hash[kSthRootHashLength], | 19 const char sha256_root_hash[kSthRootHashLength], |
| 22 const DigitallySigned& signature, | 20 const DigitallySigned& signature, |
| 23 const std::string& log_id) | 21 const std::string& log_id) |
| 24 : version(version), | 22 : version(version), |
| 25 timestamp(timestamp), | 23 timestamp(timestamp), |
| 26 tree_size(tree_size), | 24 tree_size(tree_size), |
| 27 signature(signature), | 25 signature(signature), |
| 28 log_id(log_id) { | 26 log_id(log_id) { |
| 29 memcpy(this->sha256_root_hash, sha256_root_hash, kSthRootHashLength); | 27 memcpy(this->sha256_root_hash, sha256_root_hash, kSthRootHashLength); |
| 30 } | 28 } |
| 31 | 29 |
| 32 SignedTreeHead::~SignedTreeHead() {} | 30 SignedTreeHead::~SignedTreeHead() {} |
| 33 | 31 |
| 34 void PrintTo(const SignedTreeHead& sth, std::ostream* os) { | 32 std::ostream& operator<<(std::ostream& stream, const SignedTreeHead& sth) { |
| 35 (*os) << "{\n" | 33 return stream << "{\n" |
| 36 << "\t\"version\": " << sth.version << ",\n" | 34 << "\t\"version\": " << sth.version << ",\n" |
| 37 << "\t\"timestamp\": " << sth.timestamp << ",\n" | 35 << "\t\"timestamp\": " << sth.timestamp << ",\n" |
| 38 << "\t\"tree_size\": " << sth.tree_size << ",\n" | 36 << "\t\"tree_size\": " << sth.tree_size << ",\n" |
| 39 << "\t\"sha256_root_hash\": \"" | 37 << "\t\"sha256_root_hash\": \"" |
| 40 << base::HexEncode(sth.sha256_root_hash, kSthRootHashLength) | 38 << base::HexEncode(sth.sha256_root_hash, kSthRootHashLength) |
| 41 << "\",\n\t\"log_id\": \"" | 39 << "\",\n\t\"log_id\": \"" |
| 42 << base::HexEncode(sth.log_id.data(), sth.log_id.size()) << "\"\n" | 40 << base::HexEncode(sth.log_id.data(), sth.log_id.size()) |
| 43 << "}"; | 41 << "\"\n" |
| 42 << "}"; |
| 44 } | 43 } |
| 45 | 44 |
| 46 } // namespace ct | 45 } // namespace ct |
| 47 } // namespace net | 46 } // namespace net |
| OLD | NEW |