Lines Matching refs:slot

710 psa_status_t psa_allocate_buffer_to_slot(psa_key_slot_t *slot,  in psa_allocate_buffer_to_slot()  argument
718 if (slot->key.data != NULL) { in psa_allocate_buffer_to_slot()
722 slot->key.data = mbedtls_calloc(1, buffer_length); in psa_allocate_buffer_to_slot()
723 if (slot->key.data == NULL) { in psa_allocate_buffer_to_slot()
728 slot->key.bytes = buffer_length; in psa_allocate_buffer_to_slot()
732 psa_status_t psa_copy_key_material_into_slot(psa_key_slot_t *slot, in psa_copy_key_material_into_slot() argument
736 psa_status_t status = psa_allocate_buffer_to_slot(slot, in psa_copy_key_material_into_slot()
742 memcpy(slot->key.data, data, data_length); in psa_copy_key_material_into_slot()
1109 psa_key_slot_t *slot = NULL; in psa_get_and_lock_key_slot_with_policy() local
1115 slot = *p_slot; in psa_get_and_lock_key_slot_with_policy()
1121 if (PSA_KEY_TYPE_IS_PUBLIC_KEY(slot->attr.type)) { in psa_get_and_lock_key_slot_with_policy()
1125 if ((slot->attr.policy.usage & usage) != usage) { in psa_get_and_lock_key_slot_with_policy()
1132 status = psa_key_policy_permits(&slot->attr.policy, in psa_get_and_lock_key_slot_with_policy()
1133 slot->attr.type, in psa_get_and_lock_key_slot_with_policy()
1144 psa_unregister_read_under_mutex(slot); in psa_get_and_lock_key_slot_with_policy()
1193 psa_status_t psa_remove_key_data_from_memory(psa_key_slot_t *slot) in psa_remove_key_data_from_memory() argument
1196 if (slot->key.bytes > 0) { in psa_remove_key_data_from_memory()
1197 mbedtls_platform_zeroize(slot->key.data, MBEDTLS_PSA_STATIC_KEY_SLOT_BUFFER_SIZE); in psa_remove_key_data_from_memory()
1200 if (slot->key.data != NULL) { in psa_remove_key_data_from_memory()
1201 mbedtls_zeroize_and_free(slot->key.data, slot->key.bytes); in psa_remove_key_data_from_memory()
1204 slot->key.data = NULL; in psa_remove_key_data_from_memory()
1207 slot->key.bytes = 0; in psa_remove_key_data_from_memory()
1214 psa_status_t psa_wipe_key_slot(psa_key_slot_t *slot) in psa_wipe_key_slot() argument
1216 psa_status_t status = psa_remove_key_data_from_memory(slot); in psa_wipe_key_slot()
1228 switch (slot->state) { in psa_wipe_key_slot()
1235 if (slot->var.occupied.registered_readers != 1) { in psa_wipe_key_slot()
1236 MBEDTLS_TEST_HOOK_TEST_ASSERT(slot->var.occupied.registered_readers == 1); in psa_wipe_key_slot()
1242 if (slot->var.occupied.registered_readers != 0) { in psa_wipe_key_slot()
1243 MBEDTLS_TEST_HOOK_TEST_ASSERT(slot->var.occupied.registered_readers == 0); in psa_wipe_key_slot()
1249 MBEDTLS_TEST_HOOK_TEST_ASSERT(slot->state != PSA_SLOT_EMPTY); in psa_wipe_key_slot()
1258 size_t slice_index = slot->slice_index; in psa_wipe_key_slot()
1271 memset(slot, 0, sizeof(*slot)); in psa_wipe_key_slot()
1279 status = psa_free_key_slot(slice_index, slot); in psa_wipe_key_slot()
1288 psa_key_slot_t *slot; in psa_destroy_key() local
1306 status = psa_get_and_lock_key_slot(key, &slot); in psa_destroy_key()
1319 if (slot->state == PSA_SLOT_PENDING_DELETION) { in psa_destroy_key()
1323 status = psa_unregister_read(slot); in psa_destroy_key()
1338 overall_status = psa_key_slot_state_transition(slot, PSA_SLOT_FULL, in psa_destroy_key()
1345 if (PSA_KEY_LIFETIME_IS_READ_ONLY(slot->attr.lifetime)) { in psa_destroy_key()
1356 driver = psa_get_se_driver_entry(slot->attr.lifetime); in psa_destroy_key()
1364 psa_crypto_transaction.key.lifetime = slot->attr.lifetime; in psa_destroy_key()
1365 psa_crypto_transaction.key.slot = psa_key_slot_get_slot_number(slot); in psa_destroy_key()
1366 psa_crypto_transaction.key.id = slot->attr.id; in psa_destroy_key()
1382 psa_key_slot_get_slot_number(slot)); in psa_destroy_key()
1390 if (!PSA_KEY_LIFETIME_IS_VOLATILE(slot->attr.lifetime)) { in psa_destroy_key()
1394 status = psa_destroy_persistent_key(slot->attr.id); in psa_destroy_key()
1417 status = psa_unregister_read(slot); in psa_destroy_key()
1440 psa_key_slot_t *slot; in psa_get_key_attributes() local
1444 status = psa_get_and_lock_key_slot_with_policy(key, &slot, 0, 0); in psa_get_key_attributes()
1449 *attributes = slot->attr; in psa_get_key_attributes()
1452 if (psa_get_se_driver_entry(slot->attr.lifetime) != NULL) { in psa_get_key_attributes()
1454 psa_key_slot_get_slot_number(slot)); in psa_get_key_attributes()
1458 return psa_unregister_read_under_mutex(slot); in psa_get_key_attributes()
1520 psa_key_slot_t *slot; in psa_export_key() local
1540 status = psa_get_and_lock_key_slot_with_policy(key, &slot, in psa_export_key()
1548 status = psa_driver_wrapper_export_key(&slot->attr, in psa_export_key()
1549 slot->key.data, slot->key.bytes, in psa_export_key()
1555 unlock_status = psa_unregister_read_under_mutex(slot); in psa_export_key()
1635 psa_key_slot_t *slot; in psa_export_public_key() local
1653 status = psa_get_and_lock_key_slot_with_policy(key, &slot, 0, 0); in psa_export_public_key()
1660 if (!PSA_KEY_TYPE_IS_ASYMMETRIC(slot->attr.type)) { in psa_export_public_key()
1666 &slot->attr, slot->key.data, slot->key.bytes, in psa_export_public_key()
1670 unlock_status = psa_unregister_read_under_mutex(slot); in psa_export_public_key()
1824 psa_key_slot_t *slot = *p_slot; local
1834 slot->attr = *attributes;
1837 slot->attr.id = volatile_key_id;
1839 slot->attr.id.key_id = volatile_key_id;
1871 psa_crypto_transaction.key.lifetime = slot->attr.lifetime;
1872 psa_crypto_transaction.key.slot = slot_number;
1873 psa_crypto_transaction.key.id = slot->attr.id;
1882 slot, (uint8_t *) (&slot_number), sizeof(slot_number));
1928 psa_key_slot_t *slot, argument
1933 (void) slot;
1942 if (!PSA_KEY_LIFETIME_IS_VOLATILE(slot->attr.lifetime)) {
1947 psa_key_slot_get_slot_number(slot);
1954 status = psa_save_persistent_key(&slot->attr,
1962 status = psa_save_persistent_key(&slot->attr,
1963 slot->key.data,
1964 slot->key.bytes);
1979 psa_destroy_persistent_key(slot->attr.id);
1992 *key = slot->attr.id;
1993 status = psa_key_slot_state_transition(slot, PSA_SLOT_FILLING,
2019 static void psa_fail_key_creation(psa_key_slot_t *slot, argument
2024 if (slot == NULL) {
2052 psa_wipe_key_slot(slot);
2069 const psa_key_slot_t *slot, argument
2073 if (attributes->type != slot->attr.type) {
2079 if (attributes->bits != slot->attr.bits) {
2094 psa_key_slot_t *slot = NULL; local
2116 &slot, &driver);
2125 if (slot->key.bytes == 0) {
2133 status = psa_allocate_buffer_to_slot(slot, storage_size);
2139 bits = slot->attr.bits;
2142 slot->key.data,
2143 slot->key.bytes,
2144 &slot->key.bytes, &bits);
2149 if (slot->attr.bits == 0) {
2150 slot->attr.bits = (psa_key_bits_t) bits;
2151 } else if (bits != slot->attr.bits) {
2162 status = psa_validate_optional_attributes(slot, attributes);
2167 status = psa_finish_key_creation(slot, driver, key);
2171 psa_fail_key_creation(slot, driver);
2182 psa_key_slot_t *slot = NULL; local
2206 &slot, &driver);
2211 status = psa_finish_key_creation(slot, driver, &key);
2215 psa_fail_key_creation(slot, driver);
2649 psa_key_slot_t *slot = NULL; local
2659 &slot,
2666 status = psa_mac_finalize_alg_and_key_validation(alg, &slot->attr,
2676 &slot->attr,
2677 slot->key.data,
2678 slot->key.bytes,
2682 &slot->attr,
2683 slot->key.data,
2684 slot->key.bytes,
2693 unlock_status = psa_unregister_read_under_mutex(slot);
2850 psa_key_slot_t *slot; local
2855 &slot,
2862 status = psa_mac_finalize_alg_and_key_validation(alg, &slot->attr,
2874 &slot->attr,
2875 slot->key.data, slot->key.bytes,
2894 unlock_status = psa_unregister_read_under_mutex(slot);
3004 psa_key_slot_t *slot; local
3022 key, &slot,
3031 if (!PSA_KEY_TYPE_IS_KEY_PAIR(slot->attr.type)) {
3038 &slot->attr, slot->key.data, slot->key.bytes,
3044 &slot->attr, slot->key.data, slot->key.bytes,
3054 unlock_status = psa_unregister_read_under_mutex(slot);
3069 psa_key_slot_t *slot; local
3077 key, &slot,
3088 &slot->attr, slot->key.data, slot->key.bytes,
3093 &slot->attr, slot->key.data, slot->key.bytes,
3098 unlock_status = psa_unregister_read_under_mutex(slot);
3381 psa_key_slot_t *slot; local
3400 key, &slot, PSA_KEY_USAGE_ENCRYPT, alg);
3404 if (!(PSA_KEY_TYPE_IS_PUBLIC_KEY(slot->attr.type) ||
3405 PSA_KEY_TYPE_IS_KEY_PAIR(slot->attr.type))) {
3415 &slot->attr, slot->key.data, slot->key.bytes,
3419 unlock_status = psa_unregister_read_under_mutex(slot);
3440 psa_key_slot_t *slot; local
3459 key, &slot, PSA_KEY_USAGE_DECRYPT, alg);
3463 if (!PSA_KEY_TYPE_IS_KEY_PAIR(slot->attr.type)) {
3473 &slot->attr, slot->key.data, slot->key.bytes,
3478 unlock_status = psa_unregister_read_under_mutex(slot);
3545 psa_key_slot_t *slot; local
3561 status = psa_get_and_lock_key_slot_with_policy(key, &slot,
3569 if (!PSA_KEY_TYPE_IS_KEY_PAIR(slot->attr.type)) {
3579 status = psa_driver_wrapper_sign_hash_start(operation, &slot->attr,
3580 slot->key.data,
3581 slot->key.bytes, alg,
3590 unlock_status = psa_unregister_read_under_mutex(slot);
3704 psa_key_slot_t *slot; local
3721 status = psa_get_and_lock_key_slot_with_policy(key, &slot,
3736 status = psa_driver_wrapper_verify_hash_start(operation, &slot->attr,
3737 slot->key.data,
3738 slot->key.bytes,
3750 unlock_status = psa_unregister_read_under_mutex(slot);
4313 psa_key_slot_t *slot = NULL; local
4329 status = psa_get_and_lock_key_slot_with_policy(key, &slot, usage, alg);
4344 operation->default_iv_length = PSA_CIPHER_IV_LENGTH(slot->attr.type, alg);
4349 &slot->attr,
4350 slot->key.data,
4351 slot->key.bytes,
4355 &slot->attr,
4356 slot->key.data,
4357 slot->key.bytes,
4366 unlock_status = psa_unregister_read_under_mutex(slot);
4593 psa_key_slot_t *slot = NULL; local
4605 status = psa_get_and_lock_key_slot_with_policy(key, &slot,
4612 default_iv_length = PSA_CIPHER_IV_LENGTH(slot->attr.type, alg);
4634 &slot->attr, slot->key.data, slot->key.bytes,
4640 unlock_status = psa_unregister_read_under_mutex(slot);
4670 psa_key_slot_t *slot = NULL; local
4680 status = psa_get_and_lock_key_slot_with_policy(key, &slot,
4687 if (input_length < PSA_CIPHER_IV_LENGTH(slot->attr.type, alg)) {
4696 &slot->attr, slot->key.data, slot->key.bytes,
4701 unlock_status = psa_unregister_read_under_mutex(slot);
4793 psa_key_slot_t *slot; local
4808 key, &slot, PSA_KEY_USAGE_ENCRYPT, alg);
4824 &slot->attr, slot->key.data, slot->key.bytes,
4841 psa_unregister_read_under_mutex(slot);
4859 psa_key_slot_t *slot; local
4874 key, &slot, PSA_KEY_USAGE_DECRYPT, alg);
4891 &slot->attr, slot->key.data, slot->key.bytes,
4908 psa_unregister_read_under_mutex(slot);
4960 psa_key_slot_t *slot = NULL; local
4985 status = psa_get_and_lock_key_slot_with_policy(key, &slot, key_usage,
4997 &slot->attr,
4998 slot->key.data,
4999 slot->key.bytes,
5003 &slot->attr,
5004 slot->key.data,
5005 slot->key.bytes,
5012 operation->key_type = psa_get_key_type(&slot->attr);
5015 unlock_status = psa_unregister_read_under_mutex(slot);
6204 psa_key_slot_t *slot, argument
6222 slot->attr.type);
6363 psa_key_slot_t *slot, size_t bits, argument
6366 (void) slot;
6385 psa_key_slot_t *slot, argument
6394 if (PSA_KEY_TYPE_IS_PUBLIC_KEY(slot->attr.type)) {
6400 if (PSA_KEY_TYPE_IS_ECC(slot->attr.type)) {
6401 psa_ecc_family_t curve = PSA_KEY_TYPE_ECC_GET_FAMILY(slot->attr.type);
6404 status = psa_generate_derived_ecc_key_weierstrass_helper(slot, bits, operation, &data);
6418 if (key_type_is_raw_bytes(slot->attr.type)) {
6432 if (slot->attr.type == PSA_KEY_TYPE_DES) {
6440 slot->attr.bits = (psa_key_bits_t) bits;
6442 if (psa_key_lifetime_is_external(slot->attr.lifetime)) {
6443 status = psa_driver_wrapper_get_key_buffer_size(&slot->attr,
6449 status = psa_allocate_buffer_to_slot(slot, storage_size);
6454 status = psa_driver_wrapper_import_key(&slot->attr,
6456 slot->key.data,
6457 slot->key.bytes,
6458 &slot->key.bytes, &bits);
6459 if (bits != slot->attr.bits) {
6493 psa_key_slot_t *slot = NULL; local
6518 &slot, &driver);
6526 status = psa_generate_derived_key_internal(slot,
6531 status = psa_finish_key_creation(slot, driver, key);
6534 psa_fail_key_creation(slot, driver);
7501 psa_key_slot_t *slot; local
7504 key, &slot, PSA_KEY_USAGE_DERIVE, operation->alg);
7518 step, slot->attr.type,
7519 slot->key.data,
7520 slot->key.bytes);
7522 unlock_status = psa_unregister_read_under_mutex(slot);
7652 psa_key_slot_t *slot; local
7659 private_key, &slot, PSA_KEY_USAGE_DERIVE, operation->alg);
7666 slot,
7682 unlock_status = psa_unregister_read_under_mutex(slot);
7698 psa_key_slot_t *slot = NULL; local
7709 private_key, &slot, PSA_KEY_USAGE_DERIVE, alg);
7723 PSA_RAW_KEY_AGREEMENT_OUTPUT_SIZE(slot->attr.type, slot->attr.bits);
7730 status = psa_key_agreement_raw_internal(alg, slot,
7755 unlock_status = psa_unregister_read_under_mutex(slot);
8004 psa_key_slot_t *slot = NULL; local
8033 &slot, &driver);
8042 if (slot->key.bytes == 0) {
8062 status = psa_allocate_buffer_to_slot(slot, key_buffer_size);
8071 slot->key.data, slot->key.bytes,
8072 &slot->key.bytes);
8074 psa_remove_key_data_from_memory(slot);
8079 status = psa_finish_key_creation(slot, driver, key);
8082 psa_fail_key_creation(slot, driver);
8543 psa_key_slot_t *slot = NULL; local
8551 status = psa_get_and_lock_key_slot_with_policy(password, &slot,
8558 type = psa_get_key_type(&slot->attr);
8566 operation->data.inputs.password = mbedtls_calloc(1, slot->key.bytes);
8572 memcpy(operation->data.inputs.password, slot->key.data, slot->key.bytes);
8573 operation->data.inputs.password_len = slot->key.bytes;
8574 operation->data.inputs.attributes = slot->attr;
8580 unlock_status = psa_unregister_read_under_mutex(slot);