blob: 820e37dbd366bfc5ed04dc1816519b6498a0116c [file] [log] [blame]
Tamas Ban48a0eb52018-08-17 12:48:05 +01001/*
Raef Coles793574c2019-10-09 10:59:42 +01002 * Copyright (c) 2018-2020, 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 Band2b2f092019-01-23 22:29:14 +000012#include "tfm_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
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 */
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 *
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 Szing40a7af02019-02-06 14:19:47 +010086 * \param[in,out] out_vec Pointer out_vec array, which contains output data
Tamas Ban48a0eb52018-08-17 12:48:05 +010087 * to attestation service
88 * \param[in] num_outvec Number of elements in out_vec array
89 *
Raef Coles793574c2019-10-09 10:59:42 +010090 * \return Returns error code as specified in \ref psa_status_t
Tamas Ban48a0eb52018-08-17 12:48:05 +010091 */
Raef Coles793574c2019-10-09 10:59:42 +010092psa_status_t
Tamas Ban48a0eb52018-08-17 12:48:05 +010093initial_attest_get_token(const psa_invec *in_vec, uint32_t num_invec,
94 psa_outvec *out_vec, uint32_t num_outvec);
95
Tamas Banb6b80562019-01-04 22:49:24 +000096/**
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 Coles793574c2019-10-09 10:59:42 +0100106 * \return Returns error code as specified in \ref psa_status_t
Tamas Banb6b80562019-01-04 22:49:24 +0000107 */
Raef Coles793574c2019-10-09 10:59:42 +0100108psa_status_t
Tamas Banb6b80562019-01-04 22:49:24 +0000109initial_attest_get_token_size(const psa_invec *in_vec, uint32_t num_invec,
110 psa_outvec *out_vec, uint32_t num_outvec);
David Vincze20c3e4e2019-11-11 11:16:06 +0100111
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 Coles793574c2019-10-09 10:59:42 +0100122 * \return Returns error code as specified in \ref psa_status_t
David Vincze20c3e4e2019-11-11 11:16:06 +0100123 */
Raef Coles793574c2019-10-09 10:59:42 +0100124psa_status_t
David Vincze20c3e4e2019-11-11 11:16:06 +0100125initial_attest_get_public_key(const psa_invec *in_vec, uint32_t num_invec,
126 psa_outvec *out_vec, uint32_t num_outvec);
127
Tamas Ban48a0eb52018-08-17 12:48:05 +0100128#ifdef __cplusplus
129}
130#endif
131
Tamas Banc3c08492020-08-27 10:15:42 +0100132#endif /* __ATTEST_H__ */