Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "net/cert/signed_tree_head.h" | |
| 6 | |
| 7 #include "base/strings/string_number_conversions.h" | |
| 8 | |
| 9 namespace net { | |
| 10 namespace ct { | |
| 11 | |
| 12 SignedTreeHead::SignedTreeHead() {} | |
| 13 | |
| 14 SignedTreeHead::SignedTreeHead(Version version, | |
| 15 const base::Time& timestamp, | |
| 16 uint64_t tree_size, | |
| 17 const char sha256_root_hash[kSthRootHashLength], | |
| 18 const DigitallySigned& signature, | |
| 19 const std::string& log_id) | |
| 20 : version(version), | |
| 21 timestamp(timestamp), | |
| 22 tree_size(tree_size), | |
| 23 signature(signature), | |
| 24 log_id(log_id) { | |
| 25 strncpy(this->sha256_root_hash, sha256_root_hash, kSthRootHashLength); | |
|
Eran Messeri
2016/01/14 12:46:45
You should use memcpy - strncpy breaks if there's
| |
| 26 } | |
| 27 | |
| 28 SignedTreeHead::~SignedTreeHead() {} | |
| 29 | |
| 30 bool operator==(const SignedTreeHead& sth1, const SignedTreeHead& sth2) { | |
| 31 return sth1.log_id == sth2.log_id && sth1.timestamp == sth2.timestamp; | |
| 32 } | |
| 33 | |
| 34 bool operator!=(const SignedTreeHead& sth1, const SignedTreeHead& sth2) { | |
| 35 return !(sth1 == sth2); | |
| 36 } | |
| 37 | |
| 38 std::ostream& operator<<(std::ostream& stream, const SignedTreeHead& sth) { | |
| 39 return stream << "{\n" | |
| 40 << "\t\"version\": " << sth.version << ",\n" | |
| 41 << "\t\"timestamp\": " << sth.timestamp << ",\n" | |
| 42 << "\t\"tree_size\": " << sth.tree_size << ",\n" | |
| 43 << "\t\"log_id\": \"" | |
| 44 << base::HexEncode(sth.log_id.data(), sth.log_id.size()) | |
| 45 << "\",\n" | |
| 46 << "}"; | |
| 47 } | |
| 48 | |
| 49 } // namespace ct | |
| 50 } // namespace net | |
| OLD | NEW |