From 1841cf43ee438e31512bdf5bc43c673c9a26e015 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 8 Oct 2019 15:48:25 +0200 Subject: [PATCH] Make psa_close_key(0) and psa_destroy_key(0) succeed --- library/psa_crypto.c | 3 +++ library/psa_crypto_slot_management.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index b9ea00f2c..e8ab01f63 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -1013,6 +1013,9 @@ psa_status_t psa_destroy_key( psa_key_handle_t handle ) psa_se_drv_table_entry_t *driver; #endif /* MBEDTLS_PSA_CRYPTO_SE_C */ + if( handle == 0 ) + return( PSA_SUCCESS ); + status = psa_get_key_slot( handle, &slot ); if( status != PSA_SUCCESS ) return( status ); diff --git a/library/psa_crypto_slot_management.c b/library/psa_crypto_slot_management.c index 59be319ce..6cd6a1135 100644 --- a/library/psa_crypto_slot_management.c +++ b/library/psa_crypto_slot_management.c @@ -255,6 +255,9 @@ psa_status_t psa_close_key( psa_key_handle_t handle ) psa_status_t status; psa_key_slot_t *slot; + if( handle == 0 ) + return( PSA_SUCCESS ); + status = psa_get_key_slot( handle, &slot ); if( status != PSA_SUCCESS ) return( status );