vquic-tls.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #ifndef HEADER_CURL_VQUIC_TLS_H
  2. #define HEADER_CURL_VQUIC_TLS_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 "bufq.h"
  28. #include "vtls/vtls.h"
  29. #include "vtls/openssl.h"
  30. #if defined(USE_HTTP3) && \
  31. (defined(USE_OPENSSL) || defined(USE_GNUTLS) || defined(USE_WOLFSSL))
  32. #include "vtls/wolfssl.h"
  33. struct ssl_peer;
  34. struct Curl_ssl_session;
  35. struct curl_tls_ctx {
  36. #ifdef USE_OPENSSL
  37. struct ossl_ctx ossl;
  38. #elif defined(USE_GNUTLS)
  39. struct gtls_ctx gtls;
  40. #elif defined(USE_WOLFSSL)
  41. struct wolfssl_ctx wssl;
  42. #endif
  43. };
  44. /**
  45. * Callback passed to `Curl_vquic_tls_init()` that can
  46. * do early initializations on the not otherwise configured TLS
  47. * instances created. This varies by TLS backend:
  48. * - openssl/wolfssl: SSL_CTX* has just been created
  49. * - gnutls: gtls_client_init() has run
  50. */
  51. typedef CURLcode Curl_vquic_tls_ctx_setup(struct Curl_cfilter *cf,
  52. struct Curl_easy *data,
  53. void *cb_user_data);
  54. typedef CURLcode Curl_vquic_session_reuse_cb(struct Curl_cfilter *cf,
  55. struct Curl_easy *data,
  56. struct Curl_ssl_session *scs,
  57. bool *do_early_data);
  58. /**
  59. * Initialize the QUIC TLS instances based of the SSL configurations
  60. * for the connection filter, transfer and peer.
  61. * @param ctx the TLS context to initialize
  62. * @param cf the connection filter involved
  63. * @param data the transfer involved
  64. * @param peer the peer that will be connected to
  65. * @param alpn the ALPN string in protocol format ((len+bytes+)+),
  66. * may be NULL
  67. * @param alpn_len the overall number of bytes in `alpn`
  68. * @param cb_setup optional callback for early TLS config
  69. * @param cb_user_data user_data param for callback
  70. * @param ssl_user_data optional pointer to set in TLS application context
  71. * @param session_reuse_cb callback to handle session reuse, signal early data
  72. */
  73. CURLcode Curl_vquic_tls_init(struct curl_tls_ctx *ctx,
  74. struct Curl_cfilter *cf,
  75. struct Curl_easy *data,
  76. struct ssl_peer *peer,
  77. const char *alpn, size_t alpn_len,
  78. Curl_vquic_tls_ctx_setup *cb_setup,
  79. void *cb_user_data,
  80. void *ssl_user_data,
  81. Curl_vquic_session_reuse_cb *session_reuse_cb);
  82. /**
  83. * Cleanup all data that has been initialized.
  84. */
  85. void Curl_vquic_tls_cleanup(struct curl_tls_ctx *ctx);
  86. CURLcode Curl_vquic_tls_before_recv(struct curl_tls_ctx *ctx,
  87. struct Curl_cfilter *cf,
  88. struct Curl_easy *data);
  89. /**
  90. * After the QUIC basic handshake has been, verify that the peer
  91. * (and its certificate) fulfill our requirements.
  92. */
  93. CURLcode Curl_vquic_tls_verify_peer(struct curl_tls_ctx *ctx,
  94. struct Curl_cfilter *cf,
  95. struct Curl_easy *data,
  96. struct ssl_peer *peer);
  97. #endif /* !USE_HTTP3 && (USE_OPENSSL || USE_GNUTLS || USE_WOLFSSL) */
  98. #endif /* HEADER_CURL_VQUIC_TLS_H */