Joachim Bauernberger e462a2ea4e Validate the TLS 1.3 server key_share extension
The TLS 1.3 server accepted a malformed key_share extension in the
ClientHello and then closed the connection without sending an alert:

- a zero-length key_exchange was accepted;
- a key_exchange whose length did not match its group was only caught
  later, by the key agreement, which returned without pending an alert;
- data trailing the client_shares list was ignored.

Reject these in ssl_tls13_parse_key_shares_ext() and in the shared
key-exchange reader mbedtls_ssl_tls13_read_public_xxdhe_share():

- a zero-length key_exchange and trailing data after client_shares are
  rejected with a decode_error alert;
- a key_exchange whose length does not match the group is rejected with
  an illegal_parameter alert, which is what OpenSSL does.

The shared reader is also used by the client, so it now checks that a
ServerHello key_share is consumed exactly.

Expose ssl_tls13_parse_key_shares_ext() with MBEDTLS_STATIC_TESTABLE and
add unit tests that feed crafted key_share extensions to the server
parser.

Fixes #10887.
Fixes #10737.

Signed-off-by: Joachim Bauernberger <joachim.bauernberger@protonmail.com>
2026-10-25 20:18:11 +01:00
..
.jenkins
configs Remove deprecated items 2025-08-01 11:45:14 +01:00
git-scripts Header updates 2023-11-03 12:21:36 +00:00
include/test Merge pull request #10394 from gilles-peskine-arm/threading-1.0-alt-build-mbedtls 2026-09-01 11:00:04 +02:00
opt-testcases Do not check fail cases for verify skipped 2026-03-13 18:04:16 +00:00
scripts Removed explicit include path from consistency check 2026-10-19 14:12:30 +01:00
src tests: ssl_helpers: run ssl_context reset check only when the SSL context is setup 2026-06-24 15:37:00 +02:00
suites Validate the TLS 1.3 server key_share extension 2026-10-25 20:18:11 +01:00
.gitignore cmake: Generate test_keys.h and test_certs.h in the build tree 2025-03-26 21:19:28 +01:00
CMakeLists.txt Add fix for -DENABLE_PROGRAMS=OFF build error 2026-06-30 15:36:19 +01:00
compat-in-docker.sh Header updates 2023-11-03 12:21:36 +00:00
compat.sh Merge pull request #10663 from yiwu0b11/remove_unused_ffdh_code 2026-05-13 16:49:20 +00:00
context-info.sh Fix test and formatting in ssl_context_info 2025-04-29 22:02:24 +02:00
Descriptions.txt
make-in-docker.sh Header updates 2023-11-03 12:21:36 +00:00
Makefile Make installable pqcp headers available to the libtestdriver1 build 2026-08-18 16:07:13 +02:00
ssl-opt.sh Merge pull request #10620 from mpg/ref-for-drivers 2026-08-13 09:56:09 +00:00