From ea0500936eafd2db80c990c6fa770218a3f2c4fc Mon Sep 17 00:00:00 2001 From: mohammad1603 Date: Tue, 17 Apr 2018 00:31:34 -0700 Subject: [PATCH] Change behavior of psa_get_key_lifetime() psa_get_key_lifetime() behavior changed regarding empty slots, now it return the lifetime of and empty slots. Documentation in header file updated accordingly. --- include/psa/crypto.h | 12 ++---------- library/psa_crypto.c | 3 --- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/include/psa/crypto.h b/include/psa/crypto.h index ac763f973..07c1da1f9 100644 --- a/include/psa/crypto.h +++ b/include/psa/crypto.h @@ -103,10 +103,6 @@ typedef enum { * Applications may call this function more than once. Once a call * succeeds, subsequent calls are guaranteed to succeed. * - * \note Initial lifetime value for each key slot is initiated - * to PSA_KEY_LIFETIME_VOLATILE, user should change this value - * before calling psa_import_key() if needed. - * * \retval PSA_SUCCESS * \retval PSA_ERROR_INSUFFICIENT_MEMORY * \retval PSA_ERROR_COMMUNICATION_FAILURE @@ -609,9 +605,7 @@ typedef uint32_t psa_key_lifetime_t; * Success. * \retval PSA_ERROR_INVALID_ARGUMENT * The key slot is invalid, - * or the key data is not correctly formatted. - * \retval PSA_ERROR_EMPTY_SLOT - * The key slot is not occupied. + * or the key data is not correctly formatted. */ psa_status_t psa_get_key_lifetime(psa_key_slot_t key, psa_key_lifetime_t *lifetime); @@ -630,11 +624,9 @@ psa_status_t psa_get_key_lifetime(psa_key_slot_t key, * \retval PSA_ERROR_INVALID_ARGUMENT * The key slot is invalid, * or the key data is not correctly formatted. - * \retval PSA_ERROR_EMPTY_SLOT - * The key slot is not occupied. */ psa_status_t psa_set_key_lifetime(psa_key_slot_t key, - const psa_key_lifetime_t lifetime); + psa_key_lifetime_t lifetime); /**@}*/ diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 152fb17bf..fef053919 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -1274,9 +1274,6 @@ psa_status_t psa_get_key_lifetime(psa_key_slot_t key, return( PSA_ERROR_INVALID_ARGUMENT ); slot = &global_data.key_slots[key]; - - if( slot->type == PSA_KEY_TYPE_NONE ) - return( PSA_ERROR_EMPTY_SLOT ); *lifetime = slot->lifetime;