From c08ee30d1670349e864bc8933583e2a215ff7aac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bence=20Sz=C3=A9pk=C3=BAti?= Date: Mon, 9 Mar 2026 15:45:35 +0100 Subject: [PATCH] Make framework compatible with -Wundef MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No logical changes intended Signed-off-by: Bence Szépkúti --- tests/include/test/psa_crypto_helpers.h | 14 +++++++++----- tests/src/psa_exercise_key.c | 13 ++++++++----- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/tests/include/test/psa_crypto_helpers.h b/tests/include/test/psa_crypto_helpers.h index 5d880d9ed..520a98edc 100644 --- a/tests/include/test/psa_crypto_helpers.h +++ b/tests/include/test/psa_crypto_helpers.h @@ -12,8 +12,10 @@ #include "build_info.h" #include "test/helpers.h" -#if (MBEDTLS_VERSION_MAJOR < 4 && defined(MBEDTLS_PSA_CRYPTO_C)) || \ - (MBEDTLS_VERSION_MAJOR >= 4 && defined(MBEDTLS_PSA_CRYPTO_CLIENT)) +#if ((defined(TF_PSA_CRYPTO_VERSION_MAJOR) || MBEDTLS_VERSION_MAJOR < 4) && \ + defined(MBEDTLS_PSA_CRYPTO_C)) || \ + (defined(MBEDTLS_VERSION_MAJOR) && MBEDTLS_VERSION_MAJOR >= 4 && \ + defined(MBEDTLS_PSA_CRYPTO_CLIENT)) #include "test/psa_helpers.h" #endif @@ -55,8 +57,10 @@ #define PSA_DONE() ((void) 0) #endif /* MBEDTLS_PSA_CRYPTO_C */ -#if (MBEDTLS_VERSION_MAJOR < 4 && defined(MBEDTLS_PSA_CRYPTO_C)) || \ - (MBEDTLS_VERSION_MAJOR >= 4 && defined(MBEDTLS_PSA_CRYPTO_CLIENT)) +#if ((defined(TF_PSA_CRYPTO_VERSION_MAJOR) || MBEDTLS_VERSION_MAJOR < 4) && \ + defined(MBEDTLS_PSA_CRYPTO_C)) || \ + (defined(MBEDTLS_VERSION_MAJOR) && MBEDTLS_VERSION_MAJOR >= 4 && \ + defined(MBEDTLS_PSA_CRYPTO_CLIENT)) #if defined(MBEDTLS_PSA_CRYPTO_STORAGE_C) @@ -358,7 +362,7 @@ uint64_t mbedtls_test_parse_binary_string(data_t *bin_string); #endif /* MBEDTLS_PSA_CRYPTO_CLIENT || MBEDTLS_PSA_CRYPTO_C */ -#if MBEDTLS_VERSION_MAJOR >= 4 +#if defined(MBEDTLS_VERSION_MAJOR) && MBEDTLS_VERSION_MAJOR >= 4 /* Legacy PSA_INIT() / PSA_DONE() variants from 3.6 */ #define USE_PSA_INIT() PSA_INIT() #define USE_PSA_DONE() PSA_DONE() diff --git a/tests/src/psa_exercise_key.c b/tests/src/psa_exercise_key.c index ffed3becf..0153e2c49 100644 --- a/tests/src/psa_exercise_key.c +++ b/tests/src/psa_exercise_key.c @@ -12,8 +12,11 @@ #include #include -#if (MBEDTLS_VERSION_MAJOR < 4 && defined(MBEDTLS_PSA_CRYPTO_C)) || \ - (MBEDTLS_VERSION_MAJOR >= 4 && defined(MBEDTLS_PSA_CRYPTO_CLIENT)) +#if ((defined(TF_PSA_CRYPTO_VERSION_MAJOR) || MBEDTLS_VERSION_MAJOR < 4) && \ + defined(MBEDTLS_PSA_CRYPTO_C)) || \ + ((defined(MBEDTLS_VERSION_MAJOR) && MBEDTLS_VERSION_MAJOR >= 4) && \ + defined(MBEDTLS_PSA_CRYPTO_CLIENT)) + #include #include @@ -712,7 +715,7 @@ psa_status_t mbedtls_test_psa_raw_key_agreement_with_self( uint8_t output[1024]; size_t output_length; -#if MBEDTLS_VERSION_MAJOR >= 4 +#if defined(MBEDTLS_VERSION_MAJOR) && MBEDTLS_VERSION_MAJOR >= 4 uint8_t *exported = NULL; size_t exported_size = 0; size_t exported_length = 0; @@ -766,7 +769,7 @@ psa_status_t mbedtls_test_psa_raw_key_agreement_with_self( PSA_RAW_KEY_AGREEMENT_OUTPUT_MAX_SIZE); } -#if MBEDTLS_VERSION_MAJOR >= 4 +#if defined(MBEDTLS_VERSION_MAJOR) && MBEDTLS_VERSION_MAJOR >= 4 psa_status_t raw_status = status; psa_set_key_type(&shared_secret_attributes, PSA_KEY_TYPE_DERIVE); @@ -880,7 +883,7 @@ psa_status_t mbedtls_test_psa_raw_key_agreement_with_self( */ psa_reset_key_attributes(&attributes); -#if MBEDTLS_VERSION_MAJOR >= 4 +#if defined(MBEDTLS_VERSION_MAJOR) && MBEDTLS_VERSION_MAJOR >= 4 psa_reset_key_attributes(&export_attributes); /* Make sure to reset and free derived key attributes and slot. */