Complain if -twopass is used incorrectly
[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 IMPLEMENT_tls_meth_func(TLS1_3_VERSION, 0, SSL_OP_NO_TLSv1_3,
23                         tlsv1_3_method,
24                         ossl_statem_accept,
25                         ossl_statem_connect, TLSv1_3_enc_data)
26 #ifndef OPENSSL_NO_TLS1_2_METHOD
27 IMPLEMENT_tls_meth_func(TLS1_2_VERSION, 0, SSL_OP_NO_TLSv1_2,
28                         tlsv1_2_method,
29                         ossl_statem_accept,
30                         ossl_statem_connect, TLSv1_2_enc_data)
31 #endif
32 #ifndef OPENSSL_NO_TLS1_1_METHOD
33 IMPLEMENT_tls_meth_func(TLS1_1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_TLSv1_1,
34                         tlsv1_1_method,
35                         ossl_statem_accept,
36                         ossl_statem_connect, TLSv1_1_enc_data)
37 #endif
38 #ifndef OPENSSL_NO_TLS1_METHOD
39 IMPLEMENT_tls_meth_func(TLS1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_TLSv1,
40                         tlsv1_method,
41                         ossl_statem_accept, ossl_statem_connect, TLSv1_enc_data)
42 #endif
43 #ifndef OPENSSL_NO_SSL3_METHOD
44 IMPLEMENT_ssl3_meth_func(sslv3_method, ossl_statem_accept, ossl_statem_connect)
45 #endif
46 /*-
47  * TLS/SSLv3 server methods
48  */
49 IMPLEMENT_tls_meth_func(TLS_ANY_VERSION, 0, 0,
50                         TLS_server_method,
51                         ossl_statem_accept,
52                         ssl_undefined_function, TLSv1_2_enc_data)
53 IMPLEMENT_tls_meth_func(TLS1_3_VERSION, 0, SSL_OP_NO_TLSv1_3,
54                         tlsv1_3_server_method,
55                         ossl_statem_accept,
56                         ssl_undefined_function, TLSv1_3_enc_data)
57 #ifndef OPENSSL_NO_TLS1_2_METHOD
58 IMPLEMENT_tls_meth_func(TLS1_2_VERSION, 0, SSL_OP_NO_TLSv1_2,
59                         tlsv1_2_server_method,
60                         ossl_statem_accept,
61                         ssl_undefined_function, TLSv1_2_enc_data)
62 #endif
63 #ifndef OPENSSL_NO_TLS1_1_METHOD
64 IMPLEMENT_tls_meth_func(TLS1_1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_TLSv1_1,
65                         tlsv1_1_server_method,
66                         ossl_statem_accept,
67                         ssl_undefined_function, TLSv1_1_enc_data)
68 #endif
69 #ifndef OPENSSL_NO_TLS1_METHOD
70 IMPLEMENT_tls_meth_func(TLS1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_TLSv1,
71                         tlsv1_server_method,
72                         ossl_statem_accept,
73                         ssl_undefined_function, TLSv1_enc_data)
74 #endif
75 #ifndef OPENSSL_NO_SSL3_METHOD
76 IMPLEMENT_ssl3_meth_func(sslv3_server_method,
77                          ossl_statem_accept, ssl_undefined_function)
78 #endif
79 /*-
80  * TLS/SSLv3 client methods
81  */
82 IMPLEMENT_tls_meth_func(TLS_ANY_VERSION, 0, 0,
83                         TLS_client_method,
84                         ssl_undefined_function,
85                         ossl_statem_connect, TLSv1_2_enc_data)
86 IMPLEMENT_tls_meth_func(TLS1_3_VERSION, 0, SSL_OP_NO_TLSv1_3,
87                         tlsv1_3_client_method,
88                         ssl_undefined_function,
89                         ossl_statem_connect, TLSv1_3_enc_data)
90 #ifndef OPENSSL_NO_TLS1_2_METHOD
91 IMPLEMENT_tls_meth_func(TLS1_2_VERSION, 0, SSL_OP_NO_TLSv1_2,
92                         tlsv1_2_client_method,
93                         ssl_undefined_function,
94                         ossl_statem_connect, TLSv1_2_enc_data)
95 #endif
96 #ifndef OPENSSL_NO_TLS1_1_METHOD
97 IMPLEMENT_tls_meth_func(TLS1_1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_TLSv1_1,
98                         tlsv1_1_client_method,
99                         ssl_undefined_function,
100                         ossl_statem_connect, TLSv1_1_enc_data)
101 #endif
102 #ifndef OPENSSL_NO_TLS1_METHOD
103 IMPLEMENT_tls_meth_func(TLS1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_TLSv1,
104                         tlsv1_client_method,
105                         ssl_undefined_function,
106                         ossl_statem_connect, TLSv1_enc_data)
107 #endif
108 #ifndef OPENSSL_NO_SSL3_METHOD
109 IMPLEMENT_ssl3_meth_func(sslv3_client_method,
110                          ssl_undefined_function, ossl_statem_connect)
111 #endif
112 /*-
113  * DTLS methods
114  */
115 #ifndef OPENSSL_NO_DTLS1_METHOD
116 IMPLEMENT_dtls1_meth_func(DTLS1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_DTLSv1,
117                           dtlsv1_method,
118                           ossl_statem_accept,
119                           ossl_statem_connect, DTLSv1_enc_data)
120 #endif
121 #ifndef OPENSSL_NO_DTLS1_2_METHOD
122 IMPLEMENT_dtls1_meth_func(DTLS1_2_VERSION, 0, SSL_OP_NO_DTLSv1_2,
123                           dtlsv1_2_method,
124                           ossl_statem_accept,
125                           ossl_statem_connect, DTLSv1_2_enc_data)
126 #endif
127 IMPLEMENT_dtls1_meth_func(DTLS_ANY_VERSION, 0, 0,
128                           DTLS_method,
129                           ossl_statem_accept,
130                           ossl_statem_connect, DTLSv1_2_enc_data)
131
132 /*-
133  * DTLS server methods
134  */
135 #ifndef OPENSSL_NO_DTLS1_METHOD
136 IMPLEMENT_dtls1_meth_func(DTLS1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_DTLSv1,
137                           dtlsv1_server_method,
138                           ossl_statem_accept,
139                           ssl_undefined_function, DTLSv1_enc_data)
140 #endif
141 #ifndef OPENSSL_NO_DTLS1_2_METHOD
142 IMPLEMENT_dtls1_meth_func(DTLS1_2_VERSION, 0, SSL_OP_NO_DTLSv1_2,
143                           dtlsv1_2_server_method,
144                           ossl_statem_accept,
145                           ssl_undefined_function, DTLSv1_2_enc_data)
146 #endif
147 IMPLEMENT_dtls1_meth_func(DTLS_ANY_VERSION, 0, 0,
148                           DTLS_server_method,
149                           ossl_statem_accept,
150                           ssl_undefined_function, DTLSv1_2_enc_data)
151
152 /*-
153  * DTLS client methods
154  */
155 #ifndef OPENSSL_NO_DTLS1_METHOD
156 IMPLEMENT_dtls1_meth_func(DTLS1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_DTLSv1,
157                           dtlsv1_client_method,
158                           ssl_undefined_function,
159                           ossl_statem_connect, DTLSv1_enc_data)
160 IMPLEMENT_dtls1_meth_func(DTLS1_BAD_VER, SSL_METHOD_NO_SUITEB, SSL_OP_NO_DTLSv1,
161                           dtls_bad_ver_client_method,
162                           ssl_undefined_function,
163                           ossl_statem_connect, DTLSv1_enc_data)
164 #endif
165 #ifndef OPENSSL_NO_DTLS1_2_METHOD
166 IMPLEMENT_dtls1_meth_func(DTLS1_2_VERSION, 0, SSL_OP_NO_DTLSv1_2,
167                           dtlsv1_2_client_method,
168                           ssl_undefined_function,
169                           ossl_statem_connect, DTLSv1_2_enc_data)
170 #endif
171 IMPLEMENT_dtls1_meth_func(DTLS_ANY_VERSION, 0, 0,
172                           DTLS_client_method,
173                           ssl_undefined_function,
174                           ossl_statem_connect, DTLSv1_2_enc_data)
175 #if OPENSSL_API_COMPAT < 0x10100000L
176 # ifndef OPENSSL_NO_TLS1_2_METHOD
177 const SSL_METHOD *TLSv1_2_method(void)
178 {
179     return tlsv1_2_method();
180 }
181
182 const SSL_METHOD *TLSv1_2_server_method(void)
183 {
184     return tlsv1_2_server_method();
185 }
186
187 const SSL_METHOD *TLSv1_2_client_method(void)
188 {
189     return tlsv1_2_client_method();
190 }
191 # endif
192
193 # ifndef OPENSSL_NO_TLS1_1_METHOD
194 const SSL_METHOD *TLSv1_1_method(void)
195 {
196     return tlsv1_1_method();
197 }
198
199 const SSL_METHOD *TLSv1_1_server_method(void)
200 {
201     return tlsv1_1_server_method();
202 }
203
204 const SSL_METHOD *TLSv1_1_client_method(void)
205 {
206     return tlsv1_1_client_method();
207 }
208 # endif
209
210 # ifndef OPENSSL_NO_TLS1_METHOD
211 const SSL_METHOD *TLSv1_method(void)
212 {
213     return tlsv1_method();
214 }
215
216 const SSL_METHOD *TLSv1_server_method(void)
217 {
218     return tlsv1_server_method();
219 }
220
221 const SSL_METHOD *TLSv1_client_method(void)
222 {
223     return tlsv1_client_method();
224 }
225 # endif
226
227 # ifndef OPENSSL_NO_SSL3_METHOD
228 const SSL_METHOD *SSLv3_method(void)
229 {
230     return sslv3_method();
231 }
232
233 const SSL_METHOD *SSLv3_server_method(void)
234 {
235     return sslv3_server_method();
236 }
237
238 const SSL_METHOD *SSLv3_client_method(void)
239 {
240     return sslv3_client_method();
241 }
242 # endif
243
244 # ifndef OPENSSL_NO_DTLS1_2_METHOD
245 const SSL_METHOD *DTLSv1_2_method(void)
246 {
247     return dtlsv1_2_method();
248 }
249
250 const SSL_METHOD *DTLSv1_2_server_method(void)
251 {
252     return dtlsv1_2_server_method();
253 }
254
255 const SSL_METHOD *DTLSv1_2_client_method(void)
256 {
257     return dtlsv1_2_client_method();
258 }
259 # endif
260
261 # ifndef OPENSSL_NO_DTLS1_METHOD
262 const SSL_METHOD *DTLSv1_method(void)
263 {
264     return dtlsv1_method();
265 }
266
267 const SSL_METHOD *DTLSv1_server_method(void)
268 {
269     return dtlsv1_server_method();
270 }
271
272 const SSL_METHOD *DTLSv1_client_method(void)
273 {
274     return dtlsv1_client_method();
275 }
276 # endif
277
278 #endif