v1rtu3x 893f6ca501 Fix TLS 1.3 handshakes with opaque PSKs
Opaque PSKs configured through mbedtls_ssl_conf_psk_opaque() were broken in TLS 1.3: the client computed an incorrect PSK binder, the server rejected the PSK identity, and the early key schedule exported the key with psa_export_key(), which fails for non-exportable keys.

Consume non-exportable opaque PSKs directly with psa_key_derivation_input_key(). Exportable PSKs (in particular raw PSKs imported by mbedtls_ssl_set_hs_psk()) keep the byte path, which works with whatever hash the negotiated ciphersuite requires: a key imported with a concrete HKDF-Extract policy cannot be a derivation input for another hash, and PSA_ALG_ANY_HASH policies are not accepted for KDF inputs either.

Also fix a NULL dereference when importing a TLS 1.3 resumption PSK before the ciphersuite is negotiated, and guard the mbedtls_ssl_get_opaque_psk() call, which only exists when MBEDTLS_SSL_HANDSHAKE_WITH_PSK_ENABLED is defined.

ssl_client2/ssl_server2 now import opaque PSKs with the HKDF-Extract algorithm of the negotiated ciphersuite for TLS 1.3.

Fixes Mbed-TLS#10956.

Signed-off-by: v1rtu3x <149050962+v1rtu3x@users.noreply.github.com>
2026-10-20 14:21:22 +03:00
..
CMakeLists.txt Update paths for moved program files in CMakeLists 2025-02-19 15:30:24 +00:00
dtls_client.c Remove Deprecated Items From Sample Programs 2026-01-14 13:01:22 +00:00
dtls_server.c Remove Deprecated Items From Sample Programs 2026-01-14 13:01:22 +00:00
mini_client.c Remove Deprecated Items From Sample Programs 2026-01-14 13:01:22 +00:00
ssl_client1.c Remove Deprecated Items From Sample Programs 2026-01-14 13:01:22 +00:00
ssl_client2.c Fix TLS 1.3 handshakes with opaque PSKs 2026-10-20 14:21:22 +03:00
ssl_context_info.c Stop using MBEDTLS_PRINTF_SIZET 2026-02-26 19:56:23 +00:00
ssl_fork_server.c Remove Deprecated Items From Sample Programs 2026-01-14 13:01:22 +00:00
ssl_mail_client.c Remove Deprecated Items From Sample Programs 2026-01-14 13:01:22 +00:00
ssl_pthread_server.c Remove Deprecated Items From Sample Programs 2026-01-14 13:01:22 +00:00
ssl_server2.c Fix TLS 1.3 handshakes with opaque PSKs 2026-10-20 14:21:22 +03:00
ssl_server.c Remove Deprecated Items From Sample Programs 2026-01-14 13:01:22 +00:00
ssl_test_common_source.c Only check for certificates if it is supported 2025-03-20 17:53:07 +01:00
ssl_test_lib.c Add further rng removals highlighted by the ci 2026-01-14 13:01:23 +00:00
ssl_test_lib.h Tell MSVC to allow non-s functions where needed 2026-03-04 11:32:18 +01:00