OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_CT_SERIALIZATION_H_ | 5 #ifndef NET_CERT_CT_SERIALIZATION_H_ |
6 #define NET_CERT_CT_SERIALIZATION_H_ | 6 #define NET_CERT_CT_SERIALIZATION_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/strings/string_piece.h" | 11 #include "base/strings/string_piece.h" |
12 #include "net/base/net_export.h" | 12 #include "net/base/net_export.h" |
13 #include "net/cert/ct_trans_item.h" | |
13 #include "net/cert/signed_certificate_timestamp.h" | 14 #include "net/cert/signed_certificate_timestamp.h" |
14 #include "net/cert/signed_tree_head.h" | 15 #include "net/cert/signed_tree_head.h" |
15 | 16 |
16 namespace net { | 17 namespace net { |
17 | 18 |
18 // Utility functions for encoding/decoding structures used by Certificate | 19 // Utility functions for encoding/decoding structures used by Certificate |
19 // Transparency to/from the TLS wire format encoding. | 20 // Transparency to/from the TLS wire format encoding. |
20 namespace ct { | 21 namespace ct { |
21 | 22 |
23 struct MerkleConsistencyProof; | |
24 struct TransItem; | |
Eran Messeri
2016/01/14 12:46:45
Unnecessary as you're including ct_trans_item.h
| |
25 | |
22 // If |input.signature_data| is less than kMaxSignatureLength, encodes the | 26 // If |input.signature_data| is less than kMaxSignatureLength, encodes the |
23 // |input| to |output| and returns true. Otherwise, returns false. | 27 // |input| to |output| and returns true. Otherwise, returns false. |
24 NET_EXPORT_PRIVATE bool EncodeDigitallySigned(const DigitallySigned& input, | 28 NET_EXPORT_PRIVATE bool EncodeDigitallySigned(const DigitallySigned& input, |
25 std::string* output); | 29 std::string* output); |
26 | 30 |
27 // Reads and decodes a DigitallySigned object from |input|. | 31 // Reads and decodes a DigitallySigned object from |input|. |
28 // The bytes read from |input| are discarded (i.e. |input|'s prefix removed) | 32 // The bytes read from |input| are discarded (i.e. |input|'s prefix removed) |
29 // Returns true and fills |output| if all fields can be read, false otherwise. | 33 // Returns true and fills |output| if all fields can be read, false otherwise. |
30 NET_EXPORT_PRIVATE bool DecodeDigitallySigned(base::StringPiece* input, | 34 NET_EXPORT_PRIVATE bool DecodeDigitallySigned(base::StringPiece* input, |
31 DigitallySigned* output); | 35 DigitallySigned* output); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
66 NET_EXPORT_PRIVATE bool DecodeSCTList(base::StringPiece* input, | 70 NET_EXPORT_PRIVATE bool DecodeSCTList(base::StringPiece* input, |
67 std::vector<base::StringPiece>* output); | 71 std::vector<base::StringPiece>* output); |
68 | 72 |
69 // Decodes a single SCT from |input| to |output|. | 73 // Decodes a single SCT from |input| to |output|. |
70 // Returns true if all fields in the SCT could be read and decoded, false | 74 // Returns true if all fields in the SCT could be read and decoded, false |
71 // otherwise. | 75 // otherwise. |
72 NET_EXPORT_PRIVATE bool DecodeSignedCertificateTimestamp( | 76 NET_EXPORT_PRIVATE bool DecodeSignedCertificateTimestamp( |
73 base::StringPiece* input, | 77 base::StringPiece* input, |
74 scoped_refptr<ct::SignedCertificateTimestamp>* output); | 78 scoped_refptr<ct::SignedCertificateTimestamp>* output); |
75 | 79 |
80 NET_EXPORT_PRIVATE bool EncodeSignedCertificateTimestamp( | |
81 const SignedCertificateTimestamp& input, | |
82 std::string* output); | |
83 | |
76 // Writes an SCTList into |output|, containing a single |sct|. | 84 // Writes an SCTList into |output|, containing a single |sct|. |
77 NET_EXPORT_PRIVATE bool EncodeSCTListForTesting(const base::StringPiece& sct, | 85 NET_EXPORT_PRIVATE bool EncodeSCTListForTesting(const base::StringPiece& sct, |
78 std::string* output); | 86 std::string* output); |
87 | |
88 NET_EXPORT_PRIVATE bool DecodeSignedTreeHead(base::StringPiece* input, | |
Eran Messeri
2016/01/14 12:46:45
Comment that all of these are from RFC6962-bis, no
| |
89 SignedTreeHead* output); | |
90 | |
91 NET_EXPORT_PRIVATE bool EncodeSignedTreeHead(const SignedTreeHead& sth, | |
92 std::string* output); | |
93 | |
94 NET_EXPORT_PRIVATE bool DecodeConsistencyProof(base::StringPiece* input, | |
95 MerkleConsistencyProof* output); | |
96 | |
97 NET_EXPORT_PRIVATE bool EncodeConsistencyProof( | |
98 const MerkleConsistencyProof& input, | |
99 std::string* output); | |
100 | |
101 // Decodes a CT item from |input| to |output|. | |
102 // Any pointers in |output| are owned by the caller. | |
103 // Returns true if all fields in the TransItem could be read and decoded, false | |
104 // otherwise. | |
105 NET_EXPORT bool DecodeTransItem(base::StringPiece* input, TransItem* output); | |
106 | |
107 NET_EXPORT_PRIVATE bool DecodeTransItem(base::StringPiece* input, | |
108 TransItemV1* output); | |
109 | |
110 // Encodes the TransItem |input| into |output|. | |
111 // Returns true if all of the fields in the TransItem could be encoded and | |
112 // written, false otherwise. | |
113 NET_EXPORT bool EncodeTransItem(const TransItem& input, std::string* output); | |
114 | |
115 NET_EXPORT bool EncodeTransItem(const TransItemV1& input, std::string* output); | |
116 | |
79 } // namespace ct | 117 } // namespace ct |
80 | 118 |
81 } // namespace net | 119 } // namespace net |
82 | 120 |
83 #endif // NET_CERT_CT_SERIALIZATION_H_ | 121 #endif // NET_CERT_CT_SERIALIZATION_H_ |
OLD | NEW |