1*71023d34Sjsing /* $OpenBSD: ssl_methods.c,v 1.4 2019/03/17 17:28:08 jsing Exp $ */ 29158af98Sjsing /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 39158af98Sjsing * All rights reserved. 49158af98Sjsing * 59158af98Sjsing * This package is an SSL implementation written 69158af98Sjsing * by Eric Young (eay@cryptsoft.com). 79158af98Sjsing * The implementation was written so as to conform with Netscapes SSL. 89158af98Sjsing * 99158af98Sjsing * This library is free for commercial and non-commercial use as long as 109158af98Sjsing * the following conditions are aheared to. The following conditions 119158af98Sjsing * apply to all code found in this distribution, be it the RC4, RSA, 129158af98Sjsing * lhash, DES, etc., code; not just the SSL code. The SSL documentation 139158af98Sjsing * included with this distribution is covered by the same copyright terms 149158af98Sjsing * except that the holder is Tim Hudson (tjh@cryptsoft.com). 159158af98Sjsing * 169158af98Sjsing * Copyright remains Eric Young's, and as such any Copyright notices in 179158af98Sjsing * the code are not to be removed. 189158af98Sjsing * If this package is used in a product, Eric Young should be given attribution 199158af98Sjsing * as the author of the parts of the library used. 209158af98Sjsing * This can be in the form of a textual message at program startup or 219158af98Sjsing * in documentation (online or textual) provided with the package. 229158af98Sjsing * 239158af98Sjsing * Redistribution and use in source and binary forms, with or without 249158af98Sjsing * modification, are permitted provided that the following conditions 259158af98Sjsing * are met: 269158af98Sjsing * 1. Redistributions of source code must retain the copyright 279158af98Sjsing * notice, this list of conditions and the following disclaimer. 289158af98Sjsing * 2. Redistributions in binary form must reproduce the above copyright 299158af98Sjsing * notice, this list of conditions and the following disclaimer in the 309158af98Sjsing * documentation and/or other materials provided with the distribution. 319158af98Sjsing * 3. All advertising materials mentioning features or use of this software 329158af98Sjsing * must display the following acknowledgement: 339158af98Sjsing * "This product includes cryptographic software written by 349158af98Sjsing * Eric Young (eay@cryptsoft.com)" 359158af98Sjsing * The word 'cryptographic' can be left out if the rouines from the library 369158af98Sjsing * being used are not cryptographic related :-). 379158af98Sjsing * 4. If you include any Windows specific code (or a derivative thereof) from 389158af98Sjsing * the apps directory (application code) you must include an acknowledgement: 399158af98Sjsing * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 409158af98Sjsing * 419158af98Sjsing * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 429158af98Sjsing * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 439158af98Sjsing * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 449158af98Sjsing * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 459158af98Sjsing * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 469158af98Sjsing * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 479158af98Sjsing * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 489158af98Sjsing * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 499158af98Sjsing * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 509158af98Sjsing * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 519158af98Sjsing * SUCH DAMAGE. 529158af98Sjsing * 539158af98Sjsing * The licence and distribution terms for any publically available version or 549158af98Sjsing * derivative of this code cannot be changed. i.e. this code cannot simply be 559158af98Sjsing * copied and put under another distribution licence 569158af98Sjsing * [including the GNU Public Licence.] 579158af98Sjsing */ 589158af98Sjsing 599158af98Sjsing #include "ssl_locl.h" 60efee3f2fSjsing #include "tls13_internal.h" 619158af98Sjsing 629158af98Sjsing static const SSL_METHOD_INTERNAL DTLSv1_client_method_internal_data = { 639158af98Sjsing .version = DTLS1_VERSION, 649158af98Sjsing .min_version = DTLS1_VERSION, 659158af98Sjsing .max_version = DTLS1_VERSION, 669158af98Sjsing .ssl_new = dtls1_new, 679158af98Sjsing .ssl_clear = dtls1_clear, 689158af98Sjsing .ssl_free = dtls1_free, 699158af98Sjsing .ssl_accept = ssl_undefined_function, 709158af98Sjsing .ssl_connect = ssl3_connect, 719158af98Sjsing .get_ssl_method = dtls1_get_client_method, 729158af98Sjsing .get_timeout = dtls1_default_timeout, 739158af98Sjsing .ssl_version = ssl_undefined_void_function, 749158af98Sjsing .ssl_renegotiate = ssl3_renegotiate, 759158af98Sjsing .ssl_renegotiate_check = ssl3_renegotiate_check, 769158af98Sjsing .ssl_get_message = dtls1_get_message, 779158af98Sjsing .ssl_read_bytes = dtls1_read_bytes, 789158af98Sjsing .ssl_write_bytes = dtls1_write_app_data_bytes, 799158af98Sjsing .ssl3_enc = &DTLSv1_enc_data, 809158af98Sjsing }; 819158af98Sjsing 829158af98Sjsing static const SSL_METHOD DTLSv1_client_method_data = { 839158af98Sjsing .ssl_dispatch_alert = dtls1_dispatch_alert, 849158af98Sjsing .num_ciphers = ssl3_num_ciphers, 859158af98Sjsing .get_cipher = dtls1_get_cipher, 869158af98Sjsing .get_cipher_by_char = ssl3_get_cipher_by_char, 879158af98Sjsing .put_cipher_by_char = ssl3_put_cipher_by_char, 889158af98Sjsing .internal = &DTLSv1_client_method_internal_data, 899158af98Sjsing }; 909158af98Sjsing 919158af98Sjsing const SSL_METHOD * 929158af98Sjsing DTLSv1_client_method(void) 939158af98Sjsing { 949158af98Sjsing return &DTLSv1_client_method_data; 959158af98Sjsing } 969158af98Sjsing 979158af98Sjsing const SSL_METHOD * 98*71023d34Sjsing DTLS_client_method(void) 99*71023d34Sjsing { 100*71023d34Sjsing return DTLSv1_client_method(); 101*71023d34Sjsing } 102*71023d34Sjsing 103*71023d34Sjsing const SSL_METHOD * 1049158af98Sjsing dtls1_get_client_method(int ver) 1059158af98Sjsing { 1069158af98Sjsing if (ver == DTLS1_VERSION) 1079158af98Sjsing return (DTLSv1_client_method()); 1089158af98Sjsing return (NULL); 1099158af98Sjsing } 1109158af98Sjsing 1119158af98Sjsing static const SSL_METHOD *dtls1_get_method(int ver); 1129158af98Sjsing 1139158af98Sjsing static const SSL_METHOD_INTERNAL DTLSv1_method_internal_data = { 1149158af98Sjsing .version = DTLS1_VERSION, 1159158af98Sjsing .min_version = DTLS1_VERSION, 1169158af98Sjsing .max_version = DTLS1_VERSION, 1179158af98Sjsing .ssl_new = dtls1_new, 1189158af98Sjsing .ssl_clear = dtls1_clear, 1199158af98Sjsing .ssl_free = dtls1_free, 1209158af98Sjsing .ssl_accept = ssl3_accept, 1219158af98Sjsing .ssl_connect = ssl3_connect, 1229158af98Sjsing .get_ssl_method = dtls1_get_method, 1239158af98Sjsing .get_timeout = dtls1_default_timeout, 1249158af98Sjsing .ssl_version = ssl_undefined_void_function, 1259158af98Sjsing .ssl_renegotiate = ssl3_renegotiate, 1269158af98Sjsing .ssl_renegotiate_check = ssl3_renegotiate_check, 1279158af98Sjsing .ssl_get_message = dtls1_get_message, 1289158af98Sjsing .ssl_read_bytes = dtls1_read_bytes, 1299158af98Sjsing .ssl_write_bytes = dtls1_write_app_data_bytes, 1309158af98Sjsing .ssl3_enc = &DTLSv1_enc_data, 1319158af98Sjsing }; 1329158af98Sjsing 1339158af98Sjsing static const SSL_METHOD DTLSv1_method_data = { 1349158af98Sjsing .ssl_dispatch_alert = dtls1_dispatch_alert, 1359158af98Sjsing .num_ciphers = ssl3_num_ciphers, 1369158af98Sjsing .get_cipher = dtls1_get_cipher, 1379158af98Sjsing .get_cipher_by_char = ssl3_get_cipher_by_char, 1389158af98Sjsing .put_cipher_by_char = ssl3_put_cipher_by_char, 1399158af98Sjsing .internal = &DTLSv1_method_internal_data, 1409158af98Sjsing }; 1419158af98Sjsing 1429158af98Sjsing const SSL_METHOD * 1439158af98Sjsing DTLSv1_method(void) 1449158af98Sjsing { 1459158af98Sjsing return &DTLSv1_method_data; 1469158af98Sjsing } 1479158af98Sjsing 148*71023d34Sjsing const SSL_METHOD * 149*71023d34Sjsing DTLS_method(void) 150*71023d34Sjsing { 151*71023d34Sjsing return DTLSv1_method(); 152*71023d34Sjsing } 153*71023d34Sjsing 1549158af98Sjsing static const SSL_METHOD * 1559158af98Sjsing dtls1_get_method(int ver) 1569158af98Sjsing { 1579158af98Sjsing if (ver == DTLS1_VERSION) 1589158af98Sjsing return (DTLSv1_method()); 1599158af98Sjsing return (NULL); 1609158af98Sjsing } 1619158af98Sjsing 1629158af98Sjsing static const SSL_METHOD_INTERNAL DTLSv1_server_method_internal_data = { 1639158af98Sjsing .version = DTLS1_VERSION, 1649158af98Sjsing .min_version = DTLS1_VERSION, 1659158af98Sjsing .max_version = DTLS1_VERSION, 1669158af98Sjsing .ssl_new = dtls1_new, 1679158af98Sjsing .ssl_clear = dtls1_clear, 1689158af98Sjsing .ssl_free = dtls1_free, 1699158af98Sjsing .ssl_accept = ssl3_accept, 1709158af98Sjsing .ssl_connect = ssl_undefined_function, 1719158af98Sjsing .get_ssl_method = dtls1_get_server_method, 1729158af98Sjsing .get_timeout = dtls1_default_timeout, 1739158af98Sjsing .ssl_version = ssl_undefined_void_function, 1749158af98Sjsing .ssl_renegotiate = ssl3_renegotiate, 1759158af98Sjsing .ssl_renegotiate_check = ssl3_renegotiate_check, 1769158af98Sjsing .ssl_get_message = dtls1_get_message, 1779158af98Sjsing .ssl_read_bytes = dtls1_read_bytes, 1789158af98Sjsing .ssl_write_bytes = dtls1_write_app_data_bytes, 1799158af98Sjsing .ssl3_enc = &DTLSv1_enc_data, 1809158af98Sjsing }; 1819158af98Sjsing 1829158af98Sjsing static const SSL_METHOD DTLSv1_server_method_data = { 1839158af98Sjsing .ssl_dispatch_alert = dtls1_dispatch_alert, 1849158af98Sjsing .num_ciphers = ssl3_num_ciphers, 1859158af98Sjsing .get_cipher = dtls1_get_cipher, 1869158af98Sjsing .get_cipher_by_char = ssl3_get_cipher_by_char, 1879158af98Sjsing .put_cipher_by_char = ssl3_put_cipher_by_char, 1889158af98Sjsing .internal = &DTLSv1_server_method_internal_data, 1899158af98Sjsing }; 1909158af98Sjsing 1919158af98Sjsing const SSL_METHOD * 1929158af98Sjsing DTLSv1_server_method(void) 1939158af98Sjsing { 1949158af98Sjsing return &DTLSv1_server_method_data; 1959158af98Sjsing } 1969158af98Sjsing 1979158af98Sjsing const SSL_METHOD * 198*71023d34Sjsing DTLS_server_method(void) 199*71023d34Sjsing { 200*71023d34Sjsing return DTLSv1_server_method(); 201*71023d34Sjsing } 202*71023d34Sjsing 203*71023d34Sjsing const SSL_METHOD * 2049158af98Sjsing dtls1_get_server_method(int ver) 2059158af98Sjsing { 2069158af98Sjsing if (ver == DTLS1_VERSION) 2079158af98Sjsing return (DTLSv1_server_method()); 2089158af98Sjsing return (NULL); 2099158af98Sjsing } 2109158af98Sjsing 21164a0a0c8Sjsing #ifdef LIBRESSL_HAS_TLS1_3 2129158af98Sjsing static const SSL_METHOD_INTERNAL TLS_client_method_internal_data = { 213efee3f2fSjsing .version = TLS1_3_VERSION, 214efee3f2fSjsing .min_version = TLS1_VERSION, 215efee3f2fSjsing .max_version = TLS1_3_VERSION, 216efee3f2fSjsing .ssl_new = tls1_new, 217efee3f2fSjsing .ssl_clear = tls1_clear, 218efee3f2fSjsing .ssl_free = tls1_free, 219efee3f2fSjsing .ssl_accept = ssl_undefined_function, 220efee3f2fSjsing .ssl_connect = tls13_legacy_connect, 221efee3f2fSjsing .get_ssl_method = tls1_get_client_method, 222efee3f2fSjsing .get_timeout = tls1_default_timeout, 223efee3f2fSjsing .ssl_version = ssl_undefined_void_function, 224efee3f2fSjsing .ssl_renegotiate = ssl_undefined_function, 225efee3f2fSjsing .ssl_renegotiate_check = ssl_ok, 226efee3f2fSjsing .ssl_get_message = ssl3_get_message, 227efee3f2fSjsing .ssl_read_bytes = tls13_legacy_read_bytes, 228efee3f2fSjsing .ssl_write_bytes = tls13_legacy_write_bytes, 229efee3f2fSjsing .ssl3_enc = &TLSv1_2_enc_data, 230efee3f2fSjsing }; 231efee3f2fSjsing 232efee3f2fSjsing static const SSL_METHOD TLS_client_method_data = { 233efee3f2fSjsing .ssl_dispatch_alert = ssl3_dispatch_alert, 234efee3f2fSjsing .num_ciphers = ssl3_num_ciphers, 235efee3f2fSjsing .get_cipher = ssl3_get_cipher, 236efee3f2fSjsing .get_cipher_by_char = ssl3_get_cipher_by_char, 237efee3f2fSjsing .put_cipher_by_char = ssl3_put_cipher_by_char, 238efee3f2fSjsing .internal = &TLS_client_method_internal_data, 239efee3f2fSjsing }; 240efee3f2fSjsing #endif 241efee3f2fSjsing 242efee3f2fSjsing static const SSL_METHOD_INTERNAL TLS_legacy_client_method_internal_data = { 2439158af98Sjsing .version = TLS1_2_VERSION, 2449158af98Sjsing .min_version = TLS1_VERSION, 2459158af98Sjsing .max_version = TLS1_2_VERSION, 2469158af98Sjsing .ssl_new = tls1_new, 2479158af98Sjsing .ssl_clear = tls1_clear, 2489158af98Sjsing .ssl_free = tls1_free, 2499158af98Sjsing .ssl_accept = ssl_undefined_function, 2509158af98Sjsing .ssl_connect = ssl3_connect, 2519158af98Sjsing .get_ssl_method = tls1_get_client_method, 2529158af98Sjsing .get_timeout = tls1_default_timeout, 2539158af98Sjsing .ssl_version = ssl_undefined_void_function, 2549158af98Sjsing .ssl_renegotiate = ssl_undefined_function, 2559158af98Sjsing .ssl_renegotiate_check = ssl_ok, 2569158af98Sjsing .ssl_get_message = ssl3_get_message, 2579158af98Sjsing .ssl_read_bytes = ssl3_read_bytes, 2589158af98Sjsing .ssl_write_bytes = ssl3_write_bytes, 2599158af98Sjsing .ssl3_enc = &TLSv1_2_enc_data, 2609158af98Sjsing }; 2619158af98Sjsing 262efee3f2fSjsing static const SSL_METHOD TLS_legacy_client_method_data = { 2639158af98Sjsing .ssl_dispatch_alert = ssl3_dispatch_alert, 2649158af98Sjsing .num_ciphers = ssl3_num_ciphers, 2659158af98Sjsing .get_cipher = ssl3_get_cipher, 2669158af98Sjsing .get_cipher_by_char = ssl3_get_cipher_by_char, 2679158af98Sjsing .put_cipher_by_char = ssl3_put_cipher_by_char, 268efee3f2fSjsing .internal = &TLS_legacy_client_method_internal_data, 2699158af98Sjsing }; 2709158af98Sjsing 2719158af98Sjsing static const SSL_METHOD_INTERNAL TLSv1_client_method_internal_data = { 2729158af98Sjsing .version = TLS1_VERSION, 2739158af98Sjsing .min_version = TLS1_VERSION, 2749158af98Sjsing .max_version = TLS1_VERSION, 2759158af98Sjsing .ssl_new = tls1_new, 2769158af98Sjsing .ssl_clear = tls1_clear, 2779158af98Sjsing .ssl_free = tls1_free, 2789158af98Sjsing .ssl_accept = ssl_undefined_function, 2799158af98Sjsing .ssl_connect = ssl3_connect, 2809158af98Sjsing .get_ssl_method = tls1_get_client_method, 2819158af98Sjsing .get_timeout = tls1_default_timeout, 2829158af98Sjsing .ssl_version = ssl_undefined_void_function, 2839158af98Sjsing .ssl_renegotiate = ssl3_renegotiate, 2849158af98Sjsing .ssl_renegotiate_check = ssl3_renegotiate_check, 2859158af98Sjsing .ssl_get_message = ssl3_get_message, 2869158af98Sjsing .ssl_read_bytes = ssl3_read_bytes, 2879158af98Sjsing .ssl_write_bytes = ssl3_write_bytes, 2889158af98Sjsing .ssl3_enc = &TLSv1_enc_data, 2899158af98Sjsing }; 2909158af98Sjsing 2919158af98Sjsing static const SSL_METHOD TLSv1_client_method_data = { 2929158af98Sjsing .ssl_dispatch_alert = ssl3_dispatch_alert, 2939158af98Sjsing .num_ciphers = ssl3_num_ciphers, 2949158af98Sjsing .get_cipher = ssl3_get_cipher, 2959158af98Sjsing .get_cipher_by_char = ssl3_get_cipher_by_char, 2969158af98Sjsing .put_cipher_by_char = ssl3_put_cipher_by_char, 2979158af98Sjsing .internal = &TLSv1_client_method_internal_data, 2989158af98Sjsing }; 2999158af98Sjsing 3009158af98Sjsing static const SSL_METHOD_INTERNAL TLSv1_1_client_method_internal_data = { 3019158af98Sjsing .version = TLS1_1_VERSION, 3029158af98Sjsing .min_version = TLS1_1_VERSION, 3039158af98Sjsing .max_version = TLS1_1_VERSION, 3049158af98Sjsing .ssl_new = tls1_new, 3059158af98Sjsing .ssl_clear = tls1_clear, 3069158af98Sjsing .ssl_free = tls1_free, 3079158af98Sjsing .ssl_accept = ssl_undefined_function, 3089158af98Sjsing .ssl_connect = ssl3_connect, 3099158af98Sjsing .get_ssl_method = tls1_get_client_method, 3109158af98Sjsing .get_timeout = tls1_default_timeout, 3119158af98Sjsing .ssl_version = ssl_undefined_void_function, 3129158af98Sjsing .ssl_renegotiate = ssl3_renegotiate, 3139158af98Sjsing .ssl_renegotiate_check = ssl3_renegotiate_check, 3149158af98Sjsing .ssl_get_message = ssl3_get_message, 3159158af98Sjsing .ssl_read_bytes = ssl3_read_bytes, 3169158af98Sjsing .ssl_write_bytes = ssl3_write_bytes, 3179158af98Sjsing .ssl3_enc = &TLSv1_1_enc_data, 3189158af98Sjsing }; 3199158af98Sjsing 3209158af98Sjsing static const SSL_METHOD TLSv1_1_client_method_data = { 3219158af98Sjsing .ssl_dispatch_alert = ssl3_dispatch_alert, 3229158af98Sjsing .num_ciphers = ssl3_num_ciphers, 3239158af98Sjsing .get_cipher = ssl3_get_cipher, 3249158af98Sjsing .get_cipher_by_char = ssl3_get_cipher_by_char, 3259158af98Sjsing .put_cipher_by_char = ssl3_put_cipher_by_char, 3269158af98Sjsing .internal = &TLSv1_1_client_method_internal_data, 3279158af98Sjsing }; 3289158af98Sjsing 3299158af98Sjsing static const SSL_METHOD_INTERNAL TLSv1_2_client_method_internal_data = { 3309158af98Sjsing .version = TLS1_2_VERSION, 3319158af98Sjsing .min_version = TLS1_2_VERSION, 3329158af98Sjsing .max_version = TLS1_2_VERSION, 3339158af98Sjsing .ssl_new = tls1_new, 3349158af98Sjsing .ssl_clear = tls1_clear, 3359158af98Sjsing .ssl_free = tls1_free, 3369158af98Sjsing .ssl_accept = ssl_undefined_function, 3379158af98Sjsing .ssl_connect = ssl3_connect, 3389158af98Sjsing .get_ssl_method = tls1_get_client_method, 3399158af98Sjsing .get_timeout = tls1_default_timeout, 3409158af98Sjsing .ssl_version = ssl_undefined_void_function, 3419158af98Sjsing .ssl_renegotiate = ssl3_renegotiate, 3429158af98Sjsing .ssl_renegotiate_check = ssl3_renegotiate_check, 3439158af98Sjsing .ssl_get_message = ssl3_get_message, 3449158af98Sjsing .ssl_read_bytes = ssl3_read_bytes, 3459158af98Sjsing .ssl_write_bytes = ssl3_write_bytes, 3469158af98Sjsing .ssl3_enc = &TLSv1_2_enc_data, 3479158af98Sjsing }; 3489158af98Sjsing 3499158af98Sjsing static const SSL_METHOD TLSv1_2_client_method_data = { 3509158af98Sjsing .ssl_dispatch_alert = ssl3_dispatch_alert, 3519158af98Sjsing .num_ciphers = ssl3_num_ciphers, 3529158af98Sjsing .get_cipher = ssl3_get_cipher, 3539158af98Sjsing .get_cipher_by_char = ssl3_get_cipher_by_char, 3549158af98Sjsing .put_cipher_by_char = ssl3_put_cipher_by_char, 3559158af98Sjsing .internal = &TLSv1_2_client_method_internal_data, 3569158af98Sjsing }; 3579158af98Sjsing 3589158af98Sjsing const SSL_METHOD * 3599158af98Sjsing tls1_get_client_method(int ver) 3609158af98Sjsing { 3619158af98Sjsing if (ver == TLS1_2_VERSION) 3629158af98Sjsing return (TLSv1_2_client_method()); 3639158af98Sjsing if (ver == TLS1_1_VERSION) 3649158af98Sjsing return (TLSv1_1_client_method()); 3659158af98Sjsing if (ver == TLS1_VERSION) 3669158af98Sjsing return (TLSv1_client_method()); 3679158af98Sjsing return (NULL); 3689158af98Sjsing } 3699158af98Sjsing 3709158af98Sjsing const SSL_METHOD * 3719158af98Sjsing SSLv23_client_method(void) 3729158af98Sjsing { 3739158af98Sjsing return (TLS_client_method()); 3749158af98Sjsing } 3759158af98Sjsing 3769158af98Sjsing const SSL_METHOD * 3779158af98Sjsing TLS_client_method(void) 3789158af98Sjsing { 37964a0a0c8Sjsing #ifdef LIBRESSL_HAS_TLS1_3 3809158af98Sjsing return (&TLS_client_method_data); 381efee3f2fSjsing #else 382efee3f2fSjsing return tls_legacy_client_method(); 383efee3f2fSjsing #endif 384efee3f2fSjsing } 385efee3f2fSjsing 386efee3f2fSjsing const SSL_METHOD * 387efee3f2fSjsing tls_legacy_client_method(void) 388efee3f2fSjsing { 389efee3f2fSjsing return (&TLS_legacy_client_method_data); 3909158af98Sjsing } 3919158af98Sjsing 3929158af98Sjsing const SSL_METHOD * 3939158af98Sjsing TLSv1_client_method(void) 3949158af98Sjsing { 3959158af98Sjsing return (&TLSv1_client_method_data); 3969158af98Sjsing } 3979158af98Sjsing 3989158af98Sjsing const SSL_METHOD * 3999158af98Sjsing TLSv1_1_client_method(void) 4009158af98Sjsing { 4019158af98Sjsing return (&TLSv1_1_client_method_data); 4029158af98Sjsing } 4039158af98Sjsing 4049158af98Sjsing const SSL_METHOD * 4059158af98Sjsing TLSv1_2_client_method(void) 4069158af98Sjsing { 4079158af98Sjsing return (&TLSv1_2_client_method_data); 4089158af98Sjsing } 4099158af98Sjsing 4109158af98Sjsing static const SSL_METHOD *tls1_get_method(int ver); 4119158af98Sjsing 4129158af98Sjsing static const SSL_METHOD_INTERNAL TLS_method_internal_data = { 4139158af98Sjsing .version = TLS1_2_VERSION, 4149158af98Sjsing .min_version = TLS1_VERSION, 4159158af98Sjsing .max_version = TLS1_2_VERSION, 4169158af98Sjsing .ssl_new = tls1_new, 4179158af98Sjsing .ssl_clear = tls1_clear, 4189158af98Sjsing .ssl_free = tls1_free, 4199158af98Sjsing .ssl_accept = ssl3_accept, 4209158af98Sjsing .ssl_connect = ssl3_connect, 4219158af98Sjsing .get_ssl_method = tls1_get_method, 4229158af98Sjsing .get_timeout = tls1_default_timeout, 4239158af98Sjsing .ssl_version = ssl_undefined_void_function, 4249158af98Sjsing .ssl_renegotiate = ssl_undefined_function, 4259158af98Sjsing .ssl_renegotiate_check = ssl_ok, 4269158af98Sjsing .ssl_get_message = ssl3_get_message, 4279158af98Sjsing .ssl_read_bytes = ssl3_read_bytes, 4289158af98Sjsing .ssl_write_bytes = ssl3_write_bytes, 4299158af98Sjsing .ssl3_enc = &TLSv1_2_enc_data, 4309158af98Sjsing }; 4319158af98Sjsing 4329158af98Sjsing static const SSL_METHOD TLS_method_data = { 4339158af98Sjsing .ssl_dispatch_alert = ssl3_dispatch_alert, 4349158af98Sjsing .num_ciphers = ssl3_num_ciphers, 4359158af98Sjsing .get_cipher = ssl3_get_cipher, 4369158af98Sjsing .get_cipher_by_char = ssl3_get_cipher_by_char, 4379158af98Sjsing .put_cipher_by_char = ssl3_put_cipher_by_char, 4389158af98Sjsing .internal = &TLS_method_internal_data, 4399158af98Sjsing }; 4409158af98Sjsing 4419158af98Sjsing static const SSL_METHOD_INTERNAL TLSv1_method_internal_data = { 4429158af98Sjsing .version = TLS1_VERSION, 4439158af98Sjsing .min_version = TLS1_VERSION, 4449158af98Sjsing .max_version = TLS1_VERSION, 4459158af98Sjsing .ssl_new = tls1_new, 4469158af98Sjsing .ssl_clear = tls1_clear, 4479158af98Sjsing .ssl_free = tls1_free, 4489158af98Sjsing .ssl_accept = ssl3_accept, 4499158af98Sjsing .ssl_connect = ssl3_connect, 4509158af98Sjsing .get_ssl_method = tls1_get_method, 4519158af98Sjsing .get_timeout = tls1_default_timeout, 4529158af98Sjsing .ssl_version = ssl_undefined_void_function, 4539158af98Sjsing .ssl_renegotiate = ssl3_renegotiate, 4549158af98Sjsing .ssl_renegotiate_check = ssl3_renegotiate_check, 4559158af98Sjsing .ssl_get_message = ssl3_get_message, 4569158af98Sjsing .ssl_read_bytes = ssl3_read_bytes, 4579158af98Sjsing .ssl_write_bytes = ssl3_write_bytes, 4589158af98Sjsing .ssl3_enc = &TLSv1_enc_data, 4599158af98Sjsing }; 4609158af98Sjsing 4619158af98Sjsing static const SSL_METHOD TLSv1_method_data = { 4629158af98Sjsing .ssl_dispatch_alert = ssl3_dispatch_alert, 4639158af98Sjsing .num_ciphers = ssl3_num_ciphers, 4649158af98Sjsing .get_cipher = ssl3_get_cipher, 4659158af98Sjsing .get_cipher_by_char = ssl3_get_cipher_by_char, 4669158af98Sjsing .put_cipher_by_char = ssl3_put_cipher_by_char, 4679158af98Sjsing .internal = &TLSv1_method_internal_data, 4689158af98Sjsing }; 4699158af98Sjsing 4709158af98Sjsing static const SSL_METHOD_INTERNAL TLSv1_1_method_internal_data = { 4719158af98Sjsing .version = TLS1_1_VERSION, 4729158af98Sjsing .min_version = TLS1_1_VERSION, 4739158af98Sjsing .max_version = TLS1_1_VERSION, 4749158af98Sjsing .ssl_new = tls1_new, 4759158af98Sjsing .ssl_clear = tls1_clear, 4769158af98Sjsing .ssl_free = tls1_free, 4779158af98Sjsing .ssl_accept = ssl3_accept, 4789158af98Sjsing .ssl_connect = ssl3_connect, 4799158af98Sjsing .get_ssl_method = tls1_get_method, 4809158af98Sjsing .get_timeout = tls1_default_timeout, 4819158af98Sjsing .ssl_version = ssl_undefined_void_function, 4829158af98Sjsing .ssl_renegotiate = ssl3_renegotiate, 4839158af98Sjsing .ssl_renegotiate_check = ssl3_renegotiate_check, 4849158af98Sjsing .ssl_get_message = ssl3_get_message, 4859158af98Sjsing .ssl_read_bytes = ssl3_read_bytes, 4869158af98Sjsing .ssl_write_bytes = ssl3_write_bytes, 4879158af98Sjsing .ssl3_enc = &TLSv1_1_enc_data, 4889158af98Sjsing }; 4899158af98Sjsing 4909158af98Sjsing static const SSL_METHOD TLSv1_1_method_data = { 4919158af98Sjsing .ssl_dispatch_alert = ssl3_dispatch_alert, 4929158af98Sjsing .num_ciphers = ssl3_num_ciphers, 4939158af98Sjsing .get_cipher = ssl3_get_cipher, 4949158af98Sjsing .get_cipher_by_char = ssl3_get_cipher_by_char, 4959158af98Sjsing .put_cipher_by_char = ssl3_put_cipher_by_char, 4969158af98Sjsing .internal = &TLSv1_1_method_internal_data, 4979158af98Sjsing }; 4989158af98Sjsing 4999158af98Sjsing static const SSL_METHOD_INTERNAL TLSv1_2_method_internal_data = { 5009158af98Sjsing .version = TLS1_2_VERSION, 5019158af98Sjsing .min_version = TLS1_2_VERSION, 5029158af98Sjsing .max_version = TLS1_2_VERSION, 5039158af98Sjsing .ssl_new = tls1_new, 5049158af98Sjsing .ssl_clear = tls1_clear, 5059158af98Sjsing .ssl_free = tls1_free, 5069158af98Sjsing .ssl_accept = ssl3_accept, 5079158af98Sjsing .ssl_connect = ssl3_connect, 5089158af98Sjsing .get_ssl_method = tls1_get_method, 5099158af98Sjsing .get_timeout = tls1_default_timeout, 5109158af98Sjsing .ssl_version = ssl_undefined_void_function, 5119158af98Sjsing .ssl_renegotiate = ssl3_renegotiate, 5129158af98Sjsing .ssl_renegotiate_check = ssl3_renegotiate_check, 5139158af98Sjsing .ssl_get_message = ssl3_get_message, 5149158af98Sjsing .ssl_read_bytes = ssl3_read_bytes, 5159158af98Sjsing .ssl_write_bytes = ssl3_write_bytes, 5169158af98Sjsing .ssl3_enc = &TLSv1_2_enc_data, 5179158af98Sjsing }; 5189158af98Sjsing 5199158af98Sjsing static const SSL_METHOD TLSv1_2_method_data = { 5209158af98Sjsing .ssl_dispatch_alert = ssl3_dispatch_alert, 5219158af98Sjsing .num_ciphers = ssl3_num_ciphers, 5229158af98Sjsing .get_cipher = ssl3_get_cipher, 5239158af98Sjsing .get_cipher_by_char = ssl3_get_cipher_by_char, 5249158af98Sjsing .put_cipher_by_char = ssl3_put_cipher_by_char, 5259158af98Sjsing .internal = &TLSv1_2_method_internal_data, 5269158af98Sjsing }; 5279158af98Sjsing 5289158af98Sjsing static const SSL_METHOD * 5299158af98Sjsing tls1_get_method(int ver) 5309158af98Sjsing { 5319158af98Sjsing if (ver == TLS1_2_VERSION) 5329158af98Sjsing return (TLSv1_2_method()); 5339158af98Sjsing if (ver == TLS1_1_VERSION) 5349158af98Sjsing return (TLSv1_1_method()); 5359158af98Sjsing if (ver == TLS1_VERSION) 5369158af98Sjsing return (TLSv1_method()); 5379158af98Sjsing return (NULL); 5389158af98Sjsing } 5399158af98Sjsing 5409158af98Sjsing const SSL_METHOD * 5419158af98Sjsing SSLv23_method(void) 5429158af98Sjsing { 5439158af98Sjsing return (TLS_method()); 5449158af98Sjsing } 5459158af98Sjsing 5469158af98Sjsing const SSL_METHOD * 5479158af98Sjsing TLS_method(void) 5489158af98Sjsing { 5499158af98Sjsing return &TLS_method_data; 5509158af98Sjsing } 5519158af98Sjsing 5529158af98Sjsing const SSL_METHOD * 5539158af98Sjsing TLSv1_method(void) 5549158af98Sjsing { 5559158af98Sjsing return (&TLSv1_method_data); 5569158af98Sjsing } 5579158af98Sjsing 5589158af98Sjsing const SSL_METHOD * 5599158af98Sjsing TLSv1_1_method(void) 5609158af98Sjsing { 5619158af98Sjsing return (&TLSv1_1_method_data); 5629158af98Sjsing } 5639158af98Sjsing 5649158af98Sjsing const SSL_METHOD * 5659158af98Sjsing TLSv1_2_method(void) 5669158af98Sjsing { 5679158af98Sjsing return (&TLSv1_2_method_data); 5689158af98Sjsing } 5699158af98Sjsing 5709158af98Sjsing static const SSL_METHOD_INTERNAL TLS_server_method_internal_data = { 5719158af98Sjsing .version = TLS1_2_VERSION, 5729158af98Sjsing .min_version = TLS1_VERSION, 5739158af98Sjsing .max_version = TLS1_2_VERSION, 5749158af98Sjsing .ssl_new = tls1_new, 5759158af98Sjsing .ssl_clear = tls1_clear, 5769158af98Sjsing .ssl_free = tls1_free, 5779158af98Sjsing .ssl_accept = ssl3_accept, 5789158af98Sjsing .ssl_connect = ssl_undefined_function, 5799158af98Sjsing .get_ssl_method = tls1_get_server_method, 5809158af98Sjsing .get_timeout = tls1_default_timeout, 5819158af98Sjsing .ssl_version = ssl_undefined_void_function, 5829158af98Sjsing .ssl_renegotiate = ssl_undefined_function, 5839158af98Sjsing .ssl_renegotiate_check = ssl_ok, 5849158af98Sjsing .ssl_get_message = ssl3_get_message, 5859158af98Sjsing .ssl_read_bytes = ssl3_read_bytes, 5869158af98Sjsing .ssl_write_bytes = ssl3_write_bytes, 5879158af98Sjsing .ssl3_enc = &TLSv1_2_enc_data, 5889158af98Sjsing }; 5899158af98Sjsing 5909158af98Sjsing static const SSL_METHOD TLS_server_method_data = { 5919158af98Sjsing .ssl_dispatch_alert = ssl3_dispatch_alert, 5929158af98Sjsing .num_ciphers = ssl3_num_ciphers, 5939158af98Sjsing .get_cipher = ssl3_get_cipher, 5949158af98Sjsing .get_cipher_by_char = ssl3_get_cipher_by_char, 5959158af98Sjsing .put_cipher_by_char = ssl3_put_cipher_by_char, 5969158af98Sjsing .internal = &TLS_server_method_internal_data, 5979158af98Sjsing }; 5989158af98Sjsing 5999158af98Sjsing static const SSL_METHOD_INTERNAL TLSv1_server_method_internal_data = { 6009158af98Sjsing .version = TLS1_VERSION, 6019158af98Sjsing .min_version = TLS1_VERSION, 6029158af98Sjsing .max_version = TLS1_VERSION, 6039158af98Sjsing .ssl_new = tls1_new, 6049158af98Sjsing .ssl_clear = tls1_clear, 6059158af98Sjsing .ssl_free = tls1_free, 6069158af98Sjsing .ssl_accept = ssl3_accept, 6079158af98Sjsing .ssl_connect = ssl_undefined_function, 6089158af98Sjsing .get_ssl_method = tls1_get_server_method, 6099158af98Sjsing .get_timeout = tls1_default_timeout, 6109158af98Sjsing .ssl_version = ssl_undefined_void_function, 6119158af98Sjsing .ssl_renegotiate = ssl3_renegotiate, 6129158af98Sjsing .ssl_renegotiate_check = ssl3_renegotiate_check, 6139158af98Sjsing .ssl_get_message = ssl3_get_message, 6149158af98Sjsing .ssl_read_bytes = ssl3_read_bytes, 6159158af98Sjsing .ssl_write_bytes = ssl3_write_bytes, 6169158af98Sjsing .ssl3_enc = &TLSv1_enc_data, 6179158af98Sjsing }; 6189158af98Sjsing 6199158af98Sjsing static const SSL_METHOD TLSv1_server_method_data = { 6209158af98Sjsing .ssl_dispatch_alert = ssl3_dispatch_alert, 6219158af98Sjsing .num_ciphers = ssl3_num_ciphers, 6229158af98Sjsing .get_cipher = ssl3_get_cipher, 6239158af98Sjsing .get_cipher_by_char = ssl3_get_cipher_by_char, 6249158af98Sjsing .put_cipher_by_char = ssl3_put_cipher_by_char, 6259158af98Sjsing .internal = &TLSv1_server_method_internal_data, 6269158af98Sjsing }; 6279158af98Sjsing 6289158af98Sjsing static const SSL_METHOD_INTERNAL TLSv1_1_server_method_internal_data = { 6299158af98Sjsing .version = TLS1_1_VERSION, 6309158af98Sjsing .min_version = TLS1_1_VERSION, 6319158af98Sjsing .max_version = TLS1_1_VERSION, 6329158af98Sjsing .ssl_new = tls1_new, 6339158af98Sjsing .ssl_clear = tls1_clear, 6349158af98Sjsing .ssl_free = tls1_free, 6359158af98Sjsing .ssl_accept = ssl3_accept, 6369158af98Sjsing .ssl_connect = ssl_undefined_function, 6379158af98Sjsing .get_ssl_method = tls1_get_server_method, 6389158af98Sjsing .get_timeout = tls1_default_timeout, 6399158af98Sjsing .ssl_version = ssl_undefined_void_function, 6409158af98Sjsing .ssl_renegotiate = ssl3_renegotiate, 6419158af98Sjsing .ssl_renegotiate_check = ssl3_renegotiate_check, 6429158af98Sjsing .ssl_get_message = ssl3_get_message, 6439158af98Sjsing .ssl_read_bytes = ssl3_read_bytes, 6449158af98Sjsing .ssl_write_bytes = ssl3_write_bytes, 6459158af98Sjsing .ssl3_enc = &TLSv1_1_enc_data, 6469158af98Sjsing }; 6479158af98Sjsing 6489158af98Sjsing static const SSL_METHOD TLSv1_1_server_method_data = { 6499158af98Sjsing .ssl_dispatch_alert = ssl3_dispatch_alert, 6509158af98Sjsing .num_ciphers = ssl3_num_ciphers, 6519158af98Sjsing .get_cipher = ssl3_get_cipher, 6529158af98Sjsing .get_cipher_by_char = ssl3_get_cipher_by_char, 6539158af98Sjsing .put_cipher_by_char = ssl3_put_cipher_by_char, 6549158af98Sjsing .internal = &TLSv1_1_server_method_internal_data, 6559158af98Sjsing }; 6569158af98Sjsing 6579158af98Sjsing static const SSL_METHOD_INTERNAL TLSv1_2_server_method_internal_data = { 6589158af98Sjsing .version = TLS1_2_VERSION, 6599158af98Sjsing .min_version = TLS1_2_VERSION, 6609158af98Sjsing .max_version = TLS1_2_VERSION, 6619158af98Sjsing .ssl_new = tls1_new, 6629158af98Sjsing .ssl_clear = tls1_clear, 6639158af98Sjsing .ssl_free = tls1_free, 6649158af98Sjsing .ssl_accept = ssl3_accept, 6659158af98Sjsing .ssl_connect = ssl_undefined_function, 6669158af98Sjsing .get_ssl_method = tls1_get_server_method, 6679158af98Sjsing .get_timeout = tls1_default_timeout, 6689158af98Sjsing .ssl_version = ssl_undefined_void_function, 6699158af98Sjsing .ssl_renegotiate = ssl3_renegotiate, 6709158af98Sjsing .ssl_renegotiate_check = ssl3_renegotiate_check, 6719158af98Sjsing .ssl_get_message = ssl3_get_message, 6729158af98Sjsing .ssl_read_bytes = ssl3_read_bytes, 6739158af98Sjsing .ssl_write_bytes = ssl3_write_bytes, 6749158af98Sjsing .ssl3_enc = &TLSv1_2_enc_data, 6759158af98Sjsing }; 6769158af98Sjsing 6779158af98Sjsing static const SSL_METHOD TLSv1_2_server_method_data = { 6789158af98Sjsing .ssl_dispatch_alert = ssl3_dispatch_alert, 6799158af98Sjsing .num_ciphers = ssl3_num_ciphers, 6809158af98Sjsing .get_cipher = ssl3_get_cipher, 6819158af98Sjsing .get_cipher_by_char = ssl3_get_cipher_by_char, 6829158af98Sjsing .put_cipher_by_char = ssl3_put_cipher_by_char, 6839158af98Sjsing .internal = &TLSv1_2_server_method_internal_data, 6849158af98Sjsing }; 6859158af98Sjsing 6869158af98Sjsing const SSL_METHOD * 6879158af98Sjsing tls1_get_server_method(int ver) 6889158af98Sjsing { 6899158af98Sjsing if (ver == TLS1_2_VERSION) 6909158af98Sjsing return (TLSv1_2_server_method()); 6919158af98Sjsing if (ver == TLS1_1_VERSION) 6929158af98Sjsing return (TLSv1_1_server_method()); 6939158af98Sjsing if (ver == TLS1_VERSION) 6949158af98Sjsing return (TLSv1_server_method()); 6959158af98Sjsing return (NULL); 6969158af98Sjsing } 6979158af98Sjsing 6989158af98Sjsing const SSL_METHOD * 6999158af98Sjsing SSLv23_server_method(void) 7009158af98Sjsing { 7019158af98Sjsing return (TLS_server_method()); 7029158af98Sjsing } 7039158af98Sjsing 7049158af98Sjsing const SSL_METHOD * 7059158af98Sjsing TLS_server_method(void) 7069158af98Sjsing { 7079158af98Sjsing return (&TLS_server_method_data); 7089158af98Sjsing } 7099158af98Sjsing 7109158af98Sjsing const SSL_METHOD * 7119158af98Sjsing TLSv1_server_method(void) 7129158af98Sjsing { 7139158af98Sjsing return (&TLSv1_server_method_data); 7149158af98Sjsing } 7159158af98Sjsing 7169158af98Sjsing const SSL_METHOD * 7179158af98Sjsing TLSv1_1_server_method(void) 7189158af98Sjsing { 7199158af98Sjsing return (&TLSv1_1_server_method_data); 7209158af98Sjsing } 7219158af98Sjsing 7229158af98Sjsing const SSL_METHOD * 7239158af98Sjsing TLSv1_2_server_method(void) 7249158af98Sjsing { 7259158af98Sjsing return (&TLSv1_2_server_method_data); 7269158af98Sjsing } 727