From 3cec8e88646050c114e7a2763e269ede6378ed3d Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Sun, 27 Mar 2022 14:34:09 +0200 Subject: [PATCH] tests: Init PSA crypto if TLS 1.3 is enabled Initialize PSA crypto in tests if TLS 1.3 is enabled as done when MBEDTLS_USE_PSA_CRYPTO is enabled. Signed-off-by: Ronald Cron --- tests/include/test/psa_crypto_helpers.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/include/test/psa_crypto_helpers.h b/tests/include/test/psa_crypto_helpers.h index f5622e2d2d..6f42882646 100644 --- a/tests/include/test/psa_crypto_helpers.h +++ b/tests/include/test/psa_crypto_helpers.h @@ -282,8 +282,11 @@ psa_key_usage_t mbedtls_test_update_key_usage_flags( psa_key_usage_t usage_flags /** \def USE_PSA_INIT * * Call this macro to initialize the PSA subsystem if #MBEDTLS_USE_PSA_CRYPTO - * is enabled and do nothing otherwise. If the initialization fails, mark - * the test case as failed and jump to the \p exit label. + * or #MBEDTLS_SSL_PROTO_TLS1_3 (In contrast to TLS 1.2 implementation, the + * TLS 1.3 one uses PSA independently of the definition of + * #MBEDTLS_USE_PSA_CRYPTO) is enabled and do nothing otherwise. If the + * initialization fails, mark the test case as failed and jump to the \p exit + * label. */ /** \def USE_PSA_DONE * @@ -291,15 +294,15 @@ psa_key_usage_t mbedtls_test_update_key_usage_flags( psa_key_usage_t usage_flags * This is like #PSA_DONE, except that it does nothing if * #MBEDTLS_USE_PSA_CRYPTO is disabled. */ -#if defined(MBEDTLS_USE_PSA_CRYPTO) +#if defined(MBEDTLS_USE_PSA_CRYPTO) || defined(MBEDTLS_SSL_PROTO_TLS1_3) #define USE_PSA_INIT( ) PSA_INIT( ) #define USE_PSA_DONE( ) PSA_DONE( ) -#else /* MBEDTLS_USE_PSA_CRYPTO */ +#else /* MBEDTLS_USE_PSA_CRYPTO || MBEDTLS_SSL_PROTO_TLS1_3 */ /* Define empty macros so that we can use them in the preamble and teardown * of every test function that uses PSA conditionally based on * MBEDTLS_USE_PSA_CRYPTO. */ #define USE_PSA_INIT( ) ( (void) 0 ) #define USE_PSA_DONE( ) ( (void) 0 ) -#endif /* !MBEDTLS_USE_PSA_CRYPTO */ +#endif /* !MBEDTLS_USE_PSA_CRYPTO && !MBEDTLS_SSL_PROTO_TLS1_3 */ #endif /* PSA_CRYPTO_HELPERS_H */