Introduce PSA_KEY_HANDLE_INIT macro
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
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 */