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