1 // Copyright 2014 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef NET_CERT_SIGNED_TREE_HEAD_H_ 6 #define NET_CERT_SIGNED_TREE_HEAD_H_ 7 8 #include <stdint.h> 9 10 #include <iosfwd> 11 #include <string> 12 #include <vector> 13 14 #include "base/time/time.h" 15 #include "net/base/hash_value.h" 16 #include "net/base/net_export.h" 17 #include "net/cert/signed_certificate_timestamp.h" 18 19 namespace net::ct { 20 21 static const uint8_t kSthRootHashLength = 32; 22 23 // Signed Tree Head as defined in section 3.5. of RFC6962 24 struct NET_EXPORT SignedTreeHead { 25 // Version enum in RFC 6962, Section 3.2. Note that while in the current 26 // RFC the STH and SCT share the versioning scheme, there are plans in 27 // RFC6962-bis to use separate versions, so using a separate scheme here. 28 enum Version { V1 = 0, }; 29 30 SignedTreeHead(); 31 SignedTreeHead(Version version, 32 const base::Time& timestamp, 33 uint64_t tree_size, 34 const char sha256_root_hash[kSthRootHashLength], 35 const DigitallySigned& signature, 36 const std::string& log_id); 37 SignedTreeHead(const SignedTreeHead& other); 38 ~SignedTreeHead(); 39 40 Version version; 41 base::Time timestamp; 42 uint64_t tree_size; 43 char sha256_root_hash[kSthRootHashLength]; 44 DigitallySigned signature; 45 46 // Added in RFC6962-bis, Appendix A. Needed to identify which log 47 // this STH belongs to. 48 std::string log_id; 49 }; 50 51 NET_EXPORT void PrintTo(const SignedTreeHead& sth, std::ostream* os); 52 53 NET_EXPORT bool operator==(const SignedTreeHead& lhs, 54 const SignedTreeHead& rhs); 55 NET_EXPORT bool operator!=(const SignedTreeHead& lhs, 56 const SignedTreeHead& rhs); 57 58 } // namespace net::ct 59 60 #endif // NET_CERT_SIGNED_TREE_HEAD_H_ 61