VirtualBox

source: vbox/trunk/src/libs/curl-8.11.1/lib/vtls/vtls.h@ 108333

最後變更 在這個檔案從108333是 108048,由 vboxsync 提交於 7 週 前

curl-8.11.1: Applied and adjusted our curl changes to 8.7.1. jiraref:VBP-1535

  • 屬性 svn:eol-style 設為 native
檔案大小: 10.7 KB
 
1#ifndef HEADER_CURL_VTLS_H
2#define HEADER_CURL_VTLS_H
3/***************************************************************************
4 * _ _ ____ _
5 * Project ___| | | | _ \| |
6 * / __| | | | |_) | |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
9 *
10 * Copyright (C) Daniel Stenberg, <[email protected]>, 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
28struct connectdata;
29struct ssl_config_data;
30struct ssl_primary_config;
31struct Curl_ssl_session;
32
33#define SSLSUPP_CA_PATH (1<<0) /* supports CAPATH */
34#define SSLSUPP_CERTINFO (1<<1) /* supports CURLOPT_CERTINFO */
35#define SSLSUPP_PINNEDPUBKEY (1<<2) /* supports CURLOPT_PINNEDPUBLICKEY */
36#define SSLSUPP_SSL_CTX (1<<3) /* supports CURLOPT_SSL_CTX */
37#define SSLSUPP_HTTPS_PROXY (1<<4) /* supports access via HTTPS proxies */
38#define SSLSUPP_TLS13_CIPHERSUITES (1<<5) /* supports TLS 1.3 ciphersuites */
39#define SSLSUPP_CAINFO_BLOB (1<<6)
40#define SSLSUPP_ECH (1<<7)
41#define SSLSUPP_CA_CACHE (1<<8)
42#define SSLSUPP_CIPHER_LIST (1<<9) /* supports TLS 1.0-1.2 ciphersuites */
43
44#define ALPN_ACCEPTED "ALPN: server accepted "
45
46#define VTLS_INFOF_NO_ALPN \
47 "ALPN: server did not agree on a protocol. Uses default."
48#define VTLS_INFOF_ALPN_OFFER_1STR \
49 "ALPN: curl offers %s"
50#define VTLS_INFOF_ALPN_ACCEPTED \
51 ALPN_ACCEPTED "%.*s"
52
53#define VTLS_INFOF_NO_ALPN_DEFERRED \
54 "ALPN: deferred handshake for early data without specific protocol."
55#define VTLS_INFOF_ALPN_DEFERRED \
56 "ALPN: deferred handshake for early data using '%.*s'."
57
58/* Curl_multi SSL backend-specific data; declared differently by each SSL
59 backend */
60struct Curl_cfilter;
61
62CURLsslset Curl_init_sslset_nolock(curl_sslbackend id, const char *name,
63 const curl_ssl_backend ***avail);
64
65#ifndef MAX_PINNED_PUBKEY_SIZE
66#define MAX_PINNED_PUBKEY_SIZE 1048576 /* 1MB */
67#endif
68
69#ifndef CURL_SHA256_DIGEST_LENGTH
70#define CURL_SHA256_DIGEST_LENGTH 32 /* fixed size */
71#endif
72
73curl_sslbackend Curl_ssl_backend(void);
74
75/**
76 * Init ssl config for a new easy handle.
77 */
78void Curl_ssl_easy_config_init(struct Curl_easy *data);
79
80/**
81 * Init the `data->set.ssl` and `data->set.proxy_ssl` for
82 * connection matching use.
83 */
84CURLcode Curl_ssl_easy_config_complete(struct Curl_easy *data);
85
86/**
87 * Init SSL configs (main + proxy) for a new connection from the easy handle.
88 */
89CURLcode Curl_ssl_conn_config_init(struct Curl_easy *data,
90 struct connectdata *conn);
91
92/**
93 * Free allocated resources in SSL configs (main + proxy) for
94 * the given connection.
95 */
96void Curl_ssl_conn_config_cleanup(struct connectdata *conn);
97
98/**
99 * Return TRUE iff SSL configuration from `data` is functionally the
100 * same as the one on `candidate`.
101 * @param proxy match the proxy SSL config or the main one
102 */
103bool Curl_ssl_conn_config_match(struct Curl_easy *data,
104 struct connectdata *candidate,
105 bool proxy);
106
107/* Update certain connection SSL config flags after they have
108 * been changed on the easy handle. Will work for `verifypeer`,
109 * `verifyhost` and `verifystatus`. */
110void Curl_ssl_conn_config_update(struct Curl_easy *data, bool for_proxy);
111
112/**
113 * Init SSL peer information for filter. Can be called repeatedly.
114 */
115CURLcode Curl_ssl_peer_init(struct ssl_peer *peer,
116 struct Curl_cfilter *cf, int transport);
117/**
118 * Free all allocated data and reset peer information.
119 */
120void Curl_ssl_peer_cleanup(struct ssl_peer *peer);
121
122#ifdef USE_SSL
123int Curl_ssl_init(void);
124void Curl_ssl_cleanup(void);
125/* tell the SSL stuff to close down all open information regarding
126 connections (and thus session ID caching etc) */
127void Curl_ssl_close_all(struct Curl_easy *data);
128CURLcode Curl_ssl_set_engine(struct Curl_easy *data, const char *engine);
129/* Sets engine as default for all SSL operations */
130CURLcode Curl_ssl_set_engine_default(struct Curl_easy *data);
131struct curl_slist *Curl_ssl_engines_list(struct Curl_easy *data);
132
133/* init the SSL session ID cache */
134CURLcode Curl_ssl_initsessions(struct Curl_easy *, size_t);
135void Curl_ssl_version(char *buffer, size_t size);
136
137/* Certificate information list handling. */
138#define CURL_X509_STR_MAX 100000
139
140void Curl_ssl_free_certinfo(struct Curl_easy *data);
141CURLcode Curl_ssl_init_certinfo(struct Curl_easy *data, int num);
142CURLcode Curl_ssl_push_certinfo_len(struct Curl_easy *data, int certnum,
143 const char *label, const char *value,
144 size_t valuelen);
145CURLcode Curl_ssl_push_certinfo(struct Curl_easy *data, int certnum,
146 const char *label, const char *value);
147
148/* Functions to be used by SSL library adaptation functions */
149
150/* Lock session cache mutex.
151 * Call this before calling other Curl_ssl_*session* functions
152 * Caller should unlock this mutex as soon as possible, as it may block
153 * other SSL connection from making progress.
154 * The purpose of explicitly locking SSL session cache data is to allow
155 * individual SSL engines to manage session lifetime in their specific way.
156 */
157void Curl_ssl_sessionid_lock(struct Curl_easy *data);
158
159/* Unlock session cache mutex */
160void Curl_ssl_sessionid_unlock(struct Curl_easy *data);
161
162/* Kill a single session ID entry in the cache
163 * Sessionid mutex must be locked (see Curl_ssl_sessionid_lock).
164 * This will call engine-specific curlssl_session_free function, which must
165 * take sessionid object ownership from sessionid cache
166 * (e.g. decrement refcount).
167 */
168void Curl_ssl_kill_session(struct Curl_ssl_session *session);
169/* delete a session from the cache
170 * Sessionid mutex must be locked (see Curl_ssl_sessionid_lock).
171 * This will call engine-specific curlssl_session_free function, which must
172 * take sessionid object ownership from sessionid cache
173 * (e.g. decrement refcount).
174 */
175void Curl_ssl_delsessionid(struct Curl_easy *data, void *ssl_sessionid);
176
177/* get N random bytes into the buffer */
178CURLcode Curl_ssl_random(struct Curl_easy *data, unsigned char *buffer,
179 size_t length);
180/* Check pinned public key. */
181CURLcode Curl_pin_peer_pubkey(struct Curl_easy *data,
182 const char *pinnedpubkey,
183 const unsigned char *pubkey, size_t pubkeylen);
184
185bool Curl_ssl_cert_status_request(void);
186
187bool Curl_ssl_false_start(struct Curl_easy *data);
188
189/* The maximum size of the SSL channel binding is 85 bytes, as defined in
190 * RFC 5929, Section 4.1. The 'tls-server-end-point:' prefix is 21 bytes long,
191 * and SHA-512 is the longest supported hash algorithm, with a digest length of
192 * 64 bytes.
193 * The maximum size of the channel binding is therefore 21 + 64 = 85 bytes.
194 */
195#define SSL_CB_MAX_SIZE 85
196
197/* Return the tls-server-end-point channel binding, including the
198 * 'tls-server-end-point:' prefix.
199 * If successful, the data is written to the dynbuf, and CURLE_OK is returned.
200 * The dynbuf MUST HAVE a minimum toobig size of SSL_CB_MAX_SIZE.
201 * If the dynbuf is too small, CURLE_OUT_OF_MEMORY is returned.
202 * If channel binding is not supported, binding stays empty and CURLE_OK is
203 * returned.
204 */
205CURLcode Curl_ssl_get_channel_binding(struct Curl_easy *data, int sockindex,
206 struct dynbuf *binding);
207
208#define SSL_SHUTDOWN_TIMEOUT 10000 /* ms */
209
210CURLcode Curl_ssl_cfilter_add(struct Curl_easy *data,
211 struct connectdata *conn,
212 int sockindex);
213
214CURLcode Curl_cf_ssl_insert_after(struct Curl_cfilter *cf_at,
215 struct Curl_easy *data);
216
217CURLcode Curl_ssl_cfilter_remove(struct Curl_easy *data,
218 int sockindex, bool send_shutdown);
219
220#ifndef CURL_DISABLE_PROXY
221CURLcode Curl_cf_ssl_proxy_insert_after(struct Curl_cfilter *cf_at,
222 struct Curl_easy *data);
223#endif /* !CURL_DISABLE_PROXY */
224
225/**
226 * True iff the underlying SSL implementation supports the option.
227 * Option is one of the defined SSLSUPP_* values.
228 * `data` maybe NULL for the features of the default implementation.
229 */
230bool Curl_ssl_supports(struct Curl_easy *data, unsigned int ssl_option);
231
232/**
233 * Get the internal ssl instance (like OpenSSL's SSL*) from the filter
234 * chain at `sockindex` of type specified by `info`.
235 * For `n` == 0, the first active (top down) instance is returned.
236 * 1 gives the second active, etc.
237 * NULL is returned when no active SSL filter is present.
238 */
239void *Curl_ssl_get_internals(struct Curl_easy *data, int sockindex,
240 CURLINFO info, int n);
241
242/**
243 * Get the ssl_config_data in `data` that is relevant for cfilter `cf`.
244 */
245struct ssl_config_data *Curl_ssl_cf_get_config(struct Curl_cfilter *cf,
246 struct Curl_easy *data);
247
248/**
249 * Get the primary config relevant for the filter from its connection.
250 */
251struct ssl_primary_config *
252 Curl_ssl_cf_get_primary_config(struct Curl_cfilter *cf);
253
254extern struct Curl_cftype Curl_cft_ssl;
255#ifndef CURL_DISABLE_PROXY
256extern struct Curl_cftype Curl_cft_ssl_proxy;
257#endif
258
259#else /* if not USE_SSL */
260
261/* When SSL support is not present, just define away these function calls */
262#define Curl_ssl_init() 1
263#define Curl_ssl_cleanup() Curl_nop_stmt
264#define Curl_ssl_close_all(x) Curl_nop_stmt
265#define Curl_ssl_set_engine(x,y) CURLE_NOT_BUILT_IN
266#define Curl_ssl_set_engine_default(x) CURLE_NOT_BUILT_IN
267#define Curl_ssl_engines_list(x) NULL
268#define Curl_ssl_initsessions(x,y) CURLE_OK
269#define Curl_ssl_free_certinfo(x) Curl_nop_stmt
270#define Curl_ssl_kill_session(x) Curl_nop_stmt
271#define Curl_ssl_random(x,y,z) ((void)x, CURLE_NOT_BUILT_IN)
272#define Curl_ssl_cert_status_request() FALSE
273#define Curl_ssl_false_start(a) FALSE
274#define Curl_ssl_get_internals(a,b,c,d) NULL
275#define Curl_ssl_supports(a,b) FALSE
276#define Curl_ssl_cfilter_add(a,b,c) CURLE_NOT_BUILT_IN
277#define Curl_ssl_cfilter_remove(a,b,c) CURLE_OK
278#define Curl_ssl_cf_get_config(a,b) NULL
279#define Curl_ssl_cf_get_primary_config(a) NULL
280#endif
281
282#endif /* HEADER_CURL_VTLS_H */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette