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> |
davidben
2016/03/02 17:30:39
Nit: I think this wants newline here? At least, th
Eran Messeri
2016/03/04 11:28:30
Done.
| |
8 #include <sstream> | |
8 | 9 |
9 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
10 | 11 |
11 namespace net { | 12 namespace net { |
12 namespace ct { | 13 namespace ct { |
13 | 14 |
14 SignedTreeHead::SignedTreeHead() {} | 15 SignedTreeHead::SignedTreeHead() {} |
15 | 16 |
16 SignedTreeHead::SignedTreeHead(Version version, | 17 SignedTreeHead::SignedTreeHead(Version version, |
17 const base::Time& timestamp, | 18 const base::Time& timestamp, |
18 uint64_t tree_size, | 19 uint64_t tree_size, |
19 const char sha256_root_hash[kSthRootHashLength], | 20 const char sha256_root_hash[kSthRootHashLength], |
20 const DigitallySigned& signature, | 21 const DigitallySigned& signature, |
21 const std::string& log_id) | 22 const std::string& log_id) |
22 : version(version), | 23 : version(version), |
23 timestamp(timestamp), | 24 timestamp(timestamp), |
24 tree_size(tree_size), | 25 tree_size(tree_size), |
25 signature(signature), | 26 signature(signature), |
26 log_id(log_id) { | 27 log_id(log_id) { |
27 memcpy(this->sha256_root_hash, sha256_root_hash, kSthRootHashLength); | 28 memcpy(this->sha256_root_hash, sha256_root_hash, kSthRootHashLength); |
28 } | 29 } |
29 | 30 |
30 SignedTreeHead::~SignedTreeHead() {} | 31 SignedTreeHead::~SignedTreeHead() {} |
31 | 32 |
32 std::ostream& operator<<(std::ostream& stream, const SignedTreeHead& sth) { | 33 std::string DebugString(const SignedTreeHead& sth) { |
33 return stream << "{\n" | 34 std::ostringstream stream; |
34 << "\t\"version\": " << sth.version << ",\n" | 35 stream << "{\n" |
35 << "\t\"timestamp\": " << sth.timestamp << ",\n" | 36 << "\t\"version\": " << sth.version << ",\n" |
36 << "\t\"tree_size\": " << sth.tree_size << ",\n" | 37 << "\t\"timestamp\": " << sth.timestamp << ",\n" |
37 << "\t\"sha256_root_hash\": \"" | 38 << "\t\"tree_size\": " << sth.tree_size << ",\n" |
38 << base::HexEncode(sth.sha256_root_hash, kSthRootHashLength) | 39 << "\t\"sha256_root_hash\": \"" |
39 << "\",\n\t\"log_id\": \"" | 40 << base::HexEncode(sth.sha256_root_hash, kSthRootHashLength) |
40 << base::HexEncode(sth.log_id.data(), sth.log_id.size()) | 41 << "\",\n\t\"log_id\": \"" |
41 << "\"\n" | 42 << base::HexEncode(sth.log_id.data(), sth.log_id.size()) << "\"\n" |
42 << "}"; | 43 << "}"; |
44 return stream.str(); | |
43 } | 45 } |
44 | 46 |
45 } // namespace ct | 47 } // namespace ct |
46 } // namespace net | 48 } // namespace net |
OLD | NEW |