OLD | NEW |
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/cert/ct_log_verifier.h" | 5 #include "net/cert/ct_log_verifier.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
| 9 #include <memory> |
9 #include <string> | 10 #include <string> |
10 | 11 |
11 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
12 #include "base/time/time.h" | 13 #include "base/time/time.h" |
13 #include "crypto/secure_hash.h" | 14 #include "crypto/secure_hash.h" |
14 #include "net/base/hash_value.h" | 15 #include "net/base/hash_value.h" |
15 #include "net/cert/ct_log_verifier_util.h" | 16 #include "net/cert/ct_log_verifier_util.h" |
16 #include "net/cert/merkle_consistency_proof.h" | 17 #include "net/cert/merkle_consistency_proof.h" |
17 #include "net/cert/signed_certificate_timestamp.h" | 18 #include "net/cert/signed_certificate_timestamp.h" |
18 #include "net/cert/signed_tree_head.h" | 19 #include "net/cert/signed_tree_head.h" |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 public: | 403 public: |
403 static std::string HashEmpty() { | 404 static std::string HashEmpty() { |
404 return HexToBytes(kSHA256EmptyTreeHash.str, | 405 return HexToBytes(kSHA256EmptyTreeHash.str, |
405 kSHA256EmptyTreeHash.length_bytes); | 406 kSHA256EmptyTreeHash.length_bytes); |
406 } | 407 } |
407 | 408 |
408 static std::string HashLeaf(const std::string& leaf) { | 409 static std::string HashLeaf(const std::string& leaf) { |
409 SHA256HashValue sha256; | 410 SHA256HashValue sha256; |
410 memset(sha256.data, 0, sizeof(sha256.data)); | 411 memset(sha256.data, 0, sizeof(sha256.data)); |
411 | 412 |
412 scoped_ptr<crypto::SecureHash> hash( | 413 std::unique_ptr<crypto::SecureHash> hash( |
413 crypto::SecureHash::Create(crypto::SecureHash::SHA256)); | 414 crypto::SecureHash::Create(crypto::SecureHash::SHA256)); |
414 hash->Update(kLeafPrefix, 1); | 415 hash->Update(kLeafPrefix, 1); |
415 hash->Update(leaf.data(), leaf.size()); | 416 hash->Update(leaf.data(), leaf.size()); |
416 hash->Finish(sha256.data, sizeof(sha256.data)); | 417 hash->Finish(sha256.data, sizeof(sha256.data)); |
417 | 418 |
418 return std::string(reinterpret_cast<const char*>(sha256.data), | 419 return std::string(reinterpret_cast<const char*>(sha256.data), |
419 sizeof(sha256.data)); | 420 sizeof(sha256.data)); |
420 } | 421 } |
421 }; | 422 }; |
422 | 423 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 ReferenceSnapshotConsistency(data.data(), tree_size, snapshot, true); | 509 ReferenceSnapshotConsistency(data.data(), tree_size, snapshot, true); |
509 root1 = ReferenceMerkleTreeHash(data.data(), snapshot); | 510 root1 = ReferenceMerkleTreeHash(data.data(), snapshot); |
510 VerifierConsistencyCheck(snapshot, tree_size, root1, root2, proof); | 511 VerifierConsistencyCheck(snapshot, tree_size, root1, root2, proof); |
511 } | 512 } |
512 } | 513 } |
513 } | 514 } |
514 | 515 |
515 } // namespace | 516 } // namespace |
516 | 517 |
517 } // namespace net | 518 } // namespace net |
OLD | NEW |