From: Matt Caswell Date: Wed, 31 Jul 2024 14:25:48 +0000 (+0100) Subject: Fix the alert used on a missing key_share X-Git-Tag: openssl-3.4.0-alpha1~78 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=60358f2c5e3a26e516ece2e075d0fd4198665412;p=thirdparty%2Fopenssl.git Fix the alert used on a missing key_share RFC8446 requires we send an illegal_parameter alert if we don't get a key_share back from the server and our kex_modes require one. We were instead reporting this as missing_extension. Fixes #25040 Reviewed-by: Neil Horman Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/25059) --- diff --git a/ssl/statem/extensions.c b/ssl/statem/extensions.c index 837ac739c33..e0e25afcb68 100644 --- a/ssl/statem/extensions.c +++ b/ssl/statem/extensions.c @@ -1382,12 +1382,15 @@ static int final_key_share(SSL_CONNECTION *s, unsigned int context, int sent) * fail; */ if (!s->server - && !sent - && (!s->hit - || (s->ext.psk_kex_mode & TLSEXT_KEX_MODE_FLAG_KE) == 0)) { - /* Nothing left we can do - just fail */ - SSLfatal(s, SSL_AD_MISSING_EXTENSION, SSL_R_NO_SUITABLE_KEY_SHARE); - return 0; + && !sent) { + if ((s->ext.psk_kex_mode & TLSEXT_KEX_MODE_FLAG_KE) == 0) { + SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER, SSL_R_NO_SUITABLE_KEY_SHARE); + return 0; + } + if (!s->hit) { + SSLfatal(s, SSL_AD_MISSING_EXTENSION, SSL_R_NO_SUITABLE_KEY_SHARE); + return 0; + } } /* * IF