Revert "Imported Upstream version 7.44.0"
[platform/upstream/curl.git] / lib / vtls / vtls.h
1 #ifndef HEADER_CURL_VTLS_H
2 #define HEADER_CURL_VTLS_H
3 /***************************************************************************
4  *                                  _   _ ____  _
5  *  Project                     ___| | | |  _ \| |
6  *                             / __| | | | |_) | |
7  *                            | (__| |_| |  _ <| |___
8  *                             \___|\___/|_| \_\_____|
9  *
10  * Copyright (C) 1998 - 2014, 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 http://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 #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 "curl_schannel.h"  /* Schannel SSPI version */
34 #include "curl_darwinssl.h" /* SecureTransport (Darwin) version */
35
36 #ifndef MAX_PINNED_PUBKEY_SIZE
37 #define MAX_PINNED_PUBKEY_SIZE 1048576 /* 1MB */
38 #endif
39
40 #ifndef MD5_DIGEST_LENGTH
41 #define MD5_DIGEST_LENGTH 16 /* fixed size */
42 #endif
43
44 /* see http://tools.ietf.org/html/draft-ietf-tls-applayerprotoneg-04 */
45 #define ALPN_HTTP_1_1_LENGTH 8
46 #define ALPN_HTTP_1_1 "http/1.1"
47
48 bool Curl_ssl_config_matches(struct ssl_config_data* data,
49                              struct ssl_config_data* needle);
50 bool Curl_clone_ssl_config(struct ssl_config_data* source,
51                            struct ssl_config_data* dest);
52 void Curl_free_ssl_config(struct ssl_config_data* sslc);
53
54 unsigned int Curl_rand(struct SessionHandle *);
55
56 int Curl_ssl_backend(void);
57
58 #ifdef USE_SSL
59 int Curl_ssl_init(void);
60 void Curl_ssl_cleanup(void);
61 CURLcode Curl_ssl_connect(struct connectdata *conn, int sockindex);
62 CURLcode Curl_ssl_connect_nonblocking(struct connectdata *conn,
63                                       int sockindex,
64                                       bool *done);
65 /* tell the SSL stuff to close down all open information regarding
66    connections (and thus session ID caching etc) */
67 void Curl_ssl_close_all(struct SessionHandle *data);
68 void Curl_ssl_close(struct connectdata *conn, int sockindex);
69 CURLcode Curl_ssl_shutdown(struct connectdata *conn, int sockindex);
70 CURLcode Curl_ssl_set_engine(struct SessionHandle *data, const char *engine);
71 /* Sets engine as default for all SSL operations */
72 CURLcode Curl_ssl_set_engine_default(struct SessionHandle *data);
73 struct curl_slist *Curl_ssl_engines_list(struct SessionHandle *data);
74
75 /* init the SSL session ID cache */
76 CURLcode Curl_ssl_initsessions(struct SessionHandle *, size_t);
77 size_t Curl_ssl_version(char *buffer, size_t size);
78 bool Curl_ssl_data_pending(const struct connectdata *conn,
79                            int connindex);
80 int Curl_ssl_check_cxn(struct connectdata *conn);
81
82 /* Certificate information list handling. */
83
84 void Curl_ssl_free_certinfo(struct SessionHandle *data);
85 CURLcode Curl_ssl_init_certinfo(struct SessionHandle * data, int num);
86 CURLcode Curl_ssl_push_certinfo_len(struct SessionHandle * data, int certnum,
87                                     const char * label, const char * value,
88                                     size_t valuelen);
89 CURLcode Curl_ssl_push_certinfo(struct SessionHandle * data, int certnum,
90                                 const char * label, const char * value);
91
92 /* Functions to be used by SSL library adaptation functions */
93
94 /* extract a session ID */
95 bool Curl_ssl_getsessionid(struct connectdata *conn,
96                            void **ssl_sessionid,
97                            size_t *idsize) /* set 0 if unknown */;
98 /* add a new session ID */
99 CURLcode Curl_ssl_addsessionid(struct connectdata *conn,
100                                void *ssl_sessionid,
101                                size_t idsize);
102 /* Kill a single session ID entry in the cache */
103 void Curl_ssl_kill_session(struct curl_ssl_session *session);
104 /* delete a session from the cache */
105 void Curl_ssl_delsessionid(struct connectdata *conn, void *ssl_sessionid);
106
107 /* get N random bytes into the buffer, return 0 if a find random is filled
108    in */
109 int Curl_ssl_random(struct SessionHandle *data, unsigned char *buffer,
110                     size_t length);
111 void Curl_ssl_md5sum(unsigned char *tmp, /* input */
112                      size_t tmplen,
113                      unsigned char *md5sum, /* output */
114                      size_t md5len);
115 /* Check pinned public key. */
116 CURLcode Curl_pin_peer_pubkey(const char *pinnedpubkey,
117                               const unsigned char *pubkey, size_t pubkeylen);
118
119 #define SSL_SHUTDOWN_TIMEOUT 10000 /* ms */
120
121 #else
122 /* When SSL support is not present, just define away these function calls */
123 #define Curl_ssl_init() 1
124 #define Curl_ssl_cleanup() Curl_nop_stmt
125 #define Curl_ssl_connect(x,y) CURLE_NOT_BUILT_IN
126 #define Curl_ssl_close_all(x) Curl_nop_stmt
127 #define Curl_ssl_close(x,y) Curl_nop_stmt
128 #define Curl_ssl_shutdown(x,y) CURLE_NOT_BUILT_IN
129 #define Curl_ssl_set_engine(x,y) CURLE_NOT_BUILT_IN
130 #define Curl_ssl_set_engine_default(x) CURLE_NOT_BUILT_IN
131 #define Curl_ssl_engines_list(x) NULL
132 #define Curl_ssl_send(a,b,c,d,e) -1
133 #define Curl_ssl_recv(a,b,c,d,e) -1
134 #define Curl_ssl_initsessions(x,y) CURLE_OK
135 #define Curl_ssl_version(x,y) 0
136 #define Curl_ssl_data_pending(x,y) 0
137 #define Curl_ssl_check_cxn(x) 0
138 #define Curl_ssl_free_certinfo(x) Curl_nop_stmt
139 #define Curl_ssl_connect_nonblocking(x,y,z) CURLE_NOT_BUILT_IN
140 #define Curl_ssl_kill_session(x) Curl_nop_stmt
141 #define Curl_ssl_random(x,y,z) ((void)x, CURLE_NOT_BUILT_IN)
142 #define CURL_SSL_BACKEND CURLSSLBACKEND_NONE
143 #endif
144
145 #endif /* HEADER_CURL_VTLS_H */