OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_SIGNED_TREE_HEAD_H_ | 5 #ifndef NET_CERT_SIGNED_TREE_HEAD_H_ |
6 #define NET_CERT_SIGNED_TREE_HEAD_H_ | 6 #define NET_CERT_SIGNED_TREE_HEAD_H_ |
7 | 7 |
| 8 #include <ostream> |
8 #include <string> | 9 #include <string> |
9 #include <vector> | 10 #include <vector> |
10 | 11 |
11 #include "base/time/time.h" | 12 #include "base/time/time.h" |
12 #include "net/base/hash_value.h" | 13 #include "net/base/hash_value.h" |
13 #include "net/base/net_export.h" | 14 #include "net/base/net_export.h" |
14 #include "net/cert/signed_certificate_timestamp.h" | 15 #include "net/cert/signed_certificate_timestamp.h" |
15 | 16 |
16 namespace net { | 17 namespace net { |
17 | 18 |
18 namespace ct { | 19 namespace ct { |
19 | 20 |
20 static const uint8_t kSthRootHashLength = 32; | 21 static const uint8_t kSthRootHashLength = 32; |
21 | 22 |
22 // Signed Tree Head as defined in section 3.5. of RFC6962 | 23 // Signed Tree Head as defined in section 3.5. of RFC6962 |
23 struct NET_EXPORT SignedTreeHead { | 24 struct NET_EXPORT SignedTreeHead { |
24 // Version enum in RFC 6962, Section 3.2. Note that while in the current | 25 // Version enum in RFC 6962, Section 3.2. Note that while in the current |
25 // RFC the STH and SCT share the versioning scheme, there are plans in | 26 // RFC the STH and SCT share the versioning scheme, there are plans in |
26 // RFC6962-bis to use separate versions, so using a separate scheme here. | 27 // RFC6962-bis to use separate versions, so using a separate scheme here. |
27 enum Version { V1 = 0, }; | 28 enum Version { V1 = 0, }; |
28 | 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(); |
| 38 |
29 Version version; | 39 Version version; |
30 base::Time timestamp; | 40 base::Time timestamp; |
31 uint64_t tree_size; | 41 uint64_t tree_size; |
32 char sha256_root_hash[kSthRootHashLength]; | 42 char sha256_root_hash[kSthRootHashLength]; |
33 DigitallySigned signature; | 43 DigitallySigned signature; |
| 44 |
| 45 // Added in RFC6962-bis, Appendix A |
| 46 std::string log_id; |
34 }; | 47 }; |
35 | 48 |
| 49 // Two STHs are considered equal if they are from the same log and have matching |
| 50 // timestamps, since RFC6962 forbids a log from issuing two different STHs with |
| 51 // the same timestamp. |
| 52 NET_EXPORT bool operator==(const SignedTreeHead& sth1, |
| 53 const SignedTreeHead& sth2); |
| 54 NET_EXPORT bool operator!=(const SignedTreeHead& sth1, |
| 55 const SignedTreeHead& sth2); |
| 56 |
| 57 NET_EXPORT std::ostream& operator<<(std::ostream& stream, |
| 58 const SignedTreeHead& sth); |
| 59 |
36 } // namespace ct | 60 } // namespace ct |
37 | 61 |
38 } // namespace net | 62 } // namespace net |
39 | 63 |
40 #endif | 64 #endif // NET_CERT_SIGNED_TREE_HEAD_H_ |
| 65 |
OLD | NEW |