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

Side by Side Diff: net/test/ct_test_util.cc

Issue 1845113003: Certificate Transparency: Start tracking logs' state (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments, test improvement Created 4 years, 7 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/test/ct_test_util.h" 5 #include "net/test/ct_test_util.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <string.h> 8 #include <string.h>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 } 272 }
273 273
274 // A sample, valid STH 274 // A sample, valid STH
275 bool GetSampleSignedTreeHead(SignedTreeHead* sth) { 275 bool GetSampleSignedTreeHead(SignedTreeHead* sth) {
276 sth->version = SignedTreeHead::V1; 276 sth->version = SignedTreeHead::V1;
277 sth->timestamp = base::Time::UnixEpoch() + 277 sth->timestamp = base::Time::UnixEpoch() +
278 base::TimeDelta::FromMilliseconds(kTestTimestamp); 278 base::TimeDelta::FromMilliseconds(kTestTimestamp);
279 sth->tree_size = kSampleSTHTreeSize; 279 sth->tree_size = kSampleSTHTreeSize;
280 std::string sha256_root_hash = GetSampleSTHSHA256RootHash(); 280 std::string sha256_root_hash = GetSampleSTHSHA256RootHash();
281 memcpy(sth->sha256_root_hash, sha256_root_hash.c_str(), kSthRootHashLength); 281 memcpy(sth->sha256_root_hash, sha256_root_hash.c_str(), kSthRootHashLength);
282 sth->log_id = GetTestPublicKeyId();
282 283
283 return GetSampleSTHTreeHeadDecodedSignature(&(sth->signature)); 284 return GetSampleSTHTreeHeadDecodedSignature(&(sth->signature));
284 } 285 }
285 286
286 bool GetSampleEmptySignedTreeHead(SignedTreeHead* sth) { 287 bool GetSampleEmptySignedTreeHead(SignedTreeHead* sth) {
287 sth->version = SignedTreeHead::V1; 288 sth->version = SignedTreeHead::V1;
288 sth->timestamp = base::Time::UnixEpoch() + 289 sth->timestamp = base::Time::UnixEpoch() +
289 base::TimeDelta::FromMilliseconds(INT64_C(1450443594920)); 290 base::TimeDelta::FromMilliseconds(INT64_C(1450443594920));
290 sth->tree_size = 0; 291 sth->tree_size = 0;
291 std::string empty_root_hash = HexToBytes( 292 std::string empty_root_hash = HexToBytes(
292 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"); 293 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855");
293 memcpy(sth->sha256_root_hash, empty_root_hash.c_str(), kSthRootHashLength); 294 memcpy(sth->sha256_root_hash, empty_root_hash.c_str(), kSthRootHashLength);
295 sth->log_id = GetTestPublicKeyId();
294 296
295 std::string tree_head_signature = HexToBytes( 297 std::string tree_head_signature = HexToBytes(
296 "040300463044022046c26401de9416403da54762dc1f1687c38eafd791b15e484ab4c5f7" 298 "040300463044022046c26401de9416403da54762dc1f1687c38eafd791b15e484ab4c5f7"
297 "f52721fe02201bf537a3bbea47109fc76c2273fe0f3349f493a07de9335c266330105fb0" 299 "f52721fe02201bf537a3bbea47109fc76c2273fe0f3349f493a07de9335c266330105fb0"
298 "2a4a"); 300 "2a4a");
299 base::StringPiece sp(tree_head_signature); 301 base::StringPiece sp(tree_head_signature);
300 return DecodeDigitallySigned(&sp, &(sth->signature)) && sp.empty(); 302 return DecodeDigitallySigned(&sp, &(sth->signature)) && sp.empty();
301 } 303 }
302 304
303 bool GetBadEmptySignedTreeHead(SignedTreeHead* sth) { 305 bool GetBadEmptySignedTreeHead(SignedTreeHead* sth) {
304 sth->version = SignedTreeHead::V1; 306 sth->version = SignedTreeHead::V1;
305 sth->timestamp = base::Time::UnixEpoch() + 307 sth->timestamp = base::Time::UnixEpoch() +
306 base::TimeDelta::FromMilliseconds(INT64_C(1450870952897)); 308 base::TimeDelta::FromMilliseconds(INT64_C(1450870952897));
307 sth->tree_size = 0; 309 sth->tree_size = 0;
308 memset(sth->sha256_root_hash, 'f', kSthRootHashLength); 310 memset(sth->sha256_root_hash, 'f', kSthRootHashLength);
311 sth->log_id = GetTestPublicKeyId();
309 312
310 std::string tree_head_signature = HexToBytes( 313 std::string tree_head_signature = HexToBytes(
311 "04030046304402207cab04c62dee5d1cbc95fec30cd8417313f71587b75f133ad2e6f324" 314 "04030046304402207cab04c62dee5d1cbc95fec30cd8417313f71587b75f133ad2e6f324"
312 "74f164d702205e2f3a9bce46f87d7e20e951a4e955da3cb502f8717a22fabd7c5d7e1bef" 315 "74f164d702205e2f3a9bce46f87d7e20e951a4e955da3cb502f8717a22fabd7c5d7e1bef"
313 "46ea"); 316 "46ea");
314 base::StringPiece sp(tree_head_signature); 317 base::StringPiece sp(tree_head_signature);
315 return DecodeDigitallySigned(&sp, &(sth->signature)) && sp.empty(); 318 return DecodeDigitallySigned(&sp, &(sth->signature)) && sp.empty();
316 } 319 }
317 320
318 std::string GetSampleSTHSHA256RootHash() { 321 std::string GetSampleSTHSHA256RootHash() {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 408
406 bool CheckForSCTOrigin(const ct::CTVerifyResult& result, 409 bool CheckForSCTOrigin(const ct::CTVerifyResult& result,
407 ct::SignedCertificateTimestamp::Origin origin) { 410 ct::SignedCertificateTimestamp::Origin origin) {
408 return (result.verified_scts.size() > 0) && 411 return (result.verified_scts.size() > 0) &&
409 (result.verified_scts[0]->origin == origin); 412 (result.verified_scts[0]->origin == origin);
410 } 413 }
411 414
412 } // namespace ct 415 } // namespace ct
413 416
414 } // namespace net 417 } // namespace net
OLDNEW
« components/certificate_transparency/tree_state_tracker.cc ('K') | « net/cert/ct_verifier.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698