Change all our uses of CRYPTO_THREAD_run_once to use RUN_ONCE instead
[openssl.git] / ssl / methods.c
1 /*
2  * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
3  *
4  * Licensed under the OpenSSL license (the "License").  You may not use
5  * this file except in compliance with the License.  You can obtain a copy
6  * in the file LICENSE in the source distribution or at
7  * https://www.openssl.org/source/license.html
8  */
9
10 #include <stdio.h>
11 #include <openssl/objects.h>
12 #include "ssl_locl.h"
13
14 /*
15  * TLS/SSLv3 methods
16  */
17
18 IMPLEMENT_tls_meth_func(TLS_ANY_VERSION, 0, 0,
19                         TLS_method,
20                         ossl_statem_accept,
21                         ossl_statem_connect, TLSv1_2_enc_data)
22
23 #ifndef OPENSSL_NO_TLS1_2_METHOD
24 IMPLEMENT_tls_meth_func(TLS1_2_VERSION, 0, SSL_OP_NO_TLSv1_2,
25                         tlsv1_2_method,
26                         ossl_statem_accept,
27                         ossl_statem_connect, TLSv1_2_enc_data)
28 #endif
29
30 #ifndef OPENSSL_NO_TLS1_1_METHOD
31 IMPLEMENT_tls_meth_func(TLS1_1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_TLSv1_1,
32                         tlsv1_1_method,
33                         ossl_statem_accept,
34                         ossl_statem_connect, TLSv1_1_enc_data)
35 #endif
36
37 #ifndef OPENSSL_NO_TLS1_METHOD
38 IMPLEMENT_tls_meth_func(TLS1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_TLSv1,
39                         tlsv1_method,
40                         ossl_statem_accept,
41                         ossl_statem_connect, TLSv1_enc_data)
42 #endif
43
44 #ifndef OPENSSL_NO_SSL3_METHOD
45 IMPLEMENT_ssl3_meth_func(sslv3_method, ossl_statem_accept, ossl_statem_connect)
46 #endif
47
48
49 /*
50  * TLS/SSLv3 server methods
51  */
52
53 IMPLEMENT_tls_meth_func(TLS_ANY_VERSION, 0, 0,
54                         TLS_server_method,
55                         ossl_statem_accept,
56                         ssl_undefined_function,
57                         TLSv1_2_enc_data)
58
59 #ifndef OPENSSL_NO_TLS1_2_METHOD
60 IMPLEMENT_tls_meth_func(TLS1_2_VERSION, 0, SSL_OP_NO_TLSv1_2,
61                         tlsv1_2_server_method,
62                         ossl_statem_accept,
63                         ssl_undefined_function,
64                         TLSv1_2_enc_data)
65 #endif
66
67 #ifndef OPENSSL_NO_TLS1_1_METHOD
68 IMPLEMENT_tls_meth_func(TLS1_1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_TLSv1_1,
69                         tlsv1_1_server_method,
70                         ossl_statem_accept,
71                         ssl_undefined_function,
72                         TLSv1_1_enc_data)
73 #endif
74
75 #ifndef OPENSSL_NO_TLS1_METHOD
76 IMPLEMENT_tls_meth_func(TLS1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_TLSv1,
77                         tlsv1_server_method,
78                         ossl_statem_accept,
79                         ssl_undefined_function,
80                         TLSv1_enc_data)
81 #endif
82
83 #ifndef OPENSSL_NO_SSL3_METHOD
84 IMPLEMENT_ssl3_meth_func(sslv3_server_method,
85                          ossl_statem_accept,
86                          ssl_undefined_function)
87 #endif
88
89
90 /*
91  * TLS/SSLv3 client methods
92  */
93
94 IMPLEMENT_tls_meth_func(TLS_ANY_VERSION, 0, 0,
95                         TLS_client_method,
96                         ssl_undefined_function,
97                         ossl_statem_connect,
98                         TLSv1_2_enc_data)
99
100 #ifndef OPENSSL_NO_TLS1_2_METHOD
101 IMPLEMENT_tls_meth_func(TLS1_2_VERSION, 0, SSL_OP_NO_TLSv1_2,
102                         tlsv1_2_client_method,
103                         ssl_undefined_function,
104                         ossl_statem_connect,
105                         TLSv1_2_enc_data)
106 #endif
107
108 #ifndef OPENSSL_NO_TLS1_1_METHOD
109 IMPLEMENT_tls_meth_func(TLS1_1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_TLSv1_1,
110                         tlsv1_1_client_method,
111                         ssl_undefined_function,
112                         ossl_statem_connect,
113                         TLSv1_1_enc_data)
114 #endif
115
116 #ifndef OPENSSL_NO_TLS1_METHOD
117 IMPLEMENT_tls_meth_func(TLS1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_TLSv1,
118                         tlsv1_client_method,
119                         ssl_undefined_function,
120                         ossl_statem_connect,
121                         TLSv1_enc_data)
122 #endif
123
124 #ifndef OPENSSL_NO_SSL3_METHOD
125 IMPLEMENT_ssl3_meth_func(sslv3_client_method,
126                          ssl_undefined_function,
127                          ossl_statem_connect)
128 #endif
129
130
131 /*
132  * DTLS methods
133  */
134
135 #ifndef OPENSSL_NO_DTLS1_METHOD
136 IMPLEMENT_dtls1_meth_func(DTLS1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_DTLSv1,
137                           dtlsv1_method,
138                           ossl_statem_accept,
139                           ossl_statem_connect,
140                           DTLSv1_enc_data)
141 #endif
142
143 #ifndef OPENSSL_NO_DTLS1_2_METHOD
144 IMPLEMENT_dtls1_meth_func(DTLS1_2_VERSION, 0, SSL_OP_NO_DTLSv1_2,
145                           dtlsv1_2_method,
146                           ossl_statem_accept,
147                           ossl_statem_connect,
148                           DTLSv1_2_enc_data)
149 #endif
150
151 IMPLEMENT_dtls1_meth_func(DTLS_ANY_VERSION, 0, 0,
152                           DTLS_method,
153                           ossl_statem_accept,
154                           ossl_statem_connect,
155                           DTLSv1_2_enc_data)
156
157 /*
158  * DTLS server methods
159  */
160
161 #ifndef OPENSSL_NO_DTLS1_METHOD
162 IMPLEMENT_dtls1_meth_func(DTLS1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_DTLSv1,
163                           dtlsv1_server_method,
164                           ossl_statem_accept,
165                           ssl_undefined_function,
166                           DTLSv1_enc_data)
167 #endif
168
169 #ifndef OPENSSL_NO_DTLS1_2_METHOD
170 IMPLEMENT_dtls1_meth_func(DTLS1_2_VERSION, 0, SSL_OP_NO_DTLSv1_2,
171                           dtlsv1_2_server_method,
172                           ossl_statem_accept,
173                           ssl_undefined_function,
174                           DTLSv1_2_enc_data)
175 #endif
176
177 IMPLEMENT_dtls1_meth_func(DTLS_ANY_VERSION, 0, 0,
178                           DTLS_server_method,
179                           ossl_statem_accept,
180                           ssl_undefined_function,
181                           DTLSv1_2_enc_data)
182
183
184 /*
185  * DTLS client methods
186  */
187
188 #ifndef OPENSSL_NO_DTLS1_METHOD
189 IMPLEMENT_dtls1_meth_func(DTLS1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_DTLSv1,
190                           dtlsv1_client_method,
191                           ssl_undefined_function,
192                           ossl_statem_connect,
193                           DTLSv1_enc_data)
194 #endif
195
196 #ifndef OPENSSL_NO_DTLS1_2_METHOD
197 IMPLEMENT_dtls1_meth_func(DTLS1_2_VERSION, 0, SSL_OP_NO_DTLSv1_2,
198                           dtlsv1_2_client_method,
199                           ssl_undefined_function,
200                           ossl_statem_connect,
201                           DTLSv1_2_enc_data)
202 #endif
203
204 IMPLEMENT_dtls1_meth_func(DTLS_ANY_VERSION, 0, 0,
205                           DTLS_client_method,
206                           ssl_undefined_function,
207                           ossl_statem_connect,
208                           DTLSv1_2_enc_data)
209
210 #if OPENSSL_API_COMPAT < 0x10100000L
211
212 # ifndef OPENSSL_NO_TLS1_2_METHOD
213 const SSL_METHOD *TLSv1_2_method(void)
214 {
215     return tlsv1_2_method();
216 }
217
218 const SSL_METHOD *TLSv1_2_server_method(void)
219 {
220     return tlsv1_2_server_method();
221 }
222
223 const SSL_METHOD *TLSv1_2_client_method(void)
224 {
225     return tlsv1_2_client_method();
226 }
227 # endif
228
229 # ifndef OPENSSL_NO_TLS1_1_METHOD
230 const SSL_METHOD *TLSv1_1_method(void)
231 {
232     return tlsv1_1_method();
233 }
234
235 const SSL_METHOD *TLSv1_1_server_method(void)
236 {
237     return tlsv1_1_server_method();
238 }
239
240 const SSL_METHOD *TLSv1_1_client_method(void)
241 {
242     return tlsv1_1_client_method();
243 }
244 # endif
245
246 # ifndef OPENSSL_NO_TLS1_METHOD
247 const SSL_METHOD *TLSv1_method(void)
248 {
249     return tlsv1_method();
250 }
251
252 const SSL_METHOD *TLSv1_server_method(void)
253 {
254     return tlsv1_server_method();
255 }
256
257 const SSL_METHOD *TLSv1_client_method(void)
258 {
259     return tlsv1_client_method();
260 }
261 # endif
262
263 # ifndef OPENSSL_NO_SSL3_METHOD
264 const SSL_METHOD *SSLv3_method(void)
265 {
266     return sslv3_method();
267 }
268
269 const SSL_METHOD *SSLv3_server_method(void)
270 {
271     return sslv3_server_method();
272 }
273
274 const SSL_METHOD *SSLv3_client_method(void)
275 {
276     return sslv3_client_method();
277 }
278 # endif
279
280 # ifndef OPENSSL_NO_DTLS1_2_METHOD
281 const SSL_METHOD *DTLSv1_2_method(void)
282 {
283     return dtlsv1_2_method();
284 }
285
286 const SSL_METHOD *DTLSv1_2_server_method(void)
287 {
288     return dtlsv1_2_server_method();
289 }
290
291 const SSL_METHOD *DTLSv1_2_client_method(void)
292 {
293     return dtlsv1_2_client_method();
294 }
295 # endif
296
297 # ifndef OPENSSL_NO_DTLS1_METHOD
298 const SSL_METHOD *DTLSv1_method(void)
299 {
300     return dtlsv1_method();
301 }
302
303 const SSL_METHOD *DTLSv1_server_method(void)
304 {
305     return dtlsv1_server_method();
306 }
307
308 const SSL_METHOD *DTLSv1_client_method(void)
309 {
310     return dtlsv1_client_method();
311 }
312 # endif
313
314 #endif
315