Skip to content

psa_util.c included in builds without PSA, which can break the build #9311

Closed
@gilles-peskine-arm

Description

@gilles-peskine-arm

In Mbed TLS 3.6.0, when MBEDTLS_ECDSA_C is enabled but MBEDTLS_PSA_CRYPTO_C is disabled, some code from psa_util.c is included and declares a 0-size array, resulting in a compilation error (except under some non-picky compilers). In this configuration, no code from psa_util.c should be included.

The culprit seems to be the definition of MBEDTLS_PSA_UTIL_HAVE_ECDSA in include/mbedtls/config_adjust_legacy_crypto.h:

#if defined(MBEDTLS_ECDSA_C) || (defined(MBEDTLS_PSA_CRYPTO_C) && \
    (defined(PSA_WANT_ALG_ECDSA) || defined(PSA_WANT_ALG_DETERMINISTIC_ECDSA)))
#define MBEDTLS_PSA_UTIL_HAVE_ECDSA
#endif

MBEDTLS_PSA_UTIL_xxx should be either undefined or ignored if MBEDTLS_PSA_CRYPTO_C isn't defined. (Or should this be MBEDTLS_PSA_CRYPTO_CLIENT?)

Originally reported on the mailing list

Definition of done:

  • When MBEDTLS_PSA_CRYPTO_C is disabled, no code from psa_util.c should be enabled.
  • This should have been caught by the CI, in component_test_no_psa_crypto_full_cmake_asan and in some of the reference configurations. Figure out why it wasn't caught and fix that.

Metadata

Metadata

Assignees

Labels

bugcomponent-cryptoCrypto primitives and low-level interfacessize-sEstimated task size: small (~2d)

Type

No type

Projects

Status

Done

Status

3.6.1 patch release

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions