Rename some lowercase API's
[openssl.git] / ssl / methods.c
1 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
2  * All rights reserved.
3  *
4  * This package is an SSL implementation written
5  * by Eric Young (eay@cryptsoft.com).
6  * The implementation was written so as to conform with Netscapes SSL.
7  *
8  * This library is free for commercial and non-commercial use as long as
9  * the following conditions are aheared to.  The following conditions
10  * apply to all code found in this distribution, be it the RC4, RSA,
11  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
12  * included with this distribution is covered by the same copyright terms
13  * except that the holder is Tim Hudson (tjh@cryptsoft.com).
14  *
15  * Copyright remains Eric Young's, and as such any Copyright notices in
16  * the code are not to be removed.
17  * If this package is used in a product, Eric Young should be given attribution
18  * as the author of the parts of the library used.
19  * This can be in the form of a textual message at program startup or
20  * in documentation (online or textual) provided with the package.
21  *
22  * Redistribution and use in source and binary forms, with or without
23  * modification, are permitted provided that the following conditions
24  * are met:
25  * 1. Redistributions of source code must retain the copyright
26  *    notice, this list of conditions and the following disclaimer.
27  * 2. Redistributions in binary form must reproduce the above copyright
28  *    notice, this list of conditions and the following disclaimer in the
29  *    documentation and/or other materials provided with the distribution.
30  * 3. All advertising materials mentioning features or use of this software
31  *    must display the following acknowledgement:
32  *    "This product includes cryptographic software written by
33  *     Eric Young (eay@cryptsoft.com)"
34  *    The word 'cryptographic' can be left out if the rouines from the library
35  *    being used are not cryptographic related :-).
36  * 4. If you include any Windows specific code (or a derivative thereof) from
37  *    the apps directory (application code) you must include an acknowledgement:
38  *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
39  *
40  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
41  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
43  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
44  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
45  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
46  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
48  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
49  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
50  * SUCH DAMAGE.
51  *
52  * The licence and distribution terms for any publically available version or
53  * derivative of this code cannot be changed.  i.e. this code cannot simply be
54  * copied and put under another distribution licence
55  * [including the GNU Public Licence.]
56  */
57 /* ====================================================================
58  * Copyright (c) 1998-2015 The OpenSSL Project.  All rights reserved.
59  *
60  * Redistribution and use in source and binary forms, with or without
61  * modification, are permitted provided that the following conditions
62  * are met:
63  *
64  * 1. Redistributions of source code must retain the above copyright
65  *    notice, this list of conditions and the following disclaimer.
66  *
67  * 2. Redistributions in binary form must reproduce the above copyright
68  *    notice, this list of conditions and the following disclaimer in
69  *    the documentation and/or other materials provided with the
70  *    distribution.
71  *
72  * 3. All advertising materials mentioning features or use of this
73  *    software must display the following acknowledgment:
74  *    "This product includes software developed by the OpenSSL Project
75  *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
76  *
77  * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
78  *    endorse or promote products derived from this software without
79  *    prior written permission. For written permission, please contact
80  *    openssl-core@openssl.org.
81  *
82  * 5. Products derived from this software may not be called "OpenSSL"
83  *    nor may "OpenSSL" appear in their names without prior written
84  *    permission of the OpenSSL Project.
85  *
86  * 6. Redistributions of any form whatsoever must retain the following
87  *    acknowledgment:
88  *    "This product includes software developed by the OpenSSL Project
89  *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
90  *
91  * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
92  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
93  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
94  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
95  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
96  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
97  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
98  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
99  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
100  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
101  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
102  * OF THE POSSIBILITY OF SUCH DAMAGE.
103  * ====================================================================
104  *
105  * This product includes cryptographic software written by Eric Young
106  * (eay@cryptsoft.com).  This product includes software written by Tim
107  * Hudson (tjh@cryptsoft.com).
108  *
109  */
110
111 #include <stdio.h>
112 #include <openssl/objects.h>
113 #include "ssl_locl.h"
114
115 /*
116  * TLS/SSLv3 methods
117  */
118
119 IMPLEMENT_tls_meth_func(TLS_ANY_VERSION, 0, 0,
120                         TLS_method,
121                         ossl_statem_accept,
122                         ossl_statem_connect, TLSv1_2_enc_data)
123
124 #ifndef OPENSSL_NO_TLS1_2_METHOD
125 IMPLEMENT_tls_meth_func(TLS1_2_VERSION, 0, SSL_OP_NO_TLSv1_2,
126                         tlsv1_2_method,
127                         ossl_statem_accept,
128                         ossl_statem_connect, TLSv1_2_enc_data)
129 #endif
130
131 #ifndef OPENSSL_NO_TLS1_1_METHOD
132 IMPLEMENT_tls_meth_func(TLS1_1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_TLSv1_1,
133                         tlsv1_1_method,
134                         ossl_statem_accept,
135                         ossl_statem_connect, TLSv1_1_enc_data)
136 #endif
137
138 #ifndef OPENSSL_NO_TLS1_METHOD
139 IMPLEMENT_tls_meth_func(TLS1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_TLSv1,
140                         tlsv1_method,
141                         ossl_statem_accept,
142                         ossl_statem_connect, TLSv1_enc_data)
143 #endif
144
145 #ifndef OPENSSL_NO_SSL3_METHOD
146 IMPLEMENT_ssl3_meth_func(sslv3_method, ossl_statem_accept, ossl_statem_connect)
147 #endif
148
149
150 /*
151  * TLS/SSLv3 server methods
152  */
153
154 IMPLEMENT_tls_meth_func(TLS_ANY_VERSION, 0, 0,
155                         TLS_server_method,
156                         ossl_statem_accept,
157                         ssl_undefined_function,
158                         TLSv1_2_enc_data)
159
160 #ifndef OPENSSL_NO_TLS1_2_METHOD
161 IMPLEMENT_tls_meth_func(TLS1_2_VERSION, 0, SSL_OP_NO_TLSv1_2,
162                         tlsv1_2_server_method,
163                         ossl_statem_accept,
164                         ssl_undefined_function,
165                         TLSv1_2_enc_data)
166 #endif
167
168 #ifndef OPENSSL_NO_TLS1_1_METHOD
169 IMPLEMENT_tls_meth_func(TLS1_1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_TLSv1_1,
170                         tlsv1_1_server_method,
171                         ossl_statem_accept,
172                         ssl_undefined_function,
173                         TLSv1_1_enc_data)
174 #endif
175
176 #ifndef OPENSSL_NO_TLS1_METHOD
177 IMPLEMENT_tls_meth_func(TLS1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_TLSv1,
178                         tlsv1_server_method,
179                         ossl_statem_accept,
180                         ssl_undefined_function,
181                         TLSv1_enc_data)
182 #endif
183
184 #ifndef OPENSSL_NO_SSL3_METHOD
185 IMPLEMENT_ssl3_meth_func(sslv3_server_method,
186                          ossl_statem_accept,
187                          ssl_undefined_function)
188 #endif
189
190
191 /*
192  * TLS/SSLv3 client methods
193  */
194
195 IMPLEMENT_tls_meth_func(TLS_ANY_VERSION, 0, 0,
196                         TLS_client_method,
197                         ssl_undefined_function,
198                         ossl_statem_connect,
199                         TLSv1_2_enc_data)
200
201 #ifndef OPENSSL_NO_TLS1_2_METHOD
202 IMPLEMENT_tls_meth_func(TLS1_2_VERSION, 0, SSL_OP_NO_TLSv1_2,
203                         tlsv1_2_client_method,
204                         ssl_undefined_function,
205                         ossl_statem_connect,
206                         TLSv1_2_enc_data)
207 #endif
208
209 #ifndef OPENSSL_NO_TLS1_1_METHOD
210 IMPLEMENT_tls_meth_func(TLS1_1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_TLSv1_1,
211                         tlsv1_1_client_method,
212                         ssl_undefined_function,
213                         ossl_statem_connect,
214                         TLSv1_1_enc_data)
215 #endif
216
217 #ifndef OPENSSL_NO_TLS1_METHOD
218 IMPLEMENT_tls_meth_func(TLS1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_TLSv1,
219                         tlsv1_client_method,
220                         ssl_undefined_function,
221                         ossl_statem_connect,
222                         TLSv1_enc_data)
223 #endif
224
225 #ifndef OPENSSL_NO_SSL3_METHOD
226 IMPLEMENT_ssl3_meth_func(sslv3_client_method,
227                          ssl_undefined_function,
228                          ossl_statem_connect)
229 #endif
230
231
232 /*
233  * DTLS methods
234  */
235
236 #ifndef OPENSSL_NO_DTLS1_METHOD
237 IMPLEMENT_dtls1_meth_func(DTLS1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_DTLSv1,
238                           dtlsv1_method,
239                           ossl_statem_accept,
240                           ossl_statem_connect,
241                           DTLSv1_enc_data)
242 #endif
243
244 #ifndef OPENSSL_NO_DTLS1_2_METHOD
245 IMPLEMENT_dtls1_meth_func(DTLS1_2_VERSION, 0, SSL_OP_NO_DTLSv1_2,
246                           dtlsv1_2_method,
247                           ossl_statem_accept,
248                           ossl_statem_connect,
249                           DTLSv1_2_enc_data)
250 #endif
251
252 IMPLEMENT_dtls1_meth_func(DTLS_ANY_VERSION, 0, 0,
253                           DTLS_method,
254                           ossl_statem_accept,
255                           ossl_statem_connect,
256                           DTLSv1_2_enc_data)
257
258 /*
259  * DTLS server methods
260  */
261
262 #ifndef OPENSSL_NO_DTLS1_METHOD
263 IMPLEMENT_dtls1_meth_func(DTLS1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_DTLSv1,
264                           dtlsv1_server_method,
265                           ossl_statem_accept,
266                           ssl_undefined_function,
267                           DTLSv1_enc_data)
268 #endif
269
270 #ifndef OPENSSL_NO_DTLS1_2_METHOD
271 IMPLEMENT_dtls1_meth_func(DTLS1_2_VERSION, 0, SSL_OP_NO_DTLSv1_2,
272                           dtlsv1_2_server_method,
273                           ossl_statem_accept,
274                           ssl_undefined_function,
275                           DTLSv1_2_enc_data)
276 #endif
277
278 IMPLEMENT_dtls1_meth_func(DTLS_ANY_VERSION, 0, 0,
279                           DTLS_server_method,
280                           ossl_statem_accept,
281                           ssl_undefined_function,
282                           DTLSv1_2_enc_data)
283
284
285 /*
286  * DTLS client methods
287  */
288
289 #ifndef OPENSSL_NO_DTLS1_METHOD
290 IMPLEMENT_dtls1_meth_func(DTLS1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_DTLSv1,
291                           dtlsv1_client_method,
292                           ssl_undefined_function,
293                           ossl_statem_connect,
294                           DTLSv1_enc_data)
295 #endif
296
297 #ifndef OPENSSL_NO_DTLS1_2_METHOD
298 IMPLEMENT_dtls1_meth_func(DTLS1_2_VERSION, 0, SSL_OP_NO_DTLSv1_2,
299                           dtlsv1_2_client_method,
300                           ssl_undefined_function,
301                           ossl_statem_connect,
302                           DTLSv1_2_enc_data)
303 #endif
304
305 IMPLEMENT_dtls1_meth_func(DTLS_ANY_VERSION, 0, 0,
306                           DTLS_client_method,
307                           ssl_undefined_function,
308                           ossl_statem_connect,
309                           DTLSv1_2_enc_data)
310
311 #if OPENSSL_API_COMPAT < 0x10100000L
312
313 # ifndef OPENSSL_NO_TLS1_2_METHOD
314 const SSL_METHOD *TLSv1_2_method(void)
315 {
316     return tlsv1_2_method();
317 }
318
319 const SSL_METHOD *TLSv1_2_server_method(void)
320 {
321     return tlsv1_2_server_method();
322 }
323
324 const SSL_METHOD *TLSv1_2_client_method(void)
325 {
326     return tlsv1_2_client_method();
327 }
328 # endif
329
330 # ifndef OPENSSL_NO_TLS1_1_METHOD
331 const SSL_METHOD *TLSv1_1_method(void)
332 {
333     return tlsv1_1_method();
334 }
335
336 const SSL_METHOD *TLSv1_1_server_method(void)
337 {
338     return tlsv1_1_server_method();
339 }
340
341 const SSL_METHOD *TLSv1_1_client_method(void)
342 {
343     return tlsv1_1_client_method();
344 }
345 # endif
346
347 # ifndef OPENSSL_NO_TLS1_METHOD
348 const SSL_METHOD *TLSv1_method(void)
349 {
350     return tlsv1_method();
351 }
352
353 const SSL_METHOD *TLSv1_server_method(void)
354 {
355     return tlsv1_server_method();
356 }
357
358 const SSL_METHOD *TLSv1_client_method(void)
359 {
360     return tlsv1_client_method();
361 }
362 # endif
363
364 # ifndef OPENSSL_NO_SSL3_METHOD
365 const SSL_METHOD *SSLv3_method(void)
366 {
367     return sslv3_method();
368 }
369
370 const SSL_METHOD *SSLv3_server_method(void)
371 {
372     return sslv3_server_method();
373 }
374
375 const SSL_METHOD *SSLv3_client_method(void)
376 {
377     return sslv3_client_method();
378 }
379 # endif
380
381 # ifndef OPENSSL_NO_DTLS1_2_METHOD
382 const SSL_METHOD *DTLSv1_2_method(void)
383 {
384     return dtlsv1_2_method();
385 }
386
387 const SSL_METHOD *DTLSv1_2_server_method(void)
388 {
389     return dtlsv1_2_server_method();
390 }
391
392 const SSL_METHOD *DTLSv1_2_client_method(void)
393 {
394     return dtlsv1_2_client_method();
395 }
396 # endif
397
398 # ifndef OPENSSL_NO_DTLS1_METHOD
399 const SSL_METHOD *DTLSv1_method(void)
400 {
401     return dtlsv1_method();
402 }
403
404 const SSL_METHOD *DTLSv1_server_method(void)
405 {
406     return dtlsv1_server_method();
407 }
408
409 const SSL_METHOD *DTLSv1_client_method(void)
410 {
411     return dtlsv1_client_method();
412 }
413 # endif
414
415 #endif
416