From 0dc86b5a2ac807deaa26fa6a7975ac1d5b4ec1d9 Mon Sep 17 00:00:00 2001 From: Archana Date: Wed, 14 Jul 2021 13:59:48 +0530 Subject: [PATCH] Remove dependency of builtin keys on storage The psa_open_key API depends on MBEDTLS_PSA_CRYPTO_STORAGE_C. This is unnecessary for builtin keys and so is fixed. Updated an open_fail test vector keeping with the same. Signed-off-by: Archana --- library/psa_crypto_slot_management.c | 7 ++++--- tests/suites/test_suite_psa_crypto_slot_management.data | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/library/psa_crypto_slot_management.c b/library/psa_crypto_slot_management.c index 4131e3cc4..32a6bb259 100644 --- a/library/psa_crypto_slot_management.c +++ b/library/psa_crypto_slot_management.c @@ -470,7 +470,8 @@ psa_status_t psa_validate_key_persistence( psa_key_lifetime_t lifetime ) psa_status_t psa_open_key( mbedtls_svc_key_id_t key, psa_key_handle_t *handle ) { -#if defined(MBEDTLS_PSA_CRYPTO_STORAGE_C) +#if defined(MBEDTLS_PSA_CRYPTO_STORAGE_C) || \ + defined(MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS) psa_status_t status; psa_key_slot_t *slot; @@ -488,11 +489,11 @@ psa_status_t psa_open_key( mbedtls_svc_key_id_t key, psa_key_handle_t *handle ) return( psa_unlock_key_slot( slot ) ); -#else /* defined(MBEDTLS_PSA_CRYPTO_STORAGE_C) */ +#else /* MBEDTLS_PSA_CRYPTO_STORAGE_C || MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS */ (void) key; *handle = PSA_KEY_HANDLE_INIT; return( PSA_ERROR_NOT_SUPPORTED ); -#endif /* !defined(MBEDTLS_PSA_CRYPTO_STORAGE_C) */ +#endif /* MBEDTLS_PSA_CRYPTO_STORAGE_C || MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS */ } psa_status_t psa_close_key( psa_key_handle_t handle ) diff --git a/tests/suites/test_suite_psa_crypto_slot_management.data b/tests/suites/test_suite_psa_crypto_slot_management.data index 68b196d32..147773416 100644 --- a/tests/suites/test_suite_psa_crypto_slot_management.data +++ b/tests/suites/test_suite_psa_crypto_slot_management.data @@ -160,7 +160,7 @@ depends_on:MBEDTLS_PSA_CRYPTO_STORAGE_C create_fail:PSA_KEY_LIFETIME_PERSISTENT:PSA_KEY_ID_USER_MAX + 1:PSA_ERROR_INVALID_ARGUMENT Open not supported -depends_on:!MBEDTLS_PSA_CRYPTO_STORAGE_C +depends_on:!MBEDTLS_PSA_CRYPTO_STORAGE_C:!MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS open_fail:1:PSA_ERROR_NOT_SUPPORTED Create not supported