Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(307)

Side by Side Diff: net/cert/signed_tree_head.cc

Issue 1576513002: Serialisation code for Certificate Transparency data (Closed) Base URL: ssh://caladan.lon.corp.google.com/usr/local/google/eranm/opensource_clients/chrome/src@sth_consistency_validation_2
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698