Tamas Ban | 48a0eb5 | 2018-08-17 12:48:05 +0100 | [diff] [blame] | 1 | /* |
Raef Coles | 793574c | 2019-10-09 10:59:42 +0100 | [diff] [blame] | 2 | * Copyright (c) 2018-2020, 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 | |
Tamas Ban | c3c0849 | 2020-08-27 10:15:42 +0100 | [diff] [blame^] | 8 | #ifndef __ATTEST_H__ |
| 9 | #define __ATTEST_H__ |
Tamas Ban | 48a0eb5 | 2018-08-17 12:48:05 +0100 | [diff] [blame] | 10 | |
Jamie Fox | cc31d40 | 2019-01-28 17:13:52 +0000 | [diff] [blame] | 11 | #include "psa/initial_attestation.h" |
Tamas Ban | d2b2f09 | 2019-01-23 22:29:14 +0000 | [diff] [blame] | 12 | #include "tfm_client.h" |
Mingyang Sun | 8a19e7a | 2020-06-04 15:36:58 +0800 | [diff] [blame] | 13 | #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 | |
Raef Coles | 793574c | 2019-10-09 10:59:42 +0100 | [diff] [blame] | 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 | |
Tamas Ban | d2b2f09 | 2019-01-23 22:29:14 +0000 | [diff] [blame] | 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 |
Tamas Ban | a24ce04 | 2019-02-20 11:50:22 +0000 | [diff] [blame] | 57 | attest_get_boot_data(uint8_t major_type, |
| 58 | struct tfm_boot_data *boot_data, |
| 59 | uint32_t len); |
Tamas Ban | d2b2f09 | 2019-01-23 22:29:14 +0000 | [diff] [blame] | 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 | /*! |
Tamas Ban | 48a0eb5 | 2018-08-17 12:48:05 +0100 | [diff] [blame] | 72 | * \brief Initialise the initial attestation service during the TF-M boot up |
| 73 | * process. |
| 74 | * |
Raef Coles | 793574c | 2019-10-09 10:59:42 +0100 | [diff] [blame] | 75 | * \return Returns PSA_SUCCESS if init has been completed, |
| 76 | * otherwise error as specified in \ref psa_status_t |
Tamas Ban | 48a0eb5 | 2018-08-17 12:48:05 +0100 | [diff] [blame] | 77 | */ |
Raef Coles | 793574c | 2019-10-09 10:59:42 +0100 | [diff] [blame] | 78 | psa_status_t attest_init(void); |
Tamas Ban | 48a0eb5 | 2018-08-17 12:48:05 +0100 | [diff] [blame] | 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 |
Gyorgy Szing | 40a7af0 | 2019-02-06 14:19:47 +0100 | [diff] [blame] | 86 | * \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] | 87 | * to attestation service |
| 88 | * \param[in] num_outvec Number of elements in out_vec array |
| 89 | * |
Raef Coles | 793574c | 2019-10-09 10:59:42 +0100 | [diff] [blame] | 90 | * \return Returns error code as specified in \ref psa_status_t |
Tamas Ban | 48a0eb5 | 2018-08-17 12:48:05 +0100 | [diff] [blame] | 91 | */ |
Raef Coles | 793574c | 2019-10-09 10:59:42 +0100 | [diff] [blame] | 92 | psa_status_t |
Tamas Ban | 48a0eb5 | 2018-08-17 12:48:05 +0100 | [diff] [blame] | 93 | initial_attest_get_token(const psa_invec *in_vec, uint32_t num_invec, |
| 94 | psa_outvec *out_vec, uint32_t num_outvec); |
| 95 | |
Tamas Ban | b6b8056 | 2019-01-04 22:49:24 +0000 | [diff] [blame] | 96 | /** |
| 97 | * \brief Get the size of the initial attestation token |
| 98 | * |
| 99 | * \param[in] in_vec Pointer to in_vec array, which contains input data |
| 100 | * to attestation service |
| 101 | * \param[in] num_invec Number of elements in in_vec array |
| 102 | * \param[out] out_vec Pointer to out_vec array, which contains pointer |
| 103 | * where to store the output data |
| 104 | * \param[in] num_outvec Number of elements in out_vec array |
| 105 | * |
Raef Coles | 793574c | 2019-10-09 10:59:42 +0100 | [diff] [blame] | 106 | * \return Returns error code as specified in \ref psa_status_t |
Tamas Ban | b6b8056 | 2019-01-04 22:49:24 +0000 | [diff] [blame] | 107 | */ |
Raef Coles | 793574c | 2019-10-09 10:59:42 +0100 | [diff] [blame] | 108 | psa_status_t |
Tamas Ban | b6b8056 | 2019-01-04 22:49:24 +0000 | [diff] [blame] | 109 | initial_attest_get_token_size(const psa_invec *in_vec, uint32_t num_invec, |
| 110 | psa_outvec *out_vec, uint32_t num_outvec); |
David Vincze | 20c3e4e | 2019-11-11 11:16:06 +0100 | [diff] [blame] | 111 | |
| 112 | /** |
| 113 | * \brief Get the initial attestation public key. |
| 114 | * |
| 115 | * \param[in] in_vec Pointer to in_vec array, which contains input data |
| 116 | * to attestation service |
| 117 | * \param[in] num_invec Number of elements in in_vec array |
| 118 | * \param[out] out_vec Pointer to out_vec array, which contains pointer |
| 119 | * where to store the output data |
| 120 | * \param[in] num_outvec Number of elements in out_vec array |
| 121 | * |
Raef Coles | 793574c | 2019-10-09 10:59:42 +0100 | [diff] [blame] | 122 | * \return Returns error code as specified in \ref psa_status_t |
David Vincze | 20c3e4e | 2019-11-11 11:16:06 +0100 | [diff] [blame] | 123 | */ |
Raef Coles | 793574c | 2019-10-09 10:59:42 +0100 | [diff] [blame] | 124 | psa_status_t |
David Vincze | 20c3e4e | 2019-11-11 11:16:06 +0100 | [diff] [blame] | 125 | initial_attest_get_public_key(const psa_invec *in_vec, uint32_t num_invec, |
| 126 | psa_outvec *out_vec, uint32_t num_outvec); |
| 127 | |
Tamas Ban | 48a0eb5 | 2018-08-17 12:48:05 +0100 | [diff] [blame] | 128 | #ifdef __cplusplus |
| 129 | } |
| 130 | #endif |
| 131 | |
Tamas Ban | c3c0849 | 2020-08-27 10:15:42 +0100 | [diff] [blame^] | 132 | #endif /* __ATTEST_H__ */ |