1 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
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.
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).
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.
22 * Redistribution and use in source and binary forms, with or without
23 * modification, are permitted provided that the following conditions
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)"
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
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.]
57 /* ====================================================================
58 * Copyright (c) 1998-2015 The OpenSSL Project. All rights reserved.
60 * Redistribution and use in source and binary forms, with or without
61 * modification, are permitted provided that the following conditions
64 * 1. Redistributions of source code must retain the above copyright
65 * notice, this list of conditions and the following disclaimer.
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
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/)"
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.
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.
86 * 6. Redistributions of any form whatsoever must retain the following
88 * "This product includes software developed by the OpenSSL Project
89 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
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 * ====================================================================
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).
112 #include <openssl/objects.h>
113 #include "ssl_locl.h"
119 static const SSL_METHOD *tls1_get_method(int ver)
121 if (ver == TLS_ANY_VERSION)
123 #ifndef OPENSSL_NO_TLS1_2
124 if (ver == TLS1_2_VERSION)
125 return TLSv1_2_method();
127 #ifndef OPENSSL_NO_TLS1_1
128 if (ver == TLS1_1_VERSION)
129 return TLSv1_1_method();
131 #ifndef OPENSSL_NO_TLS1
132 if (ver == TLS1_VERSION)
133 return TLSv1_method();
135 #ifndef OPENSSL_NO_SSL3
136 if (ver == SSL3_VERSION)
137 return (SSLv3_method());
143 IMPLEMENT_tls_meth_func(TLS_ANY_VERSION, 0, 0,
146 ossl_statem_connect, tls1_get_method, TLSv1_2_enc_data)
148 #ifndef OPENSSL_NO_TLS1_2_METHOD
149 IMPLEMENT_tls_meth_func(TLS1_2_VERSION, 0, SSL_OP_NO_TLSv1_2,
152 ossl_statem_connect, tls1_get_method, TLSv1_2_enc_data)
155 #ifndef OPENSSL_NO_TLS1_1_METHOD
156 IMPLEMENT_tls_meth_func(TLS1_1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_TLSv1_1,
159 ossl_statem_connect, tls1_get_method, TLSv1_1_enc_data)
162 #ifndef OPENSSL_NO_TLS1_METHOD
163 IMPLEMENT_tls_meth_func(TLS1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_TLSv1,
166 ossl_statem_connect, tls1_get_method, TLSv1_enc_data)
169 #ifndef OPENSSL_NO_SSL3_METHOD
170 IMPLEMENT_ssl3_meth_func(SSLv3_method, ossl_statem_accept, ossl_statem_connect,
176 * TLS/SSLv3 server methods
179 static const SSL_METHOD *tls1_get_server_method(int ver)
181 if (ver == TLS_ANY_VERSION)
182 return TLS_server_method();
183 #ifndef OPENSSL_NO_TLS1_2
184 if (ver == TLS1_2_VERSION)
185 return TLSv1_2_server_method();
187 #ifndef OPENSSL_NO_TLS1_1
188 if (ver == TLS1_1_VERSION)
189 return TLSv1_1_server_method();
191 #ifndef OPENSSL_NO_TLS1
192 if (ver == TLS1_VERSION)
193 return TLSv1_server_method();
195 #ifndef OPENSSL_NO_SSL3
196 if (ver == SSL3_VERSION)
197 return (SSLv3_server_method());
202 IMPLEMENT_tls_meth_func(TLS_ANY_VERSION, 0, 0,
205 ssl_undefined_function,
206 tls1_get_server_method, TLSv1_2_enc_data)
208 #ifndef OPENSSL_NO_TLS1_2_METHOD
209 IMPLEMENT_tls_meth_func(TLS1_2_VERSION, 0, SSL_OP_NO_TLSv1_2,
210 TLSv1_2_server_method,
212 ssl_undefined_function,
213 tls1_get_server_method, TLSv1_2_enc_data)
216 #ifndef OPENSSL_NO_TLS1_1_METHOD
217 IMPLEMENT_tls_meth_func(TLS1_1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_TLSv1_1,
218 TLSv1_1_server_method,
220 ssl_undefined_function,
221 tls1_get_server_method, TLSv1_1_enc_data)
224 #ifndef OPENSSL_NO_TLS1_METHOD
225 IMPLEMENT_tls_meth_func(TLS1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_TLSv1,
228 ssl_undefined_function,
229 tls1_get_server_method, TLSv1_enc_data)
232 #ifndef OPENSSL_NO_SSL3_METHOD
233 IMPLEMENT_ssl3_meth_func(SSLv3_server_method,
235 ssl_undefined_function, tls1_get_server_method)
240 * TLS/SSLv3 client methods
243 static const SSL_METHOD *tls1_get_client_method(int ver)
245 if (ver == TLS_ANY_VERSION)
246 return TLS_client_method();
247 #ifndef OPENSSL_NO_TLS1_2
248 if (ver == TLS1_2_VERSION)
249 return TLSv1_2_client_method();
251 #ifndef OPENSSL_NO_TLS1_1
252 if (ver == TLS1_1_VERSION)
253 return TLSv1_1_client_method();
255 #ifndef OPENSSL_NO_TLS1
256 if (ver == TLS1_VERSION)
257 return TLSv1_client_method();
259 #ifndef OPENSSL_NO_SSL3
260 if (ver == SSL3_VERSION)
261 return (SSLv3_client_method());
266 IMPLEMENT_tls_meth_func(TLS_ANY_VERSION, 0, 0,
268 ssl_undefined_function,
270 tls1_get_client_method, TLSv1_2_enc_data)
272 #ifndef OPENSSL_NO_TLS1_2_METHOD
273 IMPLEMENT_tls_meth_func(TLS1_2_VERSION, 0, SSL_OP_NO_TLSv1_2,
274 TLSv1_2_client_method,
275 ssl_undefined_function,
277 tls1_get_client_method, TLSv1_2_enc_data)
280 #ifndef OPENSSL_NO_TLS1_1_METHOD
281 IMPLEMENT_tls_meth_func(TLS1_1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_TLSv1_1,
282 TLSv1_1_client_method,
283 ssl_undefined_function,
285 tls1_get_client_method, TLSv1_1_enc_data)
288 #ifndef OPENSSL_NO_TLS1_METHOD
289 IMPLEMENT_tls_meth_func(TLS1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_TLSv1,
291 ssl_undefined_function,
293 tls1_get_client_method, TLSv1_enc_data)
296 #ifndef OPENSSL_NO_SSL3_METHOD
297 IMPLEMENT_ssl3_meth_func(SSLv3_client_method,
298 ssl_undefined_function,
299 ossl_statem_connect, tls1_get_client_method)
306 static const SSL_METHOD *dtls1_get_method(int ver)
308 if (ver == DTLS_ANY_VERSION)
309 return DTLS_method();
310 #ifndef OPENSSL_NO_DTLS1
311 else if (ver == DTLS1_VERSION)
312 return DTLSv1_method();
314 #ifndef OPENSSL_NO_DTLS1_2
315 else if (ver == DTLS1_2_VERSION)
316 return DTLSv1_2_method();
322 #ifndef OPENSSL_NO_DTLS1_METHOD
323 IMPLEMENT_dtls1_meth_func(DTLS1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_DTLSv1,
327 dtls1_get_method, DTLSv1_enc_data)
330 #ifndef OPENSSL_NO_DTLS1_2_METHOD
331 IMPLEMENT_dtls1_meth_func(DTLS1_2_VERSION, 0, SSL_OP_NO_DTLSv1_2,
335 dtls1_get_method, DTLSv1_2_enc_data)
338 IMPLEMENT_dtls1_meth_func(DTLS_ANY_VERSION, 0, 0,
342 dtls1_get_method, DTLSv1_2_enc_data)
345 * DTLS server methods
348 static const SSL_METHOD *dtls1_get_server_method(int ver)
350 if (ver == DTLS_ANY_VERSION)
351 return DTLS_server_method();
352 #ifndef OPENSSL_NO_DTLS1
353 else if (ver == DTLS1_VERSION)
354 return DTLSv1_server_method();
356 #ifndef OPENSSL_NO_DTLS1_2
357 else if (ver == DTLS1_2_VERSION)
358 return DTLSv1_2_server_method();
364 #ifndef OPENSSL_NO_DTLS1_METHOD
365 IMPLEMENT_dtls1_meth_func(DTLS1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_DTLSv1,
366 DTLSv1_server_method,
368 ssl_undefined_function,
369 dtls1_get_server_method, DTLSv1_enc_data)
372 #ifndef OPENSSL_NO_DTLS1_2_METHOD
373 IMPLEMENT_dtls1_meth_func(DTLS1_2_VERSION, 0, SSL_OP_NO_DTLSv1_2,
374 DTLSv1_2_server_method,
376 ssl_undefined_function,
377 dtls1_get_server_method, DTLSv1_2_enc_data)
380 IMPLEMENT_dtls1_meth_func(DTLS_ANY_VERSION, 0, 0,
383 ssl_undefined_function,
384 dtls1_get_server_method, DTLSv1_2_enc_data)
388 * DTLS client methods
391 static const SSL_METHOD *dtls1_get_client_method(int ver)
393 if (ver == DTLS_ANY_VERSION)
394 return DTLS_client_method();
395 #ifndef OPENSSL_NO_DTLS1
396 else if (ver == DTLS1_VERSION || ver == DTLS1_BAD_VER)
397 return DTLSv1_client_method();
399 #ifndef OPENSSL_NO_DTLS1_2
400 else if (ver == DTLS1_2_VERSION)
401 return DTLSv1_2_client_method();
407 #ifndef OPENSSL_NO_DTLS1_METHOD
408 IMPLEMENT_dtls1_meth_func(DTLS1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_DTLSv1,
409 DTLSv1_client_method,
410 ssl_undefined_function,
412 dtls1_get_client_method, DTLSv1_enc_data)
415 #ifndef OPENSSL_NO_DTLS1_2_METHOD
416 IMPLEMENT_dtls1_meth_func(DTLS1_2_VERSION, 0, SSL_OP_NO_DTLSv1_2,
417 DTLSv1_2_client_method,
418 ssl_undefined_function,
420 dtls1_get_client_method, DTLSv1_2_enc_data)
423 IMPLEMENT_dtls1_meth_func(DTLS_ANY_VERSION, 0, 0,
425 ssl_undefined_function,
427 dtls1_get_client_method, DTLSv1_2_enc_data)