1 /*
2  * Copyright (c) 2019-2022, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #ifndef __ATTEST_KEY_H__
9 #define __ATTEST_KEY_H__
10 
11 #include "attest.h"
12 #include "config_tfm.h"
13 #include "psa/initial_attestation.h"
14 #include "psa/crypto.h"
15 #include "q_useful_buf.h"
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 /**
22  * \brief Get the buffer of Instance ID data
23  *
24  * \param[out] id_buf  Address and length of Instance ID buffer
25  *
26  * \retval  PSA_ATTEST_ERR_SUCCESS            Instance ID was successfully
27  *                                            returned.
28  * \retval  PSA_ATTEST_ERR_CLAIM_UNAVAILABLE  Instance ID is unavailable
29  * \retval  PSA_ATTEST_ERR_GENERAL            Instance ID could not be returned.
30  */
31 enum psa_attest_err_t
32 attest_get_instance_id(struct q_useful_buf_c *id_buf);
33 
34 #if ATTEST_INCLUDE_COSE_KEY_ID
35 /**
36  * \brief Get the attestation key ID.
37  *        In asymmetric key algorithm based Initial Attestation, it is the hash
38  *        (SHA256) of the COSE_Key encoded attestation public key.
39  *        In symmetric key algorithm based Initial Attestation, the key ID raw
40  *        data is fetched from from device.
41  *
42  * \param[out] attest_key_id  Pointer and length of the key id.
43  *
44  * \retval  PSA_ATTEST_ERR_SUCCESS   Got key id successfully.
45  * \retval  PSA_ATTEST_ERR_GENERAL   Failed to get key id.
46 
47  */
48 enum psa_attest_err_t
49 attest_get_initial_attestation_key_id(struct q_useful_buf_c *attest_key_id);
50 #else /* ATTEST_INCLUDE_COSE_KEY_ID */
51 static inline enum psa_attest_err_t
attest_get_initial_attestation_key_id(struct q_useful_buf_c * attest_key_id)52 attest_get_initial_attestation_key_id(struct q_useful_buf_c *attest_key_id)
53 {
54     *attest_key_id = NULL_Q_USEFUL_BUF_C;
55     return PSA_ATTEST_ERR_SUCCESS;
56 }
57 #endif /* ATTEST_INCLUDE_COSE_KEY_ID */
58 
59 #ifdef __cplusplus
60 }
61 #endif
62 
63 #endif /* __ATTEST_KEY_H__ */
64