OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 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_CT_TRANS_ITEM_H_ |
| 6 #define NET_CERT_CT_TRANS_ITEM_H_ |
| 7 |
| 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "net/base/net_export.h" |
| 11 |
| 12 namespace net { |
| 13 namespace ct { |
| 14 |
| 15 struct MerkleConsistencyProof; |
| 16 struct SignedCertificateTimestamp; |
| 17 struct SignedTreeHead; |
| 18 |
| 19 // These values are disjoint because we only need a subset of the CTv1 types. |
| 20 enum class TransType : uint16_t { |
| 21 X509_SCT = 2, |
| 22 SIGNED_TREE_HEAD = 5, |
| 23 CONSISTENCY_PROOF = 6, |
| 24 }; |
| 25 |
| 26 NET_EXPORT std::ostream& operator<<(std::ostream& stream, |
| 27 const TransType& type); |
| 28 |
| 29 struct NET_EXPORT TransItemV1 { |
| 30 TransItemV1(); |
| 31 ~TransItemV1(); |
| 32 |
| 33 bool IsTypeSet() const { return type_ != nullptr; } |
| 34 TransType type() const; |
| 35 |
| 36 scoped_refptr<SignedCertificateTimestamp> x509_sct() const; |
| 37 const SignedTreeHead& signed_tree_head() const; |
| 38 const MerkleConsistencyProof& consistency_proof() const; |
| 39 |
| 40 void SetX509Sct(scoped_refptr<SignedCertificateTimestamp> sct); |
| 41 void SetSignedTreeHead(const SignedTreeHead& sth); |
| 42 void SetConsistencyProof(const MerkleConsistencyProof& proof); |
| 43 |
| 44 private: |
| 45 void Clear(); |
| 46 |
| 47 scoped_ptr<TransType> type_; |
| 48 // Only one of the following should be set, based on the value of |type|. |
| 49 scoped_refptr<SignedCertificateTimestamp> x509_sct_; |
| 50 scoped_ptr<SignedTreeHead> signed_tree_head_; |
| 51 scoped_ptr<MerkleConsistencyProof> consistency_proof_; |
| 52 |
| 53 DISALLOW_COPY_AND_ASSIGN(TransItemV1); |
| 54 }; |
| 55 |
| 56 NET_EXPORT std::ostream& operator<<(std::ostream& stream, |
| 57 const TransItemV1& item); |
| 58 |
| 59 struct NET_EXPORT TransItem { |
| 60 enum class Version : unsigned { |
| 61 V1 = 0, |
| 62 }; |
| 63 |
| 64 TransItem(); |
| 65 explicit TransItem(scoped_ptr<TransItemV1> item); |
| 66 ~TransItem(); |
| 67 |
| 68 bool IsVersionSet() const { return version_ != nullptr; } |
| 69 Version version() const; |
| 70 |
| 71 const TransItemV1& v1() const; |
| 72 |
| 73 void Set(scoped_ptr<TransItemV1> item); |
| 74 |
| 75 private: |
| 76 void Clear(); |
| 77 |
| 78 scoped_ptr<Version> version_; |
| 79 // Only one of the following should be set, based on the value of |version|. |
| 80 scoped_ptr<TransItemV1> v1_; |
| 81 |
| 82 DISALLOW_COPY_AND_ASSIGN(TransItem); |
| 83 }; |
| 84 |
| 85 NET_EXPORT std::ostream& operator<<(std::ostream& stream, |
| 86 const TransItem::Version& version); |
| 87 NET_EXPORT std::ostream& operator<<(std::ostream& stream, |
| 88 const TransItem& item); |
| 89 |
| 90 } // namespace ct |
| 91 } // namespace net |
| 92 |
| 93 #endif // NET_CERT_CT_TRANS_ITEM_H_ |
OLD | NEW |