1 /* $OpenBSD: ssl_methods.c,v 1.7 2020/01/22 02:34:39 jsing Exp $ */ 2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 3 * All rights reserved. 4 * 5 * This package is an SSL implementation written 6 * by Eric Young (eay@cryptsoft.com). 7 * The implementation was written so as to conform with Netscapes SSL. 8 * 9 * This library is free for commercial and non-commercial use as long as 10 * the following conditions are aheared to. The following conditions 11 * apply to all code found in this distribution, be it the RC4, RSA, 12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation 13 * included with this distribution is covered by the same copyright terms 14 * except that the holder is Tim Hudson (tjh@cryptsoft.com). 15 * 16 * Copyright remains Eric Young's, and as such any Copyright notices in 17 * the code are not to be removed. 18 * If this package is used in a product, Eric Young should be given attribution 19 * as the author of the parts of the library used. 20 * This can be in the form of a textual message at program startup or 21 * in documentation (online or textual) provided with the package. 22 * 23 * Redistribution and use in source and binary forms, with or without 24 * modification, are permitted provided that the following conditions 25 * are met: 26 * 1. Redistributions of source code must retain the copyright 27 * notice, this list of conditions and the following disclaimer. 28 * 2. Redistributions in binary form must reproduce the above copyright 29 * notice, this list of conditions and the following disclaimer in the 30 * documentation and/or other materials provided with the distribution. 31 * 3. All advertising materials mentioning features or use of this software 32 * must display the following acknowledgement: 33 * "This product includes cryptographic software written by 34 * Eric Young (eay@cryptsoft.com)" 35 * The word 'cryptographic' can be left out if the rouines from the library 36 * being used are not cryptographic related :-). 37 * 4. If you include any Windows specific code (or a derivative thereof) from 38 * the apps directory (application code) you must include an acknowledgement: 39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 40 * 41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 51 * SUCH DAMAGE. 52 * 53 * The licence and distribution terms for any publically available version or 54 * derivative of this code cannot be changed. i.e. this code cannot simply be 55 * copied and put under another distribution licence 56 * [including the GNU Public Licence.] 57 */ 58 59 #include "ssl_locl.h" 60 #include "tls13_internal.h" 61 62 static const SSL_METHOD_INTERNAL DTLSv1_client_method_internal_data = { 63 .version = DTLS1_VERSION, 64 .min_version = DTLS1_VERSION, 65 .max_version = DTLS1_VERSION, 66 .ssl_new = dtls1_new, 67 .ssl_clear = dtls1_clear, 68 .ssl_free = dtls1_free, 69 .ssl_accept = ssl_undefined_function, 70 .ssl_connect = ssl3_connect, 71 .ssl_shutdown = ssl3_shutdown, 72 .get_ssl_method = dtls1_get_client_method, 73 .get_timeout = dtls1_default_timeout, 74 .ssl_version = ssl_undefined_void_function, 75 .ssl_renegotiate = ssl3_renegotiate, 76 .ssl_renegotiate_check = ssl3_renegotiate_check, 77 .ssl_get_message = dtls1_get_message, 78 .ssl_read_bytes = dtls1_read_bytes, 79 .ssl_write_bytes = dtls1_write_app_data_bytes, 80 .ssl3_enc = &DTLSv1_enc_data, 81 }; 82 83 static const SSL_METHOD DTLSv1_client_method_data = { 84 .ssl_dispatch_alert = dtls1_dispatch_alert, 85 .num_ciphers = ssl3_num_ciphers, 86 .get_cipher = dtls1_get_cipher, 87 .get_cipher_by_char = ssl3_get_cipher_by_char, 88 .put_cipher_by_char = ssl3_put_cipher_by_char, 89 .internal = &DTLSv1_client_method_internal_data, 90 }; 91 92 const SSL_METHOD * 93 DTLSv1_client_method(void) 94 { 95 return &DTLSv1_client_method_data; 96 } 97 98 const SSL_METHOD * 99 DTLS_client_method(void) 100 { 101 return DTLSv1_client_method(); 102 } 103 104 const SSL_METHOD * 105 dtls1_get_client_method(int ver) 106 { 107 if (ver == DTLS1_VERSION) 108 return (DTLSv1_client_method()); 109 return (NULL); 110 } 111 112 static const SSL_METHOD *dtls1_get_method(int ver); 113 114 static const SSL_METHOD_INTERNAL DTLSv1_method_internal_data = { 115 .version = DTLS1_VERSION, 116 .min_version = DTLS1_VERSION, 117 .max_version = DTLS1_VERSION, 118 .ssl_new = dtls1_new, 119 .ssl_clear = dtls1_clear, 120 .ssl_free = dtls1_free, 121 .ssl_accept = ssl3_accept, 122 .ssl_connect = ssl3_connect, 123 .ssl_shutdown = ssl3_shutdown, 124 .get_ssl_method = dtls1_get_method, 125 .get_timeout = dtls1_default_timeout, 126 .ssl_version = ssl_undefined_void_function, 127 .ssl_renegotiate = ssl3_renegotiate, 128 .ssl_renegotiate_check = ssl3_renegotiate_check, 129 .ssl_get_message = dtls1_get_message, 130 .ssl_read_bytes = dtls1_read_bytes, 131 .ssl_write_bytes = dtls1_write_app_data_bytes, 132 .ssl3_enc = &DTLSv1_enc_data, 133 }; 134 135 static const SSL_METHOD DTLSv1_method_data = { 136 .ssl_dispatch_alert = dtls1_dispatch_alert, 137 .num_ciphers = ssl3_num_ciphers, 138 .get_cipher = dtls1_get_cipher, 139 .get_cipher_by_char = ssl3_get_cipher_by_char, 140 .put_cipher_by_char = ssl3_put_cipher_by_char, 141 .internal = &DTLSv1_method_internal_data, 142 }; 143 144 const SSL_METHOD * 145 DTLSv1_method(void) 146 { 147 return &DTLSv1_method_data; 148 } 149 150 const SSL_METHOD * 151 DTLS_method(void) 152 { 153 return DTLSv1_method(); 154 } 155 156 static const SSL_METHOD * 157 dtls1_get_method(int ver) 158 { 159 if (ver == DTLS1_VERSION) 160 return (DTLSv1_method()); 161 return (NULL); 162 } 163 164 static const SSL_METHOD_INTERNAL DTLSv1_server_method_internal_data = { 165 .version = DTLS1_VERSION, 166 .min_version = DTLS1_VERSION, 167 .max_version = DTLS1_VERSION, 168 .ssl_new = dtls1_new, 169 .ssl_clear = dtls1_clear, 170 .ssl_free = dtls1_free, 171 .ssl_accept = ssl3_accept, 172 .ssl_connect = ssl_undefined_function, 173 .ssl_shutdown = ssl3_shutdown, 174 .get_ssl_method = dtls1_get_server_method, 175 .get_timeout = dtls1_default_timeout, 176 .ssl_version = ssl_undefined_void_function, 177 .ssl_renegotiate = ssl3_renegotiate, 178 .ssl_renegotiate_check = ssl3_renegotiate_check, 179 .ssl_get_message = dtls1_get_message, 180 .ssl_read_bytes = dtls1_read_bytes, 181 .ssl_write_bytes = dtls1_write_app_data_bytes, 182 .ssl3_enc = &DTLSv1_enc_data, 183 }; 184 185 static const SSL_METHOD DTLSv1_server_method_data = { 186 .ssl_dispatch_alert = dtls1_dispatch_alert, 187 .num_ciphers = ssl3_num_ciphers, 188 .get_cipher = dtls1_get_cipher, 189 .get_cipher_by_char = ssl3_get_cipher_by_char, 190 .put_cipher_by_char = ssl3_put_cipher_by_char, 191 .internal = &DTLSv1_server_method_internal_data, 192 }; 193 194 const SSL_METHOD * 195 DTLSv1_server_method(void) 196 { 197 return &DTLSv1_server_method_data; 198 } 199 200 const SSL_METHOD * 201 DTLS_server_method(void) 202 { 203 return DTLSv1_server_method(); 204 } 205 206 const SSL_METHOD * 207 dtls1_get_server_method(int ver) 208 { 209 if (ver == DTLS1_VERSION) 210 return (DTLSv1_server_method()); 211 return (NULL); 212 } 213 214 #ifdef LIBRESSL_HAS_TLS1_3_CLIENT 215 static const SSL_METHOD_INTERNAL TLS_client_method_internal_data = { 216 .version = TLS1_3_VERSION, 217 .min_version = TLS1_VERSION, 218 .max_version = TLS1_3_VERSION, 219 .ssl_new = tls1_new, 220 .ssl_clear = tls1_clear, 221 .ssl_free = tls1_free, 222 .ssl_accept = ssl_undefined_function, 223 .ssl_connect = tls13_legacy_connect, 224 .ssl_shutdown = tls13_legacy_shutdown, 225 .get_ssl_method = tls1_get_client_method, 226 .get_timeout = tls1_default_timeout, 227 .ssl_version = ssl_undefined_void_function, 228 .ssl_renegotiate = ssl_undefined_function, 229 .ssl_renegotiate_check = ssl_ok, 230 .ssl_get_message = ssl3_get_message, 231 .ssl_read_bytes = tls13_legacy_read_bytes, 232 .ssl_write_bytes = tls13_legacy_write_bytes, 233 .ssl3_enc = &TLSv1_2_enc_data, 234 }; 235 236 static const SSL_METHOD TLS_client_method_data = { 237 .ssl_dispatch_alert = ssl3_dispatch_alert, 238 .num_ciphers = ssl3_num_ciphers, 239 .get_cipher = ssl3_get_cipher, 240 .get_cipher_by_char = ssl3_get_cipher_by_char, 241 .put_cipher_by_char = ssl3_put_cipher_by_char, 242 .internal = &TLS_client_method_internal_data, 243 }; 244 #endif 245 246 static const SSL_METHOD_INTERNAL TLS_legacy_client_method_internal_data = { 247 .version = TLS1_2_VERSION, 248 .min_version = TLS1_VERSION, 249 .max_version = TLS1_2_VERSION, 250 .ssl_new = tls1_new, 251 .ssl_clear = tls1_clear, 252 .ssl_free = tls1_free, 253 .ssl_accept = ssl_undefined_function, 254 .ssl_connect = ssl3_connect, 255 .ssl_shutdown = ssl3_shutdown, 256 .get_ssl_method = tls1_get_client_method, 257 .get_timeout = tls1_default_timeout, 258 .ssl_version = ssl_undefined_void_function, 259 .ssl_renegotiate = ssl_undefined_function, 260 .ssl_renegotiate_check = ssl_ok, 261 .ssl_get_message = ssl3_get_message, 262 .ssl_read_bytes = ssl3_read_bytes, 263 .ssl_write_bytes = ssl3_write_bytes, 264 .ssl3_enc = &TLSv1_2_enc_data, 265 }; 266 267 static const SSL_METHOD TLS_legacy_client_method_data = { 268 .ssl_dispatch_alert = ssl3_dispatch_alert, 269 .num_ciphers = ssl3_num_ciphers, 270 .get_cipher = ssl3_get_cipher, 271 .get_cipher_by_char = ssl3_get_cipher_by_char, 272 .put_cipher_by_char = ssl3_put_cipher_by_char, 273 .internal = &TLS_legacy_client_method_internal_data, 274 }; 275 276 static const SSL_METHOD_INTERNAL TLSv1_client_method_internal_data = { 277 .version = TLS1_VERSION, 278 .min_version = TLS1_VERSION, 279 .max_version = TLS1_VERSION, 280 .ssl_new = tls1_new, 281 .ssl_clear = tls1_clear, 282 .ssl_free = tls1_free, 283 .ssl_accept = ssl_undefined_function, 284 .ssl_connect = ssl3_connect, 285 .ssl_shutdown = ssl3_shutdown, 286 .get_ssl_method = tls1_get_client_method, 287 .get_timeout = tls1_default_timeout, 288 .ssl_version = ssl_undefined_void_function, 289 .ssl_renegotiate = ssl3_renegotiate, 290 .ssl_renegotiate_check = ssl3_renegotiate_check, 291 .ssl_get_message = ssl3_get_message, 292 .ssl_read_bytes = ssl3_read_bytes, 293 .ssl_write_bytes = ssl3_write_bytes, 294 .ssl3_enc = &TLSv1_enc_data, 295 }; 296 297 static const SSL_METHOD TLSv1_client_method_data = { 298 .ssl_dispatch_alert = ssl3_dispatch_alert, 299 .num_ciphers = ssl3_num_ciphers, 300 .get_cipher = ssl3_get_cipher, 301 .get_cipher_by_char = ssl3_get_cipher_by_char, 302 .put_cipher_by_char = ssl3_put_cipher_by_char, 303 .internal = &TLSv1_client_method_internal_data, 304 }; 305 306 static const SSL_METHOD_INTERNAL TLSv1_1_client_method_internal_data = { 307 .version = TLS1_1_VERSION, 308 .min_version = TLS1_1_VERSION, 309 .max_version = TLS1_1_VERSION, 310 .ssl_new = tls1_new, 311 .ssl_clear = tls1_clear, 312 .ssl_free = tls1_free, 313 .ssl_accept = ssl_undefined_function, 314 .ssl_connect = ssl3_connect, 315 .ssl_shutdown = ssl3_shutdown, 316 .get_ssl_method = tls1_get_client_method, 317 .get_timeout = tls1_default_timeout, 318 .ssl_version = ssl_undefined_void_function, 319 .ssl_renegotiate = ssl3_renegotiate, 320 .ssl_renegotiate_check = ssl3_renegotiate_check, 321 .ssl_get_message = ssl3_get_message, 322 .ssl_read_bytes = ssl3_read_bytes, 323 .ssl_write_bytes = ssl3_write_bytes, 324 .ssl3_enc = &TLSv1_1_enc_data, 325 }; 326 327 static const SSL_METHOD TLSv1_1_client_method_data = { 328 .ssl_dispatch_alert = ssl3_dispatch_alert, 329 .num_ciphers = ssl3_num_ciphers, 330 .get_cipher = ssl3_get_cipher, 331 .get_cipher_by_char = ssl3_get_cipher_by_char, 332 .put_cipher_by_char = ssl3_put_cipher_by_char, 333 .internal = &TLSv1_1_client_method_internal_data, 334 }; 335 336 static const SSL_METHOD_INTERNAL TLSv1_2_client_method_internal_data = { 337 .version = TLS1_2_VERSION, 338 .min_version = TLS1_2_VERSION, 339 .max_version = TLS1_2_VERSION, 340 .ssl_new = tls1_new, 341 .ssl_clear = tls1_clear, 342 .ssl_free = tls1_free, 343 .ssl_accept = ssl_undefined_function, 344 .ssl_connect = ssl3_connect, 345 .ssl_shutdown = ssl3_shutdown, 346 .get_ssl_method = tls1_get_client_method, 347 .get_timeout = tls1_default_timeout, 348 .ssl_version = ssl_undefined_void_function, 349 .ssl_renegotiate = ssl3_renegotiate, 350 .ssl_renegotiate_check = ssl3_renegotiate_check, 351 .ssl_get_message = ssl3_get_message, 352 .ssl_read_bytes = ssl3_read_bytes, 353 .ssl_write_bytes = ssl3_write_bytes, 354 .ssl3_enc = &TLSv1_2_enc_data, 355 }; 356 357 static const SSL_METHOD TLSv1_2_client_method_data = { 358 .ssl_dispatch_alert = ssl3_dispatch_alert, 359 .num_ciphers = ssl3_num_ciphers, 360 .get_cipher = ssl3_get_cipher, 361 .get_cipher_by_char = ssl3_get_cipher_by_char, 362 .put_cipher_by_char = ssl3_put_cipher_by_char, 363 .internal = &TLSv1_2_client_method_internal_data, 364 }; 365 366 const SSL_METHOD * 367 tls1_get_client_method(int ver) 368 { 369 if (ver == TLS1_2_VERSION) 370 return (TLSv1_2_client_method()); 371 if (ver == TLS1_1_VERSION) 372 return (TLSv1_1_client_method()); 373 if (ver == TLS1_VERSION) 374 return (TLSv1_client_method()); 375 return (NULL); 376 } 377 378 const SSL_METHOD * 379 SSLv23_client_method(void) 380 { 381 return (TLS_client_method()); 382 } 383 384 const SSL_METHOD * 385 TLS_client_method(void) 386 { 387 #ifdef LIBRESSL_HAS_TLS1_3_CLIENT 388 return (&TLS_client_method_data); 389 #else 390 return tls_legacy_client_method(); 391 #endif 392 } 393 394 const SSL_METHOD * 395 tls_legacy_client_method(void) 396 { 397 return (&TLS_legacy_client_method_data); 398 } 399 400 const SSL_METHOD * 401 TLSv1_client_method(void) 402 { 403 return (&TLSv1_client_method_data); 404 } 405 406 const SSL_METHOD * 407 TLSv1_1_client_method(void) 408 { 409 return (&TLSv1_1_client_method_data); 410 } 411 412 const SSL_METHOD * 413 TLSv1_2_client_method(void) 414 { 415 return (&TLSv1_2_client_method_data); 416 } 417 418 static const SSL_METHOD *tls1_get_method(int ver); 419 420 static const SSL_METHOD_INTERNAL TLS_method_internal_data = { 421 .version = TLS1_2_VERSION, 422 .min_version = TLS1_VERSION, 423 .max_version = TLS1_2_VERSION, 424 .ssl_new = tls1_new, 425 .ssl_clear = tls1_clear, 426 .ssl_free = tls1_free, 427 .ssl_accept = ssl3_accept, 428 .ssl_connect = ssl3_connect, 429 .ssl_shutdown = ssl3_shutdown, 430 .get_ssl_method = tls1_get_method, 431 .get_timeout = tls1_default_timeout, 432 .ssl_version = ssl_undefined_void_function, 433 .ssl_renegotiate = ssl_undefined_function, 434 .ssl_renegotiate_check = ssl_ok, 435 .ssl_get_message = ssl3_get_message, 436 .ssl_read_bytes = ssl3_read_bytes, 437 .ssl_write_bytes = ssl3_write_bytes, 438 .ssl3_enc = &TLSv1_2_enc_data, 439 }; 440 441 static const SSL_METHOD TLS_method_data = { 442 .ssl_dispatch_alert = ssl3_dispatch_alert, 443 .num_ciphers = ssl3_num_ciphers, 444 .get_cipher = ssl3_get_cipher, 445 .get_cipher_by_char = ssl3_get_cipher_by_char, 446 .put_cipher_by_char = ssl3_put_cipher_by_char, 447 .internal = &TLS_method_internal_data, 448 }; 449 450 static const SSL_METHOD_INTERNAL TLSv1_method_internal_data = { 451 .version = TLS1_VERSION, 452 .min_version = TLS1_VERSION, 453 .max_version = TLS1_VERSION, 454 .ssl_new = tls1_new, 455 .ssl_clear = tls1_clear, 456 .ssl_free = tls1_free, 457 .ssl_accept = ssl3_accept, 458 .ssl_connect = ssl3_connect, 459 .ssl_shutdown = ssl3_shutdown, 460 .get_ssl_method = tls1_get_method, 461 .get_timeout = tls1_default_timeout, 462 .ssl_version = ssl_undefined_void_function, 463 .ssl_renegotiate = ssl3_renegotiate, 464 .ssl_renegotiate_check = ssl3_renegotiate_check, 465 .ssl_get_message = ssl3_get_message, 466 .ssl_read_bytes = ssl3_read_bytes, 467 .ssl_write_bytes = ssl3_write_bytes, 468 .ssl3_enc = &TLSv1_enc_data, 469 }; 470 471 static const SSL_METHOD TLSv1_method_data = { 472 .ssl_dispatch_alert = ssl3_dispatch_alert, 473 .num_ciphers = ssl3_num_ciphers, 474 .get_cipher = ssl3_get_cipher, 475 .get_cipher_by_char = ssl3_get_cipher_by_char, 476 .put_cipher_by_char = ssl3_put_cipher_by_char, 477 .internal = &TLSv1_method_internal_data, 478 }; 479 480 static const SSL_METHOD_INTERNAL TLSv1_1_method_internal_data = { 481 .version = TLS1_1_VERSION, 482 .min_version = TLS1_1_VERSION, 483 .max_version = TLS1_1_VERSION, 484 .ssl_new = tls1_new, 485 .ssl_clear = tls1_clear, 486 .ssl_free = tls1_free, 487 .ssl_accept = ssl3_accept, 488 .ssl_connect = ssl3_connect, 489 .ssl_shutdown = ssl3_shutdown, 490 .get_ssl_method = tls1_get_method, 491 .get_timeout = tls1_default_timeout, 492 .ssl_version = ssl_undefined_void_function, 493 .ssl_renegotiate = ssl3_renegotiate, 494 .ssl_renegotiate_check = ssl3_renegotiate_check, 495 .ssl_get_message = ssl3_get_message, 496 .ssl_read_bytes = ssl3_read_bytes, 497 .ssl_write_bytes = ssl3_write_bytes, 498 .ssl3_enc = &TLSv1_1_enc_data, 499 }; 500 501 static const SSL_METHOD TLSv1_1_method_data = { 502 .ssl_dispatch_alert = ssl3_dispatch_alert, 503 .num_ciphers = ssl3_num_ciphers, 504 .get_cipher = ssl3_get_cipher, 505 .get_cipher_by_char = ssl3_get_cipher_by_char, 506 .put_cipher_by_char = ssl3_put_cipher_by_char, 507 .internal = &TLSv1_1_method_internal_data, 508 }; 509 510 static const SSL_METHOD_INTERNAL TLSv1_2_method_internal_data = { 511 .version = TLS1_2_VERSION, 512 .min_version = TLS1_2_VERSION, 513 .max_version = TLS1_2_VERSION, 514 .ssl_new = tls1_new, 515 .ssl_clear = tls1_clear, 516 .ssl_free = tls1_free, 517 .ssl_accept = ssl3_accept, 518 .ssl_connect = ssl3_connect, 519 .ssl_shutdown = ssl3_shutdown, 520 .get_ssl_method = tls1_get_method, 521 .get_timeout = tls1_default_timeout, 522 .ssl_version = ssl_undefined_void_function, 523 .ssl_renegotiate = ssl3_renegotiate, 524 .ssl_renegotiate_check = ssl3_renegotiate_check, 525 .ssl_get_message = ssl3_get_message, 526 .ssl_read_bytes = ssl3_read_bytes, 527 .ssl_write_bytes = ssl3_write_bytes, 528 .ssl3_enc = &TLSv1_2_enc_data, 529 }; 530 531 static const SSL_METHOD TLSv1_2_method_data = { 532 .ssl_dispatch_alert = ssl3_dispatch_alert, 533 .num_ciphers = ssl3_num_ciphers, 534 .get_cipher = ssl3_get_cipher, 535 .get_cipher_by_char = ssl3_get_cipher_by_char, 536 .put_cipher_by_char = ssl3_put_cipher_by_char, 537 .internal = &TLSv1_2_method_internal_data, 538 }; 539 540 static const SSL_METHOD * 541 tls1_get_method(int ver) 542 { 543 if (ver == TLS1_2_VERSION) 544 return (TLSv1_2_method()); 545 if (ver == TLS1_1_VERSION) 546 return (TLSv1_1_method()); 547 if (ver == TLS1_VERSION) 548 return (TLSv1_method()); 549 return (NULL); 550 } 551 552 const SSL_METHOD * 553 SSLv23_method(void) 554 { 555 return (TLS_method()); 556 } 557 558 const SSL_METHOD * 559 TLS_method(void) 560 { 561 return &TLS_method_data; 562 } 563 564 const SSL_METHOD * 565 TLSv1_method(void) 566 { 567 return (&TLSv1_method_data); 568 } 569 570 const SSL_METHOD * 571 TLSv1_1_method(void) 572 { 573 return (&TLSv1_1_method_data); 574 } 575 576 const SSL_METHOD * 577 TLSv1_2_method(void) 578 { 579 return (&TLSv1_2_method_data); 580 } 581 582 static const SSL_METHOD_INTERNAL TLS_server_method_internal_data = { 583 .version = TLS1_2_VERSION, 584 .min_version = TLS1_VERSION, 585 .max_version = TLS1_2_VERSION, 586 .ssl_new = tls1_new, 587 .ssl_clear = tls1_clear, 588 .ssl_free = tls1_free, 589 .ssl_accept = ssl3_accept, 590 .ssl_connect = ssl_undefined_function, 591 .ssl_shutdown = ssl3_shutdown, 592 .get_ssl_method = tls1_get_server_method, 593 .get_timeout = tls1_default_timeout, 594 .ssl_version = ssl_undefined_void_function, 595 .ssl_renegotiate = ssl_undefined_function, 596 .ssl_renegotiate_check = ssl_ok, 597 .ssl_get_message = ssl3_get_message, 598 .ssl_read_bytes = ssl3_read_bytes, 599 .ssl_write_bytes = ssl3_write_bytes, 600 .ssl3_enc = &TLSv1_2_enc_data, 601 }; 602 603 static const SSL_METHOD TLS_server_method_data = { 604 .ssl_dispatch_alert = ssl3_dispatch_alert, 605 .num_ciphers = ssl3_num_ciphers, 606 .get_cipher = ssl3_get_cipher, 607 .get_cipher_by_char = ssl3_get_cipher_by_char, 608 .put_cipher_by_char = ssl3_put_cipher_by_char, 609 .internal = &TLS_server_method_internal_data, 610 }; 611 612 static const SSL_METHOD_INTERNAL TLSv1_server_method_internal_data = { 613 .version = TLS1_VERSION, 614 .min_version = TLS1_VERSION, 615 .max_version = TLS1_VERSION, 616 .ssl_new = tls1_new, 617 .ssl_clear = tls1_clear, 618 .ssl_free = tls1_free, 619 .ssl_accept = ssl3_accept, 620 .ssl_connect = ssl_undefined_function, 621 .ssl_shutdown = ssl3_shutdown, 622 .get_ssl_method = tls1_get_server_method, 623 .get_timeout = tls1_default_timeout, 624 .ssl_version = ssl_undefined_void_function, 625 .ssl_renegotiate = ssl3_renegotiate, 626 .ssl_renegotiate_check = ssl3_renegotiate_check, 627 .ssl_get_message = ssl3_get_message, 628 .ssl_read_bytes = ssl3_read_bytes, 629 .ssl_write_bytes = ssl3_write_bytes, 630 .ssl3_enc = &TLSv1_enc_data, 631 }; 632 633 static const SSL_METHOD TLSv1_server_method_data = { 634 .ssl_dispatch_alert = ssl3_dispatch_alert, 635 .num_ciphers = ssl3_num_ciphers, 636 .get_cipher = ssl3_get_cipher, 637 .get_cipher_by_char = ssl3_get_cipher_by_char, 638 .put_cipher_by_char = ssl3_put_cipher_by_char, 639 .internal = &TLSv1_server_method_internal_data, 640 }; 641 642 static const SSL_METHOD_INTERNAL TLSv1_1_server_method_internal_data = { 643 .version = TLS1_1_VERSION, 644 .min_version = TLS1_1_VERSION, 645 .max_version = TLS1_1_VERSION, 646 .ssl_new = tls1_new, 647 .ssl_clear = tls1_clear, 648 .ssl_free = tls1_free, 649 .ssl_accept = ssl3_accept, 650 .ssl_connect = ssl_undefined_function, 651 .ssl_shutdown = ssl3_shutdown, 652 .get_ssl_method = tls1_get_server_method, 653 .get_timeout = tls1_default_timeout, 654 .ssl_version = ssl_undefined_void_function, 655 .ssl_renegotiate = ssl3_renegotiate, 656 .ssl_renegotiate_check = ssl3_renegotiate_check, 657 .ssl_get_message = ssl3_get_message, 658 .ssl_read_bytes = ssl3_read_bytes, 659 .ssl_write_bytes = ssl3_write_bytes, 660 .ssl3_enc = &TLSv1_1_enc_data, 661 }; 662 663 static const SSL_METHOD TLSv1_1_server_method_data = { 664 .ssl_dispatch_alert = ssl3_dispatch_alert, 665 .num_ciphers = ssl3_num_ciphers, 666 .get_cipher = ssl3_get_cipher, 667 .get_cipher_by_char = ssl3_get_cipher_by_char, 668 .put_cipher_by_char = ssl3_put_cipher_by_char, 669 .internal = &TLSv1_1_server_method_internal_data, 670 }; 671 672 static const SSL_METHOD_INTERNAL TLSv1_2_server_method_internal_data = { 673 .version = TLS1_2_VERSION, 674 .min_version = TLS1_2_VERSION, 675 .max_version = TLS1_2_VERSION, 676 .ssl_new = tls1_new, 677 .ssl_clear = tls1_clear, 678 .ssl_free = tls1_free, 679 .ssl_accept = ssl3_accept, 680 .ssl_connect = ssl_undefined_function, 681 .ssl_shutdown = ssl3_shutdown, 682 .get_ssl_method = tls1_get_server_method, 683 .get_timeout = tls1_default_timeout, 684 .ssl_version = ssl_undefined_void_function, 685 .ssl_renegotiate = ssl3_renegotiate, 686 .ssl_renegotiate_check = ssl3_renegotiate_check, 687 .ssl_get_message = ssl3_get_message, 688 .ssl_read_bytes = ssl3_read_bytes, 689 .ssl_write_bytes = ssl3_write_bytes, 690 .ssl3_enc = &TLSv1_2_enc_data, 691 }; 692 693 static const SSL_METHOD TLSv1_2_server_method_data = { 694 .ssl_dispatch_alert = ssl3_dispatch_alert, 695 .num_ciphers = ssl3_num_ciphers, 696 .get_cipher = ssl3_get_cipher, 697 .get_cipher_by_char = ssl3_get_cipher_by_char, 698 .put_cipher_by_char = ssl3_put_cipher_by_char, 699 .internal = &TLSv1_2_server_method_internal_data, 700 }; 701 702 const SSL_METHOD * 703 tls1_get_server_method(int ver) 704 { 705 if (ver == TLS1_2_VERSION) 706 return (TLSv1_2_server_method()); 707 if (ver == TLS1_1_VERSION) 708 return (TLSv1_1_server_method()); 709 if (ver == TLS1_VERSION) 710 return (TLSv1_server_method()); 711 return (NULL); 712 } 713 714 const SSL_METHOD * 715 SSLv23_server_method(void) 716 { 717 return (TLS_server_method()); 718 } 719 720 const SSL_METHOD * 721 TLS_server_method(void) 722 { 723 return (&TLS_server_method_data); 724 } 725 726 const SSL_METHOD * 727 TLSv1_server_method(void) 728 { 729 return (&TLSv1_server_method_data); 730 } 731 732 const SSL_METHOD * 733 TLSv1_1_server_method(void) 734 { 735 return (&TLSv1_1_server_method_data); 736 } 737 738 const SSL_METHOD * 739 TLSv1_2_server_method(void) 740 { 741 return (&TLSv1_2_server_method_data); 742 } 743