vtls.h
Go to the documentation of this file.
1 #ifndef HEADER_CURL_VTLS_H
2 #define HEADER_CURL_VTLS_H
3 /***************************************************************************
4  * _ _ ____ _
5  * Project ___| | | | _ \| |
6  * / __| | | | |_) | |
7  * | (__| |_| | _ <| |___
8  * \___|\___/|_| \_\_____|
9  *
10  * Copyright (C) 1998 - 2017, 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.haxx.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  ***************************************************************************/
24 #include "curl_setup.h"
25 
26 struct connectdata;
27 struct ssl_connect_data;
28 
29 struct Curl_ssl {
30  /*
31  * This *must* be the first entry to allow returning the list of available
32  * backends in curl_global_sslset().
33  */
35 
36  unsigned have_ca_path:1; /* supports CAPATH */
37  unsigned have_certinfo:1; /* supports CURLOPT_CERTINFO */
38  unsigned have_pinnedpubkey:1; /* supports CURLOPT_PINNEDPUBLICKEY */
39  unsigned have_ssl_ctx:1; /* supports CURLOPT_SSL_CTX_* */
40 
41  unsigned support_https_proxy:1; /* supports access via HTTPS proxies */
42 
44 
45  int (*init)(void);
46  void (*cleanup)(void);
47 
48  size_t (*version)(char *buffer, size_t size);
49  int (*check_cxn)(struct connectdata *cxn);
50  int (*shutdown)(struct connectdata *conn, int sockindex);
51  bool (*data_pending)(const struct connectdata *conn,
52  int connindex);
53 
54  /* return 0 if a find random is filled in */
55  CURLcode (*random)(struct Curl_easy *data, unsigned char *entropy,
56  size_t length);
58 
59  CURLcode (*connect)(struct connectdata *conn, int sockindex);
60  CURLcode (*connect_nonblocking)(struct connectdata *conn, int sockindex,
61  bool *done);
62  void *(*get_internals)(struct ssl_connect_data *connssl, CURLINFO info);
63  void (*close)(struct connectdata *conn, int sockindex);
64  void (*close_all)(struct Curl_easy *data);
65  void (*session_free)(void *ptr);
66 
67  CURLcode (*set_engine)(struct Curl_easy *data, const char *engine);
69  struct curl_slist *(*engines_list)(struct Curl_easy *data);
70 
71  bool (*false_start)(void);
72 
73  CURLcode (*md5sum)(unsigned char *input, size_t inputlen,
74  unsigned char *md5sum, size_t md5sumlen);
75  void (*sha256sum)(const unsigned char *input, size_t inputlen,
76  unsigned char *sha256sum, size_t sha256sumlen);
77 };
78 
79 #ifdef USE_SSL
80 extern const struct Curl_ssl *Curl_ssl;
81 #endif
82 
83 int Curl_none_init(void);
84 void Curl_none_cleanup(void);
85 int Curl_none_shutdown(struct connectdata *conn, int sockindex);
86 int Curl_none_check_cxn(struct connectdata *conn);
87 CURLcode Curl_none_random(struct Curl_easy *data, unsigned char *entropy,
88  size_t length);
89 void Curl_none_close_all(struct Curl_easy *data);
90 void Curl_none_session_free(void *ptr);
91 bool Curl_none_data_pending(const struct connectdata *conn, int connindex);
93 CURLcode Curl_none_set_engine(struct Curl_easy *data, const char *engine);
96 bool Curl_none_false_start(void);
97 CURLcode Curl_none_md5sum(unsigned char *input, size_t inputlen,
98  unsigned char *md5sum, size_t md5len);
99 
100 #include "openssl.h" /* OpenSSL versions */
101 #include "gtls.h" /* GnuTLS versions */
102 #include "nssg.h" /* NSS versions */
103 #include "gskit.h" /* Global Secure ToolKit versions */
104 #include "polarssl.h" /* PolarSSL versions */
105 #include "axtls.h" /* axTLS versions */
106 #include "cyassl.h" /* CyaSSL versions */
107 #include "schannel.h" /* Schannel SSPI version */
108 #include "darwinssl.h" /* SecureTransport (Darwin) version */
109 #include "mbedtls.h" /* mbedTLS versions */
110 
111 #ifndef MAX_PINNED_PUBKEY_SIZE
112 #define MAX_PINNED_PUBKEY_SIZE 1048576 /* 1MB */
113 #endif
114 
115 #ifndef MD5_DIGEST_LENGTH
116 #define MD5_DIGEST_LENGTH 16 /* fixed size */
117 #endif
118 
119 #ifndef CURL_SHA256_DIGEST_LENGTH
120 #define CURL_SHA256_DIGEST_LENGTH 32 /* fixed size */
121 #endif
122 
123 /* see https://tools.ietf.org/html/draft-ietf-tls-applayerprotoneg-04 */
124 #define ALPN_HTTP_1_1_LENGTH 8
125 #define ALPN_HTTP_1_1 "http/1.1"
126 
127 /* set of helper macros for the backends to access the correct fields. For the
128  proxy or for the remote host - to properly support HTTPS proxy */
129 
130 #define SSL_IS_PROXY() (CURLPROXY_HTTPS == conn->http_proxy.proxytype && \
131  ssl_connection_complete != conn->proxy_ssl[conn->sock[SECONDARYSOCKET] == \
132  CURL_SOCKET_BAD ? FIRSTSOCKET : SECONDARYSOCKET].state)
133 #define SSL_SET_OPTION(var) (SSL_IS_PROXY() ? data->set.proxy_ssl.var : \
134  data->set.ssl.var)
135 #define SSL_CONN_CONFIG(var) (SSL_IS_PROXY() ? \
136  conn->proxy_ssl_config.var : conn->ssl_config.var)
137 
139  struct ssl_primary_config* needle);
141  struct ssl_primary_config *dest);
143 int Curl_ssl_getsock(struct connectdata *conn, curl_socket_t *socks,
144  int numsocks);
145 
146 int Curl_ssl_backend(void);
147 
148 #ifdef USE_SSL
149 int Curl_ssl_init(void);
150 void Curl_ssl_cleanup(void);
151 CURLcode Curl_ssl_connect(struct connectdata *conn, int sockindex);
153  int sockindex,
154  bool *done);
155 /* tell the SSL stuff to close down all open information regarding
156  connections (and thus session ID caching etc) */
157 void Curl_ssl_close_all(struct Curl_easy *data);
158 void Curl_ssl_close(struct connectdata *conn, int sockindex);
159 CURLcode Curl_ssl_shutdown(struct connectdata *conn, int sockindex);
160 CURLcode Curl_ssl_set_engine(struct Curl_easy *data, const char *engine);
161 /* Sets engine as default for all SSL operations */
164 
165 /* init the SSL session ID cache */
166 CURLcode Curl_ssl_initsessions(struct Curl_easy *, size_t);
167 size_t Curl_ssl_version(char *buffer, size_t size);
168 bool Curl_ssl_data_pending(const struct connectdata *conn,
169  int connindex);
170 int Curl_ssl_check_cxn(struct connectdata *conn);
171 
172 /* Certificate information list handling. */
173 
175 CURLcode Curl_ssl_init_certinfo(struct Curl_easy *data, int num);
176 CURLcode Curl_ssl_push_certinfo_len(struct Curl_easy *data, int certnum,
177  const char *label, const char *value,
178  size_t valuelen);
179 CURLcode Curl_ssl_push_certinfo(struct Curl_easy *data, int certnum,
180  const char *label, const char *value);
181 
182 /* Functions to be used by SSL library adaptation functions */
183 
184 /* Lock session cache mutex.
185  * Call this before calling other Curl_ssl_*session* functions
186  * Caller should unlock this mutex as soon as possible, as it may block
187  * other SSL connection from making progress.
188  * The purpose of explicitly locking SSL session cache data is to allow
189  * individual SSL engines to manage session lifetime in their specific way.
190  */
191 void Curl_ssl_sessionid_lock(struct connectdata *conn);
192 
193 /* Unlock session cache mutex */
194 void Curl_ssl_sessionid_unlock(struct connectdata *conn);
195 
196 /* extract a session ID
197  * Sessionid mutex must be locked (see Curl_ssl_sessionid_lock).
198  * Caller must make sure that the ownership of returned sessionid object
199  * is properly taken (e.g. its refcount is incremented
200  * under sessionid mutex).
201  */
202 bool Curl_ssl_getsessionid(struct connectdata *conn,
203  void **ssl_sessionid,
204  size_t *idsize, /* set 0 if unknown */
205  int sockindex);
206 /* add a new session ID
207  * Sessionid mutex must be locked (see Curl_ssl_sessionid_lock).
208  * Caller must ensure that it has properly shared ownership of this sessionid
209  * object with cache (e.g. incrementing refcount on success)
210  */
211 CURLcode Curl_ssl_addsessionid(struct connectdata *conn,
212  void *ssl_sessionid,
213  size_t idsize,
214  int sockindex);
215 /* Kill a single session ID entry in the cache
216  * Sessionid mutex must be locked (see Curl_ssl_sessionid_lock).
217  * This will call engine-specific curlssl_session_free function, which must
218  * take sessionid object ownership from sessionid cache
219  * (e.g. decrement refcount).
220  */
221 void Curl_ssl_kill_session(struct curl_ssl_session *session);
222 /* delete a session from the cache
223  * Sessionid mutex must be locked (see Curl_ssl_sessionid_lock).
224  * This will call engine-specific curlssl_session_free function, which must
225  * take sessionid object ownership from sessionid cache
226  * (e.g. decrement refcount).
227  */
228 void Curl_ssl_delsessionid(struct connectdata *conn, void *ssl_sessionid);
229 
230 /* get N random bytes into the buffer */
231 CURLcode Curl_ssl_random(struct Curl_easy *data, unsigned char *buffer,
232  size_t length);
233 CURLcode Curl_ssl_md5sum(unsigned char *tmp, /* input */
234  size_t tmplen,
235  unsigned char *md5sum, /* output */
236  size_t md5len);
237 /* Check pinned public key. */
238 CURLcode Curl_pin_peer_pubkey(struct Curl_easy *data,
239  const char *pinnedpubkey,
240  const unsigned char *pubkey, size_t pubkeylen);
241 
243 
244 bool Curl_ssl_false_start(void);
245 
246 #define SSL_SHUTDOWN_TIMEOUT 10000 /* ms */
247 
248 #else
249 
250 /* When SSL support is not present, just define away these function calls */
251 #define Curl_ssl_init() 1
252 #define Curl_ssl_cleanup() Curl_nop_stmt
253 #define Curl_ssl_connect(x,y) CURLE_NOT_BUILT_IN
254 #define Curl_ssl_close_all(x) Curl_nop_stmt
255 #define Curl_ssl_close(x,y) Curl_nop_stmt
256 #define Curl_ssl_shutdown(x,y) CURLE_NOT_BUILT_IN
257 #define Curl_ssl_set_engine(x,y) CURLE_NOT_BUILT_IN
258 #define Curl_ssl_set_engine_default(x) CURLE_NOT_BUILT_IN
259 #define Curl_ssl_engines_list(x) NULL
260 #define Curl_ssl_send(a,b,c,d,e) -1
261 #define Curl_ssl_recv(a,b,c,d,e) -1
262 #define Curl_ssl_initsessions(x,y) CURLE_OK
263 #define Curl_ssl_version(x,y) 0
264 #define Curl_ssl_data_pending(x,y) 0
265 #define Curl_ssl_check_cxn(x) 0
266 #define Curl_ssl_free_certinfo(x) Curl_nop_stmt
267 #define Curl_ssl_connect_nonblocking(x,y,z) CURLE_NOT_BUILT_IN
268 #define Curl_ssl_kill_session(x) Curl_nop_stmt
269 #define Curl_ssl_random(x,y,z) ((void)x, CURLE_NOT_BUILT_IN)
270 #define Curl_ssl_cert_status_request() FALSE
271 #define Curl_ssl_false_start() FALSE
272 #endif
273 
274 #endif /* HEADER_CURL_VTLS_H */
#define Curl_ssl_random(x, y, z)
Definition: vtls.h:269
unsigned have_pinnedpubkey
Definition: vtls.h:38
unsigned have_certinfo
Definition: vtls.h:37
Definition: vtls.h:29
int Curl_none_init(void)
CURLcode(* set_engine)(struct Curl_easy *data, const char *engine)
Definition: vtls.h:67
void Curl_none_session_free(void *ptr)
CURLcode(* connect)(struct connectdata *conn, int sockindex)
Definition: vtls.h:59
UNITTEST_START char * ptr
Definition: unit1330.c:38
CURLcode
Definition: curl.h:454
#define Curl_ssl_close(x, y)
Definition: vtls.h:255
#define Curl_ssl_set_engine_default(x)
Definition: vtls.h:258
CURLINFO
Definition: curl.h:2439
int Curl_none_shutdown(struct connectdata *conn, int sockindex)
bool Curl_none_data_pending(const struct connectdata *conn, int connindex)
#define Curl_ssl_connect(x, y)
Definition: vtls.h:253
#define Curl_ssl_connect_nonblocking(x, y, z)
Definition: vtls.h:267
CURLcode(* random)(struct Curl_easy *data, unsigned char *entropy, size_t length)
Definition: vtls.h:55
unsigned have_ca_path
Definition: vtls.h:36
char buffer[]
Definition: unit1308.c:48
bool(* false_start)(void)
Definition: vtls.h:71
#define Curl_ssl_data_pending(x, y)
Definition: vtls.h:264
#define Curl_ssl_shutdown(x, y)
Definition: vtls.h:256
bool Curl_ssl_config_matches(struct ssl_primary_config *data, struct ssl_primary_config *needle)
Definition: vtls.c:86
CURLcode Curl_none_random(struct Curl_easy *data, unsigned char *entropy, size_t length)
int Curl_none_check_cxn(struct connectdata *conn)
#define Curl_ssl_engines_list(x)
Definition: vtls.h:259
CURLcode(* set_engine_default)(struct Curl_easy *data)
Definition: vtls.h:68
void(* session_free)(void *ptr)
Definition: vtls.h:65
bool(* data_pending)(const struct connectdata *conn, int connindex)
Definition: vtls.h:51
curl_easy_setopt expects a curl_off_t argument for this option curl_easy_setopt expects a curl_write_callback argument for this option curl_easy_setopt expects a curl_ioctl_callback argument for this option curl_easy_setopt expects a curl_opensocket_callback argument for this option curl_easy_setopt expects a curl_debug_callback argument for this option curl_easy_setopt expects a curl_conv_callback argument for this option curl_easy_setopt expects a private data pointer as argument for this option curl_easy_setopt expects a FILE *argument for this option curl_easy_setopt expects a struct curl_httppost *argument for this option curl_easy_setopt expects a struct curl_slist *argument for this option curl_easy_getinfo expects a pointer to char *for this info curl_easy_getinfo expects a pointer to double for this info curl_easy_getinfo expects a pointer to struct curl_tlssessioninfo *for this info curl_easy_getinfo expects a pointer to curl_socket_t for this info size_t
CURLcode(* connect_nonblocking)(struct connectdata *conn, int sockindex, bool *done)
Definition: vtls.h:60
bool Curl_none_false_start(void)
#define Curl_ssl_version(x, y)
Definition: vtls.h:263
bool Curl_none_cert_status_request(void)
#define Curl_ssl_check_cxn(x)
Definition: vtls.h:265
UNITTEST_START struct Curl_easy data
Definition: unit1399.c:82
#define Curl_ssl_initsessions(x, y)
Definition: vtls.h:262
void Curl_none_cleanup(void)
CURLcode(* md5sum)(unsigned char *input, size_t inputlen, unsigned char *md5sum, size_t md5sumlen)
Definition: vtls.h:73
void(* close_all)(struct Curl_easy *data)
Definition: vtls.h:64
int Curl_ssl_backend(void)
Definition: vtls.c:140
int(* check_cxn)(struct connectdata *cxn)
Definition: vtls.h:49
CURLcode Curl_none_md5sum(unsigned char *input, size_t inputlen, unsigned char *md5sum, size_t md5len)
#define Curl_ssl_cleanup()
Definition: vtls.h:252
unsigned support_https_proxy
Definition: vtls.h:41
bool Curl_clone_primary_ssl_config(struct ssl_primary_config *source, struct ssl_primary_config *dest)
Definition: vtls.c:106
CURLcode Curl_none_set_engine(struct Curl_easy *data, const char *engine)
int Curl_ssl_getsock(struct connectdata *conn, curl_socket_t *socks, int numsocks)
void Curl_free_primary_ssl_config(struct ssl_primary_config *sslc)
Definition: vtls.c:126
#define Curl_ssl_init()
Definition: vtls.h:251
#define Curl_ssl_set_engine(x, y)
Definition: vtls.h:257
struct curl_slist * Curl_none_engines_list(struct Curl_easy *data)
#define Curl_ssl_kill_session(x)
Definition: vtls.h:268
UNITTEST_START int * value
Definition: unit1602.c:51
#define Curl_ssl_cert_status_request()
Definition: vtls.h:270
int(* shutdown)(struct connectdata *conn, int sockindex)
Definition: vtls.h:50
TFSIMD_FORCE_INLINE tfScalar length(const Quaternion &q)
void(* close)(struct connectdata *conn, int sockindex)
Definition: vtls.h:63
unsigned have_ssl_ctx
Definition: vtls.h:39
int(* init)(void)
Definition: vtls.h:45
size_t size
Definition: unit1302.c:52
void(* cleanup)(void)
Definition: vtls.h:46
size_t sizeof_ssl_backend_data
Definition: vtls.h:43
curl_ssl_backend info
Definition: vtls.h:34
#define Curl_ssl_free_certinfo(x)
Definition: vtls.h:266
#define Curl_ssl_false_start()
Definition: vtls.h:271
int curl_socket_t
Definition: curl.h:130
bool(* cert_status_request)(void)
Definition: vtls.h:57
CURLcode Curl_none_set_engine_default(struct Curl_easy *data)
Definition: debug.c:29
void Curl_none_close_all(struct Curl_easy *data)
size_t(* version)(char *buffer, size_t size)
Definition: vtls.h:48
#define Curl_ssl_close_all(x)
Definition: vtls.h:254
void(* sha256sum)(const unsigned char *input, size_t inputlen, unsigned char *sha256sum, size_t sha256sumlen)
Definition: vtls.h:75


rc_tagdetect_client
Author(s): Monika Florek-Jasinska , Raphael Schaller
autogenerated on Sat Feb 13 2021 03:42:17