From 4184107d2e53d05d7a7b54e948da8cf63e7734fd Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Thu, 17 Sep 2020 15:28:26 +0200 Subject: [PATCH] tests: Fix checks of volatile key identifier Volatile keys have now a volatile non-null key identifier. Signed-off-by: Ronald Cron --- tests/suites/test_suite_psa_crypto.function | 9 ++++++++- .../suites/test_suite_psa_crypto_se_driver_hal.function | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index f79d9b3d9..23d827ec4 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -19,6 +19,7 @@ #define HAVE_RAM_AVAILABLE_128K #include "psa/crypto.h" +#include "psa_crypto_slot_management.h" /** An invalid export length that will never be set by psa_export_key(). */ static const size_t INVALID_EXPORT_LENGTH = ~0U; @@ -245,7 +246,13 @@ int check_key_attributes_sanity( psa_key_handle_t key ) /* Persistence */ if( lifetime == PSA_KEY_LIFETIME_VOLATILE ) - TEST_ASSERT( MBEDTLS_SVC_KEY_ID_GET_KEY_ID( id ) == 0 ); + { + TEST_ASSERT( + ( PSA_KEY_ID_VOLATILE_MIN <= + MBEDTLS_SVC_KEY_ID_GET_KEY_ID( id ) ) && + ( MBEDTLS_SVC_KEY_ID_GET_KEY_ID( id ) <= + PSA_KEY_ID_VOLATILE_MAX ) ); + } else { TEST_ASSERT( diff --git a/tests/suites/test_suite_psa_crypto_se_driver_hal.function b/tests/suites/test_suite_psa_crypto_se_driver_hal.function index a1d542d74..f22e6b7ec 100644 --- a/tests/suites/test_suite_psa_crypto_se_driver_hal.function +++ b/tests/suites/test_suite_psa_crypto_se_driver_hal.function @@ -972,6 +972,7 @@ void key_creation_import_export( int lifetime_arg, int min_slot, int restart ) psa_set_key_bits( &attributes, PSA_BYTES_TO_BITS( sizeof( key_material ) ) ); psa_set_key_slot_number( &attributes, min_slot ); + psa_set_key_id( &attributes, handle ); if( ! check_key_attributes( handle, &attributes ) ) goto exit;