Mbed OS Reference
Loading...
Searching...
No Matches
psa_initial_attestation_api.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8/***************************************************************************/
9/* DRAFT UNDER REVIEW */
10/* These APIs are still evolving and are meant as a prototype for review.*/
11/* The APIs will change depending on feedback and will be firmed up */
12/* to a stable set of APIs once all the feedback has been considered. */
13/***************************************************************************/
14
15/** @defgroup PSA-Attestation PSA-Attestation
16 @ingroup experimental-crypto-psa
17 * @{
18 */
19
20
21#ifndef __PSA_INITIAL_ATTESTATION_API_H__
22#define __PSA_INITIAL_ATTESTATION_API_H__
23
24#include <limits.h>
25#include <stdint.h>
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31/**
32* \file
33* The list of fixed claims in the initial attestation token is still evolving,
34* you can expect slight changes in the future.
35*
36* The initial attestation token is planned to be aligned with future version of
37* Entity Attestation Token format:
38* https://tools.ietf.org/html/draft-mandyam-eat-01
39*
40* Current list of claims:
41* <ul>
42* <li> \b Challenge: Input object from caller. Can be a single nonce from server
43* or hash of nonce and attested data. It is intended to provide
44* freshness to reports and the caller has responsibility to
45* arrange this. Allowed length: 32, 48, 64 bytes. The claim is
46* modeled to be eventually represented by the EAT standard
47* claim nonce. Until such a time as that standard exists,
48* the claim will be represented by a custom claim. Value
49* is encoded as byte string.</li>
50*
51* <li> \b Instance ID: It represents the unique identifier of the instance. In the
52* PSA definition it is a hash of the public attestation key
53* of the instance. The claim is modeled to be eventually
54* represented by the EAT standard claim UEID of type GUID.
55* Until such a time as that standard exists, the claim will be
56* represented by a custom claim Value is encoded as byte
57* string. </li>
58*
59* <li> \b Verification service indicator: Optional, recommended claim. It is used by
60* a Relying Party to locate a validation service for the token.
61* The value is a text string that can be used to locate the
62* service or a URL specifying the address of the service. The
63* claim is modeled to be eventually represented by the EAT
64* standard claim origination. Until such a time as that
65* standard exists, the claim will be represented by a custom
66* claim. Value is encoded as text string. </li>
67*
68* <li> \b Profile definition: Optional, recommended claim. It contains the name of
69* a document that describes the 'profile' of the token, being
70* a full description of the claims, their usage, verification
71* and token signing. The document name may include versioning.
72* Custom claim with a value encoded as text string. </li>
73*
74* <li> \b Implementation ID: It represents the original implementation signer of the
75* attestation key and identifies the contract between the
76* report and verification. A verification service will use this
77* claim to locate the details of the verification process.
78* Custom claim with a value encoded as byte string. </li>
79*
80* <li> \b Security lifecycle: It represents the current lifecycle state of the
81* instance. Custom claim with a value encoded as integer that
82* is divided to convey a major state and a minor state. The
83* PSA state and implementation state are encoded as follows: <ul>
84* <li> version[15:8] - PSA lifecycle state - major </li>
85* <li> version[7:0] - IMPLEMENTATION DEFINED state - minor </li> </ul>
86* Possible PSA lifecycle states: <ul>
87* <li> Unknown (0x1000u) </li>
88* <li> PSA_RoT_Provisioning (0x2000u)</li>
89* <li> Secured (0x3000u) </li>
90* <li> Non_PSA_RoT_Debug(0x4000u) </li>
91* <li> Recoverable_PSA_RoT_Debug (0x5000u) </li>
92* <li> Decommissioned (0x6000u) </li> </ul> </li>
93*
94* <li> \b Client ID: The partition ID of that secure partition or non-secure
95* thread who called the initial attestation API. Custom claim
96* with a value encoded as a *signed* integer. Negative number
97* represents non-secure caller, positive numbers represents
98* secure callers, zero is invalid. </li>
99*
100* <li> \b HW version: Optional claim. Globally unique number in EAN-13 format
101* identifying the GDSII that went to fabrication, HW and ROM.
102* It can be used to reference the security level of the PSA-ROT
103* via a certification website. Custom claim with a value is
104* encoded as text string. </li>
105
106* <li> \b Boot seed: It represents a random value created at system boot time that
107* will allow differentiation of reports from different system
108* sessions. The size is 32 bytes. Custom claim with a value is
109* encoded as byte string. </li>
110*
111* <li> \b Software components: Recommended claim. It represents the software state
112* of the system. The value of the claim is an array of CBOR map
113* entries, with one entry per software component within the
114* device. Each map contains multiple claims that describe
115* evidence about the details of the software component. </li>
116*
117* <li> \b Measurement type: Optional claim. It represents the role of the
118* software component. Value is encoded as short(!) text
119* string. </li>
120*
121* <li> \b Measurement value: It represents a hash of the invariant software
122* component in memory at start-up time. The value must be a
123* cryptographic hash of 256 bits or stronger.Value is
124* encoded as byte string. </li>
125*
126* <li> \b Security epoch: Optional claim. It represents the security control
127* point of the software component. Value is encoded as
128* unsigned integer. </li>
129*
130* <li> \b Version: Optional claim. It represents the issued software version.
131* Value is encoded as text string. </li>
132*
133* <li> \b Signer ID: It represents the hash of a signing authority public key.
134* Value is encoded as byte string. </li>
135*
136* <li> \b Measurement description: Optional claim. It represents the way in which
137* the measurement value of the software component is
138* computed. Value is encoded as text string containing an
139* abbreviated description (name) of the measurement method. </li>
140*
141* <li> \b No software measurements: In the event that the implementation does not
142* contain any software measurements then the software
143* components claim above can be omitted but instead
144* it is mandatory to include this claim to indicate this is a
145* deliberate state. Custom claim a value is encoded as unsigned
146* integer set to 1. </li>
147* </ul>
148*/
149
150/**
151 * \brief PSA INITIAL ATTESTATION API version
152 */
153#define PSA_INITIAL_ATTEST_API_VERSION_MAJOR (0)
154#define PSA_INITIAL_ATTEST_API_VERSION_MINOR (9)
155
156/**
157 * \enum psa_attest_err_t
158 *
159 * \brief Initial attestation service error types
160 *
161 */
163 /** Action was performed successfully */
165 /** Boot status data is unavailable or malformed */
167 /** Token buffer is too small to store the created token there */
169 /** Some of the mandatory claims are unavailable*/
171 /** Some parameter or combination of parameters are recognised as invalid:
172 * - challenge size is not allowed
173 * - challenge object is unavailable
174 * - token buffer is unavailable
175 */
177 /** Unexpected error happened during operation */
179 /** Following entry is only to ensure the error code of integer size */
182
183/*
184 * The allowed size of input challenge in bytes: 32, 48, 64
185 * Challenge can be a nonce from server
186 * or the hash of some combined data : nonce + attested data by caller.
187 */
188#define PSA_INITIAL_ATTEST_CHALLENGE_SIZE_32 (32u) ///< 32 byte challenge
189#define PSA_INITIAL_ATTEST_CHALLENGE_SIZE_48 (48u) ///< 48 byte challenge
190#define PSA_INITIAL_ATTEST_CHALLENGE_SIZE_64 (64u) ///< 64 byte challenge
191
192/**
193 * \brief Get initial attestation token
194 *
195 * \param[in] challenge_obj Pointer to buffer where challenge input is
196 * stored. Nonce and / or hash of attested data.
197 * Must have a length equal to one of the
198 * PSA_INITIAL_ATTEST_CHALLENGE_SIZE_xxx constants.
199 * \param[in] challenge_size Size of challenge object in bytes.
200 * \param[out] token Pointer to the buffer where attestation token
201 * must be stored.
202 * \param[inout] token_size Size of allocated buffer for token, which
203 * updated by initial attestation service with
204 * final token size.
205 *
206 * \return Returns error code as specified in \ref psa_attest_err_t
207 */
209psa_initial_attest_get_token(const uint8_t *challenge_obj,
210 uint32_t challenge_size,
211 uint8_t *token,
212 uint32_t *token_size);
213
214/**
215 * \brief Get the exact size of initial attestation token in bytes.
216 *
217 * It just returns with the size of the IAT token. It can be used if the caller
218 * dynamically allocates memory for the token buffer.
219 *
220 * \param[in] challenge_size Size of challenge object in bytes.
221 * \param[out] token_size Size of the token in bytes, which is created by
222 * initial attestation service.
223 *
224 * \return Returns error code as specified in \ref psa_attest_err_t
225 */
227psa_initial_attest_get_token_size(uint32_t challenge_size,
228 uint32_t *token_size);
229
230#ifdef __cplusplus
231}
232#endif
233
234/** @}*/ // PSA-Attestation
235
236#endif /* __PSA_INITIAL_ATTESTATION_API_H__ */
enum psa_attest_err_t psa_initial_attest_get_token(const uint8_t *challenge_obj, uint32_t challenge_size, uint8_t *token, uint32_t *token_size)
Get initial attestation token.
psa_attest_err_t
Initial attestation service error types.
enum psa_attest_err_t psa_initial_attest_get_token_size(uint32_t challenge_size, uint32_t *token_size)
Get the exact size of initial attestation token in bytes.
@ PSA_ATTEST_ERR_FORCE_INT_SIZE
Following entry is only to ensure the error code of integer size.
@ PSA_ATTEST_ERR_INVALID_INPUT
Some parameter or combination of parameters are recognised as invalid:
@ PSA_ATTEST_ERR_GENERAL
Unexpected error happened during operation.
@ PSA_ATTEST_ERR_TOKEN_BUFFER_OVERFLOW
Token buffer is too small to store the created token there.
@ PSA_ATTEST_ERR_INIT_FAILED
Boot status data is unavailable or malformed.
@ PSA_ATTEST_ERR_CLAIM_UNAVAILABLE
Some of the mandatory claims are unavailable.
@ PSA_ATTEST_ERR_SUCCESS
Action was performed successfully.