gtls.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #ifndef HEADER_CURL_GTLS_H
  2. #define HEADER_CURL_GTLS_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. #include <curl/curl.h>
  28. #ifdef USE_GNUTLS
  29. #include <gnutls/gnutls.h>
  30. #include "timeval.h"
  31. #ifdef HAVE_GNUTLS_SRP
  32. /* the function exists */
  33. #ifdef USE_TLS_SRP
  34. /* the functionality is not disabled */
  35. #define USE_GNUTLS_SRP
  36. #endif
  37. #endif
  38. struct Curl_easy;
  39. struct Curl_cfilter;
  40. struct ssl_primary_config;
  41. struct ssl_config_data;
  42. struct ssl_peer;
  43. struct gtls_shared_creds {
  44. gnutls_certificate_credentials_t creds;
  45. char *CAfile; /* CAfile path used to generate X509 store */
  46. struct curltime time; /* when the shared creds was created */
  47. size_t refcount;
  48. BIT(trust_setup); /* x509 anchors + CRLs have been set up */
  49. };
  50. CURLcode Curl_gtls_shared_creds_create(struct Curl_easy *data,
  51. struct gtls_shared_creds **pcreds);
  52. CURLcode Curl_gtls_shared_creds_up_ref(struct gtls_shared_creds *creds);
  53. void Curl_gtls_shared_creds_free(struct gtls_shared_creds **pcreds);
  54. struct gtls_ctx {
  55. gnutls_session_t session;
  56. struct gtls_shared_creds *shared_creds;
  57. #ifdef USE_GNUTLS_SRP
  58. gnutls_srp_client_credentials_t srp_client_cred;
  59. #endif
  60. CURLcode io_result; /* result of last IO cfilter operation */
  61. BIT(sent_shutdown);
  62. };
  63. typedef CURLcode Curl_gtls_ctx_setup_cb(struct Curl_cfilter *cf,
  64. struct Curl_easy *data,
  65. void *user_data);
  66. CURLcode Curl_gtls_ctx_init(struct gtls_ctx *gctx,
  67. struct Curl_cfilter *cf,
  68. struct Curl_easy *data,
  69. struct ssl_peer *peer,
  70. const unsigned char *alpn, size_t alpn_len,
  71. Curl_gtls_ctx_setup_cb *cb_setup,
  72. void *cb_user_data,
  73. void *ssl_user_data);
  74. CURLcode Curl_gtls_client_trust_setup(struct Curl_cfilter *cf,
  75. struct Curl_easy *data,
  76. struct gtls_ctx *gtls);
  77. CURLcode Curl_gtls_verifyserver(struct Curl_easy *data,
  78. gnutls_session_t session,
  79. struct ssl_primary_config *config,
  80. struct ssl_config_data *ssl_config,
  81. struct ssl_peer *peer,
  82. const char *pinned_key);
  83. extern const struct Curl_ssl Curl_ssl_gnutls;
  84. #endif /* USE_GNUTLS */
  85. #endif /* HEADER_CURL_GTLS_H */