Introduce psa_key_handle_is_null inline function
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
diff --git a/tests/suites/test_suite_pk.function b/tests/suites/test_suite_pk.function
index 22bf0e7..5fee0d7 100644
--- a/tests/suites/test_suite_pk.function
+++ b/tests/suites/test_suite_pk.function
@@ -158,7 +158,7 @@
mbedtls_pk_init( &pk );
key = pk_psa_genkey();
- if( key == 0 )
+ if( psa_key_handle_is_null( key ) )
goto exit;
TEST_ASSERT( mbedtls_pk_setup_opaque( &pk, key ) == 0 );
diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function
index 3c4d7c8..fbd7195 100644
--- a/tests/suites/test_suite_psa_crypto.function
+++ b/tests/suites/test_suite_psa_crypto.function
@@ -5761,7 +5761,7 @@
mbedtls_free( second_export );
psa_key_derivation_abort( &operation );
psa_destroy_key( base_key );
- if( handle == 0 )
+ if( psa_key_handle_is_null( handle ) )
{
/* In case there was a test failure after creating the persistent key
* but while it was not open, try to re-open the persistent key
diff --git a/tests/suites/test_suite_psa_crypto_init.function b/tests/suites/test_suite_psa_crypto_init.function
index fd4ff21..c9fdcd1 100644
--- a/tests/suites/test_suite_psa_crypto_init.function
+++ b/tests/suites/test_suite_psa_crypto_init.function
@@ -197,7 +197,7 @@
psa_set_key_type( &attributes, PSA_KEY_TYPE_RAW_DATA );
status = psa_import_key( &attributes, data, sizeof( data ), &handle );
TEST_EQUAL( status, PSA_ERROR_BAD_STATE );
- TEST_EQUAL( handle, 0 );
+ TEST_ASSERT( psa_key_handle_is_null( handle ) );
}
/* END_CASE */
diff --git a/tests/suites/test_suite_psa_crypto_persistent_key.function b/tests/suites/test_suite_psa_crypto_persistent_key.function
index a50eac4..34b88a7 100644
--- a/tests/suites/test_suite_psa_crypto_persistent_key.function
+++ b/tests/suites/test_suite_psa_crypto_persistent_key.function
@@ -177,7 +177,7 @@
/* Check key slot storage is removed */
TEST_EQUAL( psa_is_key_present_in_storage( key_id ), 0 );
TEST_EQUAL( psa_open_key( key_id, &handle ), PSA_ERROR_DOES_NOT_EXIST );
- TEST_EQUAL( handle, 0 );
+ TEST_ASSERT( psa_key_handle_is_null( handle ) );
/* Shutdown and restart */
PSA_DONE();
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 68a803e..a1d542d 100644
--- a/tests/suites/test_suite_psa_crypto_se_driver_hal.function
+++ b/tests/suites/test_suite_psa_crypto_se_driver_hal.function
@@ -674,7 +674,7 @@
buffer, sizeof( buffer ), &length ) );
SMOKE_ASSERT( psa_copy_key( handle, &attributes, &handle2 ) );
- if( handle2 != 0 )
+ if( ! psa_key_handle_is_null( handle2 ) )
PSA_ASSERT( psa_close_key( handle2 ) );
SMOKE_ASSERT( psa_mac_sign_setup( &mac_operation, handle, PSA_ALG_CMAC ) );
diff --git a/tests/suites/test_suite_psa_crypto_slot_management.function b/tests/suites/test_suite_psa_crypto_slot_management.function
index bee5835..39491a0 100644
--- a/tests/suites/test_suite_psa_crypto_slot_management.function
+++ b/tests/suites/test_suite_psa_crypto_slot_management.function
@@ -152,7 +152,7 @@
psa_set_key_type( &attributes, type );
PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
&handle ) );
- TEST_ASSERT( handle != 0 );
+ TEST_ASSERT( ! psa_key_handle_is_null( handle ) );
PSA_ASSERT( psa_get_key_attributes( handle, &attributes ) );
TEST_EQUAL( psa_get_key_type( &attributes ), type );
@@ -210,7 +210,7 @@
psa_set_key_enrollment_algorithm( &attributes, alg2 );
PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
&handle ) );
- TEST_ASSERT( handle != 0 );
+ TEST_ASSERT( ! psa_key_handle_is_null( handle ) );
#if defined(MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER)
TEST_EQUAL( psa_open_key( wrong_owner_id, &invalid_handle ),
@@ -342,7 +342,7 @@
psa_set_key_algorithm( &attributes, 0 );
PSA_ASSERT( psa_import_key( &attributes, material1, sizeof( material1 ),
&handle1 ) );
- TEST_ASSERT( handle1 != 0 );
+ TEST_ASSERT( ! psa_key_handle_is_null( handle1 ) );
if( reopen_policy == CLOSE_BEFORE )
PSA_ASSERT( psa_close_key( handle1 ) );
@@ -351,7 +351,7 @@
TEST_EQUAL( psa_import_key( &attributes, material2, sizeof( material2 ),
&handle2 ),
PSA_ERROR_ALREADY_EXISTS );
- TEST_EQUAL( handle2, 0 );
+ TEST_ASSERT( psa_key_handle_is_null( handle2 ) );
if( reopen_policy == CLOSE_AFTER )
PSA_ASSERT( psa_close_key( handle1 ) );
@@ -394,7 +394,7 @@
PSA_ASSERT( psa_crypto_init( ) );
TEST_EQUAL( psa_open_key( id, &handle ), expected_status );
- TEST_EQUAL( handle, 0 );
+ TEST_ASSERT( psa_key_handle_is_null( handle ) );
exit:
PSA_DONE( );
@@ -422,7 +422,7 @@
TEST_EQUAL( psa_import_key( &attributes, material, sizeof( material ),
&handle ),
expected_status );
- TEST_EQUAL( handle, 0 );
+ TEST_ASSERT( psa_key_handle_is_null( handle ) );
exit:
PSA_DONE( );
@@ -631,7 +631,7 @@
TEST_EQUAL( psa_copy_key( source_handle,
&attributes, &new_handle ),
PSA_ERROR_ALREADY_EXISTS );
- TEST_EQUAL( new_handle , 0 );
+ TEST_ASSERT( psa_key_handle_is_null( new_handle ) );
/* Test that the target slot is unaffected. */
PSA_ASSERT( psa_get_key_attributes( target_handle, &attributes2 ) );
@@ -691,7 +691,7 @@
PSA_ASSERT( psa_import_key( &attributes,
material, sizeof( material ),
&valid_handle ) );
- TEST_ASSERT( valid_handle != 0 );
+ TEST_ASSERT( ! psa_key_handle_is_null( valid_handle ) );
/* Construct an invalid handle as specified in the test case data. */
switch( handle_construction )
@@ -766,7 +766,7 @@
if( status == PSA_ERROR_INSUFFICIENT_MEMORY )
break;
PSA_ASSERT( status );
- TEST_ASSERT( handles[i] != 0 );
+ TEST_ASSERT( ! psa_key_handle_is_null( handles[i] ) );
for( j = 0; j < i; j++ )
TEST_ASSERT( handles[i] != handles[j] );
}