| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_BASE_ASN1_UTIL_H_ | 5 #ifndef NET_BASE_ASN1_UTIL_H_ |
| 6 #define NET_BASE_ASN1_UTIL_H_ | 6 #define NET_BASE_ASN1_UTIL_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/string_piece.h" | 11 #include "base/string_piece.h" |
| 12 #include "net/base/net_api.h" | 12 #include "net/base/net_export.h" |
| 13 | 13 |
| 14 namespace net { | 14 namespace net { |
| 15 | 15 |
| 16 namespace asn1 { | 16 namespace asn1 { |
| 17 | 17 |
| 18 // These are the DER encodings of the tag byte for ASN.1 objects. | 18 // These are the DER encodings of the tag byte for ASN.1 objects. |
| 19 static const unsigned kBOOLEAN = 0x01; | 19 static const unsigned kBOOLEAN = 0x01; |
| 20 static const unsigned kINTEGER = 0x02; | 20 static const unsigned kINTEGER = 0x02; |
| 21 static const unsigned kOCTETSTRING = 0x04; | 21 static const unsigned kOCTETSTRING = 0x04; |
| 22 static const unsigned kOID = 0x06; | 22 static const unsigned kOID = 0x06; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 53 // | 53 // |
| 54 // If |tag_value & kOptional| is true then this function cannot distinguish | 54 // If |tag_value & kOptional| is true then this function cannot distinguish |
| 55 // between a missing optional element and an empty one. | 55 // between a missing optional element and an empty one. |
| 56 bool GetElement(base::StringPiece* in, | 56 bool GetElement(base::StringPiece* in, |
| 57 unsigned tag_value, | 57 unsigned tag_value, |
| 58 base::StringPiece* out); | 58 base::StringPiece* out); |
| 59 | 59 |
| 60 // ExtractSPKIFromDERCert parses the DER encoded certificate in |cert| and | 60 // ExtractSPKIFromDERCert parses the DER encoded certificate in |cert| and |
| 61 // extracts the bytes of the SubjectPublicKeyInfo. On successful return, | 61 // extracts the bytes of the SubjectPublicKeyInfo. On successful return, |
| 62 // |spki_out| is set to contain the SPKI, pointing into |cert|. | 62 // |spki_out| is set to contain the SPKI, pointing into |cert|. |
| 63 NET_TEST bool ExtractSPKIFromDERCert(base::StringPiece cert, | 63 NET_EXPORT_PRIVATE bool ExtractSPKIFromDERCert(base::StringPiece cert, |
| 64 base::StringPiece* spki_out); | 64 base::StringPiece* spki_out); |
| 65 | 65 |
| 66 // ExtractCRLURLsFromDERCert parses the DER encoded certificate in |cert| and | 66 // ExtractCRLURLsFromDERCert parses the DER encoded certificate in |cert| and |
| 67 // extracts the URL of each CRL. On successful return, the elements of | 67 // extracts the URL of each CRL. On successful return, the elements of |
| 68 // |urls_out| point into |cert|. | 68 // |urls_out| point into |cert|. |
| 69 // | 69 // |
| 70 // CRLs that only cover a subset of the reasons are omitted as the spec | 70 // CRLs that only cover a subset of the reasons are omitted as the spec |
| 71 // requires that at least one CRL be included that covers all reasons. | 71 // requires that at least one CRL be included that covers all reasons. |
| 72 // | 72 // |
| 73 // CRLs that use an alternative issuer are also omitted. | 73 // CRLs that use an alternative issuer are also omitted. |
| 74 // | 74 // |
| 75 // The nested set of GeneralNames is flattened into a single list because | 75 // The nested set of GeneralNames is flattened into a single list because |
| 76 // having several CRLs with one location is equivalent to having one CRL with | 76 // having several CRLs with one location is equivalent to having one CRL with |
| 77 // several locations as far as a CRL filter is concerned. | 77 // several locations as far as a CRL filter is concerned. |
| 78 NET_TEST bool ExtractCRLURLsFromDERCert( | 78 NET_EXPORT_PRIVATE bool ExtractCRLURLsFromDERCert( |
| 79 base::StringPiece cert, | 79 base::StringPiece cert, |
| 80 std::vector<base::StringPiece>* urls_out); | 80 std::vector<base::StringPiece>* urls_out); |
| 81 | 81 |
| 82 } // namespace asn1 | 82 } // namespace asn1 |
| 83 | 83 |
| 84 } // namespace net | 84 } // namespace net |
| 85 | 85 |
| 86 #endif // NET_BASE_ASN1_UTIL_H_ | 86 #endif // NET_BASE_ASN1_UTIL_H_ |
| OLD | NEW |