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

Side by Side Diff: net/cert/ct_log_response_parser.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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/ct_log_response_parser.h" 5 #include "net/cert/ct_log_response_parser.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/json/json_value_converter.h" 8 #include "base/json/json_value_converter.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 if (!converter.Convert(json_signed_tree_head, &parsed_sth)) { 138 if (!converter.Convert(json_signed_tree_head, &parsed_sth)) {
139 DVLOG(1) << "Invalid Signed Tree Head JSON."; 139 DVLOG(1) << "Invalid Signed Tree Head JSON.";
140 return false; 140 return false;
141 } 141 }
142 142
143 if (!IsJsonSTHStructurallyValid(parsed_sth)) 143 if (!IsJsonSTHStructurallyValid(parsed_sth))
144 return false; 144 return false;
145 145
146 signed_tree_head->version = SignedTreeHead::V1; 146 signed_tree_head->version = SignedTreeHead::V1;
147 signed_tree_head->tree_size = parsed_sth.tree_size; 147 signed_tree_head->tree_size = parsed_sth.tree_size;
148 signed_tree_head->timestamp = 148 signed_tree_head->timestamp = base::Time::FromJsTime(parsed_sth.timestamp);
Ryan Sleevi 2016/03/02 19:03:22 Are you sure this is correct? Js loses precision
davidben 2016/03/02 19:11:46 What do you mean? FromJsTime and JsonSignedTreeHea
Ryan Sleevi 2016/03/02 19:16:53 I just meant that a 64-bit timestamp will be cappe
davidben 2016/03/02 19:21:04 Ah. (Well, it won't be capped but it'll lose preci
Eran Messeri 2016/03/04 11:28:30 What davidben said - I couldn't find a more accura
149 base::Time::UnixEpoch() + base::TimeDelta::FromMilliseconds(
150 static_cast<int64_t>(parsed_sth.timestamp));
151 signed_tree_head->signature = parsed_sth.signature; 149 signed_tree_head->signature = parsed_sth.signature;
152 memcpy(signed_tree_head->sha256_root_hash, 150 memcpy(signed_tree_head->sha256_root_hash,
153 parsed_sth.sha256_root_hash.c_str(), 151 parsed_sth.sha256_root_hash.c_str(),
154 kSthRootHashLength); 152 kSthRootHashLength);
155 return true; 153 return true;
156 } 154 }
157 155
158 bool FillConsistencyProof(const base::Value& json_consistency_proof, 156 bool FillConsistencyProof(const base::Value& json_consistency_proof,
159 std::vector<std::string>* consistency_proof) { 157 std::vector<std::string>* consistency_proof) {
160 JsonConsistencyProof parsed_proof; 158 JsonConsistencyProof parsed_proof;
(...skipping 14 matching lines...) Expand all
175 for (std::string* proof_node : parsed_proof.proof_nodes) { 173 for (std::string* proof_node : parsed_proof.proof_nodes) {
176 consistency_proof->push_back(*proof_node); 174 consistency_proof->push_back(*proof_node);
177 } 175 }
178 176
179 return true; 177 return true;
180 } 178 }
181 179
182 } // namespace ct 180 } // namespace ct
183 181
184 } // namespace net 182 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/cert/ct_log_response_parser_unittest.cc » ('j') | net/cert/ct_log_response_parser_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698