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