psa stats: Count locked slots instead of unlocked ones

Count locked slots and not unlocked ones to
align with the other statistics counters.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
Ronald Cron 2020-11-15 14:21:04 +01:00
parent 5c522920ba
commit 1ad1eeeaf1
3 changed files with 5 additions and 5 deletions

View file

@ -231,8 +231,8 @@ typedef struct mbedtls_psa_stats_s
size_t cache_slots; size_t cache_slots;
/** Number of slots that are not used for anything. */ /** Number of slots that are not used for anything. */
size_t empty_slots; size_t empty_slots;
/** Number of slots that are not locked. */ /** Number of slots that are locked. */
size_t unlocked_slots; size_t locked_slots;
/** Largest key id value among open keys in internal persistent storage. */ /** Largest key id value among open keys in internal persistent storage. */
psa_key_id_t max_open_internal_key_id; psa_key_id_t max_open_internal_key_id;
/** Largest key id value among open keys in secure elements. */ /** Largest key id value among open keys in secure elements. */

View file

@ -438,9 +438,9 @@ void mbedtls_psa_get_stats( mbedtls_psa_stats_t *stats )
for( slot_idx = 0; slot_idx < PSA_KEY_SLOT_COUNT; slot_idx++ ) for( slot_idx = 0; slot_idx < PSA_KEY_SLOT_COUNT; slot_idx++ )
{ {
const psa_key_slot_t *slot = &global_data.key_slots[ slot_idx ]; const psa_key_slot_t *slot = &global_data.key_slots[ slot_idx ];
if( ! psa_is_key_slot_locked( slot ) ) if( psa_is_key_slot_locked( slot ) )
{ {
++stats->unlocked_slots; ++stats->locked_slots;
} }
if( ! psa_is_key_slot_occupied( slot ) ) if( ! psa_is_key_slot_occupied( slot ) )
{ {

View file

@ -41,7 +41,7 @@ static int test_helper_is_psa_pristine( int line, const char *file )
msg = "An external slot has not been closed properly."; msg = "An external slot has not been closed properly.";
else if( stats.half_filled_slots != 0 ) else if( stats.half_filled_slots != 0 )
msg = "A half-filled slot has not been cleared properly."; msg = "A half-filled slot has not been cleared properly.";
else if( stats.unlocked_slots != PSA_KEY_SLOT_COUNT ) else if( stats.locked_slots != 0 )
{ {
msg = "Some slots are still marked as locked."; msg = "Some slots are still marked as locked.";
} }