| 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/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/strings/string_piece.h" | 12 #include "base/strings/string_piece.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "net/base/net_export.h" | 14 #include "net/base/net_export.h" |
| 15 | 15 |
| 16 namespace net { | 16 namespace net { |
| 17 | 17 |
| 18 // Utility functions for encoding/decoding structures used by Certificate | 18 // Utility functions for encoding/decoding structures used by Certificate |
| 19 // Transparency to/from the TLS wire format encoding. | 19 // Transparency to/from the TLS wire format encoding. |
| 20 namespace ct { | 20 namespace ct { |
| 21 | 21 |
| 22 struct DigitallySigned; | 22 struct DigitallySigned; |
| 23 struct LogEntry; | 23 struct LogEntry; |
| 24 struct MerkleTreeLeaf; |
| 24 struct SignedCertificateTimestamp; | 25 struct SignedCertificateTimestamp; |
| 25 struct SignedTreeHead; | 26 struct SignedTreeHead; |
| 26 | 27 |
| 27 // If |input.signature_data| is less than kMaxSignatureLength, encodes the | 28 // If |input.signature_data| is less than kMaxSignatureLength, encodes the |
| 28 // |input| to |output| and returns true. Otherwise, returns false. | 29 // |input| to |output| and returns true. Otherwise, returns false. |
| 29 NET_EXPORT_PRIVATE bool EncodeDigitallySigned(const DigitallySigned& input, | 30 NET_EXPORT_PRIVATE bool EncodeDigitallySigned(const DigitallySigned& input, |
| 30 std::string* output); | 31 std::string* output); |
| 31 | 32 |
| 32 // Reads and decodes a DigitallySigned object from |input|. | 33 // Reads and decodes a DigitallySigned object from |input|. |
| 33 // The bytes read from |input| are discarded (i.e. |input|'s prefix removed) | 34 // The bytes read from |input| are discarded (i.e. |input|'s prefix removed) |
| 34 // Returns true and fills |output| if all fields can be read, false otherwise. | 35 // Returns true and fills |output| if all fields can be read, false otherwise. |
| 35 NET_EXPORT_PRIVATE bool DecodeDigitallySigned(base::StringPiece* input, | 36 NET_EXPORT_PRIVATE bool DecodeDigitallySigned(base::StringPiece* input, |
| 36 DigitallySigned* output); | 37 DigitallySigned* output); |
| 37 | 38 |
| 38 // Encodes the |input| LogEntry to |output|. Returns true if the entry size | 39 // Encodes the |input| LogEntry to |output|. Returns true if the entry size |
| 39 // does not exceed allowed size in RFC6962, false otherwise. | 40 // does not exceed allowed size in RFC6962, false otherwise. |
| 40 NET_EXPORT_PRIVATE bool EncodeLogEntry(const LogEntry& input, | 41 NET_EXPORT_PRIVATE bool EncodeLogEntry(const LogEntry& input, |
| 41 std::string* output); | 42 std::string* output); |
| 42 | 43 |
| 44 // Serialises the Merkle tree |leaf|, appending it to |output|. |
| 45 // These bytes can be hashed for use with audit proof fetching. |
| 46 // Note that |leaf.log_id| is not part of the TLS encoding, and so will not be |
| 47 // serialized. |
| 48 NET_EXPORT bool EncodeTreeLeaf(const MerkleTreeLeaf& leaf, std::string* output); |
| 49 |
| 43 // Encodes the data signed by a Signed Certificate Timestamp (SCT) into | 50 // Encodes the data signed by a Signed Certificate Timestamp (SCT) into |
| 44 // |output|. The signature included in the SCT is then verified over these | 51 // |output|. The signature included in the SCT is then verified over these |
| 45 // bytes. | 52 // bytes. |
| 46 // |timestamp| timestamp from the SCT. | 53 // |timestamp| timestamp from the SCT. |
| 47 // |serialized_log_entry| the log entry signed by the SCT. | 54 // |serialized_log_entry| the log entry signed by the SCT. |
| 48 // |extensions| CT extensions. | 55 // |extensions| CT extensions. |
| 49 // Returns true if the extensions' length does not exceed | 56 // Returns true if the extensions' length does not exceed |
| 50 // kMaxExtensionsLength, false otherwise. | 57 // kMaxExtensionsLength, false otherwise. |
| 51 NET_EXPORT_PRIVATE bool EncodeV1SCTSignedData( | 58 NET_EXPORT_PRIVATE bool EncodeV1SCTSignedData( |
| 52 const base::Time& timestamp, | 59 const base::Time& timestamp, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 79 scoped_refptr<ct::SignedCertificateTimestamp>* output); | 86 scoped_refptr<ct::SignedCertificateTimestamp>* output); |
| 80 | 87 |
| 81 // Writes an SCTList into |output|, containing a single |sct|. | 88 // Writes an SCTList into |output|, containing a single |sct|. |
| 82 NET_EXPORT_PRIVATE bool EncodeSCTListForTesting(const base::StringPiece& sct, | 89 NET_EXPORT_PRIVATE bool EncodeSCTListForTesting(const base::StringPiece& sct, |
| 83 std::string* output); | 90 std::string* output); |
| 84 } // namespace ct | 91 } // namespace ct |
| 85 | 92 |
| 86 } // namespace net | 93 } // namespace net |
| 87 | 94 |
| 88 #endif // NET_CERT_CT_SERIALIZATION_H_ | 95 #endif // NET_CERT_CT_SERIALIZATION_H_ |
| OLD | NEW |