From 46821196abd9631f2afe4292e53614f80a69d179 Mon Sep 17 00:00:00 2001 From: Juliusz Sosinowicz Date: Tue, 22 Dec 2020 16:11:08 +0100 Subject: [PATCH] Fix call to wolfSSL_connect when in wolfSSL_connect_TLSv13 If a client is: - TLS 1.3 capable - calls connect with wolfSSL_connect_TLSv13 - on an WOLFSSL object that allows downgrading then the call to wolfSSL_connect should happen before changing state to HELLO_AGAIN. Otherwise wolfSSL_connect will assume that messages up to ServerHelloDone have been read (when in reality only ServerHello had been read). Enable keying material for OpenVPN --- configure.ac | 4 +++- src/tls13.c | 19 +++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/configure.ac b/configure.ac index 894a35461..50920d743 100644 --- a/configure.ac +++ b/configure.ac @@ -4051,7 +4051,9 @@ fi if test "$ENABLED_OPENVPN" = "yes" then - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_DES_ECB -DHAVE_EX_DATA -DWOLFSSL_KEY_GEN -DWOLFSSL_OPENVPN" + ENABLED_SUPPORTED_CURVES="yes" + AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_OPENVPN -DHAVE_KEYING_MATERIAL" + AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_DES_ECB -DHAVE_EX_DATA -DWOLFSSL_KEY_GEN" fi diff --git a/src/tls13.c b/src/tls13.c index 027be809f..c6008d8b1 100644 --- a/src/tls13.c +++ b/src/tls13.c @@ -7565,6 +7565,15 @@ int wolfSSL_connect_TLSv13(WOLFSSL* ssl) } } + if (!ssl->options.tls1_3) { + #ifndef WOLFSSL_NO_TLS12 + if (ssl->options.downgrade) + return wolfSSL_connect(ssl); + #endif + WOLFSSL_MSG("Client using higher version, fatal error"); + return VERSION_ERROR; + } + ssl->options.connectState = HELLO_AGAIN; WOLFSSL_MSG("connect state: HELLO_AGAIN"); FALL_THROUGH; @@ -7573,16 +7582,6 @@ int wolfSSL_connect_TLSv13(WOLFSSL* ssl) if (ssl->options.certOnly) return WOLFSSL_SUCCESS; - if (!ssl->options.tls1_3) { - #ifndef WOLFSSL_NO_TLS12 - if (ssl->options.downgrade) - return wolfSSL_connect(ssl); - #endif - - WOLFSSL_MSG("Client using higher version, fatal error"); - return VERSION_ERROR; - } - if (ssl->options.serverState == SERVER_HELLO_RETRY_REQUEST_COMPLETE) { #if defined(WOLFSSL_TLS13_MIDDLEBOX_COMPAT)