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 | 48a0eb5 | 2018-08-17 12:48:05 +0100 | [diff] [blame] | 13 | |
| 14 | #ifdef __cplusplus |
| 15 | extern "C" { |
| 16 | #endif |
| 17 | |
Tamas Ban | 48a0eb5 | 2018-08-17 12:48:05 +0100 | [diff] [blame] | 18 | /*! |
Tamas Ban | d2b2f09 | 2019-01-23 22:29:14 +0000 | [diff] [blame] | 19 | * \brief Type of memory access |
| 20 | */ |
| 21 | enum attest_memory_access_t { |
| 22 | TFM_ATTEST_ACCESS_RO = 1, |
| 23 | TFM_ATTEST_ACCESS_RW = 2, |
| 24 | }; |
| 25 | |
| 26 | /*! |
| 27 | * \brief Copy the boot data (coming from boot loader) from shared memory area |
| 28 | * to service memory area |
| 29 | * |
| 30 | * \param[in] major_type Major type of TLV entries to copy |
| 31 | * \param[out] ptr Pointer to the buffer to store the boot data |
| 32 | * \parma[in] len Size of the buffer to store the boot data |
| 33 | * |
| 34 | * \return Returns error code as specified in \ref psa_attest_err_t |
| 35 | */ |
| 36 | enum psa_attest_err_t |
| 37 | attest_get_boot_data(uint8_t major_type, void *ptr, uint32_t len); |
| 38 | |
| 39 | /*! |
| 40 | * \brief Get the ID of the caller thread. |
| 41 | * |
| 42 | * \param[out] caller_id Pointer where to store caller ID |
| 43 | * |
| 44 | * \return Returns error code as specified in \ref psa_attest_err_t |
| 45 | */ |
| 46 | enum psa_attest_err_t |
| 47 | attest_get_caller_client_id(int32_t *caller_id); |
| 48 | |
| 49 | /*! |
| 50 | * \brief Verify memory access rights |
| 51 | * |
| 52 | * \param[in] addr Pointer to the base of the address range to check |
| 53 | * \param[in] size Size of the address range to check |
| 54 | * \param[in] access Type of memory access as specified in |
| 55 | * \ref attest_memory_access |
| 56 | * |
| 57 | * \return Returns error code as specified in \ref psa_attest_err_t |
| 58 | */ |
| 59 | enum psa_attest_err_t |
| 60 | attest_check_memory_access(void *addr, |
| 61 | uint32_t size, |
| 62 | enum attest_memory_access_t access); |
| 63 | |
| 64 | /*! |
Tamas Ban | 48a0eb5 | 2018-08-17 12:48:05 +0100 | [diff] [blame] | 65 | * \brief Initialise the initial attestation service during the TF-M boot up |
| 66 | * process. |
| 67 | * |
| 68 | * \return Returns PSA_ATTEST_ERR_SUCCESS if init has been completed, |
| 69 | * otherwise error as specified in \ref psa_attest_err_t |
| 70 | */ |
| 71 | enum psa_attest_err_t attest_init(void); |
| 72 | |
| 73 | /*! |
| 74 | * \brief Get initial attestation token |
| 75 | * |
| 76 | * \param[in] in_vec Pointer to in_vec array, which contains input data |
| 77 | * to attestation service |
| 78 | * \param[in] num_invec Number of elements in in_vec array |
| 79 | * \param[in/out] out_vec Pointer out_vec array, which contains output data |
| 80 | * to attestation service |
| 81 | * \param[in] num_outvec Number of elements in out_vec array |
| 82 | * |
| 83 | * \return Returns error code as specified in \ref psa_attest_err_t |
| 84 | */ |
| 85 | enum psa_attest_err_t |
| 86 | initial_attest_get_token(const psa_invec *in_vec, uint32_t num_invec, |
| 87 | psa_outvec *out_vec, uint32_t num_outvec); |
| 88 | |
Tamas Ban | b6b8056 | 2019-01-04 22:49:24 +0000 | [diff] [blame] | 89 | /** |
| 90 | * \brief Get the size of the initial attestation token |
| 91 | * |
| 92 | * \param[in] in_vec Pointer to in_vec array, which contains input data |
| 93 | * to attestation service |
| 94 | * \param[in] num_invec Number of elements in in_vec array |
| 95 | * \param[out] out_vec Pointer to out_vec array, which contains pointer |
| 96 | * where to store the output data |
| 97 | * \param[in] num_outvec Number of elements in out_vec array |
| 98 | * |
| 99 | * \return Returns error code as specified in \ref psa_attest_err_t |
| 100 | */ |
| 101 | enum psa_attest_err_t |
| 102 | initial_attest_get_token_size(const psa_invec *in_vec, uint32_t num_invec, |
| 103 | psa_outvec *out_vec, uint32_t num_outvec); |
Tamas Ban | 48a0eb5 | 2018-08-17 12:48:05 +0100 | [diff] [blame] | 104 | #ifdef __cplusplus |
| 105 | } |
| 106 | #endif |
| 107 | |
| 108 | #endif /* __ATTESTATION_H__ */ |