x509asn1.h 2.9 KB

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