Lines Matching refs:slot

75  * stored in key slots. This function returns a pointer to the key slot
83 * For volatile key identifiers, only one key slot is queried as a volatile
84 * key with identifier key_id can only be stored in slot of index
87 * On success, the function locks the key slot. It is the responsibility of
88 * the caller to unlock the key slot when it does not access it anymore.
91 * global key slot mutex.
95 * key slot containing the description of the key
99 * The pointer to the key slot containing the description of the key
112 psa_key_slot_t *slot = NULL;
115 slot = &global_data.key_slots[key_id - PSA_KEY_ID_VOLATILE_MIN];
118 * identifier of key match those of the key slot. */
119 if ((slot->state == PSA_SLOT_FULL) &&
120 (mbedtls_svc_key_id_equal(key, slot->attr.id))) {
131 slot = &global_data.key_slots[slot_idx];
133 if ((slot->state == PSA_SLOT_FULL) &&
134 (mbedtls_svc_key_id_equal(key, slot->attr.id))) {
143 status = psa_register_read(slot);
145 *p_slot = slot;
168 psa_key_slot_t *slot = &global_data.key_slots[slot_idx];
169 slot->registered_readers = 1;
170 slot->state = PSA_SLOT_PENDING_DELETION;
171 (void) psa_wipe_key_slot(slot);
191 psa_key_slot_t *slot = &global_data.key_slots[slot_idx];
192 if (slot->state == PSA_SLOT_EMPTY) {
193 selected_slot = slot;
198 (slot->state == PSA_SLOT_FULL) &&
199 (!psa_key_slot_has_readers(slot)) &&
200 (!PSA_KEY_LIFETIME_IS_VOLATILE(slot->attr.lifetime))) {
201 unused_persistent_key_slot = slot;
206 * If there is no unused key slot and there is at least one unlocked key
207 * slot containing the description of a persistent key, recycle the first
208 * such key slot we encountered. If we later need to operate on the
245 static psa_status_t psa_load_persistent_key_into_slot(psa_key_slot_t *slot)
251 status = psa_load_persistent_key(&slot->attr,
262 if (psa_get_se_driver(slot->attr.lifetime, &drv, &drv_context)) {
271 slot, data->slot_number, sizeof(data->slot_number));
276 status = psa_copy_key_material_into_slot(slot, key_data, key_data_length);
289 static psa_status_t psa_load_builtin_key_into_slot(psa_key_slot_t *slot)
299 MBEDTLS_SVC_KEY_ID_GET_KEY_ID(slot->attr.id))) {
305 slot->attr.id, &lifetime, &slot_number);
312 psa_set_key_id(&attributes, slot->attr.id);
337 * into the (now properly sized) slot buffer. */
338 status = psa_allocate_buffer_to_slot(slot, key_buffer_size);
345 slot->key.data, slot->key.bytes, &key_buffer_length);
350 /* Copy actual key length and core attributes into the slot on success */
351 slot->key.bytes = key_buffer_length;
352 slot->attr = attributes;
355 psa_remove_key_data_from_memory(slot);
376 * between checking if the key is loaded and setting the slot as FULL,
383 * On success, the pointer to the slot is passed directly to the caller
384 * thus no need to unlock the key slot here.
450 psa_status_t psa_unregister_read(psa_key_slot_t *slot)
452 if (slot == NULL) {
455 if ((slot->state != PSA_SLOT_FULL) &&
456 (slot->state != PSA_SLOT_PENDING_DELETION)) {
460 /* If we are the last reader and the slot is marked for deletion,
461 * we must wipe the slot here. */
462 if ((slot->state == PSA_SLOT_PENDING_DELETION) &&
463 (slot->registered_readers == 1)) {
464 return psa_wipe_key_slot(slot);
467 if (psa_key_slot_has_readers(slot)) {
468 slot->registered_readers--;
480 MBEDTLS_TEST_HOOK_TEST_ASSERT(psa_key_slot_has_readers(slot));
484 psa_status_t psa_unregister_read_under_mutex(psa_key_slot_t *slot)
494 status = psa_unregister_read(slot);
551 psa_key_slot_t *slot;
553 status = psa_get_and_lock_key_slot(key, &slot);
565 return psa_unregister_read_under_mutex(slot);
577 psa_key_slot_t *slot;
590 status = psa_get_and_lock_key_slot_in_memory(handle, &slot);
602 if (slot->registered_readers == 1) {
603 status = psa_wipe_key_slot(slot);
605 status = psa_unregister_read(slot);
618 psa_key_slot_t *slot;
627 status = psa_get_and_lock_key_slot_in_memory(key, &slot);
636 if ((!PSA_KEY_LIFETIME_IS_VOLATILE(slot->attr.lifetime)) &&
637 (slot->registered_readers == 1)) {
638 status = psa_wipe_key_slot(slot);
640 status = psa_unregister_read(slot);
657 const psa_key_slot_t *slot = &global_data.key_slots[slot_idx];
658 if (psa_key_slot_has_readers(slot)) {
661 if (slot->state == PSA_SLOT_EMPTY) {
665 if (PSA_KEY_LIFETIME_IS_VOLATILE(slot->attr.lifetime)) {
668 psa_key_id_t id = MBEDTLS_SVC_KEY_ID_GET_KEY_ID(slot->attr.id);
674 if (PSA_KEY_LIFETIME_GET_LOCATION(slot->attr.lifetime) !=
676 psa_key_id_t id = MBEDTLS_SVC_KEY_ID_GET_KEY_ID(slot->attr.id);