From 5518a6b41f13c34882ea1415c4f1e65ba5678603 Mon Sep 17 00:00:00 2001 From: jsing <> Date: Thu, 14 Feb 2019 17:50:07 +0000 Subject: Provide a TLS 1.3 capable client method. ok tb@ --- src/lib/libssl/ssl_methods.c | 48 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-) (limited to 'src/lib/libssl/ssl_methods.c') diff --git a/src/lib/libssl/ssl_methods.c b/src/lib/libssl/ssl_methods.c index 3e9f18bc40..636fed92a0 100644 --- a/src/lib/libssl/ssl_methods.c +++ b/src/lib/libssl/ssl_methods.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_methods.c,v 1.1 2018/11/05 05:45:15 jsing Exp $ */ +/* $OpenBSD: ssl_methods.c,v 1.2 2019/02/14 17:50:07 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -57,6 +57,7 @@ */ #include "ssl_locl.h" +#include "tls13_internal.h" static const SSL_METHOD_INTERNAL DTLSv1_client_method_internal_data = { .version = DTLS1_VERSION, @@ -189,7 +190,38 @@ dtls1_get_server_method(int ver) return (NULL); } +#ifdef LIBRESSL_HAS_TLS13 static const SSL_METHOD_INTERNAL TLS_client_method_internal_data = { + .version = TLS1_3_VERSION, + .min_version = TLS1_VERSION, + .max_version = TLS1_3_VERSION, + .ssl_new = tls1_new, + .ssl_clear = tls1_clear, + .ssl_free = tls1_free, + .ssl_accept = ssl_undefined_function, + .ssl_connect = tls13_legacy_connect, + .get_ssl_method = tls1_get_client_method, + .get_timeout = tls1_default_timeout, + .ssl_version = ssl_undefined_void_function, + .ssl_renegotiate = ssl_undefined_function, + .ssl_renegotiate_check = ssl_ok, + .ssl_get_message = ssl3_get_message, + .ssl_read_bytes = tls13_legacy_read_bytes, + .ssl_write_bytes = tls13_legacy_write_bytes, + .ssl3_enc = &TLSv1_2_enc_data, +}; + +static const SSL_METHOD TLS_client_method_data = { + .ssl_dispatch_alert = ssl3_dispatch_alert, + .num_ciphers = ssl3_num_ciphers, + .get_cipher = ssl3_get_cipher, + .get_cipher_by_char = ssl3_get_cipher_by_char, + .put_cipher_by_char = ssl3_put_cipher_by_char, + .internal = &TLS_client_method_internal_data, +}; +#endif + +static const SSL_METHOD_INTERNAL TLS_legacy_client_method_internal_data = { .version = TLS1_2_VERSION, .min_version = TLS1_VERSION, .max_version = TLS1_2_VERSION, @@ -209,13 +241,13 @@ static const SSL_METHOD_INTERNAL TLS_client_method_internal_data = { .ssl3_enc = &TLSv1_2_enc_data, }; -static const SSL_METHOD TLS_client_method_data = { +static const SSL_METHOD TLS_legacy_client_method_data = { .ssl_dispatch_alert = ssl3_dispatch_alert, .num_ciphers = ssl3_num_ciphers, .get_cipher = ssl3_get_cipher, .get_cipher_by_char = ssl3_get_cipher_by_char, .put_cipher_by_char = ssl3_put_cipher_by_char, - .internal = &TLS_client_method_internal_data, + .internal = &TLS_legacy_client_method_internal_data, }; static const SSL_METHOD_INTERNAL TLSv1_client_method_internal_data = { @@ -326,7 +358,17 @@ SSLv23_client_method(void) const SSL_METHOD * TLS_client_method(void) { +#ifdef LIBRESSL_HAS_TLS13 return (&TLS_client_method_data); +#else + return tls_legacy_client_method(); +#endif +} + +const SSL_METHOD * +tls_legacy_client_method(void) +{ + return (&TLS_legacy_client_method_data); } const SSL_METHOD * -- cgit v1.2.3-55-g6feb