| 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 <ostream> | 9 #include <ostream> |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 tree_size(tree_size), | 26 tree_size(tree_size), |
| 27 signature(signature), | 27 signature(signature), |
| 28 log_id(log_id) { | 28 log_id(log_id) { |
| 29 memcpy(this->sha256_root_hash, sha256_root_hash, kSthRootHashLength); | 29 memcpy(this->sha256_root_hash, sha256_root_hash, kSthRootHashLength); |
| 30 } | 30 } |
| 31 | 31 |
| 32 SignedTreeHead::SignedTreeHead(const SignedTreeHead& other) = default; | 32 SignedTreeHead::SignedTreeHead(const SignedTreeHead& other) = default; |
| 33 | 33 |
| 34 SignedTreeHead::~SignedTreeHead() {} | 34 SignedTreeHead::~SignedTreeHead() {} |
| 35 | 35 |
| 36 bool operator==(const SignedTreeHead& sth1, const SignedTreeHead& sth2) { |
| 37 return sth1.log_id == sth2.log_id && sth1.timestamp == sth2.timestamp; |
| 38 } |
| 39 |
| 40 bool operator!=(const SignedTreeHead& sth1, const SignedTreeHead& sth2) { |
| 41 return !(sth1 == sth2); |
| 42 } |
| 43 |
| 36 void PrintTo(const SignedTreeHead& sth, std::ostream* os) { | 44 void PrintTo(const SignedTreeHead& sth, std::ostream* os) { |
| 37 (*os) << "{\n" | 45 (*os) << "{\n" |
| 38 << "\t\"version\": " << sth.version << ",\n" | 46 << "\t\"version\": " << sth.version << ",\n" |
| 39 << "\t\"timestamp\": " << sth.timestamp << ",\n" | 47 << "\t\"timestamp\": " << sth.timestamp << ",\n" |
| 40 << "\t\"tree_size\": " << sth.tree_size << ",\n" | 48 << "\t\"tree_size\": " << sth.tree_size << ",\n" |
| 41 << "\t\"sha256_root_hash\": \"" | 49 << "\t\"sha256_root_hash\": \"" |
| 42 << base::HexEncode(sth.sha256_root_hash, kSthRootHashLength) | 50 << base::HexEncode(sth.sha256_root_hash, kSthRootHashLength) |
| 43 << "\",\n\t\"log_id\": \"" | 51 << "\",\n\t\"log_id\": \"" |
| 44 << base::HexEncode(sth.log_id.data(), sth.log_id.size()) << "\"\n" | 52 << base::HexEncode(sth.log_id.data(), sth.log_id.size()) << "\"\n" |
| 45 << "}"; | 53 << "}"; |
| 46 } | 54 } |
| 47 | 55 |
| 48 } // namespace ct | 56 } // namespace ct |
| 49 } // namespace net | 57 } // namespace net |
| OLD | NEW |