Tamas Ban | 48a0eb5 | 2018-08-17 12:48:05 +0100 | [diff] [blame] | 1 | /* |
David Hu | 611610c | 2021-05-14 17:03:14 +0800 | [diff] [blame] | 2 | * Copyright (c) 2018-2021, 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 | c537139 | 2020-08-31 13:28:33 +0100 | [diff] [blame] | 12 | #include "psa/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 |
Nicola Mazzucato | 9d2fd8e | 2025-03-25 14:53:05 +0000 | [diff] [blame] | 51 | * \param[out] boot_data Pointer to the buffer to store the boot data |
Antonio de Angelis | 06df9f2 | 2025-01-06 14:41:04 +0000 | [diff] [blame] | 52 | * \param[in] len Size of the buffer to store the boot data |
Tamas Ban | d2b2f09 | 2019-01-23 22:29:14 +0000 | [diff] [blame] | 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 | * |
Nicola Mazzucato | 9d2fd8e | 2025-03-25 14:53:05 +0000 | [diff] [blame] | 83 | * \param[in] challenge_buf Pointer to buffer where challenge input is |
| 84 | * stored. |
| 85 | * \param[in] challenge_size Size of challenge object in bytes. |
| 86 | * \param[out] token_buf Pointer to the buffer where attestation token |
| 87 | * will be stored. |
| 88 | * \param[in] token_buf_size Size of allocated buffer for token, in bytes. |
| 89 | * \param[out] token_size Size of the token that has been returned, in |
| 90 | * bytes. |
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 | * \return Returns error code as specified in \ref psa_status_t |
Tamas Ban | 48a0eb5 | 2018-08-17 12:48:05 +0100 | [diff] [blame] | 93 | */ |
Raef Coles | 793574c | 2019-10-09 10:59:42 +0100 | [diff] [blame] | 94 | psa_status_t |
Kevin Peng | 4da4424 | 2022-04-02 19:22:47 +0800 | [diff] [blame] | 95 | initial_attest_get_token(const void *challenge_buf, size_t challenge_size, |
| 96 | void *token_buf, size_t token_buf_size, |
| 97 | size_t *token_size); |
Tamas Ban | 48a0eb5 | 2018-08-17 12:48:05 +0100 | [diff] [blame] | 98 | |
Tamas Ban | b6b8056 | 2019-01-04 22:49:24 +0000 | [diff] [blame] | 99 | /** |
| 100 | * \brief Get the size of the initial attestation token |
| 101 | * |
Nicola Mazzucato | 9d2fd8e | 2025-03-25 14:53:05 +0000 | [diff] [blame] | 102 | * \param[in] challenge_size Size of challenge object in bytes. This must be |
| 103 | * a supported challenge size. |
| 104 | * \param[out] token_size Size of the token in bytes, which is created by |
| 105 | * initial attestation service. |
Tamas Ban | b6b8056 | 2019-01-04 22:49:24 +0000 | [diff] [blame] | 106 | * |
Raef Coles | 793574c | 2019-10-09 10:59:42 +0100 | [diff] [blame] | 107 | * \return Returns error code as specified in \ref psa_status_t |
Tamas Ban | b6b8056 | 2019-01-04 22:49:24 +0000 | [diff] [blame] | 108 | */ |
Raef Coles | 793574c | 2019-10-09 10:59:42 +0100 | [diff] [blame] | 109 | psa_status_t |
Kevin Peng | 4da4424 | 2022-04-02 19:22:47 +0800 | [diff] [blame] | 110 | initial_attest_get_token_size(size_t challenge_size, size_t *token_size); |
David Vincze | 20c3e4e | 2019-11-11 11:16:06 +0100 | [diff] [blame] | 111 | |
Tamas Ban | 48a0eb5 | 2018-08-17 12:48:05 +0100 | [diff] [blame] | 112 | #ifdef __cplusplus |
| 113 | } |
| 114 | #endif |
| 115 | |
Tamas Ban | c3c0849 | 2020-08-27 10:15:42 +0100 | [diff] [blame] | 116 | #endif /* __ATTEST_H__ */ |