1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-08-05 19:35:48 +03:00

Implement psa_key_slot_has_readers and remove psa_is_key_slot_occupied

Remove psa_is_key_slot_occupied, any function which calls this can just check
the state variable instead.
Replace psa_is_key_slot_locked with psa_key_slot_has_readers.
References to the now removed functions are changed in future commits.

Signed-off-by: Ryan Everett <ryan.everett@arm.com>
This commit is contained in:
Ryan Everett
2024-01-02 16:21:03 +00:00
parent aa33c512cc
commit 62aa79ac5c

View File

@@ -106,31 +106,15 @@ typedef struct {
#define PSA_KA_MASK_INTERNAL_ONLY ( \ #define PSA_KA_MASK_INTERNAL_ONLY ( \
0) 0)
/** Test whether a key slot is occupied. /** Test whether a key slot has any registered readers.
*
* A key slot is occupied iff the key type is nonzero. This works because
* no valid key can have 0 as its key type.
* *
* \param[in] slot The key slot to test. * \param[in] slot The key slot to test.
* *
* \return 1 if the slot is occupied, 0 otherwise. * \return 1 if the slot has any registered readers, 0 otherwise.
*/ */
static inline int psa_is_key_slot_occupied(const psa_key_slot_t *slot) static inline int psa_key_slot_has_readers(const psa_key_slot_t *slot)
{ {
return slot->status == PSA_SLOT_OCCUPIED; return slot->registered_readers > 0;
}
/** Test whether a key slot is locked.
*
* A key slot is locked iff its lock counter is strictly greater than 0.
*
* \param[in] slot The key slot to test.
*
* \return 1 if the slot is locked, 0 otherwise.
*/
static inline int psa_is_key_slot_locked(const psa_key_slot_t *slot)
{
return slot->lock_count > 0;
} }
/** Retrieve flags from psa_key_slot_t::attr::core::flags. /** Retrieve flags from psa_key_slot_t::attr::core::flags.