Introduce PSA_KEY_HANDLE_INIT macro

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
diff --git a/include/mbedtls/ssl_internal.h b/include/mbedtls/ssl_internal.h
index 1dc9648..30be676 100644
--- a/include/mbedtls/ssl_internal.h
+++ b/include/mbedtls/ssl_internal.h
@@ -1070,7 +1070,7 @@
     if( ssl->conf->psk_opaque != 0 )
         return( ssl->conf->psk_opaque );
 
-    return( 0 );
+    return( PSA_KEY_HANDLE_INIT );
 }
 #endif /* MBEDTLS_USE_PSA_CRYPTO */
 
diff --git a/include/psa/crypto_platform.h b/include/psa/crypto_platform.h
index c64f61d..6ada324 100644
--- a/include/psa/crypto_platform.h
+++ b/include/psa/crypto_platform.h
@@ -51,6 +51,7 @@
 
 /* Integral type representing a key handle. */
 typedef uint16_t psa_key_handle_t;
+#define PSA_KEY_HANDLE_INIT ( (psa_key_handle_t)0 )
 
 #if defined(MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER)
 
diff --git a/library/pk_wrap.c b/library/pk_wrap.c
index 903c53b..a40734b 100644
--- a/library/pk_wrap.c
+++ b/library/pk_wrap.c
@@ -543,7 +543,7 @@
     mbedtls_ecdsa_context *ctx = ctx_arg;
     int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
-    psa_key_handle_t key_handle = 0;
+    psa_key_handle_t key_handle = PSA_KEY_HANDLE_INIT;
     psa_status_t status;
     mbedtls_pk_context key;
     int key_len;
diff --git a/library/psa_crypto.c b/library/psa_crypto.c
index c813ca3..85d9df4 100644
--- a/library/psa_crypto.c
+++ b/library/psa_crypto.c
@@ -2185,7 +2185,7 @@
     if( status != PSA_SUCCESS )
     {
         psa_fail_key_creation( slot, driver );
-        *handle = 0;
+        *handle = PSA_KEY_HANDLE_INIT;
     }
     return( status );
 }
@@ -2197,7 +2197,7 @@
     psa_status_t status;
     psa_key_slot_t *slot = NULL;
     psa_se_drv_table_entry_t *driver = NULL;
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
 
     /* Leaving attributes unspecified is not currently supported.
      * It could make sense to query the key type and size from the
@@ -2290,7 +2290,7 @@
     if( status != PSA_SUCCESS )
     {
         psa_fail_key_creation( target_slot, driver );
-        *target_handle = 0;
+        *target_handle = PSA_KEY_HANDLE_INIT;
     }
     return( status );
 }
@@ -5390,7 +5390,7 @@
     if( status != PSA_SUCCESS )
     {
         psa_fail_key_creation( slot, driver );
-        *handle = 0;
+        *handle = PSA_KEY_HANDLE_INIT;
     }
     return( status );
 }
@@ -6232,7 +6232,7 @@
     if( status != PSA_SUCCESS )
     {
         psa_fail_key_creation( slot, driver );
-        *handle = 0;
+        *handle = PSA_KEY_HANDLE_INIT;
     }
     return( status );
 }
diff --git a/library/psa_crypto_slot_management.c b/library/psa_crypto_slot_management.c
index 060606e..dacd7f6 100644
--- a/library/psa_crypto_slot_management.c
+++ b/library/psa_crypto_slot_management.c
@@ -245,13 +245,13 @@
     if( status != PSA_SUCCESS )
     {
         psa_wipe_key_slot( slot );
-        *handle = 0;
+        *handle = PSA_KEY_HANDLE_INIT;
     }
     return( status );
 
 #else /* defined(MBEDTLS_PSA_CRYPTO_STORAGE_C) */
     (void) key;
-    *handle = 0;
+    *handle = PSA_KEY_HANDLE_INIT;
     return( PSA_ERROR_NOT_SUPPORTED );
 #endif /* !defined(MBEDTLS_PSA_CRYPTO_STORAGE_C) */
 }
diff --git a/library/ssl_cli.c b/library/ssl_cli.c
index 76be8ab..9494c65 100644
--- a/library/ssl_cli.c
+++ b/library/ssl_cli.c
@@ -3802,7 +3802,7 @@
         status = psa_destroy_key( handshake->ecdh_psa_privkey );
         if( status != PSA_SUCCESS )
             return( MBEDTLS_ERR_SSL_HW_ACCEL_FAILED );
-        handshake->ecdh_psa_privkey = 0;
+        handshake->ecdh_psa_privkey = PSA_KEY_HANDLE_INIT;
     }
     else
 #endif /* MBEDTLS_USE_PSA_CRYPTO &&
diff --git a/library/ssl_tls.c b/library/ssl_tls.c
index 7cb5b8c..6144851 100644
--- a/library/ssl_tls.c
+++ b/library/ssl_tls.c
@@ -507,7 +507,7 @@
 {
     psa_status_t status;
     psa_algorithm_t alg;
-    psa_key_handle_t master_slot = 0;
+    psa_key_handle_t master_slot = PSA_KEY_HANDLE_INIT;
     psa_key_derivation_operation_t derivation =
         PSA_KEY_DERIVATION_OPERATION_INIT;
 
@@ -4348,7 +4348,7 @@
     {
         /* The maintenance of the PSK key slot is the
          * user's responsibility. */
-        conf->psk_opaque = 0;
+        conf->psk_opaque = PSA_KEY_HANDLE_INIT;
     }
     /* This and the following branch should never
      * be taken simultaenously as we maintain the
@@ -4434,7 +4434,7 @@
 #if defined(MBEDTLS_USE_PSA_CRYPTO)
     if( ssl->handshake->psk_opaque != 0 )
     {
-        ssl->handshake->psk_opaque = 0;
+        ssl->handshake->psk_opaque = PSA_KEY_HANDLE_INIT;
     }
     else
 #endif /* MBEDTLS_USE_PSA_CRYPTO */
diff --git a/programs/psa/crypto_examples.c b/programs/psa/crypto_examples.c
index 15aabf9..86ceecc 100644
--- a/programs/psa/crypto_examples.c
+++ b/programs/psa/crypto_examples.c
@@ -165,7 +165,7 @@
 
     psa_status_t status;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
-    psa_key_handle_t key_handle = 0;
+    psa_key_handle_t key_handle = PSA_KEY_HANDLE_INIT;
     size_t output_len = 0;
     uint8_t iv[block_size];
     uint8_t input[block_size];
@@ -215,7 +215,7 @@
 
     psa_status_t status;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
-    psa_key_handle_t key_handle = 0;
+    psa_key_handle_t key_handle = PSA_KEY_HANDLE_INIT;
     size_t output_len = 0;
     uint8_t iv[block_size], input[input_size],
             encrypt[input_size + block_size], decrypt[input_size + block_size];
@@ -262,7 +262,7 @@
 
     psa_status_t status;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
-    psa_key_handle_t key_handle = 0;
+    psa_key_handle_t key_handle = PSA_KEY_HANDLE_INIT;
     size_t output_len = 0;
     uint8_t iv[block_size], input[input_size], encrypt[input_size],
             decrypt[input_size];
diff --git a/programs/psa/key_ladder_demo.c b/programs/psa/key_ladder_demo.c
index a3628f0..456d8d6 100644
--- a/programs/psa/key_ladder_demo.c
+++ b/programs/psa/key_ladder_demo.c
@@ -197,7 +197,7 @@
 static psa_status_t generate( const char *key_file_name )
 {
     psa_status_t status = PSA_SUCCESS;
-    psa_key_handle_t key_handle = 0;
+    psa_key_handle_t key_handle = PSA_KEY_HANDLE_INIT;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
 
     psa_set_key_usage_flags( &attributes,
@@ -232,7 +232,7 @@
     FILE *key_file = NULL;
     unsigned char extra_byte;
 
-    *master_key_handle = 0;
+    *master_key_handle = PSA_KEY_HANDLE_INIT;
 
     SYS_CHECK( ( key_file = fopen( key_file_name, "rb" ) ) != NULL );
     SYS_CHECK( ( key_size = fread( key_data, 1, sizeof( key_data ),
@@ -262,7 +262,7 @@
          * *master_key_handle is 0. psa_destroy_key(0) is guaranteed to do
          * nothing and return PSA_ERROR_INVALID_HANDLE. */
         (void) psa_destroy_key( *master_key_handle );
-        *master_key_handle = 0;
+        *master_key_handle = PSA_KEY_HANDLE_INIT;
     }
     return( status );
 }
@@ -304,7 +304,7 @@
         /* When the parent key is not the master key, destroy it,
          * since it is no longer needed. */
         PSA_CHECK( psa_close_key( *key_handle ) );
-        *key_handle = 0;
+        *key_handle = PSA_KEY_HANDLE_INIT;
         /* Derive the next intermediate key from the parent key. */
         PSA_CHECK( psa_key_derivation_output_key( &attributes, &operation,
                                                   key_handle ) );
@@ -316,7 +316,7 @@
     if( status != PSA_SUCCESS )
     {
         psa_close_key( *key_handle );
-        *key_handle = 0;
+        *key_handle = PSA_KEY_HANDLE_INIT;
     }
     return( status );
 }
@@ -330,7 +330,7 @@
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
     psa_key_derivation_operation_t operation = PSA_KEY_DERIVATION_OPERATION_INIT;
 
-    *wrapping_key_handle = 0;
+    *wrapping_key_handle = PSA_KEY_HANDLE_INIT;
 
     /* Set up a key derivation operation from the key derived from
      * the master key. */
@@ -527,8 +527,8 @@
                          const char *output_file_name )
 {
     psa_status_t status = PSA_SUCCESS;
-    psa_key_handle_t derivation_key_handle = 0;
-    psa_key_handle_t wrapping_key_handle = 0;
+    psa_key_handle_t derivation_key_handle = PSA_KEY_HANDLE_INIT;
+    psa_key_handle_t wrapping_key_handle = PSA_KEY_HANDLE_INIT;
 
     /* Initialize the PSA crypto library. */
     PSA_CHECK( psa_crypto_init( ) );
diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c
index 54cdd7d..16bd619 100644
--- a/programs/ssl/ssl_client2.c
+++ b/programs/ssl/ssl_client2.c
@@ -1207,7 +1207,7 @@
     const char *pers = "ssl_client2";
 
 #if defined(MBEDTLS_USE_PSA_CRYPTO)
-    psa_key_handle_t slot = 0;
+    psa_key_handle_t slot = PSA_KEY_HANDLE_INIT;
     psa_algorithm_t alg = 0;
     psa_key_attributes_t key_attributes;
     psa_status_t status;
@@ -1232,7 +1232,7 @@
     mbedtls_x509_crt clicert;
     mbedtls_pk_context pkey;
 #if defined(MBEDTLS_USE_PSA_CRYPTO)
-    psa_key_handle_t key_slot = 0; /* invalid key slot */
+    psa_key_handle_t key_slot = PSA_KEY_HANDLE_INIT; /* invalid key slot */
 #endif
 #endif
     char *p, *q;
diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c
index ec3d6ad..c11b081 100644
--- a/programs/ssl/ssl_server2.c
+++ b/programs/ssl/ssl_server2.c
@@ -1795,7 +1795,7 @@
 #if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED)
 #if defined(MBEDTLS_USE_PSA_CRYPTO)
     psa_algorithm_t alg = 0;
-    psa_key_handle_t psk_slot = 0;
+    psa_key_handle_t psk_slot = PSA_KEY_HANDLE_INIT;
 #endif /* MBEDTLS_USE_PSA_CRYPTO */
     unsigned char psk[MBEDTLS_PSK_MAX_LEN];
     size_t psk_len = 0;
diff --git a/tests/suites/test_suite_pk.function b/tests/suites/test_suite_pk.function
index c6041b2..22bf0e7 100644
--- a/tests/suites/test_suite_pk.function
+++ b/tests/suites/test_suite_pk.function
@@ -151,7 +151,7 @@
 
     TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
 
-    TEST_ASSERT( mbedtls_pk_setup_opaque( &pk, 0 ) ==
+    TEST_ASSERT( mbedtls_pk_setup_opaque( &pk, PSA_KEY_HANDLE_INIT ) ==
                  MBEDTLS_ERR_PK_BAD_INPUT_DATA );
 
     mbedtls_pk_free( &pk );
diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function
index fc563cb..3c4d7c8 100644
--- a/tests/suites/test_suite_psa_crypto.function
+++ b/tests/suites/test_suite_psa_crypto.function
@@ -298,7 +298,7 @@
                         psa_mac_operation_t *operation,
                         psa_status_t *status )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
 
     psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_SIGN_HASH );
@@ -333,7 +333,7 @@
                            psa_cipher_operation_t *operation,
                            psa_status_t *status )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
 
     psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_ENCRYPT );
@@ -1452,7 +1452,7 @@
 {
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
     psa_key_attributes_t got_attributes = PSA_KEY_ATTRIBUTES_INIT;
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_type_t type = type_arg;
     psa_key_usage_t usage = usage_arg;
     psa_algorithm_t alg = alg_arg;
@@ -1496,7 +1496,7 @@
 {
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
     psa_key_attributes_t got_attributes = PSA_KEY_ATTRIBUTES_INIT;
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_type_t type = type_arg;
     size_t attr_bits = attr_bits_arg;
     psa_status_t expected_status = expected_status_arg;
@@ -1536,7 +1536,7 @@
     size_t byte_size = byte_size_arg;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
     psa_status_t expected_status = expected_status_arg;
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_status_t status;
     uint8_t *buffer = NULL;
     size_t buffer_size = byte_size + 1;
@@ -1580,7 +1580,7 @@
 /* BEGIN_CASE */
 void import_rsa_made_up( int bits_arg, int keypair, int expected_status_arg )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     size_t bits = bits_arg;
     psa_status_t expected_status = expected_status_arg;
     psa_status_t status;
@@ -1624,7 +1624,7 @@
                     int expected_export_status_arg,
                     int canonical_input )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_type_t type = type_arg;
     psa_algorithm_t alg = alg_arg;
     psa_status_t expected_export_status = expected_export_status_arg;
@@ -1717,7 +1717,7 @@
                                int expected_export_status_arg,
                                data_t *expected_public_key )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_type_t type = type_arg;
     psa_algorithm_t alg = alg_arg;
     psa_status_t expected_export_status = expected_export_status_arg;
@@ -1768,7 +1768,7 @@
                               int bits_arg,
                               int alg_arg )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_type_t type = type_arg;
     size_t bits = bits_arg;
     psa_algorithm_t alg = alg_arg;
@@ -1810,7 +1810,7 @@
                                int usage_arg, int expected_usage_arg,
                                int alg_arg, int expected_alg_arg )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_type_t key_type = type_arg;
     psa_key_type_t expected_key_type = expected_type_arg;
     size_t bits = bits_arg;
@@ -1896,7 +1896,7 @@
                      data_t *key_data,
                      int exercise_alg )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
     psa_mac_operation_t operation = PSA_MAC_OPERATION_INIT;
     psa_status_t status;
@@ -1941,7 +1941,7 @@
                         data_t *key_data,
                         int exercise_alg )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
     psa_cipher_operation_t operation = PSA_CIPHER_OPERATION_INIT;
     psa_status_t status;
@@ -1986,7 +1986,7 @@
                       int tag_length_arg,
                       int exercise_alg )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
     psa_status_t status;
     unsigned char nonce[16] = {0};
@@ -2045,7 +2045,7 @@
                                        data_t *key_data,
                                        int exercise_alg )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
     psa_status_t status;
     size_t key_bits;
@@ -2108,7 +2108,7 @@
                                       int exercise_alg,
                                       int payload_length_arg )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
     psa_status_t status;
     unsigned char payload[PSA_HASH_MAX_SIZE] = {1};
@@ -2161,7 +2161,7 @@
                         data_t *key_data,
                         int exercise_alg )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
     psa_key_derivation_operation_t operation = PSA_KEY_DERIVATION_OPERATION_INIT;
     psa_status_t status;
@@ -2211,7 +2211,7 @@
                            int exercise_alg,
                            int expected_status_arg )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
     psa_key_type_t key_type = key_type_arg;
     psa_key_derivation_operation_t operation = PSA_KEY_DERIVATION_OPERATION_INIT;
@@ -2243,7 +2243,7 @@
 void key_policy_alg2( int key_type_arg, data_t *key_data,
                       int usage_arg, int alg_arg, int alg2_arg )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_type_t key_type = key_type_arg;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
     psa_key_attributes_t got_attributes = PSA_KEY_ATTRIBUTES_INIT;
@@ -2284,7 +2284,7 @@
                                int exercise_alg,
                                int expected_status_arg )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
     psa_key_type_t key_type = key_type_arg;
     psa_key_derivation_operation_t operation = PSA_KEY_DERIVATION_OPERATION_INIT;
@@ -2326,8 +2326,8 @@
     psa_key_usage_t expected_usage = expected_usage_arg;
     psa_algorithm_t expected_alg = expected_alg_arg;
     psa_algorithm_t expected_alg2 = expected_alg2_arg;
-    psa_key_handle_t source_handle = 0;
-    psa_key_handle_t target_handle = 0;
+    psa_key_handle_t source_handle = PSA_KEY_HANDLE_INIT;
+    psa_key_handle_t target_handle = PSA_KEY_HANDLE_INIT;
     uint8_t *export_buffer = NULL;
 
     PSA_ASSERT( psa_crypto_init( ) );
@@ -2404,8 +2404,8 @@
 {
     psa_key_attributes_t source_attributes = PSA_KEY_ATTRIBUTES_INIT;
     psa_key_attributes_t target_attributes = PSA_KEY_ATTRIBUTES_INIT;
-    psa_key_handle_t source_handle = 0;
-    psa_key_handle_t target_handle = 0;
+    psa_key_handle_t source_handle = PSA_KEY_HANDLE_INIT;
+    psa_key_handle_t target_handle = PSA_KEY_HANDLE_INIT;
 
     PSA_ASSERT( psa_crypto_init( ) );
 
@@ -2909,7 +2909,7 @@
 /* BEGIN_CASE */
 void mac_bad_order( )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_type_t key_type = PSA_KEY_TYPE_HMAC;
     psa_algorithm_t alg = PSA_ALG_HMAC(PSA_ALG_SHA_256);
     const uint8_t key[] = {
@@ -3036,7 +3036,7 @@
                data_t *input,
                data_t *expected_mac )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_type_t key_type = key_type_arg;
     psa_algorithm_t alg = alg_arg;
     psa_mac_operation_t operation = PSA_MAC_OPERATION_INIT;
@@ -3110,7 +3110,7 @@
                  data_t *input,
                  data_t *expected_mac )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_type_t key_type = key_type_arg;
     psa_algorithm_t alg = alg_arg;
     psa_mac_operation_t operation = PSA_MAC_OPERATION_INIT;
@@ -3264,7 +3264,7 @@
 /* BEGIN_CASE */
 void cipher_bad_order( )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_type_t key_type = PSA_KEY_TYPE_AES;
     psa_algorithm_t alg = PSA_ALG_CBC_PKCS7;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
@@ -3420,7 +3420,7 @@
                      data_t *input, data_t *expected_output,
                      int expected_status_arg )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_status_t status;
     psa_key_type_t key_type = key_type_arg;
     psa_algorithm_t alg = alg_arg;
@@ -3487,7 +3487,7 @@
                                int output1_length_arg, int output2_length_arg,
                                data_t *expected_output )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_type_t key_type = key_type_arg;
     psa_algorithm_t alg = alg_arg;
     size_t first_part_size = first_part_size_arg;
@@ -3560,8 +3560,7 @@
                                int output1_length_arg, int output2_length_arg,
                                data_t *expected_output )
 {
-    psa_key_handle_t handle = 0;
-
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_type_t key_type = key_type_arg;
     psa_algorithm_t alg = alg_arg;
     size_t first_part_size = first_part_size_arg;
@@ -3633,7 +3632,7 @@
                      data_t *input, data_t *expected_output,
                      int expected_status_arg )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_status_t status;
     psa_key_type_t key_type = key_type_arg;
     psa_algorithm_t alg = alg_arg;
@@ -3697,7 +3696,7 @@
                            data_t *key,
                            data_t *input )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_type_t key_type = key_type_arg;
     psa_algorithm_t alg = alg_arg;
     unsigned char iv[16] = {0};
@@ -3790,7 +3789,7 @@
                                      data_t *input,
                                      int first_part_size_arg )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_type_t key_type = key_type_arg;
     psa_algorithm_t alg = alg_arg;
     size_t first_part_size = first_part_size_arg;
@@ -3903,7 +3902,7 @@
                            data_t *input_data,
                            int expected_result_arg )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_type_t key_type = key_type_arg;
     psa_algorithm_t alg = alg_arg;
     unsigned char *output_data = NULL;
@@ -3979,7 +3978,7 @@
                    data_t *input_data,
                    data_t *expected_result )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_type_t key_type = key_type_arg;
     psa_algorithm_t alg = alg_arg;
     unsigned char *output_data = NULL;
@@ -4030,7 +4029,7 @@
                    data_t *expected_data,
                    int expected_result_arg )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_type_t key_type = key_type_arg;
     psa_algorithm_t alg = alg_arg;
     unsigned char *output_data = NULL;
@@ -4103,7 +4102,7 @@
                          int alg_arg, data_t *input_data,
                          data_t *output_data )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_type_t key_type = key_type_arg;
     psa_algorithm_t alg = alg_arg;
     size_t key_bits;
@@ -4164,7 +4163,7 @@
                 int alg_arg, data_t *input_data,
                 int signature_size_arg, int expected_status_arg )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_type_t key_type = key_type_arg;
     psa_algorithm_t alg = alg_arg;
     size_t signature_size = signature_size_arg;
@@ -4218,7 +4217,7 @@
 void sign_verify( int key_type_arg, data_t *key_data,
                   int alg_arg, data_t *input_data )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_type_t key_type = key_type_arg;
     psa_algorithm_t alg = alg_arg;
     size_t key_bits;
@@ -4285,7 +4284,7 @@
                         int alg_arg, data_t *hash_data,
                         data_t *signature_data )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_type_t key_type = key_type_arg;
     psa_algorithm_t alg = alg_arg;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
@@ -4326,7 +4325,7 @@
                              data_t *signature_data,
                              int expected_status_arg )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_type_t key_type = key_type_arg;
     psa_algorithm_t alg = alg_arg;
     psa_status_t actual_status;
@@ -4370,7 +4369,7 @@
                          int expected_output_length_arg,
                          int expected_status_arg )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_type_t key_type = key_type_arg;
     psa_algorithm_t alg = alg_arg;
     size_t expected_output_length = expected_output_length_arg;
@@ -4437,7 +4436,7 @@
                                  data_t *input_data,
                                  data_t *label )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_type_t key_type = key_type_arg;
     psa_algorithm_t alg = alg_arg;
     size_t key_bits;
@@ -4503,7 +4502,7 @@
                          data_t *label,
                          data_t *expected_data )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_type_t key_type = key_type_arg;
     psa_algorithm_t alg = alg_arg;
     unsigned char *output = NULL;
@@ -4566,7 +4565,7 @@
                               int output_size_arg,
                               int expected_status_arg  )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_type_t key_type = key_type_arg;
     psa_algorithm_t alg = alg_arg;
     unsigned char *output = NULL;
@@ -4705,12 +4704,14 @@
                                         expected_status_arg2,
                                         expected_status_arg3};
     data_t *inputs[] = {input1, input2, input3};
-    psa_key_handle_t handles[] = {0, 0, 0};
+    psa_key_handle_t handles[] = { PSA_KEY_HANDLE_INIT,
+                                   PSA_KEY_HANDLE_INIT,
+                                   PSA_KEY_HANDLE_INIT};
     psa_key_derivation_operation_t operation = PSA_KEY_DERIVATION_OPERATION_INIT;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
     size_t i;
     psa_key_type_t output_key_type = output_key_type_arg;
-    psa_key_handle_t output_handle = 0;
+    psa_key_handle_t output_handle = PSA_KEY_HANDLE_INIT;
     psa_status_t expected_output_status = expected_output_status_arg;
     psa_status_t actual_output_status;
 
@@ -4784,7 +4785,7 @@
 void test_derive_invalid_key_derivation_state( int alg_arg )
 {
     psa_algorithm_t alg = alg_arg;
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     size_t key_type = PSA_KEY_TYPE_DERIVE;
     psa_key_derivation_operation_t operation = PSA_KEY_DERIVATION_OPERATION_INIT;
     unsigned char input1[] = "Input 1";
@@ -4872,7 +4873,9 @@
     psa_algorithm_t alg = alg_arg;
     psa_key_derivation_step_t steps[] = {step1_arg, step2_arg, step3_arg};
     data_t *inputs[] = {input1, input2, input3};
-    psa_key_handle_t handles[] = {0, 0, 0};
+    psa_key_handle_t handles[] = { PSA_KEY_HANDLE_INIT,
+                                   PSA_KEY_HANDLE_INIT,
+                                   PSA_KEY_HANDLE_INIT};
     size_t requested_capacity = requested_capacity_arg;
     psa_key_derivation_operation_t operation = PSA_KEY_DERIVATION_OPERATION_INIT;
     uint8_t *expected_outputs[2] =
@@ -4982,7 +4985,7 @@
                   data_t *input2,
                   int requested_capacity_arg )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_algorithm_t alg = alg_arg;
     size_t requested_capacity = requested_capacity_arg;
     psa_key_derivation_operation_t operation = PSA_KEY_DERIVATION_OPERATION_INIT;
@@ -5048,8 +5051,8 @@
                           int derived_usage_arg,
                           int derived_alg_arg )
 {
-    psa_key_handle_t base_handle = 0;
-    psa_key_handle_t derived_handle = 0;
+    psa_key_handle_t base_handle = PSA_KEY_HANDLE_INIT;
+    psa_key_handle_t derived_handle = PSA_KEY_HANDLE_INIT;
     psa_algorithm_t alg = alg_arg;
     psa_key_type_t derived_type = derived_type_arg;
     size_t derived_bits = derived_bits_arg;
@@ -5107,8 +5110,8 @@
                         int bytes1_arg,
                         int bytes2_arg )
 {
-    psa_key_handle_t base_handle = 0;
-    psa_key_handle_t derived_handle = 0;
+    psa_key_handle_t base_handle = PSA_KEY_HANDLE_INIT;
+    psa_key_handle_t derived_handle = PSA_KEY_HANDLE_INIT;
     psa_algorithm_t alg = alg_arg;
     size_t bytes1 = bytes1_arg;
     size_t bytes2 = bytes2_arg;
@@ -5186,8 +5189,8 @@
                  int type_arg, int bits_arg,
                  int expected_status_arg )
 {
-    psa_key_handle_t base_handle = 0;
-    psa_key_handle_t derived_handle = 0;
+    psa_key_handle_t base_handle = PSA_KEY_HANDLE_INIT;
+    psa_key_handle_t derived_handle = PSA_KEY_HANDLE_INIT;
     psa_algorithm_t alg = alg_arg;
     psa_key_type_t type = type_arg;
     size_t bits = bits_arg;
@@ -5231,7 +5234,7 @@
                           data_t *our_key_data, data_t *peer_key_data,
                           int expected_status_arg )
 {
-    psa_key_handle_t our_key = 0;
+    psa_key_handle_t our_key = PSA_KEY_HANDLE_INIT;
     psa_algorithm_t alg = alg_arg;
     psa_algorithm_t our_key_alg = our_key_alg_arg;
     psa_key_type_t our_key_type = our_key_type_arg;
@@ -5280,7 +5283,7 @@
                         data_t *peer_key_data,
                         data_t *expected_output )
 {
-    psa_key_handle_t our_key = 0;
+    psa_key_handle_t our_key = PSA_KEY_HANDLE_INIT;
     psa_algorithm_t alg = alg_arg;
     psa_key_type_t our_key_type = our_key_type_arg;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
@@ -5317,7 +5320,7 @@
                              data_t *peer_key_data,
                              int expected_capacity_arg )
 {
-    psa_key_handle_t our_key = 0;
+    psa_key_handle_t our_key = PSA_KEY_HANDLE_INIT;
     psa_algorithm_t alg = alg_arg;
     psa_key_type_t our_key_type = our_key_type_arg;
     psa_key_derivation_operation_t operation = PSA_KEY_DERIVATION_OPERATION_INIT;
@@ -5377,7 +5380,7 @@
                            data_t *peer_key_data,
                            data_t *expected_output1, data_t *expected_output2 )
 {
-    psa_key_handle_t our_key = 0;
+    psa_key_handle_t our_key = PSA_KEY_HANDLE_INIT;
     psa_algorithm_t alg = alg_arg;
     psa_key_type_t our_key_type = our_key_type_arg;
     psa_key_derivation_operation_t operation = PSA_KEY_DERIVATION_OPERATION_INIT;
@@ -5491,7 +5494,7 @@
                    int alg_arg,
                    int expected_status_arg )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_type_t type = type_arg;
     psa_key_usage_t usage = usage_arg;
     size_t bits = bits_arg;
@@ -5533,7 +5536,7 @@
                        data_t *e_arg,
                        int expected_status_arg )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_type_t type = PSA_KEY_TYPE_RSA_KEY_PAIR;
     size_t bits = bits_arg;
     psa_key_usage_t usage = PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT;
@@ -5639,8 +5642,8 @@
 {
     mbedtls_svc_key_id_t key_id = mbedtls_svc_key_id_make( 1, 1 );
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
-    psa_key_handle_t handle = 0;
-    psa_key_handle_t base_key = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
+    psa_key_handle_t base_key = PSA_KEY_HANDLE_INIT;
     psa_key_type_t type = type_arg;
     size_t bits = bits_arg;
     psa_key_usage_t usage_flags = usage_flags_arg;
@@ -5704,7 +5707,7 @@
                                                            &handle ) );
                 PSA_ASSERT( psa_key_derivation_abort( &operation ) );
                 PSA_ASSERT( psa_destroy_key( base_key ) );
-                base_key = 0;
+                base_key = PSA_KEY_HANDLE_INIT;
             }
         break;
     }
diff --git a/tests/suites/test_suite_psa_crypto_driver_wrappers.function b/tests/suites/test_suite_psa_crypto_driver_wrappers.function
index a0140d2..53df781 100644
--- a/tests/suites/test_suite_psa_crypto_driver_wrappers.function
+++ b/tests/suites/test_suite_psa_crypto_driver_wrappers.function
@@ -19,7 +19,7 @@
 {
     psa_status_t force_status = force_status_arg;
     psa_status_t expected_status = expected_status_arg;
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
     psa_algorithm_t alg = PSA_ALG_DETERMINISTIC_ECDSA( PSA_ALG_SHA_256 );
     uint8_t signature[64];
@@ -73,7 +73,7 @@
 {
     psa_status_t force_status = force_status_arg;
     psa_status_t expected_status = expected_status_arg;
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
     psa_algorithm_t alg = PSA_ALG_DETERMINISTIC_ECDSA( PSA_ALG_SHA_256 );
     psa_status_t actual_status;
@@ -124,7 +124,7 @@
 {
     psa_status_t force_status = force_status_arg;
     psa_status_t expected_status = expected_status_arg;
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
     psa_algorithm_t alg = PSA_ALG_ECDSA( PSA_ALG_SHA_256 );
     const uint8_t *expected_output = NULL;
@@ -226,7 +226,7 @@
                      int force_status_arg,
                      int expected_status_arg )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_status_t status;
     psa_key_type_t key_type = key_type_arg;
     psa_algorithm_t alg = alg_arg;
@@ -319,7 +319,7 @@
                                int output1_length_arg, int output2_length_arg,
                                data_t *expected_output )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_type_t key_type = key_type_arg;
     psa_algorithm_t alg = alg_arg;
     size_t first_part_size = first_part_size_arg;
@@ -404,8 +404,7 @@
                                int output1_length_arg, int output2_length_arg,
                                data_t *expected_output )
 {
-    psa_key_handle_t handle = 0;
-
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_type_t key_type = key_type_arg;
     psa_algorithm_t alg = alg_arg;
     size_t first_part_size = first_part_size_arg;
@@ -492,7 +491,7 @@
                      int force_status_arg,
                      int expected_status_arg )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_status_t status;
     psa_key_type_t key_type = key_type_arg;
     psa_algorithm_t alg = alg_arg;
@@ -581,7 +580,7 @@
                           data_t *key, data_t *iv,
                           data_t *input )
 {
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_status_t status;
     psa_key_type_t key_type = key_type_arg;
     psa_algorithm_t alg = alg_arg;
diff --git a/tests/suites/test_suite_psa_crypto_persistent_key.function b/tests/suites/test_suite_psa_crypto_persistent_key.function
index 7ee17f9..a50eac4 100644
--- a/tests/suites/test_suite_psa_crypto_persistent_key.function
+++ b/tests/suites/test_suite_psa_crypto_persistent_key.function
@@ -117,7 +117,7 @@
 void save_large_persistent_key( int data_length_arg, int expected_status )
 {
     mbedtls_svc_key_id_t key_id = mbedtls_svc_key_id_make( 1, 42 );
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     uint8_t *data = NULL;
     size_t data_length = data_length_arg;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
@@ -149,7 +149,7 @@
 {
     mbedtls_svc_key_id_t key_id =
         mbedtls_svc_key_id_make( owner_id_arg, key_id_arg );
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_type_t first_type = (psa_key_type_t) first_type_arg;
     psa_key_type_t second_type = (psa_key_type_t) second_type_arg;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
@@ -204,7 +204,7 @@
     mbedtls_svc_key_id_t key_id =
         mbedtls_svc_key_id_make( owner_id_arg, key_id_arg );
     psa_key_type_t type = (psa_key_type_t) type_arg;
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
 
     PSA_ASSERT( psa_crypto_init() );
@@ -254,7 +254,7 @@
 {
     mbedtls_svc_key_id_t key_id = mbedtls_svc_key_id_make( 1, 42 );
     psa_key_type_t type = (psa_key_type_t) type_arg;
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     unsigned char *exported = NULL;
     size_t export_size = data->len;
     size_t exported_length;
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 8584e5e..68a803e 100644
--- a/tests/suites/test_suite_psa_crypto_se_driver_hal.function
+++ b/tests/suites/test_suite_psa_crypto_se_driver_hal.function
@@ -450,7 +450,7 @@
 {
     ram_slot_t *slot;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_status_t status = PSA_ERROR_GENERIC_ERROR;
 
     (void) context;
@@ -483,7 +483,7 @@
 {
     ram_slot_t *slot;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_status_t status = PSA_ERROR_GENERIC_ERROR;
 
     (void) context;
@@ -664,7 +664,7 @@
         PSA_KEY_DERIVATION_OPERATION_INIT;
     uint8_t buffer[80]; /* large enough for a public key for ECDH */
     size_t length;
-    psa_key_handle_t handle2 = 0;
+    psa_key_handle_t handle2 = PSA_KEY_HANDLE_INIT;
 
     SMOKE_ASSERT( psa_get_key_attributes( handle, &attributes ) );
 
@@ -880,7 +880,7 @@
     psa_key_lifetime_t lifetime = (psa_key_lifetime_t) lifetime_arg;
     psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( lifetime );
     mbedtls_svc_key_id_t id = mbedtls_svc_key_id_make( 1, 1 );
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
     const uint8_t key_material[3] = {0xfa, 0xca, 0xde};
     uint8_t exported[sizeof( key_material )];
@@ -983,7 +983,7 @@
                     exported, exported_length );
 
     PSA_ASSERT( psa_destroy_key( handle ) );
-    handle = 0;
+    handle = PSA_KEY_HANDLE_INIT;
     if( ! check_persistent_data( location,
                                  &ram_shadow_slot_usage,
                                  sizeof( ram_shadow_slot_usage ) ) )
@@ -1014,7 +1014,7 @@
     psa_key_lifetime_t lifetime = TEST_SE_PERSISTENT_LIFETIME;
     psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( lifetime );
     mbedtls_svc_key_id_t id = mbedtls_svc_key_id_make( 1, 1 );
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
     const uint8_t key_material[3] = {0xfa, 0xca, 0xde};
 
@@ -1072,7 +1072,7 @@
     PSA_ASSERT( psa_get_key_attributes( handle, &attributes ) );
 
     PSA_ASSERT( psa_destroy_key( handle ) );
-    handle = 0;
+    handle = PSA_KEY_HANDLE_INIT;
     if( ! check_persistent_data( location,
                                  &ram_shadow_slot_usage,
                                  sizeof( ram_shadow_slot_usage ) ) )
@@ -1098,7 +1098,7 @@
     psa_key_lifetime_t lifetime = TEST_SE_PERSISTENT_LIFETIME;
     psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( lifetime );
     mbedtls_svc_key_id_t id = mbedtls_svc_key_id_make( 1, 1 );
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
 
     TEST_USES_KEY_ID( id );
@@ -1148,7 +1148,7 @@
 
     /* We're done. */
     PSA_ASSERT( psa_destroy_key( handle ) );
-    handle = 0;
+    handle = PSA_KEY_HANDLE_INIT;
     if( ! check_persistent_data( location,
                                  &shadow_counter, sizeof( shadow_counter ) ) )
         goto exit;
@@ -1172,7 +1172,7 @@
     psa_key_lifetime_t lifetime = TEST_SE_PERSISTENT_LIFETIME;
     psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( lifetime );
     mbedtls_svc_key_id_t id = mbedtls_svc_key_id_make( 1, 1 );
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
 
     TEST_USES_KEY_ID( id );
@@ -1213,7 +1213,7 @@
     psa_key_lifetime_t lifetime = TEST_SE_PERSISTENT_LIFETIME;
     psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( lifetime );
     mbedtls_svc_key_id_t id = mbedtls_svc_key_id_make( 1, 1 );
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
 
     TEST_USES_KEY_ID( id );
@@ -1262,7 +1262,7 @@
 
     /* We're done. */
     PSA_ASSERT( psa_destroy_key( handle ) );
-    handle = 0;
+    handle = PSA_KEY_HANDLE_INIT;
     if( ! check_persistent_data( location,
                                  &shadow_counter, sizeof( shadow_counter ) ) )
         goto exit;
@@ -1295,8 +1295,8 @@
     psa_key_lifetime_t lifetime = TEST_SE_PERSISTENT_LIFETIME;
     psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( lifetime );
     mbedtls_svc_key_id_t id = mbedtls_svc_key_id_make( 1, 1 );
-    psa_key_handle_t drv_handle = 0; /* key managed by the driver */
-    psa_key_handle_t sw_handle = 0; /* transparent key */
+    psa_key_handle_t drv_handle = PSA_KEY_HANDLE_INIT; /* key managed by the driver */
+    psa_key_handle_t sw_handle = PSA_KEY_HANDLE_INIT; /* transparent key */
     psa_key_attributes_t sw_attributes = PSA_KEY_ATTRIBUTES_INIT;
     psa_key_attributes_t drv_attributes;
     uint8_t signature[PSA_SIGNATURE_MAX_SIZE];
@@ -1462,7 +1462,7 @@
     mbedtls_svc_key_id_t id = mbedtls_svc_key_id_make( owner_id_arg, id_arg );
     size_t bit_size = 48;
     psa_key_slot_number_t wanted_slot = 0x123456789;
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_status_t status;
 
     TEST_USES_KEY_ID( id );
@@ -1518,7 +1518,7 @@
         goto exit;
     /* This time, destroy the key. */
     PSA_ASSERT( psa_destroy_key( handle ) );
-    handle = 0;
+    handle = PSA_KEY_HANDLE_INIT;
     TEST_EQUAL( psa_open_key( id, &handle ),
                 PSA_ERROR_DOES_NOT_EXIST );
 
diff --git a/tests/suites/test_suite_psa_crypto_se_driver_hal_mocks.function b/tests/suites/test_suite_psa_crypto_se_driver_hal_mocks.function
index 7d4a591..0e2e203 100644
--- a/tests/suites/test_suite_psa_crypto_se_driver_hal_mocks.function
+++ b/tests/suites/test_suite_psa_crypto_se_driver_hal_mocks.function
@@ -333,7 +333,7 @@
     psa_key_lifetime_t lifetime = TEST_SE_PERSISTENT_LIFETIME;
     psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( lifetime );
     mbedtls_svc_key_id_t id = mbedtls_svc_key_id_make( 1, 1 );
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
     const uint8_t key_material[3] = {0xfa, 0xca, 0xde};
 
@@ -402,7 +402,7 @@
     psa_key_lifetime_t lifetime = TEST_SE_PERSISTENT_LIFETIME;
     psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( lifetime );
     mbedtls_svc_key_id_t id = mbedtls_svc_key_id_make( 1, 1 );
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
     const uint8_t key_material[3] = {0xfa, 0xca, 0xde};
     uint8_t exported[sizeof( key_material )];
@@ -456,7 +456,7 @@
     psa_key_lifetime_t lifetime = TEST_SE_PERSISTENT_LIFETIME;
     psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( lifetime );
     mbedtls_svc_key_id_t id = mbedtls_svc_key_id_make( 1, 1 );
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
 
     mock_allocate_data.return_value = mock_alloc_return_value;
@@ -523,7 +523,7 @@
     psa_key_lifetime_t lifetime = TEST_SE_PERSISTENT_LIFETIME;
     psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( lifetime );
     mbedtls_svc_key_id_t id = mbedtls_svc_key_id_make( 1, 1 );
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
     const uint8_t key_material[3] = {0xfa, 0xca, 0xde};
     uint8_t exported[sizeof( key_material )];
@@ -573,7 +573,7 @@
     psa_key_lifetime_t lifetime = TEST_SE_PERSISTENT_LIFETIME;
     psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( lifetime );
     mbedtls_svc_key_id_t id = mbedtls_svc_key_id_make( 1, 1 );
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
     const uint8_t key_material[3] = {0xfa, 0xca, 0xde};
     psa_algorithm_t algorithm = PSA_ALG_ECDSA(PSA_ALG_SHA_256);
@@ -634,7 +634,7 @@
     psa_key_lifetime_t lifetime = TEST_SE_PERSISTENT_LIFETIME;
     psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( lifetime );
     mbedtls_svc_key_id_t id = mbedtls_svc_key_id_make( 1, 1 );
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
     const uint8_t key_material[3] = {0xfa, 0xca, 0xde};
     psa_algorithm_t algorithm = PSA_ALG_ECDSA(PSA_ALG_SHA_256);
diff --git a/tests/suites/test_suite_psa_crypto_slot_management.function b/tests/suites/test_suite_psa_crypto_slot_management.function
index fa3dd6e..bee5835 100644
--- a/tests/suites/test_suite_psa_crypto_slot_management.function
+++ b/tests/suites/test_suite_psa_crypto_slot_management.function
@@ -141,7 +141,7 @@
     psa_key_usage_t usage_flags = usage_arg;
     psa_key_type_t type = type_arg;
     close_method_t close_method = close_method_arg;
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
 
     PSA_ASSERT( psa_crypto_init( ) );
@@ -185,7 +185,7 @@
     psa_key_usage_t usage_flags = usage_arg;
     psa_key_type_t type = type_arg;
     close_method_t close_method = close_method_arg;
-    psa_key_handle_t handle = 0;
+    psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
     psa_key_attributes_t read_attributes = PSA_KEY_ATTRIBUTES_INIT;
     uint8_t *reexported = NULL;
@@ -194,7 +194,7 @@
 #if defined(MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER)
     mbedtls_svc_key_id_t wrong_owner_id =
         mbedtls_svc_key_id_make( owner_id_arg + 1, id_arg );
-    psa_key_handle_t invalid_handle = 0;
+    psa_key_handle_t invalid_handle = PSA_KEY_HANDLE_INIT;
 #endif
 
     TEST_USES_KEY_ID( id );
@@ -319,7 +319,8 @@
 {
     psa_key_lifetime_t lifetime = lifetime_arg;
     mbedtls_svc_key_id_t id = mbedtls_svc_key_id_make( owner_id_arg, id_arg );
-    psa_key_handle_t handle1 = 0, handle2 = 0;
+    psa_key_handle_t handle1 = PSA_KEY_HANDLE_INIT;
+    psa_key_handle_t handle2 = PSA_KEY_HANDLE_INIT;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
     psa_key_type_t type1 = PSA_KEY_TYPE_RAW_DATA;
     const uint8_t material1[5] = "a key";
@@ -447,7 +448,7 @@
         mbedtls_svc_key_id_make( source_owner_id_arg, source_id_arg );
     psa_key_usage_t source_usage = source_usage_arg;
     psa_algorithm_t source_alg = source_alg_arg;
-    psa_key_handle_t source_handle = 0;
+    psa_key_handle_t source_handle = PSA_KEY_HANDLE_INIT;
     psa_key_attributes_t source_attributes = PSA_KEY_ATTRIBUTES_INIT;
     psa_key_type_t source_type = type_arg;
     psa_key_lifetime_t target_lifetime = target_lifetime_arg;
@@ -455,7 +456,7 @@
         mbedtls_svc_key_id_make( target_owner_id_arg, target_id_arg );
     psa_key_usage_t target_usage = target_usage_arg;
     psa_algorithm_t target_alg = target_alg_arg;
-    psa_key_handle_t target_handle = 0;
+    psa_key_handle_t target_handle = PSA_KEY_HANDLE_INIT;
     psa_key_attributes_t target_attributes = PSA_KEY_ATTRIBUTES_INIT;
     psa_key_usage_t expected_usage = expected_usage_arg;
     psa_algorithm_t expected_alg = expected_alg_arg;
@@ -573,14 +574,14 @@
         mbedtls_svc_key_id_make( 1, source_id_arg );
     psa_key_usage_t source_usage = source_usage_arg;
     psa_algorithm_t source_alg = source_alg_arg;
-    psa_key_handle_t source_handle = 0;
+    psa_key_handle_t source_handle = PSA_KEY_HANDLE_INIT;
     psa_key_type_t source_type = source_type_arg;
     psa_key_lifetime_t target_lifetime = target_lifetime_arg;
     mbedtls_svc_key_id_t target_id =
         mbedtls_svc_key_id_make( 1, target_id_arg );
     psa_key_usage_t target_usage = target_usage_arg;
     psa_algorithm_t target_alg = target_alg_arg;
-    psa_key_handle_t target_handle = 0;
+    psa_key_handle_t target_handle = PSA_KEY_HANDLE_INIT;
     psa_key_type_t target_type = target_type_arg;
     psa_key_handle_t new_handle = 0xdead;
     uint8_t *export_buffer = NULL;
@@ -674,8 +675,8 @@
 void invalid_handle( int handle_construction,
                      int close_status_arg, int usage_status_arg )
 {
-    psa_key_handle_t valid_handle = 0;
-    psa_key_handle_t invalid_handle = 0;
+    psa_key_handle_t valid_handle = PSA_KEY_HANDLE_INIT;
+    psa_key_handle_t invalid_handle = PSA_KEY_HANDLE_INIT;
     psa_status_t close_status = close_status_arg;
     psa_status_t usage_status = usage_status_arg;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
@@ -696,7 +697,7 @@
     switch( handle_construction )
     {
         case INVALID_HANDLE_0:
-            invalid_handle = 0;
+            invalid_handle = PSA_KEY_HANDLE_INIT;
             break;
         case INVALID_HANDLE_UNOPENED:
             /* We can't easily construct a handle that's never been opened
diff --git a/tests/suites/test_suite_x509write.function b/tests/suites/test_suite_x509write.function
index 31d6000..1dd2642 100644
--- a/tests/suites/test_suite_x509write.function
+++ b/tests/suites/test_suite_x509write.function
@@ -161,7 +161,7 @@
                                  int cert_type )
 {
     mbedtls_pk_context key;
-    psa_key_handle_t slot = 0;
+    psa_key_handle_t slot = PSA_KEY_HANDLE_INIT;
     psa_algorithm_t md_alg_psa;
     mbedtls_x509write_csr req;
     unsigned char buf[4096];