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/signed_certificate_timestamp.h" | 13 #include "net/cert/signed_certificate_timestamp.h" |
14 #include "net/cert/signed_tree_head.h" | |
14 | 15 |
15 namespace net { | 16 namespace net { |
16 | 17 |
17 // Utility functions for encoding/decoding structures used by Certificate | 18 // Utility functions for encoding/decoding structures used by Certificate |
18 // Transparency to/from the TLS wire format encoding. | 19 // Transparency to/from the TLS wire format encoding. |
19 namespace ct { | 20 namespace ct { |
20 | 21 |
21 // If |input.signature_data| is less than kMaxSignatureLength, encodes the | 22 // If |input.signature_data| is less than kMaxSignatureLength, encodes the |
22 // |input| to |output| and returns true. Otherwise, returns false. | 23 // |input| to |output| and returns true. Otherwise, returns false. |
23 NET_EXPORT_PRIVATE bool EncodeDigitallySigned(const DigitallySigned& input, | 24 NET_EXPORT_PRIVATE bool EncodeDigitallySigned(const DigitallySigned& input, |
(...skipping 17 matching lines...) Expand all Loading... | |
41 // |serialized_log_entry| the log entry signed by the SCT. | 42 // |serialized_log_entry| the log entry signed by the SCT. |
42 // |extensions| CT extensions. | 43 // |extensions| CT extensions. |
43 // Returns true if the extensions' length does not exceed | 44 // Returns true if the extensions' length does not exceed |
44 // kMaxExtensionsLength, false otherwise. | 45 // kMaxExtensionsLength, false otherwise. |
45 NET_EXPORT_PRIVATE bool EncodeV1SCTSignedData( | 46 NET_EXPORT_PRIVATE bool EncodeV1SCTSignedData( |
46 const base::Time& timestamp, | 47 const base::Time& timestamp, |
47 const std::string& serialized_log_entry, | 48 const std::string& serialized_log_entry, |
48 const std::string& extensions, | 49 const std::string& extensions, |
49 std::string* output); | 50 std::string* output); |
50 | 51 |
52 // Encodes the data signed by a Signed Tree Head (STH) |sth| into |output|. | |
53 // The signature included in the |sth| can then be verified over these bytes. | |
54 NET_EXPORT_PRIVATE void EncodeTreeHeadSignature(const SignedTreeHead& sth, | |
Ryan Sleevi
2014/04/25 23:33:19
s/sth/signed_tree_head/
or just tree_head (which
Eran Messeri
2014/04/29 15:22:24
Done - changed sth to signed_tree_head.
| |
55 std::string* output); | |
56 | |
51 // Decode a list of Signed Certificate Timestamps | 57 // Decode a list of Signed Certificate Timestamps |
52 // (SignedCertificateTimestampList as defined in RFC6962): from a single | 58 // (SignedCertificateTimestampList as defined in RFC6962): from a single |
53 // string in |input| to a vector of individually-encoded SCTs |output|. | 59 // string in |input| to a vector of individually-encoded SCTs |output|. |
54 // This list is typically obtained from the CT extension in a certificate. | 60 // This list is typically obtained from the CT extension in a certificate. |
55 // Returns true if the list could be read and decoded successfully, false | 61 // Returns true if the list could be read and decoded successfully, false |
56 // otherwise (note that the validity of each individual SCT should be checked | 62 // otherwise (note that the validity of each individual SCT should be checked |
57 // separately). | 63 // separately). |
58 NET_EXPORT_PRIVATE bool DecodeSCTList(base::StringPiece* input, | 64 NET_EXPORT_PRIVATE bool DecodeSCTList(base::StringPiece* input, |
59 std::vector<base::StringPiece>* output); | 65 std::vector<base::StringPiece>* output); |
60 | 66 |
61 // Decodes a single SCT from |input| to |output|. | 67 // Decodes a single SCT from |input| to |output|. |
62 // Returns true if all fields in the SCT could be read and decoded, false | 68 // Returns true if all fields in the SCT could be read and decoded, false |
63 // otherwise. | 69 // otherwise. |
64 NET_EXPORT_PRIVATE bool DecodeSignedCertificateTimestamp( | 70 NET_EXPORT_PRIVATE bool DecodeSignedCertificateTimestamp( |
65 base::StringPiece* input, | 71 base::StringPiece* input, |
66 scoped_refptr<ct::SignedCertificateTimestamp>* output); | 72 scoped_refptr<ct::SignedCertificateTimestamp>* output); |
67 | 73 |
68 // Writes an SCTList into |output|, containing a single |sct|. | 74 // Writes an SCTList into |output|, containing a single |sct|. |
69 NET_EXPORT_PRIVATE bool EncodeSCTListForTesting(const base::StringPiece& sct, | 75 NET_EXPORT_PRIVATE bool EncodeSCTListForTesting(const base::StringPiece& sct, |
70 std::string* output); | 76 std::string* output); |
71 } // namespace ct | 77 } // namespace ct |
72 | 78 |
73 } // namespace net | 79 } // namespace net |
74 | 80 |
75 #endif // NET_CERT_CT_SERIALIZATION_H_ | 81 #endif // NET_CERT_CT_SERIALIZATION_H_ |
OLD | NEW |