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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 // is unique. Note that certificate verification must consume each extension | 317 // is unique. Note that certificate verification must consume each extension |
318 // marked as critical. | 318 // marked as critical. |
319 // | 319 // |
320 // Returns true on success and fills |extensions|. The output will reference | 320 // Returns true on success and fills |extensions|. The output will reference |
321 // bytes in |extensions_tlv|, so that data must be kept alive. | 321 // bytes in |extensions_tlv|, so that data must be kept alive. |
322 // On failure |extensions| may be partially written to and should not be used. | 322 // On failure |extensions| may be partially written to and should not be used. |
323 NET_EXPORT bool ParseExtensions( | 323 NET_EXPORT bool ParseExtensions( |
324 const der::Input& extensions_tlv, | 324 const der::Input& extensions_tlv, |
325 std::map<der::Input, ParsedExtension>* extensions) WARN_UNUSED_RESULT; | 325 std::map<der::Input, ParsedExtension>* extensions) WARN_UNUSED_RESULT; |
326 | 326 |
| 327 // Removes the extension with OID |oid| from |unconsumed_extensions| and fills |
| 328 // |extension| with the matching extension value. If there was no extension |
| 329 // matching |oid| then returns |false|. |
| 330 NET_EXPORT bool ConsumeExtension( |
| 331 const der::Input& oid, |
| 332 std::map<der::Input, ParsedExtension>* unconsumed_extensions, |
| 333 ParsedExtension* extension) WARN_UNUSED_RESULT; |
| 334 |
327 struct ParsedBasicConstraints { | 335 struct ParsedBasicConstraints { |
328 bool is_ca = false; | 336 bool is_ca = false; |
329 bool has_path_len = false; | 337 bool has_path_len = false; |
330 uint8_t path_len = 0; | 338 uint8_t path_len = 0; |
331 }; | 339 }; |
332 | 340 |
333 // Parses the BasicConstraints extension as defined by RFC 5280: | 341 // Parses the BasicConstraints extension as defined by RFC 5280: |
334 // | 342 // |
335 // BasicConstraints ::= SEQUENCE { | 343 // BasicConstraints ::= SEQUENCE { |
336 // cA BOOLEAN DEFAULT FALSE, | 344 // cA BOOLEAN DEFAULT FALSE, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 // be set. | 387 // be set. |
380 // | 388 // |
381 // To test if a particular key usage is set, call, e.g.: | 389 // To test if a particular key usage is set, call, e.g.: |
382 // key_usage->AssertsBit(KEY_USAGE_BIT_DIGITAL_SIGNATURE); | 390 // key_usage->AssertsBit(KEY_USAGE_BIT_DIGITAL_SIGNATURE); |
383 NET_EXPORT bool ParseKeyUsage(const der::Input& key_usage_tlv, | 391 NET_EXPORT bool ParseKeyUsage(const der::Input& key_usage_tlv, |
384 der::BitString* key_usage) WARN_UNUSED_RESULT; | 392 der::BitString* key_usage) WARN_UNUSED_RESULT; |
385 | 393 |
386 } // namespace net | 394 } // namespace net |
387 | 395 |
388 #endif // NET_CERT_INTERNAL_PARSE_CERTIFICATE_H_ | 396 #endif // NET_CERT_INTERNAL_PARSE_CERTIFICATE_H_ |
OLD | NEW |