2
0

x509asn1.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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_GNUTLS) || defined(USE_WOLFSSL) || \
  28. defined(USE_SCHANNEL) || defined(USE_SECTRANSP) || \
  29. defined(USE_MBEDTLS)
  30. #include "cfilters.h"
  31. #include "urldata.h"
  32. /*
  33. * Types.
  34. */
  35. /* ASN.1 parsed element. */
  36. struct Curl_asn1Element {
  37. const char *header; /* Pointer to header byte. */
  38. const char *beg; /* Pointer to element data. */
  39. const char *end; /* Pointer to 1st byte after element. */
  40. unsigned char class; /* ASN.1 element class. */
  41. unsigned char tag; /* ASN.1 element tag. */
  42. bool constructed; /* Element is constructed. */
  43. };
  44. /* X509 certificate: RFC 5280. */
  45. struct Curl_X509certificate {
  46. struct Curl_asn1Element certificate;
  47. struct Curl_asn1Element version;
  48. struct Curl_asn1Element serialNumber;
  49. struct Curl_asn1Element signatureAlgorithm;
  50. struct Curl_asn1Element signature;
  51. struct Curl_asn1Element issuer;
  52. struct Curl_asn1Element notBefore;
  53. struct Curl_asn1Element notAfter;
  54. struct Curl_asn1Element subject;
  55. struct Curl_asn1Element subjectPublicKeyInfo;
  56. struct Curl_asn1Element subjectPublicKeyAlgorithm;
  57. struct Curl_asn1Element subjectPublicKey;
  58. struct Curl_asn1Element issuerUniqueID;
  59. struct Curl_asn1Element subjectUniqueID;
  60. struct Curl_asn1Element extensions;
  61. };
  62. /*
  63. * Prototypes.
  64. */
  65. int Curl_parseX509(struct Curl_X509certificate *cert,
  66. const char *beg, const char *end);
  67. CURLcode Curl_extract_certinfo(struct Curl_easy *data, int certnum,
  68. const char *beg, const char *end);
  69. CURLcode Curl_verifyhost(struct Curl_cfilter *cf, struct Curl_easy *data,
  70. const char *beg, const char *end);
  71. #ifdef UNITTESTS
  72. #if defined(USE_GNUTLS) || defined(USE_SCHANNEL) || defined(USE_SECTRANSP) || \
  73. defined(USE_MBEDTLS)
  74. /* used by unit1656.c */
  75. CURLcode Curl_x509_GTime2str(struct dynbuf *store,
  76. const char *beg, const char *end);
  77. #endif
  78. #endif
  79. #endif /* USE_GNUTLS or USE_WOLFSSL or USE_SCHANNEL or USE_SECTRANSP */
  80. #endif /* HEADER_CURL_X509ASN1_H */