Paulo Santos cf6d40a92d
ssl: size _pms_ecdh against PSA_RAW_KEY_AGREEMENT_OUTPUT_MAX_SIZE
In PSA-client-only builds (MBEDTLS_PSA_CRYPTO_C disabled, e.g. NS-side
mbedtls dispatching to a secure PSA service like TF-M), the local
ECP_LIGHT cascade does not run and MBEDTLS_ECP_MAX_BYTES collapses to 1.
The `_pms_ecdh` and `_pms_ecdhe_psk` members of `union
mbedtls_ssl_premaster_secret` then declare 1-byte arrays. In builds
where only ECDHE-RSA / ECDHE-ECDSA is enabled (no PSK, no ECJPAKE), the
whole union ends up that small, and psa_raw_key_agreement() returns
PSA_ERROR_BUFFER_TOO_SMALL during the TLS 1.2 ECDHE handshake. The
handshake aborts as MBEDTLS_ERR_SSL_HW_ACCEL_FAILED with no path to
success in this configuration.

Introduce MBEDTLS_SSL_PMS_ECDH_SIZE as
max(PSA_RAW_KEY_AGREEMENT_OUTPUT_MAX_SIZE, MBEDTLS_ECP_MAX_BYTES) so
both legacy ECP and PSA-client builds get a sufficient buffer.
PSA_RAW_KEY_AGREEMENT_OUTPUT_MAX_SIZE is always defined, sized by the
enabled PSA_WANT_ECC_* curves.

Signed-off-by: Paulo Santos <paulo.santos-ext@hexagon.com>
2026-05-20 14:39:00 -03:00
..
mbedtls ssl: size _pms_ecdh against PSA_RAW_KEY_AGREEMENT_OUTPUT_MAX_SIZE 2026-05-20 14:39:00 -03:00
.gitignore Rename include directory to mbedtls 2015-03-10 11:23:56 +00:00
CMakeLists.txt Use GNUInstallDirs CMAKE_INSTALL_INCLUDEDDIR path for headers installation 2025-10-24 12:50:51 +02:00