Balint Dobszay | dc945e9 | 2024-01-15 16:07:21 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include "crypto_partition.h" |
| 8 | |
| 9 | key_id_namespace_t crypto_partition_get_namespace(uint32_t client_id) |
| 10 | { |
| 11 | /* |
| 12 | * Current just use the client_id as the namespace so keys are strictly |
| 13 | * partitioned by client id. |
| 14 | */ |
| 15 | return (key_id_namespace_t)client_id; |
| 16 | } |
| 17 | |
| 18 | namespaced_key_id_t crypto_partition_get_namespaced_key_id(uint32_t client_id, psa_key_id_t key_id) |
| 19 | { |
| 20 | namespaced_key_id_t ns_id = NAMESPACED_KEY_ID_INIT; |
| 21 | |
| 22 | namespaced_key_id_init(&ns_id, crypto_partition_get_namespace(client_id), key_id); |
| 23 | |
| 24 | return ns_id; |
| 25 | } |
| 26 | |
| 27 | void crypto_partition_bind_to_owner(psa_key_attributes_t *attributes, uint32_t client_id) |
| 28 | { |
| 29 | key_id_namespace_t ns = crypto_partition_get_namespace(client_id); |
| 30 | |
| 31 | namespaced_key_id_set_namespace(attributes, ns); |
| 32 | } |