mbedtls: select the prerequisites of the EC-JPAKE key exchange

Enabling MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED currently adds no cipher suite
at all. A build with the option on offers the same 26 suites as a build with
it off.

mbedTLS defines exactly one EC-JPAKE cipher suite,
TLS-ECJPAKE-WITH-AES-128-CCM-8, and its entry in ssl_ciphersuites.c is also
guarded by MBEDTLS_SSL_HAVE_AES and MBEDTLS_SSL_HAVE_CCM, which
config_adjust_legacy_crypto.h derives from MBEDTLS_AES_C and MBEDTLS_CCM_C
while MBEDTLS_USE_PSA_CRYPTO is off, as it is here. With MBEDTLS_CCM_C left
at its default the suite is compiled out, so the option enables handshake
code that nothing can negotiate.

Select the symbols the option needs, the same way MBEDTLS_SSL_PROTO_TLS1_3
already selects the ones it needs:

- MBEDTLS_AES_C is default y, so it only guards against a configuration that
  turns it off.
- MBEDTLS_CCM_C is the one the suite is missing today, and it is default n.
- MBEDTLS_ECP_DP_SECP256R1_ENABLED is default y as well, but turning it off
  is worse than a missing suite: check_config.h fails the build outright,
  because mbedTLS' EC-JPAKE is fixed to that curve.

The default build does not change: MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED stays
default n, so none of the selects fire. For someone who has enabled EC-JPAKE
this increases the size of libmbedcrypto.so by about 4096 bytes
(arm_cortex-a9_vfpv3-d16, stripped as packaged), all of it MBEDTLS_CCM_C; the
other two are already on in a default build:

Without:
352395 libmbedcrypto.so.3.6.6

With:
356491 libmbedcrypto.so.3.6.6

libmbedtls.so.3.6.6 and libmbedx509.so.3.6.6 are unchanged in size.

Signed-off-by: Christian Glombek <c.glombek@cosa.systems>
Link: https://github.com/openwrt/openwrt/pull/24544
Signed-off-by: Robert Marko <robimarko@gmail.com>
This commit is contained in:
Christian Glombek authored and Robert Marko committed 2026-11-16 11:59:17 +01:00
1 parent 02e70c7548
commit 13fc2e4e4b
1 file changed
+3
+3
View File
@@ -86,6 +86,9 @@ config MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED
config MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
bool "MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED"
select MBEDTLS_AES_C
select MBEDTLS_CCM_C
select MBEDTLS_ECP_DP_SECP256R1_ENABLED
default n
comment "Curves - unselect old or less-used curves to reduce binary size"