summaryrefslogtreecommitdiff
path: root/chromium/net/cert/merkle_tree_leaf.h
blob: 8f314f56a70641142300f8c6d556ab349178966b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef NET_CERT_MERKLE_TREE_LEAF_H_
#define NET_CERT_MERKLE_TREE_LEAF_H_

#include <memory>
#include <string>

#include "base/time/time.h"
#include "net/base/net_export.h"
#include "net/cert/signed_certificate_timestamp.h"

namespace net {

class X509Certificate;

namespace ct {

// Represents a MerkleTreeLeaf as defined in RFC6962, section 3.4.
// Has all the data as the MerkleTreeLeaf defined in the RFC, arranged
// slightly differently.
struct NET_EXPORT MerkleTreeLeaf {
  MerkleTreeLeaf();
  ~MerkleTreeLeaf();

  // The log id this leaf belongs to.
  std::string log_id;

  // Certificate / Precertificate and indication of entry type.
  LogEntry log_entry;

  // Timestamp from the SCT.
  base::Time timestamp;

  // Extensions from the SCT.
  std::string extensions;
};

NET_EXPORT bool GetMerkleTreeLeaf(const X509Certificate* cert,
                                  const SignedCertificateTimestamp* sct,
                                  MerkleTreeLeaf* merkle_tree_leaf);

// Sets |*out| to the hash of the Merkle |tree_leaf|, as defined in RFC6962.
// Returns true if the hash was generated, false if an error occurred.
NET_EXPORT bool Hash(const MerkleTreeLeaf& tree_leaf, std::string* out);

}  // namespace ct

}  // namespace net

#endif  // NET_CERT_MERKLE_TREE_LEAF_H_