1 #ifndef HEADER_CURL_VTLS_H
2 #define HEADER_CURL_VTLS_H
3 /***************************************************************************
5 * Project ___| | | | _ \| |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
10 * Copyright (C) 1998 - 2015, 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 http://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 */
36 #ifndef MAX_PINNED_PUBKEY_SIZE
37 #define MAX_PINNED_PUBKEY_SIZE 1048576 /* 1MB */
40 #ifndef MD5_DIGEST_LENGTH
41 #define MD5_DIGEST_LENGTH 16 /* fixed size */
44 #ifndef SHA256_DIGEST_LENGTH
45 #define SHA256_DIGEST_LENGTH 32 /* fixed size */
48 /* see http://tools.ietf.org/html/draft-ietf-tls-applayerprotoneg-04 */
49 #define ALPN_HTTP_1_1_LENGTH 8
50 #define ALPN_HTTP_1_1 "http/1.1"
52 bool Curl_ssl_config_matches(struct ssl_config_data* data,
53 struct ssl_config_data* needle);
54 bool Curl_clone_ssl_config(struct ssl_config_data* source,
55 struct ssl_config_data* dest);
56 void Curl_free_ssl_config(struct ssl_config_data* sslc);
58 unsigned int Curl_rand(struct SessionHandle *);
60 int Curl_ssl_backend(void);
63 int Curl_ssl_init(void);
64 void Curl_ssl_cleanup(void);
65 CURLcode Curl_ssl_connect(struct connectdata *conn, int sockindex);
66 CURLcode Curl_ssl_connect_nonblocking(struct connectdata *conn,
69 /* tell the SSL stuff to close down all open information regarding
70 connections (and thus session ID caching etc) */
71 void Curl_ssl_close_all(struct SessionHandle *data);
72 void Curl_ssl_close(struct connectdata *conn, int sockindex);
73 CURLcode Curl_ssl_shutdown(struct connectdata *conn, int sockindex);
74 CURLcode Curl_ssl_set_engine(struct SessionHandle *data, const char *engine);
75 /* Sets engine as default for all SSL operations */
76 CURLcode Curl_ssl_set_engine_default(struct SessionHandle *data);
77 struct curl_slist *Curl_ssl_engines_list(struct SessionHandle *data);
79 /* init the SSL session ID cache */
80 CURLcode Curl_ssl_initsessions(struct SessionHandle *, size_t);
81 size_t Curl_ssl_version(char *buffer, size_t size);
82 bool Curl_ssl_data_pending(const struct connectdata *conn,
84 int Curl_ssl_check_cxn(struct connectdata *conn);
86 /* Certificate information list handling. */
88 void Curl_ssl_free_certinfo(struct SessionHandle *data);
89 CURLcode Curl_ssl_init_certinfo(struct SessionHandle * data, int num);
90 CURLcode Curl_ssl_push_certinfo_len(struct SessionHandle * data, int certnum,
91 const char * label, const char * value,
93 CURLcode Curl_ssl_push_certinfo(struct SessionHandle * data, int certnum,
94 const char * label, const char * value);
96 /* Functions to be used by SSL library adaptation functions */
98 /* extract a session ID */
99 bool Curl_ssl_getsessionid(struct connectdata *conn,
100 void **ssl_sessionid,
101 size_t *idsize) /* set 0 if unknown */;
102 /* add a new session ID */
103 CURLcode Curl_ssl_addsessionid(struct connectdata *conn,
106 /* Kill a single session ID entry in the cache */
107 void Curl_ssl_kill_session(struct curl_ssl_session *session);
108 /* delete a session from the cache */
109 void Curl_ssl_delsessionid(struct connectdata *conn, void *ssl_sessionid);
111 /* get N random bytes into the buffer, return 0 if a find random is filled
113 int Curl_ssl_random(struct SessionHandle *data, unsigned char *buffer,
115 CURLcode Curl_ssl_md5sum(unsigned char *tmp, /* input */
117 unsigned char *md5sum, /* output */
119 /* Check pinned public key. */
120 CURLcode Curl_pin_peer_pubkey(const char *pinnedpubkey,
121 const unsigned char *pubkey, size_t pubkeylen);
123 bool Curl_ssl_cert_status_request(void);
125 bool Curl_ssl_false_start(void);
127 #define SSL_SHUTDOWN_TIMEOUT 10000 /* ms */
130 /* Set the API backend definition to none */
131 #define CURL_SSL_BACKEND CURLSSLBACKEND_NONE
133 /* When SSL support is not present, just define away these function calls */
134 #define Curl_ssl_init() 1
135 #define Curl_ssl_cleanup() Curl_nop_stmt
136 #define Curl_ssl_connect(x,y) CURLE_NOT_BUILT_IN
137 #define Curl_ssl_close_all(x) Curl_nop_stmt
138 #define Curl_ssl_close(x,y) Curl_nop_stmt
139 #define Curl_ssl_shutdown(x,y) CURLE_NOT_BUILT_IN
140 #define Curl_ssl_set_engine(x,y) CURLE_NOT_BUILT_IN
141 #define Curl_ssl_set_engine_default(x) CURLE_NOT_BUILT_IN
142 #define Curl_ssl_engines_list(x) NULL
143 #define Curl_ssl_send(a,b,c,d,e) -1
144 #define Curl_ssl_recv(a,b,c,d,e) -1
145 #define Curl_ssl_initsessions(x,y) CURLE_OK
146 #define Curl_ssl_version(x,y) 0
147 #define Curl_ssl_data_pending(x,y) 0
148 #define Curl_ssl_check_cxn(x) 0
149 #define Curl_ssl_free_certinfo(x) Curl_nop_stmt
150 #define Curl_ssl_connect_nonblocking(x,y,z) CURLE_NOT_BUILT_IN
151 #define Curl_ssl_kill_session(x) Curl_nop_stmt
152 #define Curl_ssl_random(x,y,z) ((void)x, CURLE_NOT_BUILT_IN)
153 #define Curl_ssl_cert_status_request() FALSE
154 #define Curl_ssl_false_start() FALSE
157 #endif /* HEADER_CURL_VTLS_H */