| 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 207   // | 207   // | 
| 208   // This contains the full (unverified) Tag-Length-Value for a SEQUENCE. No | 208   // This contains the full (unverified) Tag-Length-Value for a SEQUENCE. No | 
| 209   // guarantees are made regarding the value of this SEQUENCE. (Note that the | 209   // guarantees are made regarding the value of this SEQUENCE. (Note that the | 
| 210   // EXPLICIT outer tag is stripped.) | 210   // EXPLICIT outer tag is stripped.) | 
| 211   // | 211   // | 
| 212   // Parsing guarantees that if extensions is present the version is v3. | 212   // Parsing guarantees that if extensions is present the version is v3. | 
| 213   bool has_extensions = false; | 213   bool has_extensions = false; | 
| 214   der::Input extensions_tlv; | 214   der::Input extensions_tlv; | 
| 215 }; | 215 }; | 
| 216 | 216 | 
|  | 217 // ParsedExtension represents a parsed "Extension" from RFC 5280. It contains | 
|  | 218 // der:Inputs which are not owned so the associated data must be kept alive. | 
|  | 219 // | 
|  | 220 //    Extension  ::=  SEQUENCE  { | 
|  | 221 //            extnID      OBJECT IDENTIFIER, | 
|  | 222 //            critical    BOOLEAN DEFAULT FALSE, | 
|  | 223 //            extnValue   OCTET STRING | 
|  | 224 //                        -- contains the DER encoding of an ASN.1 value | 
|  | 225 //                        -- corresponding to the extension type identified | 
|  | 226 //                        -- by extnID | 
|  | 227 //            } | 
|  | 228 struct NET_EXPORT ParsedExtension { | 
|  | 229   der::Input oid; | 
|  | 230   // |value| will contain the contents of the OCTET STRING. For instance for | 
|  | 231   // basicConstraints it will be the TLV for a SEQUENCE. | 
|  | 232   der::Input value; | 
|  | 233   bool critical = false; | 
|  | 234 }; | 
|  | 235 | 
|  | 236 // Parses a DER-encoded "Extension" as specified by RFC 5280. Returns true on | 
|  | 237 // success and sets the results in |out|. | 
|  | 238 // | 
|  | 239 // Note that on success |out| aliases data from the input |extension_tlv|. | 
|  | 240 // Hence the fields of the ParsedExtension are only valid as long as | 
|  | 241 // |extension_tlv| remains valid. | 
|  | 242 // | 
|  | 243 // On failure |out| has an undefined state. Some of its fields may have been | 
|  | 244 // updated during parsing, whereas others may not have been changed. | 
|  | 245 NET_EXPORT bool ParseExtension(const der::Input& extension_tlv, | 
|  | 246                                ParsedExtension* out) WARN_UNUSED_RESULT; | 
|  | 247 | 
| 217 }  // namespace net | 248 }  // namespace net | 
| 218 | 249 | 
| 219 #endif  // NET_CERT_INTERNAL_PARSE_CERTIFICATE_H_ | 250 #endif  // NET_CERT_INTERNAL_PARSE_CERTIFICATE_H_ | 
| OLD | NEW | 
|---|