Lines Matching refs:slice_idx
129 static psa_key_id_t volatile_key_id_of_index(size_t slice_idx, in volatile_key_id_of_index() argument
136 (slice_idx << KEY_ID_SLOT_INDEX_WIDTH) | in volatile_key_id_of_index()
221 static inline size_t key_slice_length(size_t slice_idx);
251 static inline psa_key_slot_t *get_key_slot(size_t slice_idx, size_t slot_idx);
256 size_t (*mbedtls_test_hook_psa_volatile_key_slice_length)(size_t slice_idx) = NULL;
259 static inline size_t key_slice_length(size_t slice_idx) in key_slice_length() argument
261 if (slice_idx == KEY_SLOT_CACHE_SLICE_INDEX) { in key_slice_length()
266 return mbedtls_test_hook_psa_volatile_key_slice_length(slice_idx); in key_slice_length()
269 return KEY_SLOT_VOLATILE_SLICE_BASE_LENGTH << slice_idx; in key_slice_length()
275 size_t slice_idx = slice_index_of_volatile_key_id(key_id); in get_volatile_key_slot() local
276 if (slice_idx >= KEY_SLOT_VOLATILE_SLICE_COUNT) { in get_volatile_key_slot()
280 if (slot_idx >= key_slice_length(slice_idx)) { in get_volatile_key_slot()
283 psa_key_slot_t *slice = global_data.key_slices[slice_idx]; in get_volatile_key_slot()
295 static inline psa_key_slot_t *get_key_slot(size_t slice_idx, size_t slot_idx) in get_key_slot() argument
297 return &global_data.key_slices[slice_idx][slot_idx]; in get_key_slot()
302 static inline size_t key_slice_length(size_t slice_idx) in key_slice_length() argument
304 (void) slice_idx; in key_slice_length()
321 static inline psa_key_slot_t *get_key_slot(size_t slice_idx, size_t slot_idx) in get_key_slot() argument
323 (void) slice_idx; in get_key_slot()
453 for (size_t slice_idx = 0; slice_idx < KEY_SLICE_COUNT; slice_idx++) { in psa_wipe_all_key_slots() local
455 if (global_data.key_slices[slice_idx] == NULL) { in psa_wipe_all_key_slots()
459 for (size_t slot_idx = 0; slot_idx < key_slice_length(slice_idx); slot_idx++) { in psa_wipe_all_key_slots()
460 psa_key_slot_t *slot = get_key_slot(slice_idx, slot_idx); in psa_wipe_all_key_slots()
484 mbedtls_free(global_data.key_slices[slice_idx]); in psa_wipe_all_key_slots()
485 global_data.key_slices[slice_idx] = NULL; in psa_wipe_all_key_slots()
490 for (size_t slice_idx = 0; slice_idx < KEY_SLOT_VOLATILE_SLICE_COUNT; slice_idx++) { in psa_wipe_all_key_slots() local
491 global_data.first_free_slot_index[slice_idx] = 0; in psa_wipe_all_key_slots()
504 size_t slice_idx; in psa_allocate_volatile_key_slot() local
505 for (slice_idx = 0; slice_idx < KEY_SLOT_VOLATILE_SLICE_COUNT; slice_idx++) { in psa_allocate_volatile_key_slot()
506 if (global_data.first_free_slot_index[slice_idx] != FREE_SLOT_INDEX_NONE) { in psa_allocate_volatile_key_slot()
510 if (slice_idx == KEY_SLOT_VOLATILE_SLICE_COUNT) { in psa_allocate_volatile_key_slot()
514 if (global_data.key_slices[slice_idx] == NULL) { in psa_allocate_volatile_key_slot()
515 global_data.key_slices[slice_idx] = in psa_allocate_volatile_key_slot()
516 mbedtls_calloc(key_slice_length(slice_idx), in psa_allocate_volatile_key_slot()
518 if (global_data.key_slices[slice_idx] == NULL) { in psa_allocate_volatile_key_slot()
522 psa_key_slot_t *slice = global_data.key_slices[slice_idx]; in psa_allocate_volatile_key_slot()
524 size_t slot_idx = global_data.first_free_slot_index[slice_idx]; in psa_allocate_volatile_key_slot()
525 *key_id = volatile_key_id_of_index(slice_idx, slot_idx); in psa_allocate_volatile_key_slot()
529 if (next_free >= key_slice_length(slice_idx)) { in psa_allocate_volatile_key_slot()
532 global_data.first_free_slot_index[slice_idx] = next_free; in psa_allocate_volatile_key_slot()
551 slot->slice_index = (uint8_t) slice_idx; in psa_allocate_volatile_key_slot()
555 psa_status_t psa_free_key_slot(size_t slice_idx, in psa_free_key_slot() argument
559 if (slice_idx == KEY_SLOT_CACHE_SLICE_INDEX) { in psa_free_key_slot()
564 if (slice_idx >= KEY_SLOT_VOLATILE_SLICE_COUNT) { in psa_free_key_slot()
568 psa_key_slot_t *slice = global_data.key_slices[slice_idx]; in psa_free_key_slot()
569 psa_key_slot_t *slice_end = slice + key_slice_length(slice_idx); in psa_free_key_slot()
581 size_t next_free = global_data.first_free_slot_index[slice_idx]; in psa_free_key_slot()
582 if (next_free >= key_slice_length(slice_idx)) { in psa_free_key_slot()
585 next_free = key_slice_length(slice_idx); in psa_free_key_slot()
587 global_data.first_free_slot_index[slice_idx] = slot_idx; in psa_free_key_slot()
1095 for (size_t slice_idx = 0; slice_idx < KEY_SLICE_COUNT; slice_idx++) { in mbedtls_psa_get_stats() local
1097 if (global_data.key_slices[slice_idx] == NULL) { in mbedtls_psa_get_stats()
1101 for (size_t slot_idx = 0; slot_idx < key_slice_length(slice_idx); slot_idx++) { in mbedtls_psa_get_stats()
1102 const psa_key_slot_t *slot = get_key_slot(slice_idx, slot_idx); in mbedtls_psa_get_stats()