Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/merkle_tree_leaf.h" | 5 #include "net/cert/merkle_tree_leaf.h" |
| 6 | 6 |
| 7 #include "crypto/sha2.h" | 7 #include "crypto/sha2.h" |
| 8 #include "net/cert/ct_objects_extractor.h" | 8 #include "net/cert/ct_objects_extractor.h" |
| 9 #include "net/cert/ct_serialization.h" | 9 #include "net/cert/ct_serialization.h" |
| 10 #include "net/cert/x509_certificate.h" | 10 #include "net/cert/x509_certificate.h" |
| 11 | 11 |
| 12 namespace net { | 12 namespace net { |
| 13 | 13 |
| 14 namespace ct { | 14 namespace ct { |
| 15 | 15 |
| 16 MerkleTreeLeaf::MerkleTreeLeaf() {} | 16 MerkleTreeLeaf::MerkleTreeLeaf() {} |
| 17 | 17 |
| 18 MerkleTreeLeaf::MerkleTreeLeaf(const MerkleTreeLeaf& other) | |
| 19 : log_id(other.log_id), | |
| 20 log_entry(other.log_entry), | |
| 21 timestamp(other.timestamp), | |
| 22 extensions(other.extensions) {} | |
| 23 | |
| 18 MerkleTreeLeaf::~MerkleTreeLeaf() {} | 24 MerkleTreeLeaf::~MerkleTreeLeaf() {} |
| 19 | 25 |
| 20 bool Hash(const MerkleTreeLeaf& tree_leaf, std::string* out) { | 26 bool Hash(const MerkleTreeLeaf& tree_leaf, std::string* out) { |
| 21 // Prepend 0 byte as per RFC 6962, section-2.1 | 27 // Prepend 0 byte as per RFC 6962, section-2.1 |
| 22 std::string leaf_in_tls_format("\x00", 1); | 28 std::string leaf_in_tls_format("\x00", 1); |
| 23 if (!EncodeTreeLeaf(tree_leaf, &leaf_in_tls_format)) | 29 if (!EncodeTreeLeaf(tree_leaf, &leaf_in_tls_format)) |
| 24 return false; | 30 return false; |
| 25 | 31 |
| 26 *out = crypto::SHA256HashString(leaf_in_tls_format); | 32 *out = crypto::SHA256HashString(leaf_in_tls_format); |
| 27 return true; | 33 return true; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 43 return false; | 49 return false; |
| 44 } | 50 } |
| 45 } | 51 } |
| 46 | 52 |
| 47 merkle_tree_leaf->log_id = sct->log_id; | 53 merkle_tree_leaf->log_id = sct->log_id; |
| 48 merkle_tree_leaf->timestamp = sct->timestamp; | 54 merkle_tree_leaf->timestamp = sct->timestamp; |
| 49 merkle_tree_leaf->extensions = sct->extensions; | 55 merkle_tree_leaf->extensions = sct->extensions; |
| 50 return true; | 56 return true; |
| 51 } | 57 } |
| 52 | 58 |
| 59 NET_EXPORT bool CompareLeaves(const MerkleTreeLeaf& lhs, | |
| 60 const MerkleTreeLeaf& rhs); | |
|
Rob Percival
2016/05/26 17:33:15
I assume this shouldn't be here?
Eran Messeri
2016/06/30 19:58:28
Correct.
| |
| 61 | |
| 53 } // namespace ct | 62 } // namespace ct |
| 54 | 63 |
| 55 } // namespace net | 64 } // namespace net |
| OLD | NEW |