Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(679)

Side by Side Diff: net/cert/ct_serialization.h

Issue 230713002: Certificate Transparency: Parse Signed Tree Heads and validate them (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing more of Ryan's comments Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/cert/ct_log_verifier_unittest.cc ('k') | net/cert/ct_serialization.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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) |signed_tree_head| into
53 // |output|. The signature included in the |signed_tree_head| can then be
54 // verified over these bytes.
55 NET_EXPORT_PRIVATE void EncodeTreeHeadSignature(
56 const SignedTreeHead& signed_tree_head,
57 std::string* output);
58
51 // Decode a list of Signed Certificate Timestamps 59 // Decode a list of Signed Certificate Timestamps
52 // (SignedCertificateTimestampList as defined in RFC6962): from a single 60 // (SignedCertificateTimestampList as defined in RFC6962): from a single
53 // string in |input| to a vector of individually-encoded SCTs |output|. 61 // string in |input| to a vector of individually-encoded SCTs |output|.
54 // This list is typically obtained from the CT extension in a certificate. 62 // 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 63 // 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 64 // otherwise (note that the validity of each individual SCT should be checked
57 // separately). 65 // separately).
58 NET_EXPORT_PRIVATE bool DecodeSCTList(base::StringPiece* input, 66 NET_EXPORT_PRIVATE bool DecodeSCTList(base::StringPiece* input,
59 std::vector<base::StringPiece>* output); 67 std::vector<base::StringPiece>* output);
60 68
61 // Decodes a single SCT from |input| to |output|. 69 // Decodes a single SCT from |input| to |output|.
62 // Returns true if all fields in the SCT could be read and decoded, false 70 // Returns true if all fields in the SCT could be read and decoded, false
63 // otherwise. 71 // otherwise.
64 NET_EXPORT_PRIVATE bool DecodeSignedCertificateTimestamp( 72 NET_EXPORT_PRIVATE bool DecodeSignedCertificateTimestamp(
65 base::StringPiece* input, 73 base::StringPiece* input,
66 scoped_refptr<ct::SignedCertificateTimestamp>* output); 74 scoped_refptr<ct::SignedCertificateTimestamp>* output);
67 75
68 // Writes an SCTList into |output|, containing a single |sct|. 76 // Writes an SCTList into |output|, containing a single |sct|.
69 NET_EXPORT_PRIVATE bool EncodeSCTListForTesting(const base::StringPiece& sct, 77 NET_EXPORT_PRIVATE bool EncodeSCTListForTesting(const base::StringPiece& sct,
70 std::string* output); 78 std::string* output);
71 } // namespace ct 79 } // namespace ct
72 80
73 } // namespace net 81 } // namespace net
74 82
75 #endif // NET_CERT_CT_SERIALIZATION_H_ 83 #endif // NET_CERT_CT_SERIALIZATION_H_
OLDNEW
« no previous file with comments | « net/cert/ct_log_verifier_unittest.cc ('k') | net/cert/ct_serialization.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698