1 /*
2  * Copyright (c) 2017-2022, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #ifndef __TFM_PLAT_CRYPTO_KEYS_H__
9 #define __TFM_PLAT_CRYPTO_KEYS_H__
10 /**
11  * \note The interfaces defined in this file must be implemented for each
12  *       SoC.
13  */
14 
15 #define MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER
16 
17 #include "tfm_mbedcrypto_include.h"
18 
19 #include "tfm_plat_defs.h"
20 
21 #include <stddef.h>
22 #include <stdint.h>
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 /**
29  * \brief Gets key usage for a given builtin key ID and owner.
30  *
31  * \param[in]  key_id        ID of key
32  * \param[in]  user          Which user to get the usage permissions for
33  * \param[out] usage         The permissions that the given user has for the key
34  *
35  * \return Returns error code specified in \ref tfm_plat_err_t
36  */
37 enum tfm_plat_err_t tfm_plat_builtin_key_get_usage(psa_key_id_t key_id,
38                                                    mbedtls_key_owner_id_t user,
39                                                    psa_key_usage_t *usage);
40 
41 /**
42  * \brief Gets key lifetime and slot number for a given builtin key ID.
43  *
44  * \param[in]  key_id        ID of key
45  * \param[out] lifetime      Lifetime and storage location of the key
46  * \param[out] slot_number   Index of the slot which the key is stored in
47  *
48  * \return Returns error code specified in \ref tfm_plat_err_t
49  */
50 enum tfm_plat_err_t tfm_plat_builtin_key_get_lifetime_and_slot(
51     mbedtls_svc_key_id_t key_id,
52     psa_key_lifetime_t *lifetime,
53     psa_drv_slot_number_t *slot_number);
54 
55 /**
56  * \brief Load all builtin keys.
57  *
58  * \return Returns error code specified in \ref tfm_plat_err_t
59  */
60 enum tfm_plat_err_t tfm_plat_load_builtin_keys(void);
61 
62 #ifdef __cplusplus
63 }
64 #endif
65 
66 #endif /* __TFM_PLAT_CRYPTO_KEYS_H__ */
67