Tamas Ban | 48a0eb5 | 2018-08-17 12:48:05 +0100 | [diff] [blame] | 1 | /* |
Tamas Ban | 2318feb | 2019-01-02 16:50:51 +0000 | [diff] [blame] | 2 | * Copyright (c) 2018-2019, Arm Limited. All rights reserved. |
Tamas Ban | 48a0eb5 | 2018-08-17 12:48:05 +0100 | [diff] [blame] | 3 | * |
| 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 Ban | d2b2f09 | 2019-01-23 22:29:14 +0000 | [diff] [blame] | 12 | #include "tfm_client.h" |
Tamas Ban | a24ce04 | 2019-02-20 11:50:22 +0000 | [diff] [blame] | 13 | #include "bl2/include/tfm_boot_status.h" |
Tamas Ban | 48a0eb5 | 2018-08-17 12:48:05 +0100 | [diff] [blame] | 14 | |
| 15 | #ifdef __cplusplus |
| 16 | extern "C" { |
| 17 | #endif |
| 18 | |
Tamas Ban | 48a0eb5 | 2018-08-17 12:48:05 +0100 | [diff] [blame] | 19 | /*! |
Tamas Ban | d2b2f09 | 2019-01-23 22:29:14 +0000 | [diff] [blame] | 20 | * \brief Type of memory access |
| 21 | */ |
| 22 | enum 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 | */ |
| 37 | enum psa_attest_err_t |
Tamas Ban | a24ce04 | 2019-02-20 11:50:22 +0000 | [diff] [blame] | 38 | attest_get_boot_data(uint8_t major_type, |
| 39 | struct tfm_boot_data *boot_data, |
| 40 | uint32_t len); |
Tamas Ban | d2b2f09 | 2019-01-23 22:29:14 +0000 | [diff] [blame] | 41 | |
| 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 | */ |
| 49 | enum psa_attest_err_t |
| 50 | attest_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 | */ |
| 62 | enum psa_attest_err_t |
| 63 | attest_check_memory_access(void *addr, |
| 64 | uint32_t size, |
| 65 | enum attest_memory_access_t access); |
| 66 | |
| 67 | /*! |
Tamas Ban | 48a0eb5 | 2018-08-17 12:48:05 +0100 | [diff] [blame] | 68 | * \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 | */ |
| 74 | enum 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 Szing | 40a7af0 | 2019-02-06 14:19:47 +0100 | [diff] [blame] | 82 | * \param[in,out] out_vec Pointer out_vec array, which contains output data |
Tamas Ban | 48a0eb5 | 2018-08-17 12:48:05 +0100 | [diff] [blame] | 83 | * 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 | */ |
| 88 | enum psa_attest_err_t |
| 89 | initial_attest_get_token(const psa_invec *in_vec, uint32_t num_invec, |
| 90 | psa_outvec *out_vec, uint32_t num_outvec); |
| 91 | |
Tamas Ban | b6b8056 | 2019-01-04 22:49:24 +0000 | [diff] [blame] | 92 | /** |
| 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 | */ |
| 104 | enum psa_attest_err_t |
| 105 | initial_attest_get_token_size(const psa_invec *in_vec, uint32_t num_invec, |
| 106 | psa_outvec *out_vec, uint32_t num_outvec); |
Tamas Ban | 48a0eb5 | 2018-08-17 12:48:05 +0100 | [diff] [blame] | 107 | #ifdef __cplusplus |
| 108 | } |
| 109 | #endif |
| 110 | |
| 111 | #endif /* __ATTESTATION_H__ */ |