OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef NET_CERT_INTERNAL_PARSE_CERTIFICATE_H_ |
| 6 #define NET_CERT_INTERNAL_PARSE_CERTIFICATE_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" |
| 10 #include "net/base/net_export.h" |
| 11 #include "net/der/input.h" |
| 12 #include "net/der/parse_values.h" |
| 13 |
| 14 namespace net { |
| 15 |
| 16 struct ParsedCertificate; |
| 17 |
| 18 // Parses a DER-encoded "Certificate" as specified by RFC 5280. Returns true on |
| 19 // success and sets the results in |out|. |
| 20 // |
| 21 // Note that on success |out| aliases data from the input |certificate_tlv|. |
| 22 // Hence the fields of the ParsedCertificate are only valid as long as |
| 23 // |certificate_tlv| remains valid. |
| 24 // |
| 25 // On failure |out| has an undefined state. Some of its fields may have been |
| 26 // updated during parsing, whereas others were not changed. |
| 27 // |
| 28 // Refer to the per-field documention of the ParsedCertificate structure for |
| 29 // details on what validity checks parsing performs. |
| 30 // |
| 31 // Certificate ::= SEQUENCE { |
| 32 // tbsCertificate TBSCertificate, |
| 33 // signatureAlgorithm AlgorithmIdentifier, |
| 34 // signatureValue BIT STRING } |
| 35 NET_EXPORT bool ParseCertificate(const der::Input& certificate_tlv, |
| 36 ParsedCertificate* out) WARN_UNUSED_RESULT; |
| 37 |
| 38 // ParsedCertificate contains pointers to the main fields of a DER-encoded RFC |
| 39 // 5280 "Certificate". |
| 40 // |
| 41 // ParsedCertificate is expected to be filled by ParseCertificate(), so |
| 42 // subsequent field descriptions are in terms of what ParseCertificate() sets. |
| 43 struct NET_EXPORT ParsedCertificate { |
| 44 // Corresponds with "tbsCertificate" from RFC 5280: |
| 45 // tbsCertificate TBSCertificate, |
| 46 // |
| 47 // This contains the full (unverified) Tag-Length-Value for a SEQUENCE. No |
| 48 // guarantees are made regarding the value of this SEQUENCE. |
| 49 der::Input tbs_certificate_tlv; |
| 50 |
| 51 // Corresponds with "signatureAlgorithm" from RFC 5280: |
| 52 // signatureAlgorithm AlgorithmIdentifier, |
| 53 // |
| 54 // This contains the full (unverified) Tag-Length-Value for a SEQUENCE. No |
| 55 // guarantees are made regarding the value of this SEQUENCE. |
| 56 // |
| 57 // This can be further parsed using SignatureValue::CreateFromDer(). |
| 58 der::Input signature_algorithm_tlv; |
| 59 |
| 60 // Corresponds with "signatureValue" from RFC 5280: |
| 61 // signatureValue BIT STRING } |
| 62 // |
| 63 // Parsing guarantees that this is a valid BIT STRING. |
| 64 der::BitString signature_value; |
| 65 }; |
| 66 |
| 67 } // namespace net |
| 68 |
| 69 #endif // NET_CERT_INTERNAL_PARSE_CERTIFICATE_H_ |
OLD | NEW |