Chromium Code Reviews| 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 27 matching lines...) Expand all Loading... | |
| 38 << "\t\"version\": " << sth.version << ",\n" | 38 << "\t\"version\": " << sth.version << ",\n" |
| 39 << "\t\"timestamp\": " << sth.timestamp << ",\n" | 39 << "\t\"timestamp\": " << sth.timestamp << ",\n" |
| 40 << "\t\"tree_size\": " << sth.tree_size << ",\n" | 40 << "\t\"tree_size\": " << sth.tree_size << ",\n" |
| 41 << "\t\"sha256_root_hash\": \"" | 41 << "\t\"sha256_root_hash\": \"" |
| 42 << base::HexEncode(sth.sha256_root_hash, kSthRootHashLength) | 42 << base::HexEncode(sth.sha256_root_hash, kSthRootHashLength) |
| 43 << "\",\n\t\"log_id\": \"" | 43 << "\",\n\t\"log_id\": \"" |
| 44 << base::HexEncode(sth.log_id.data(), sth.log_id.size()) << "\"\n" | 44 << base::HexEncode(sth.log_id.data(), sth.log_id.size()) << "\"\n" |
| 45 << "}"; | 45 << "}"; |
| 46 } | 46 } |
| 47 | 47 |
| 48 bool operator==(const SignedTreeHead& lhs, const SignedTreeHead& rhs) { | |
| 49 return lhs.version == rhs.version && lhs.timestamp == rhs.timestamp && | |
| 50 lhs.tree_size == rhs.tree_size && lhs.log_id == rhs.log_id && | |
|
Ryan Sleevi
2016/05/17 22:20:16
fwiw, you could use
return std::tie(lhs.version,
Eran Messeri
2016/05/18 10:37:20
Done - switched to using std::tie and removed the
| |
| 51 (memcmp(lhs.sha256_root_hash, rhs.sha256_root_hash, | |
| 52 kSthRootHashLength) == 0) && | |
| 53 (lhs.signature.SignatureParametersMatch( | |
| 54 rhs.signature.hash_algorithm, | |
| 55 rhs.signature.signature_algorithm)) && | |
| 56 lhs.signature.signature_data == rhs.signature.signature_data; | |
| 57 } | |
| 58 | |
| 59 bool operator!=(const SignedTreeHead& lhs, const SignedTreeHead& rhs) { | |
| 60 return !operator==(lhs, rhs); | |
|
Ryan Sleevi
2016/05/17 22:20:16
!(lhs == rhs)
No need to directly invoke operator
Eran Messeri
2016/05/18 10:37:20
Done.
| |
| 61 } | |
| 62 | |
| 48 } // namespace ct | 63 } // namespace ct |
| 49 } // namespace net | 64 } // namespace net |
| OLD | NEW |