1 /* 2 * Copyright (c) 2018-2021, Arm Limited. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 * 6 */ 7 8 #ifndef __ATTEST_H__ 9 #define __ATTEST_H__ 10 11 #include "psa/initial_attestation.h" 12 #include "psa/client.h" 13 #include "tfm_boot_status.h" 14 15 #ifdef __cplusplus 16 extern "C" { 17 #endif 18 19 /** 20 * \enum psa_attest_err_t 21 * 22 * \brief Initial attestation service error types 23 * 24 */ 25 enum psa_attest_err_t { 26 /** Action was performed successfully */ 27 PSA_ATTEST_ERR_SUCCESS = 0, 28 /** Boot status data is unavailable or malformed */ 29 PSA_ATTEST_ERR_INIT_FAILED, 30 /** Buffer is too small to store required data */ 31 PSA_ATTEST_ERR_BUFFER_OVERFLOW, 32 /** Some of the mandatory claims are unavailable*/ 33 PSA_ATTEST_ERR_CLAIM_UNAVAILABLE, 34 /** Some parameter or combination of parameters are recognised as invalid: 35 * - challenge size is not allowed 36 * - challenge object is unavailable 37 * - token buffer is unavailable 38 */ 39 PSA_ATTEST_ERR_INVALID_INPUT, 40 /** Unexpected error happened during operation */ 41 PSA_ATTEST_ERR_GENERAL, 42 /** Following entry is only to ensure the error code of integer size */ 43 PSA_ATTEST_ERR_FORCE_INT_SIZE = INT_MAX 44 }; 45 46 /*! 47 * \brief Copy the boot data (coming from boot loader) from shared memory area 48 * to service memory area 49 * 50 * \param[in] major_type Major type of TLV entries to copy 51 * \param[out] ptr Pointer to the buffer to store the boot data 52 * \parma[in] len Size of the buffer to store the boot data 53 * 54 * \return Returns error code as specified in \ref psa_attest_err_t 55 */ 56 enum psa_attest_err_t 57 attest_get_boot_data(uint8_t major_type, 58 struct tfm_boot_data *boot_data, 59 uint32_t len); 60 61 /*! 62 * \brief Get the ID of the caller thread. 63 * 64 * \param[out] caller_id Pointer where to store caller ID 65 * 66 * \return Returns error code as specified in \ref psa_attest_err_t 67 */ 68 enum psa_attest_err_t 69 attest_get_caller_client_id(int32_t *caller_id); 70 71 /*! 72 * \brief Initialise the initial attestation service during the TF-M boot up 73 * process. 74 * 75 * \return Returns PSA_SUCCESS if init has been completed, 76 * otherwise error as specified in \ref psa_status_t 77 */ 78 psa_status_t attest_init(void); 79 80 /*! 81 * \brief Get initial attestation token 82 * 83 * \param[in] in_vec Pointer to in_vec array, which contains input data 84 * to attestation service 85 * \param[in] num_invec Number of elements in in_vec array 86 * \param[in,out] out_vec Pointer out_vec array, which contains output data 87 * to attestation service 88 * \param[in] num_outvec Number of elements in out_vec array 89 * 90 * \return Returns error code as specified in \ref psa_status_t 91 */ 92 psa_status_t 93 initial_attest_get_token(const void *challenge_buf, size_t challenge_size, 94 void *token_buf, size_t token_buf_size, 95 size_t *token_size); 96 97 /** 98 * \brief Get the size of the initial attestation token 99 * 100 * \param[in] in_vec Pointer to in_vec array, which contains input data 101 * to attestation service 102 * \param[in] num_invec Number of elements in in_vec array 103 * \param[out] out_vec Pointer to out_vec array, which contains pointer 104 * where to store the output data 105 * \param[in] num_outvec Number of elements in out_vec array 106 * 107 * \return Returns error code as specified in \ref psa_status_t 108 */ 109 psa_status_t 110 initial_attest_get_token_size(size_t challenge_size, size_t *token_size); 111 112 #ifdef __cplusplus 113 } 114 #endif 115 116 #endif /* __ATTEST_H__ */ 117