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

Side by Side Diff: net/cert/internal/parse_certificate.h

Issue 2341943002: Add error details to TBSCertificate parsing function and tests. (Closed)
Patch Set: update comment Created 4 years, 3 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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_INTERNAL_PARSE_CERTIFICATE_H_ 5 #ifndef NET_CERT_INTERNAL_PARSE_CERTIFICATE_H_
6 #define NET_CERT_INTERNAL_PARSE_CERTIFICATE_H_ 6 #define NET_CERT_INTERNAL_PARSE_CERTIFICATE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 NET_EXPORT bool ParseCertificate(const der::Input& certificate_tlv, 95 NET_EXPORT bool ParseCertificate(const der::Input& certificate_tlv,
96 der::Input* out_tbs_certificate_tlv, 96 der::Input* out_tbs_certificate_tlv,
97 der::Input* out_signature_algorithm_tlv, 97 der::Input* out_signature_algorithm_tlv,
98 der::BitString* out_signature_value, 98 der::BitString* out_signature_value,
99 CertErrors* out_errors) WARN_UNUSED_RESULT; 99 CertErrors* out_errors) WARN_UNUSED_RESULT;
100 100
101 // Parses a DER-encoded "TBSCertificate" as specified by RFC 5280. Returns true 101 // Parses a DER-encoded "TBSCertificate" as specified by RFC 5280. Returns true
102 // on success and sets the results in |out|. Certain invalid inputs may 102 // on success and sets the results in |out|. Certain invalid inputs may
103 // be accepted based on the provided |options|. 103 // be accepted based on the provided |options|.
104 // 104 //
105 // If |errors| was non-null then any warnings/errors that occur during parsing
106 // are added to it.
107 //
105 // Note that on success |out| aliases data from the input |tbs_tlv|. 108 // Note that on success |out| aliases data from the input |tbs_tlv|.
106 // Hence the fields of the ParsedTbsCertificate are only valid as long as 109 // Hence the fields of the ParsedTbsCertificate are only valid as long as
107 // |tbs_tlv| remains valid. 110 // |tbs_tlv| remains valid.
108 // 111 //
109 // On failure |out| has an undefined state. Some of its fields may have been 112 // On failure |out| has an undefined state. Some of its fields may have been
110 // updated during parsing, whereas others may not have been changed. 113 // updated during parsing, whereas others may not have been changed.
111 // 114 //
112 // Refer to the per-field documentation of ParsedTbsCertificate for details on 115 // Refer to the per-field documentation of ParsedTbsCertificate for details on
113 // what validity checks parsing performs. 116 // what validity checks parsing performs.
114 // 117 //
115 // TBSCertificate ::= SEQUENCE { 118 // TBSCertificate ::= SEQUENCE {
116 // version [0] EXPLICIT Version DEFAULT v1, 119 // version [0] EXPLICIT Version DEFAULT v1,
117 // serialNumber CertificateSerialNumber, 120 // serialNumber CertificateSerialNumber,
118 // signature AlgorithmIdentifier, 121 // signature AlgorithmIdentifier,
119 // issuer Name, 122 // issuer Name,
120 // validity Validity, 123 // validity Validity,
121 // subject Name, 124 // subject Name,
122 // subjectPublicKeyInfo SubjectPublicKeyInfo, 125 // subjectPublicKeyInfo SubjectPublicKeyInfo,
123 // issuerUniqueID [1] IMPLICIT UniqueIdentifier OPTIONAL, 126 // issuerUniqueID [1] IMPLICIT UniqueIdentifier OPTIONAL,
124 // -- If present, version MUST be v2 or v3 127 // -- If present, version MUST be v2 or v3
125 // subjectUniqueID [2] IMPLICIT UniqueIdentifier OPTIONAL, 128 // subjectUniqueID [2] IMPLICIT UniqueIdentifier OPTIONAL,
126 // -- If present, version MUST be v2 or v3 129 // -- If present, version MUST be v2 or v3
127 // extensions [3] EXPLICIT Extensions OPTIONAL 130 // extensions [3] EXPLICIT Extensions OPTIONAL
128 // -- If present, version MUST be v3 131 // -- If present, version MUST be v3
129 // } 132 // }
130 NET_EXPORT bool ParseTbsCertificate(const der::Input& tbs_tlv, 133 NET_EXPORT bool ParseTbsCertificate(const der::Input& tbs_tlv,
131 const ParseCertificateOptions& options, 134 const ParseCertificateOptions& options,
132 ParsedTbsCertificate* out) 135 ParsedTbsCertificate* out,
133 WARN_UNUSED_RESULT; 136 CertErrors* errors) WARN_UNUSED_RESULT;
134 137
135 // Represents a "Version" from RFC 5280: 138 // Represents a "Version" from RFC 5280:
136 // Version ::= INTEGER { v1(0), v2(1), v3(2) } 139 // Version ::= INTEGER { v1(0), v2(1), v3(2) }
137 enum class CertificateVersion { 140 enum class CertificateVersion {
138 V1, 141 V1,
139 V2, 142 V2,
140 V3, 143 V3,
141 }; 144 };
142 145
143 // ParsedTbsCertificate contains pointers to the main fields of a DER-encoded 146 // ParsedTbsCertificate contains pointers to the main fields of a DER-encoded
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 // accessLocation types other than uniformResourceIdentifier are silently 453 // accessLocation types other than uniformResourceIdentifier are silently
451 // ignored. 454 // ignored.
452 NET_EXPORT bool ParseAuthorityInfoAccess( 455 NET_EXPORT bool ParseAuthorityInfoAccess(
453 const der::Input& authority_info_access_tlv, 456 const der::Input& authority_info_access_tlv,
454 std::vector<base::StringPiece>* out_ca_issuers_uris, 457 std::vector<base::StringPiece>* out_ca_issuers_uris,
455 std::vector<base::StringPiece>* out_ocsp_uris) WARN_UNUSED_RESULT; 458 std::vector<base::StringPiece>* out_ocsp_uris) WARN_UNUSED_RESULT;
456 459
457 } // namespace net 460 } // namespace net
458 461
459 #endif // NET_CERT_INTERNAL_PARSE_CERTIFICATE_H_ 462 #endif // NET_CERT_INTERNAL_PARSE_CERTIFICATE_H_
OLDNEW
« no previous file with comments | « no previous file | net/cert/internal/parse_certificate.cc » ('j') | net/cert/internal/parse_certificate.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698