• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef HEADER_CURL_X509ASN1_H
2 #define HEADER_CURL_X509ASN1_H
3 
4 /***************************************************************************
5  *                                  _   _ ____  _
6  *  Project                     ___| | | |  _ \| |
7  *                             / __| | | | |_) | |
8  *                            | (__| |_| |  _ <| |___
9  *                             \___|\___/|_| \_\_____|
10  *
11  * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
12  *
13  * This software is licensed as described in the file COPYING, which
14  * you should have received as part of this distribution. The terms
15  * are also available at https://curl.se/docs/copyright.html.
16  *
17  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
18  * copies of the Software, and permit persons to whom the Software is
19  * furnished to do so, under the terms of the COPYING file.
20  *
21  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
22  * KIND, either express or implied.
23  *
24  * SPDX-License-Identifier: curl
25  *
26  ***************************************************************************/
27 
28 #include "curl_setup.h"
29 
30 #if defined(USE_GSKIT) || defined(USE_NSS) || defined(USE_GNUTLS) || \
31     defined(USE_WOLFSSL) || defined(USE_SCHANNEL) || defined(USE_SECTRANSP)
32 
33 #include "cfilters.h"
34 #include "urldata.h"
35 
36 /*
37  * Types.
38  */
39 
40 /* ASN.1 parsed element. */
41 struct Curl_asn1Element {
42   const char *header;         /* Pointer to header byte. */
43   const char *beg;            /* Pointer to element data. */
44   const char *end;            /* Pointer to 1st byte after element. */
45   unsigned char class;        /* ASN.1 element class. */
46   unsigned char tag;          /* ASN.1 element tag. */
47   bool          constructed;  /* Element is constructed. */
48 };
49 
50 /* X509 certificate: RFC 5280. */
51 struct Curl_X509certificate {
52   struct Curl_asn1Element certificate;
53   struct Curl_asn1Element version;
54   struct Curl_asn1Element serialNumber;
55   struct Curl_asn1Element signatureAlgorithm;
56   struct Curl_asn1Element signature;
57   struct Curl_asn1Element issuer;
58   struct Curl_asn1Element notBefore;
59   struct Curl_asn1Element notAfter;
60   struct Curl_asn1Element subject;
61   struct Curl_asn1Element subjectPublicKeyInfo;
62   struct Curl_asn1Element subjectPublicKeyAlgorithm;
63   struct Curl_asn1Element subjectPublicKey;
64   struct Curl_asn1Element issuerUniqueID;
65   struct Curl_asn1Element subjectUniqueID;
66   struct Curl_asn1Element extensions;
67 };
68 
69 /*
70  * Prototypes.
71  */
72 
73 int Curl_parseX509(struct Curl_X509certificate *cert,
74                    const char *beg, const char *end);
75 CURLcode Curl_extract_certinfo(struct Curl_easy *data, int certnum,
76                                const char *beg, const char *end);
77 CURLcode Curl_verifyhost(struct Curl_cfilter *cf, struct Curl_easy *data,
78                          const char *beg, const char *end);
79 #endif /* USE_GSKIT or USE_NSS or USE_GNUTLS or USE_WOLFSSL or USE_SCHANNEL
80         * or USE_SECTRANSP */
81 #endif /* HEADER_CURL_X509ASN1_H */
82