1 #ifndef HEADER_CURL_VTLS_H
2 #define HEADER_CURL_VTLS_H
3 /***************************************************************************
5 * Project ___| | | | _ \| |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
10 * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
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.
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.
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
23 ***************************************************************************/
24 #include "curl_setup.h"
26 #include "openssl.h" /* OpenSSL versions */
27 #include "gtls.h" /* GnuTLS versions */
28 #include "nssg.h" /* NSS versions */
29 #include "gskit.h" /* Global Secure ToolKit versions */
30 #include "polarssl.h" /* PolarSSL versions */
31 #include "axtls.h" /* axTLS versions */
32 #include "cyassl.h" /* CyaSSL versions */
33 #include "schannel.h" /* Schannel SSPI version */
34 #include "darwinssl.h" /* SecureTransport (Darwin) version */
35 #include "mbedtls.h" /* mbedTLS versions */
37 #ifndef MAX_PINNED_PUBKEY_SIZE
38 #define MAX_PINNED_PUBKEY_SIZE 1048576 /* 1MB */
41 #ifndef MD5_DIGEST_LENGTH
42 #define MD5_DIGEST_LENGTH 16 /* fixed size */
45 #ifndef SHA256_DIGEST_LENGTH
46 #define SHA256_DIGEST_LENGTH 32 /* fixed size */
49 /* see https://tools.ietf.org/html/draft-ietf-tls-applayerprotoneg-04 */
50 #define ALPN_HTTP_1_1_LENGTH 8
51 #define ALPN_HTTP_1_1 "http/1.1"
53 bool Curl_ssl_config_matches(struct ssl_config_data* data,
54 struct ssl_config_data* needle);
55 bool Curl_clone_ssl_config(struct ssl_config_data* source,
56 struct ssl_config_data* dest);
57 void Curl_free_ssl_config(struct ssl_config_data* sslc);
59 unsigned int Curl_rand(struct Curl_easy *);
61 int Curl_ssl_backend(void);
64 int Curl_ssl_init(void);
65 void Curl_ssl_cleanup(void);
66 CURLcode Curl_ssl_connect(struct connectdata *conn, int sockindex);
67 CURLcode Curl_ssl_connect_nonblocking(struct connectdata *conn,
70 /* tell the SSL stuff to close down all open information regarding
71 connections (and thus session ID caching etc) */
72 void Curl_ssl_close_all(struct Curl_easy *data);
73 void Curl_ssl_close(struct connectdata *conn, int sockindex);
74 CURLcode Curl_ssl_shutdown(struct connectdata *conn, int sockindex);
75 CURLcode Curl_ssl_set_engine(struct Curl_easy *data, const char *engine);
76 /* Sets engine as default for all SSL operations */
77 CURLcode Curl_ssl_set_engine_default(struct Curl_easy *data);
78 struct curl_slist *Curl_ssl_engines_list(struct Curl_easy *data);
80 /* init the SSL session ID cache */
81 CURLcode Curl_ssl_initsessions(struct Curl_easy *, size_t);
82 size_t Curl_ssl_version(char *buffer, size_t size);
83 bool Curl_ssl_data_pending(const struct connectdata *conn,
85 int Curl_ssl_check_cxn(struct connectdata *conn);
87 /* Certificate information list handling. */
89 void Curl_ssl_free_certinfo(struct Curl_easy *data);
90 CURLcode Curl_ssl_init_certinfo(struct Curl_easy * data, int num);
91 CURLcode Curl_ssl_push_certinfo_len(struct Curl_easy * data, int certnum,
92 const char * label, const char * value,
94 CURLcode Curl_ssl_push_certinfo(struct Curl_easy * data, int certnum,
95 const char * label, const char * value);
97 /* Functions to be used by SSL library adaptation functions */
99 /* Lock session cache mutex.
100 * Call this before calling other Curl_ssl_*session* functions
101 * Caller should unlock this mutex as soon as possible, as it may block
102 * other SSL connection from making progress.
103 * The purpose of explicitly locking SSL session cache data is to allow
104 * individual SSL engines to manage session lifetime in their specific way.
106 void Curl_ssl_sessionid_lock(struct connectdata *conn);
108 /* Unlock session cache mutex */
109 void Curl_ssl_sessionid_unlock(struct connectdata *conn);
111 /* extract a session ID
112 * Sessionid mutex must be locked (see Curl_ssl_sessionid_lock).
113 * Caller must make sure that the ownership of returned sessionid object
114 * is properly taken (e.g. its refcount is incremented
115 * under sessionid mutex).
117 bool Curl_ssl_getsessionid(struct connectdata *conn,
118 void **ssl_sessionid,
119 size_t *idsize); /* set 0 if unknown */
120 /* add a new session ID
121 * Sessionid mutex must be locked (see Curl_ssl_sessionid_lock).
122 * Caller must ensure that it has properly shared ownership of this sessionid
123 * object with cache (e.g. incrementing refcount on success)
125 CURLcode Curl_ssl_addsessionid(struct connectdata *conn,
128 /* Kill a single session ID entry in the cache
129 * Sessionid mutex must be locked (see Curl_ssl_sessionid_lock).
130 * This will call engine-specific curlssl_session_free function, which must
131 * take sessionid object ownership from sessionid cache
132 * (e.g. decrement refcount).
134 void Curl_ssl_kill_session(struct curl_ssl_session *session);
135 /* delete a session from the cache
136 * Sessionid mutex must be locked (see Curl_ssl_sessionid_lock).
137 * This will call engine-specific curlssl_session_free function, which must
138 * take sessionid object ownership from sessionid cache
139 * (e.g. decrement refcount).
141 void Curl_ssl_delsessionid(struct connectdata *conn, void *ssl_sessionid);
143 /* get N random bytes into the buffer, return 0 if a find random is filled
145 int Curl_ssl_random(struct Curl_easy *data, unsigned char *buffer,
147 CURLcode Curl_ssl_md5sum(unsigned char *tmp, /* input */
149 unsigned char *md5sum, /* output */
151 /* Check pinned public key. */
152 CURLcode Curl_pin_peer_pubkey(struct Curl_easy *data,
153 const char *pinnedpubkey,
154 const unsigned char *pubkey, size_t pubkeylen);
156 bool Curl_ssl_cert_status_request(void);
158 bool Curl_ssl_false_start(void);
160 #define SSL_SHUTDOWN_TIMEOUT 10000 /* ms */
163 /* Set the API backend definition to none */
164 #define CURL_SSL_BACKEND CURLSSLBACKEND_NONE
166 /* When SSL support is not present, just define away these function calls */
167 #define Curl_ssl_init() 1
168 #define Curl_ssl_cleanup() Curl_nop_stmt
169 #define Curl_ssl_connect(x,y) CURLE_NOT_BUILT_IN
170 #define Curl_ssl_close_all(x) Curl_nop_stmt
171 #define Curl_ssl_close(x,y) Curl_nop_stmt
172 #define Curl_ssl_shutdown(x,y) CURLE_NOT_BUILT_IN
173 #define Curl_ssl_set_engine(x,y) CURLE_NOT_BUILT_IN
174 #define Curl_ssl_set_engine_default(x) CURLE_NOT_BUILT_IN
175 #define Curl_ssl_engines_list(x) NULL
176 #define Curl_ssl_send(a,b,c,d,e) -1
177 #define Curl_ssl_recv(a,b,c,d,e) -1
178 #define Curl_ssl_initsessions(x,y) CURLE_OK
179 #define Curl_ssl_version(x,y) 0
180 #define Curl_ssl_data_pending(x,y) 0
181 #define Curl_ssl_check_cxn(x) 0
182 #define Curl_ssl_free_certinfo(x) Curl_nop_stmt
183 #define Curl_ssl_connect_nonblocking(x,y,z) CURLE_NOT_BUILT_IN
184 #define Curl_ssl_kill_session(x) Curl_nop_stmt
185 #define Curl_ssl_random(x,y,z) ((void)x, CURLE_NOT_BUILT_IN)
186 #define Curl_ssl_cert_status_request() FALSE
187 #define Curl_ssl_false_start() FALSE
190 #endif /* HEADER_CURL_VTLS_H */