From ca68ad83771ff3542fb2bf5a32270209c02a4690 Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Fri, 5 Dec 2025 10:23:43 +0100 Subject: [PATCH] Move "libtestdriver1_" aliases to test_driver_common.h Signed-off-by: Ronald Cron --- .../include/test/drivers/test_driver_common.h | 23 +++++++++++++++++++ tests/src/drivers/test_driver_aead.c | 1 - .../test_driver_asymmetric_encryption.c | 1 - tests/src/drivers/test_driver_cipher.c | 1 - tests/src/drivers/test_driver_key_agreement.c | 1 - .../src/drivers/test_driver_key_management.c | 1 - tests/src/drivers/test_driver_mac.c | 1 - tests/src/drivers/test_driver_pake.c | 2 -- tests/src/drivers/test_driver_signature.c | 1 - 9 files changed, 23 insertions(+), 9 deletions(-) diff --git a/tests/include/test/drivers/test_driver_common.h b/tests/include/test/drivers/test_driver_common.h index a704adb2b..785e5af66 100644 --- a/tests/include/test/drivers/test_driver_common.h +++ b/tests/include/test/drivers/test_driver_common.h @@ -25,4 +25,27 @@ /* *INDENT-ON* */ +/* + * In the libtestdriver1 library used in Mbed TLS 3.6 and 4.0 for driver + * dispatch testing, the PSA core code is cloned and all identifiers starting + * with MBEDTLS_, PSA_, mbedtls_, or psa_ are prefixed with `libtestdriver1_`. + * As a result, libtestdriver1 drivers use, for example, + * `libtestdriver1_psa_key_attributes_t` instead of `psa_key_attributes_t`. + * + * With the generated test drivers introduced in TF-PSA-Crypto between 1.0 + * and 1.1, only the modules under `drivers/builtin` are cloned, not the PSA + * core. The generated test drivers therefore do not use prefixed PSA core + * identifiers. For example, they use the `psa_key_attributes_t` type, just + * like the built-in drivers. + * + * To make driver dispatch work in both cases, we define certain + * `libtestdriver1_xyz` identifiers as aliases of the corresponding `xyz` + * identifiers in the latter case. + */ +#if defined(TF_PSA_CRYPTO_TEST_LIBTESTDRIVER1) +typedef psa_key_attributes_t libtestdriver1_psa_key_attributes_t; +typedef psa_crypto_driver_pake_inputs_t libtestdriver1_psa_crypto_driver_pake_inputs_t; +typedef psa_crypto_driver_pake_step_t libtestdriver1_psa_crypto_driver_pake_step_t; +#endif + #endif /* test_driver_common.h */ diff --git a/tests/src/drivers/test_driver_aead.c b/tests/src/drivers/test_driver_aead.c index 8ee7e5219..05fe57a8d 100644 --- a/tests/src/drivers/test_driver_aead.c +++ b/tests/src/drivers/test_driver_aead.c @@ -16,7 +16,6 @@ #include "mbedtls/constant_time.h" #if defined(TF_PSA_CRYPTO_TEST_LIBTESTDRIVER1) -typedef psa_key_attributes_t libtestdriver1_psa_key_attributes_t; #include "../../libtestdriver1/src/psa_crypto_aead.h" #elif defined(MBEDTLS_TEST_LIBTESTDRIVER1) #if MBEDTLS_VERSION_MAJOR < 4 diff --git a/tests/src/drivers/test_driver_asymmetric_encryption.c b/tests/src/drivers/test_driver_asymmetric_encryption.c index 1faeecabf..63b9af46a 100644 --- a/tests/src/drivers/test_driver_asymmetric_encryption.c +++ b/tests/src/drivers/test_driver_asymmetric_encryption.c @@ -22,7 +22,6 @@ #include "test/drivers/key_management.h" #if defined(TF_PSA_CRYPTO_TEST_LIBTESTDRIVER1) -typedef psa_key_attributes_t libtestdriver1_psa_key_attributes_t; #include "../../libtestdriver1/src/psa_crypto_rsa.h" #elif defined(MBEDTLS_TEST_LIBTESTDRIVER1) #if MBEDTLS_VERSION_MAJOR < 4 diff --git a/tests/src/drivers/test_driver_cipher.c b/tests/src/drivers/test_driver_cipher.c index 3c9b37e00..0ba7e9c4a 100644 --- a/tests/src/drivers/test_driver_cipher.c +++ b/tests/src/drivers/test_driver_cipher.c @@ -24,7 +24,6 @@ #include "test/random.h" #if defined(TF_PSA_CRYPTO_TEST_LIBTESTDRIVER1) -typedef psa_key_attributes_t libtestdriver1_psa_key_attributes_t; #include "../../libtestdriver1/src/psa_crypto_cipher.h" #elif defined(MBEDTLS_TEST_LIBTESTDRIVER1) #if MBEDTLS_VERSION_MAJOR < 4 diff --git a/tests/src/drivers/test_driver_key_agreement.c b/tests/src/drivers/test_driver_key_agreement.c index 8f0571d1f..60879bfa6 100644 --- a/tests/src/drivers/test_driver_key_agreement.c +++ b/tests/src/drivers/test_driver_key_agreement.c @@ -20,7 +20,6 @@ #include #if defined(TF_PSA_CRYPTO_TEST_LIBTESTDRIVER1) -typedef psa_key_attributes_t libtestdriver1_psa_key_attributes_t; #include "../../libtestdriver1/src/psa_crypto_ecp.h" #include "../../libtestdriver1/src/psa_crypto_ffdh.h" #elif defined(MBEDTLS_TEST_LIBTESTDRIVER1) diff --git a/tests/src/drivers/test_driver_key_management.c b/tests/src/drivers/test_driver_key_management.c index 6e724b8b0..ed5d82818 100644 --- a/tests/src/drivers/test_driver_key_management.c +++ b/tests/src/drivers/test_driver_key_management.c @@ -27,7 +27,6 @@ #include "test/random.h" #if defined(TF_PSA_CRYPTO_TEST_LIBTESTDRIVER1) -typedef psa_key_attributes_t libtestdriver1_psa_key_attributes_t; #include "../../libtestdriver1/src/psa_crypto_ecp.h" #include "../../libtestdriver1/src/psa_crypto_rsa.h" #include "../../libtestdriver1/src/psa_crypto_ffdh.h" diff --git a/tests/src/drivers/test_driver_mac.c b/tests/src/drivers/test_driver_mac.c index e45acdf58..3a149299d 100644 --- a/tests/src/drivers/test_driver_mac.c +++ b/tests/src/drivers/test_driver_mac.c @@ -13,7 +13,6 @@ #include "test/drivers/mac.h" #if defined(TF_PSA_CRYPTO_TEST_LIBTESTDRIVER1) -typedef psa_key_attributes_t libtestdriver1_psa_key_attributes_t; #include "../../libtestdriver1/src/psa_crypto_mac.h" #elif defined(MBEDTLS_TEST_LIBTESTDRIVER1) #if MBEDTLS_VERSION_MAJOR < 4 diff --git a/tests/src/drivers/test_driver_pake.c b/tests/src/drivers/test_driver_pake.c index 6e6794ece..466f24613 100644 --- a/tests/src/drivers/test_driver_pake.c +++ b/tests/src/drivers/test_driver_pake.c @@ -14,8 +14,6 @@ #include "string.h" #if defined(TF_PSA_CRYPTO_TEST_LIBTESTDRIVER1) -typedef psa_crypto_driver_pake_inputs_t libtestdriver1_psa_crypto_driver_pake_inputs_t; -typedef psa_crypto_driver_pake_step_t libtestdriver1_psa_crypto_driver_pake_step_t; #include "../../libtestdriver1/src/psa_crypto_pake.h" #elif defined(MBEDTLS_TEST_LIBTESTDRIVER1) #if MBEDTLS_VERSION_MAJOR < 4 diff --git a/tests/src/drivers/test_driver_signature.c b/tests/src/drivers/test_driver_signature.c index a89ee1507..8620b14fc 100644 --- a/tests/src/drivers/test_driver_signature.c +++ b/tests/src/drivers/test_driver_signature.c @@ -34,7 +34,6 @@ #include "test/random.h" #if defined(TF_PSA_CRYPTO_TEST_LIBTESTDRIVER1) -typedef psa_key_attributes_t libtestdriver1_psa_key_attributes_t; #include "../../libtestdriver1/src/psa_crypto_ecp.h" #include "../../libtestdriver1/src/psa_crypto_hash.h" #include "../../libtestdriver1/src/psa_crypto_rsa.h"