blob: f73ed0f912065a0f25e51546c4ecc50991f3dc99 [file] [log] [blame]
Tamas Ban48a0eb52018-08-17 12:48:05 +01001/*
Tamas Ban2318feb2019-01-02 16:50:51 +00002 * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
Tamas Ban48a0eb52018-08-17 12:48:05 +01003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8#ifndef __ATTESTATION_H__
9#define __ATTESTATION_H__
10
11#include "psa_initial_attestation_api.h"
Tamas Band2b2f092019-01-23 22:29:14 +000012#include "tfm_client.h"
Tamas Bana24ce042019-02-20 11:50:22 +000013#include "bl2/include/tfm_boot_status.h"
Tamas Ban48a0eb52018-08-17 12:48:05 +010014
15#ifdef __cplusplus
16extern "C" {
17#endif
18
Tamas Ban48a0eb52018-08-17 12:48:05 +010019/*!
Tamas Band2b2f092019-01-23 22:29:14 +000020 * \brief Type of memory access
21 */
22enum attest_memory_access_t {
23 TFM_ATTEST_ACCESS_RO = 1,
24 TFM_ATTEST_ACCESS_RW = 2,
25};
26
27/*!
28 * \brief Copy the boot data (coming from boot loader) from shared memory area
29 * to service memory area
30 *
31 * \param[in] major_type Major type of TLV entries to copy
32 * \param[out] ptr Pointer to the buffer to store the boot data
33 * \parma[in] len Size of the buffer to store the boot data
34 *
35 * \return Returns error code as specified in \ref psa_attest_err_t
36 */
37enum psa_attest_err_t
Tamas Bana24ce042019-02-20 11:50:22 +000038attest_get_boot_data(uint8_t major_type,
39 struct tfm_boot_data *boot_data,
40 uint32_t len);
Tamas Band2b2f092019-01-23 22:29:14 +000041
42/*!
43 * \brief Get the ID of the caller thread.
44 *
45 * \param[out] caller_id Pointer where to store caller ID
46 *
47 * \return Returns error code as specified in \ref psa_attest_err_t
48 */
49enum psa_attest_err_t
50attest_get_caller_client_id(int32_t *caller_id);
51
52/*!
53 * \brief Verify memory access rights
54 *
55 * \param[in] addr Pointer to the base of the address range to check
56 * \param[in] size Size of the address range to check
57 * \param[in] access Type of memory access as specified in
58 * \ref attest_memory_access
59 *
60 * \return Returns error code as specified in \ref psa_attest_err_t
61 */
62enum psa_attest_err_t
63attest_check_memory_access(void *addr,
64 uint32_t size,
65 enum attest_memory_access_t access);
66
67/*!
Tamas Ban48a0eb52018-08-17 12:48:05 +010068 * \brief Initialise the initial attestation service during the TF-M boot up
69 * process.
70 *
71 * \return Returns PSA_ATTEST_ERR_SUCCESS if init has been completed,
72 * otherwise error as specified in \ref psa_attest_err_t
73 */
74enum psa_attest_err_t attest_init(void);
75
76/*!
77 * \brief Get initial attestation token
78 *
79 * \param[in] in_vec Pointer to in_vec array, which contains input data
80 * to attestation service
81 * \param[in] num_invec Number of elements in in_vec array
Gyorgy Szing40a7af02019-02-06 14:19:47 +010082 * \param[in,out] out_vec Pointer out_vec array, which contains output data
Tamas Ban48a0eb52018-08-17 12:48:05 +010083 * to attestation service
84 * \param[in] num_outvec Number of elements in out_vec array
85 *
86 * \return Returns error code as specified in \ref psa_attest_err_t
87 */
88enum psa_attest_err_t
89initial_attest_get_token(const psa_invec *in_vec, uint32_t num_invec,
90 psa_outvec *out_vec, uint32_t num_outvec);
91
Tamas Banb6b80562019-01-04 22:49:24 +000092/**
93 * \brief Get the size of the initial attestation token
94 *
95 * \param[in] in_vec Pointer to in_vec array, which contains input data
96 * to attestation service
97 * \param[in] num_invec Number of elements in in_vec array
98 * \param[out] out_vec Pointer to out_vec array, which contains pointer
99 * where to store the output data
100 * \param[in] num_outvec Number of elements in out_vec array
101 *
102 * \return Returns error code as specified in \ref psa_attest_err_t
103 */
104enum psa_attest_err_t
105initial_attest_get_token_size(const psa_invec *in_vec, uint32_t num_invec,
106 psa_outvec *out_vec, uint32_t num_outvec);
Tamas Ban48a0eb52018-08-17 12:48:05 +0100107#ifdef __cplusplus
108}
109#endif
110
111#endif /* __ATTESTATION_H__ */