gtls.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 ssl_connect_data;
  44. struct gtls_shared_creds {
  45. gnutls_certificate_credentials_t creds;
  46. char *CAfile; /* CAfile path used to generate X509 store */
  47. struct curltime time; /* when the shared creds was created */
  48. size_t refcount;
  49. BIT(trust_setup); /* x509 anchors + CRLs have been set up */
  50. };
  51. CURLcode Curl_gtls_shared_creds_create(struct Curl_easy *data,
  52. struct gtls_shared_creds **pcreds);
  53. CURLcode Curl_gtls_shared_creds_up_ref(struct gtls_shared_creds *creds);
  54. void Curl_gtls_shared_creds_free(struct gtls_shared_creds **pcreds);
  55. struct gtls_ctx {
  56. gnutls_session_t session;
  57. struct gtls_shared_creds *shared_creds;
  58. #ifdef USE_GNUTLS_SRP
  59. gnutls_srp_client_credentials_t srp_client_cred;
  60. #endif
  61. CURLcode io_result; /* result of last IO cfilter operation */
  62. BIT(sent_shutdown);
  63. };
  64. typedef CURLcode Curl_gtls_ctx_setup_cb(struct Curl_cfilter *cf,
  65. struct Curl_easy *data,
  66. void *user_data);
  67. CURLcode Curl_gtls_ctx_init(struct gtls_ctx *gctx,
  68. struct Curl_cfilter *cf,
  69. struct Curl_easy *data,
  70. struct ssl_peer *peer,
  71. const unsigned char *alpn, size_t alpn_len,
  72. struct ssl_connect_data *connssl,
  73. Curl_gtls_ctx_setup_cb *cb_setup,
  74. void *cb_user_data,
  75. void *ssl_user_data);
  76. CURLcode Curl_gtls_client_trust_setup(struct Curl_cfilter *cf,
  77. struct Curl_easy *data,
  78. struct gtls_ctx *gtls);
  79. CURLcode Curl_gtls_verifyserver(struct Curl_easy *data,
  80. gnutls_session_t session,
  81. struct ssl_primary_config *config,
  82. struct ssl_config_data *ssl_config,
  83. struct ssl_peer *peer,
  84. const char *pinned_key);
  85. /* Extract TLS session and place in cache, if configured. */
  86. CURLcode Curl_gtls_update_session_id(struct Curl_cfilter *cf,
  87. struct Curl_easy *data,
  88. gnutls_session_t session,
  89. struct ssl_peer *peer,
  90. const char *alpn);
  91. extern const struct Curl_ssl Curl_ssl_gnutls;
  92. #endif /* USE_GNUTLS */
  93. #endif /* HEADER_CURL_GTLS_H */