From 395889f9b7b9b4c9ed206d2f4cc8f60c5646f882 Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Tue, 9 Feb 2021 12:36:49 +0100 Subject: [PATCH] psa: Make sure MBEDTLS_PSA_CRYPTO_CLIENT is defined Make sure MBEDTLS_PSA_CRYPTO_CLIENT is defined when MBEDTLS_PSA_CRYPTO_C is defined and guard PSA client code only with MBEDTLS_PSA_CRYPTO_CLIENT. The definition of MBEDTLS_PSA_CRYPTO_CLIENT is done in crypto_types.h before the definition of psa_key_attributes_t. That way as PSA crypto client code is related to key attributes we can be quite confident that MBEDTLS_PSA_CRYPTO_CLIENT will be defined when needed. Signed-off-by: Ronald Cron --- include/psa/crypto_types.h | 7 +++++++ library/psa_crypto_client.c | 7 +++---- tests/suites/main_test.function | 7 ------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/include/psa/crypto_types.h b/include/psa/crypto_types.h index 98048813a2..386c7d794b 100644 --- a/include/psa/crypto_types.h +++ b/include/psa/crypto_types.h @@ -35,6 +35,13 @@ #include "crypto_platform.h" +/* If MBEDTLS_PSA_CRYPTO_C is defined, make sure MBEDTLS_PSA_CRYPTO_CLIENT + * is defined as well to include all PSA code. + */ +#if defined(MBEDTLS_PSA_CRYPTO_C) +#define MBEDTLS_PSA_CRYPTO_CLIENT +#endif /* MBEDTLS_PSA_CRYPTO_C */ + #include /** \defgroup error Error codes diff --git a/library/psa_crypto_client.c b/library/psa_crypto_client.c index 1c4d8ddbfc..e84cf3015b 100644 --- a/library/psa_crypto_client.c +++ b/library/psa_crypto_client.c @@ -19,12 +19,11 @@ */ #include "common.h" - -#if defined(MBEDTLS_PSA_CRYPTO_CLIENT) || defined(MBEDTLS_PSA_CRYPTO_C) - #include "psa_crypto_service_integration.h" #include "psa/crypto.h" +#if defined(MBEDTLS_PSA_CRYPTO_CLIENT) + #include #include "mbedtls/platform.h" #if !defined(MBEDTLS_PLATFORM_C) @@ -81,4 +80,4 @@ psa_status_t psa_get_key_domain_parameters( return( PSA_SUCCESS ); } -#endif /* MBEDTLS_PSA_CRYPTO_CLIENT || MBEDTLS_PSA_CRYPTO_C */ +#endif /* MBEDTLS_PSA_CRYPTO_CLIENT */ diff --git a/tests/suites/main_test.function b/tests/suites/main_test.function index b67bb4370d..98dab3ebbd 100644 --- a/tests/suites/main_test.function +++ b/tests/suites/main_test.function @@ -33,13 +33,6 @@ #include "psa/crypto.h" #endif /* MBEDTLS_USE_PSA_CRYPTO */ -/* If MBEDTLS_PSA_CRYPTO_C is defined, make sure MBEDTLS_PSA_CRYPTO_CLIENT - * is defined to run tests with dependency on MBEDTLS_PSA_CRYPTO_CLIENT. - */ -#if defined(MBEDTLS_PSA_CRYPTO_C) -#define MBEDTLS_PSA_CRYPTO_CLIENT -#endif /* MBEDTLS_PSA_CRYPTO_C */ - /* Test code may use deprecated identifiers only if the preprocessor symbol * MBEDTLS_TEST_DEPRECATED is defined. When building tests, set * MBEDTLS_TEST_DEPRECATED explicitly if MBEDTLS_DEPRECATED_WARNING is