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

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

Issue 1758823002: Certificate Transparency: Ensure timestamps over 32 bit are handled correctly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
« net/cert/signed_tree_head.h ('K') | « net/cert/signed_tree_head.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
OLDNEW
« net/cert/signed_tree_head.h ('K') | « net/cert/signed_tree_head.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698