mbedtls/library/ssl_tls13_invasive.h
Joachim Bauernberger f958c05fa7 Validate the TLS 1.3 server supported_groups extension
The TLS 1.3 server accepted an empty named_group_list, and data trailing
the list, in a ClientHello supported_groups extension and continued the
handshake. RFC 8446 section 4.2.7 defines the list as
NamedGroup<2..2^16-1>, so it must hold at least one group and be the
whole content of the extension.

Reject an empty list and trailing data in
ssl_tls13_parse_supported_groups_ext() with a decode_error alert, which
is what OpenSSL does. Expose the parser with MBEDTLS_STATIC_TESTABLE and
add unit tests.

Fixes #10897.
Fixes #10733.

Signed-off-by: Joachim Bauernberger <joachim.bauernberger@protonmail.com>
2026-10-25 20:18:11 +01:00

38 lines
1.2 KiB
C

/*
* Copyright The Mbed TLS Contributors
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
*/
#ifndef MBEDTLS_SSL_TLS13_INVASIVE_H
#define MBEDTLS_SSL_TLS13_INVASIVE_H
#include "ssl_misc.h"
#if defined(MBEDTLS_SSL_PROTO_TLS1_3)
#include "psa/crypto.h"
#if defined(MBEDTLS_TEST_HOOKS)
int mbedtls_ssl_tls13_parse_certificate(mbedtls_ssl_context *ssl,
const unsigned char *buf,
const unsigned char *end);
#if defined(MBEDTLS_SSL_SRV_C) && \
(defined(PSA_WANT_ALG_ECDH) || defined(PSA_WANT_ALG_FFDH))
int mbedtls_ssl_tls13_parse_supported_groups_ext(mbedtls_ssl_context *ssl,
const unsigned char *buf,
const unsigned char *end);
#endif
#if defined(MBEDTLS_SSL_SRV_C) && \
defined(MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_SOME_EPHEMERAL_ENABLED)
int mbedtls_ssl_tls13_parse_key_shares_ext(mbedtls_ssl_context *ssl,
const unsigned char *buf,
const unsigned char *end);
#endif
#endif /* MBEDTLS_TEST_HOOKS */
#endif /* MBEDTLS_SSL_PROTO_TLS1_3 */
#endif /* MBEDTLS_SSL_TLS13_INVASIVE_H */