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