x509asn1.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #ifndef HEADER_CURL_X509ASN1_H
  2. #define HEADER_CURL_X509ASN1_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 1998 - 2022, 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 "urldata.h"
  30. /*
  31. * Types.
  32. */
  33. /* ASN.1 parsed element. */
  34. struct Curl_asn1Element {
  35. const char *header; /* Pointer to header byte. */
  36. const char *beg; /* Pointer to element data. */
  37. const char *end; /* Pointer to 1st byte after element. */
  38. unsigned char class; /* ASN.1 element class. */
  39. unsigned char tag; /* ASN.1 element tag. */
  40. bool constructed; /* Element is constructed. */
  41. };
  42. /* X509 certificate: RFC 5280. */
  43. struct Curl_X509certificate {
  44. struct Curl_asn1Element certificate;
  45. struct Curl_asn1Element version;
  46. struct Curl_asn1Element serialNumber;
  47. struct Curl_asn1Element signatureAlgorithm;
  48. struct Curl_asn1Element signature;
  49. struct Curl_asn1Element issuer;
  50. struct Curl_asn1Element notBefore;
  51. struct Curl_asn1Element notAfter;
  52. struct Curl_asn1Element subject;
  53. struct Curl_asn1Element subjectPublicKeyInfo;
  54. struct Curl_asn1Element subjectPublicKeyAlgorithm;
  55. struct Curl_asn1Element subjectPublicKey;
  56. struct Curl_asn1Element issuerUniqueID;
  57. struct Curl_asn1Element subjectUniqueID;
  58. struct Curl_asn1Element extensions;
  59. };
  60. /*
  61. * Prototypes.
  62. */
  63. int Curl_parseX509(struct Curl_X509certificate *cert,
  64. const char *beg, const char *end);
  65. CURLcode Curl_extract_certinfo(struct Curl_easy *data, int certnum,
  66. const char *beg, const char *end);
  67. CURLcode Curl_verifyhost(struct Curl_easy *data, struct connectdata *conn,
  68. const char *beg, const char *end);
  69. #endif /* USE_GSKIT or USE_NSS or USE_GNUTLS or USE_WOLFSSL or USE_SCHANNEL
  70. * or USE_SECTRANSP */
  71. #endif /* HEADER_CURL_X509ASN1_H */