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

Side by Side Diff: net/cert/merkle_tree_leaf.h

Issue 2107423004: Certificate Transparency: MerkleTreeLeaf, MerkleAuditProof improvements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing botched merge Created 4 years, 5 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
« no previous file with comments | « net/cert/merkle_audit_proof.cc ('k') | net/cert/merkle_tree_leaf.cc » ('j') | 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 #ifndef NET_CERT_MERKLE_TREE_LEAF_H_ 5 #ifndef NET_CERT_MERKLE_TREE_LEAF_H_
6 #define NET_CERT_MERKLE_TREE_LEAF_H_ 6 #define NET_CERT_MERKLE_TREE_LEAF_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "net/base/net_export.h" 12 #include "net/base/net_export.h"
13 #include "net/cert/signed_certificate_timestamp.h" 13 #include "net/cert/signed_certificate_timestamp.h"
14 14
15 namespace net { 15 namespace net {
16 16
17 class X509Certificate; 17 class X509Certificate;
18 18
19 namespace ct { 19 namespace ct {
20 20
21 // Represents a MerkleTreeLeaf as defined in RFC6962, section 3.4. 21 // Represents a MerkleTreeLeaf as defined in RFC6962, section 3.4.
22 // Has all the data as the MerkleTreeLeaf defined in the RFC, arranged 22 // The goal of this struct is to represent the Merkle tree entry such that
23 // slightly differently. 23 // all details are easily accessible and a leaf hash can be easily calculated
24 // for the entry.
25 //
26 // As such, it has all the data as the MerkleTreeLeaf defined in the RFC,
27 // but it is not identical to the structure in the RFC for the following
28 // reasons:
29 // * The version is implicit - it is only used for V1 leaves currently.
30 // * the leaf_type is also implicit: There's exactly one leaf type and no
31 // new types are planned.
32 // * The timestamped_entry's |timestamp| and |extensions| fields are directly
33 // accessible.
34 // * The timestamped_entry's entry_type can be deduced from |log_entry|.type
24 struct NET_EXPORT MerkleTreeLeaf { 35 struct NET_EXPORT MerkleTreeLeaf {
25 MerkleTreeLeaf(); 36 MerkleTreeLeaf();
37 MerkleTreeLeaf(const MerkleTreeLeaf& other);
38 MerkleTreeLeaf(MerkleTreeLeaf&&);
26 ~MerkleTreeLeaf(); 39 ~MerkleTreeLeaf();
27 40
28 // The log id this leaf belongs to.
29 std::string log_id;
30
31 // Certificate / Precertificate and indication of entry type. 41 // Certificate / Precertificate and indication of entry type.
32 LogEntry log_entry; 42 LogEntry log_entry;
33 43
34 // Timestamp from the SCT. 44 // Timestamp from the SCT.
35 base::Time timestamp; 45 base::Time timestamp;
36 46
37 // Extensions from the SCT. 47 // Extensions from the SCT.
38 std::string extensions; 48 std::string extensions;
39 }; 49 };
40 50
51 // Given a |cert| and an |sct| for that certificate, constructs the
52 // representation of this entry in the Merkle tree by filling in
53 // |merkle_tree_leaf|.
54 // Returns false if it failed to construct the |merkle_tree_leaf|.
41 NET_EXPORT bool GetMerkleTreeLeaf(const X509Certificate* cert, 55 NET_EXPORT bool GetMerkleTreeLeaf(const X509Certificate* cert,
42 const SignedCertificateTimestamp* sct, 56 const SignedCertificateTimestamp* sct,
43 MerkleTreeLeaf* merkle_tree_leaf); 57 MerkleTreeLeaf* merkle_tree_leaf);
44 58
45 // Sets |*out| to the hash of the Merkle |tree_leaf|, as defined in RFC6962. 59 // Sets |*out| to the hash of the Merkle |tree_leaf|, as defined in RFC6962,
46 // Returns true if the hash was generated, false if an error occurred. 60 // section 3.4. Returns true if the hash was generated, false if an error
47 NET_EXPORT bool Hash(const MerkleTreeLeaf& tree_leaf, std::string* out); 61 // occurred.
62 NET_EXPORT bool HashMerkleTreeLeaf(const MerkleTreeLeaf& tree_leaf,
63 std::string* out);
48 64
49 } // namespace ct 65 } // namespace ct
50 66
51 } // namespace net 67 } // namespace net
52 68
53 #endif // NET_CERT_MERKLE_TREE_LEAF_H_ 69 #endif // NET_CERT_MERKLE_TREE_LEAF_H_
OLDNEW
« no previous file with comments | « net/cert/merkle_audit_proof.cc ('k') | net/cert/merkle_tree_leaf.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698