OLD | NEW |
---|---|
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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "net/base/net_export.h" | 10 #include "net/base/net_export.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
47 // -- If present, version MUST be v2 or v3 | 47 // -- If present, version MUST be v2 or v3 |
48 // subjectUniqueID [2] IMPLICIT UniqueIdentifier OPTIONAL, | 48 // subjectUniqueID [2] IMPLICIT UniqueIdentifier OPTIONAL, |
49 // -- If present, version MUST be v2 or v3 | 49 // -- If present, version MUST be v2 or v3 |
50 // extensions [3] EXPLICIT Extensions OPTIONAL | 50 // extensions [3] EXPLICIT Extensions OPTIONAL |
51 // -- If present, version MUST be v3 | 51 // -- If present, version MUST be v3 |
52 // } | 52 // } |
53 NET_EXPORT bool ParseTbsCertificate(const der::Input& tbs_tlv, | 53 NET_EXPORT bool ParseTbsCertificate(const der::Input& tbs_tlv, |
54 ParsedTbsCertificate* out) | 54 ParsedTbsCertificate* out) |
55 WARN_UNUSED_RESULT; | 55 WARN_UNUSED_RESULT; |
56 | 56 |
57 // Parses a DER-encoded "Validity" as specified by RFC 5280. Returns true on | |
58 // success and sets the results in |not_before| and |not_after|: | |
59 // | |
60 // Validity ::= SEQUENCE { | |
61 // notBefore Time, | |
62 // notAfter Time } | |
63 // | |
64 // Note that upon success it is NOT guaranteed that |*not_before <= *not_after|. | |
65 NET_EXPORT bool ParseValidity(const der::Input& validity_tlv, | |
66 der::GeneralizedTime* not_before, | |
67 der::GeneralizedTime* not_after) | |
68 WARN_UNUSED_RESULT; | |
69 | |
57 // Represents a "Version" from RFC 5280: | 70 // Represents a "Version" from RFC 5280: |
58 // Version ::= INTEGER { v1(0), v2(1), v3(2) } | 71 // Version ::= INTEGER { v1(0), v2(1), v3(2) } |
59 enum class CertificateVersion { | 72 enum class CertificateVersion { |
60 V1, | 73 V1, |
61 V2, | 74 V2, |
62 V3, | 75 V3, |
63 }; | 76 }; |
64 | 77 |
65 // ParsedCertificate contains pointers to the main fields of a DER-encoded RFC | 78 // ParsedCertificate contains pointers to the main fields of a DER-encoded RFC |
66 // 5280 "Certificate". | 79 // 5280 "Certificate". |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
135 // | 148 // |
136 // This contains the full (unverified) Tag-Length-Value for a SEQUENCE. No | 149 // This contains the full (unverified) Tag-Length-Value for a SEQUENCE. No |
137 // guarantees are made regarding the value of this SEQUENCE. | 150 // guarantees are made regarding the value of this SEQUENCE. |
138 der::Input issuer_tlv; | 151 der::Input issuer_tlv; |
139 | 152 |
140 // Corresponds with "validity" from RFC 5280: | 153 // Corresponds with "validity" from RFC 5280: |
141 // validity Validity, | 154 // validity Validity, |
142 // | 155 // |
143 // This contains the full (unverified) Tag-Length-Value for a SEQUENCE. No | 156 // This contains the full (unverified) Tag-Length-Value for a SEQUENCE. No |
144 // guarantees are made regarding the value of this SEQUENCE. | 157 // guarantees are made regarding the value of this SEQUENCE. |
158 // | |
159 // This can be further parsed using ParseValidity(). | |
145 der::Input validity_tlv; | 160 der::Input validity_tlv; |
davidben
2015/08/14 18:23:10
Since it's just two fields, I wonder if you should
eroman
2015/08/14 18:37:04
I discuss the design overview in this message:
htt
| |
146 | 161 |
147 // Corresponds with "subject" from RFC 5280: | 162 // Corresponds with "subject" from RFC 5280: |
148 // subject Name, | 163 // subject Name, |
149 // | 164 // |
150 // This contains the full (unverified) Tag-Length-Value for a SEQUENCE. No | 165 // This contains the full (unverified) Tag-Length-Value for a SEQUENCE. No |
151 // guarantees are made regarding the value of this SEQUENCE. | 166 // guarantees are made regarding the value of this SEQUENCE. |
152 der::Input subject_tlv; | 167 der::Input subject_tlv; |
153 | 168 |
154 // Corresponds with "subjectPublicKeyInfo" from RFC 5280: | 169 // Corresponds with "subjectPublicKeyInfo" from RFC 5280: |
155 // subjectPublicKeyInfo SubjectPublicKeyInfo, | 170 // subjectPublicKeyInfo SubjectPublicKeyInfo, |
(...skipping 30 matching lines...) Expand all Loading... | |
186 // EXPLICIT outter tag was stripped). | 201 // EXPLICIT outter tag was stripped). |
187 // | 202 // |
188 // Parsing guarantees that if extensions is present the version is v3. | 203 // Parsing guarantees that if extensions is present the version is v3. |
189 bool has_extensions; | 204 bool has_extensions; |
190 der::Input extensions_tlv; | 205 der::Input extensions_tlv; |
191 }; | 206 }; |
192 | 207 |
193 } // namespace net | 208 } // namespace net |
194 | 209 |
195 #endif // NET_CERT_INTERNAL_PARSE_CERTIFICATE_H_ | 210 #endif // NET_CERT_INTERNAL_PARSE_CERTIFICATE_H_ |
OLD | NEW |