blob: 5b0e99ff71c779bcbd8593d94075f5409bfbc581 [file] [log] [blame]
Tamas Ban48a0eb52018-08-17 12:48:05 +01001/*
David Hu611610c2021-05-14 17:03:14 +08002 * Copyright (c) 2018-2021, Arm Limited. All rights reserved.
Tamas Ban48a0eb52018-08-17 12:48:05 +01003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
Tamas Banc3c08492020-08-27 10:15:42 +01008#ifndef __ATTEST_H__
9#define __ATTEST_H__
Tamas Ban48a0eb52018-08-17 12:48:05 +010010
Jamie Foxcc31d402019-01-28 17:13:52 +000011#include "psa/initial_attestation.h"
Tamas Banc5371392020-08-31 13:28:33 +010012#include "psa/client.h"
Mingyang Sun8a19e7a2020-06-04 15:36:58 +080013#include "tfm_boot_status.h"
Tamas Ban48a0eb52018-08-17 12:48:05 +010014
15#ifdef __cplusplus
16extern "C" {
17#endif
18
Raef Coles793574c2019-10-09 10:59:42 +010019/**
20 * \enum psa_attest_err_t
21 *
22 * \brief Initial attestation service error types
23 *
24 */
25enum 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 Band2b2f092019-01-23 22:29:14 +000046/*!
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 Mazzucato9d2fd8e2025-03-25 14:53:05 +000051 * \param[out] boot_data Pointer to the buffer to store the boot data
Antonio de Angelis06df9f22025-01-06 14:41:04 +000052 * \param[in] len Size of the buffer to store the boot data
Tamas Band2b2f092019-01-23 22:29:14 +000053 *
54 * \return Returns error code as specified in \ref psa_attest_err_t
55 */
56enum psa_attest_err_t
Tamas Bana24ce042019-02-20 11:50:22 +000057attest_get_boot_data(uint8_t major_type,
58 struct tfm_boot_data *boot_data,
59 uint32_t len);
Tamas Band2b2f092019-01-23 22:29:14 +000060
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 */
68enum psa_attest_err_t
69attest_get_caller_client_id(int32_t *caller_id);
70
71/*!
Tamas Ban48a0eb52018-08-17 12:48:05 +010072 * \brief Initialise the initial attestation service during the TF-M boot up
73 * process.
74 *
Raef Coles793574c2019-10-09 10:59:42 +010075 * \return Returns PSA_SUCCESS if init has been completed,
76 * otherwise error as specified in \ref psa_status_t
Tamas Ban48a0eb52018-08-17 12:48:05 +010077 */
Raef Coles793574c2019-10-09 10:59:42 +010078psa_status_t attest_init(void);
Tamas Ban48a0eb52018-08-17 12:48:05 +010079
80/*!
81 * \brief Get initial attestation token
82 *
Nicola Mazzucato9d2fd8e2025-03-25 14:53:05 +000083 * \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 Ban48a0eb52018-08-17 12:48:05 +010091 *
Raef Coles793574c2019-10-09 10:59:42 +010092 * \return Returns error code as specified in \ref psa_status_t
Tamas Ban48a0eb52018-08-17 12:48:05 +010093 */
Raef Coles793574c2019-10-09 10:59:42 +010094psa_status_t
Kevin Peng4da44242022-04-02 19:22:47 +080095initial_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 Ban48a0eb52018-08-17 12:48:05 +010098
Tamas Banb6b80562019-01-04 22:49:24 +000099/**
100 * \brief Get the size of the initial attestation token
101 *
Nicola Mazzucato9d2fd8e2025-03-25 14:53:05 +0000102 * \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 Banb6b80562019-01-04 22:49:24 +0000106 *
Raef Coles793574c2019-10-09 10:59:42 +0100107 * \return Returns error code as specified in \ref psa_status_t
Tamas Banb6b80562019-01-04 22:49:24 +0000108 */
Raef Coles793574c2019-10-09 10:59:42 +0100109psa_status_t
Kevin Peng4da44242022-04-02 19:22:47 +0800110initial_attest_get_token_size(size_t challenge_size, size_t *token_size);
David Vincze20c3e4e2019-11-11 11:16:06 +0100111
Tamas Ban48a0eb52018-08-17 12:48:05 +0100112#ifdef __cplusplus
113}
114#endif
115
Tamas Banc3c08492020-08-27 10:15:42 +0100116#endif /* __ATTEST_H__ */