blob: 2a674bd026993f587fc25dfd31bae11749a67359 [file] [log] [blame]
Tamas Ban6dfa6eb2018-08-17 12:02:51 +01001/*
Tamas Ban52d4a8e2019-01-04 22:45:39 +00002 * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
Tamas Ban6dfa6eb2018-08-17 12:02:51 +01003 *
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#ifndef __PSA_INITIAL_ATTESTATION_API_H__
16#define __PSA_INITIAL_ATTESTATION_API_H__
17
Tamas Ban6dfa6eb2018-08-17 12:02:51 +010018#include <limits.h>
Tamas Baneccae9d2019-01-09 15:54:56 +000019#include <stdint.h>
Tamas Ban6dfa6eb2018-08-17 12:02:51 +010020
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25/**
26 * \brief PSA INITIAL ATTESTATION API version
Tamas Ban8bdd4582019-02-18 10:57:31 +000027 *
28 * Initial attestation API version is: 1.0-beta-0
Tamas Ban6dfa6eb2018-08-17 12:02:51 +010029 */
Tamas Ban8bdd4582019-02-18 10:57:31 +000030#define PSA_INITIAL_ATTEST_API_VERSION_MAJOR (1)
31#define PSA_INITIAL_ATTEST_API_VERSION_MINOR (0)
Tamas Ban6dfa6eb2018-08-17 12:02:51 +010032
Tamas Ban6dfa6eb2018-08-17 12:02:51 +010033/**
34 * \enum psa_attest_err_t
35 *
36 * \brief Initial attestation service error types
37 *
38 */
39enum psa_attest_err_t {
Tamas Ban52d4a8e2019-01-04 22:45:39 +000040 /** Action was performed successfully */
Tamas Ban6dfa6eb2018-08-17 12:02:51 +010041 PSA_ATTEST_ERR_SUCCESS = 0,
Tamas Ban52d4a8e2019-01-04 22:45:39 +000042 /** Boot status data is unavailable or malformed */
Tamas Baneccae9d2019-01-09 15:54:56 +000043 PSA_ATTEST_ERR_INIT_FAILED,
Tamas Ban52d4a8e2019-01-04 22:45:39 +000044 /** Token buffer is too small to store the created token there */
Tamas Ban6dfa6eb2018-08-17 12:02:51 +010045 PSA_ATTEST_ERR_TOKEN_BUFFER_OVERFLOW,
Tamas Ban52d4a8e2019-01-04 22:45:39 +000046 /** Some of the mandatory claims are unavailable*/
Tamas Ban6dfa6eb2018-08-17 12:02:51 +010047 PSA_ATTEST_ERR_CLAIM_UNAVAILABLE,
Tamas Ban52d4a8e2019-01-04 22:45:39 +000048 /** Some parameter or combination of parameters are recognised as invalid:
49 * - challenge size is not allowed
50 * - challenge object is unavailable
51 * - token buffer is unavailable
52 */
Tamas Ban6dfa6eb2018-08-17 12:02:51 +010053 PSA_ATTEST_ERR_INVALID_INPUT,
Tamas Ban52d4a8e2019-01-04 22:45:39 +000054 /** Unexpected error happened during operation */
Tamas Ban6dfa6eb2018-08-17 12:02:51 +010055 PSA_ATTEST_ERR_GENERAL,
Tamas Ban52d4a8e2019-01-04 22:45:39 +000056 /** Following entry is only to ensure the error code of integer size */
Tamas Ban6dfa6eb2018-08-17 12:02:51 +010057 PSA_ATTEST_ERR_FORCE_INT_SIZE = INT_MAX
58};
59
60/**
Tamas Ban52d4a8e2019-01-04 22:45:39 +000061 * The allowed size of input challenge in bytes: 32, 48, 64
62 * Challenge can be a nonce from server
63 * or the hash of some combined data : nonce + attested data by caller.
Tamas Ban6dfa6eb2018-08-17 12:02:51 +010064 */
Tamas Ban52d4a8e2019-01-04 22:45:39 +000065#define PSA_INITIAL_ATTEST_CHALLENGE_SIZE_32 (32u)
66#define PSA_INITIAL_ATTEST_CHALLENGE_SIZE_48 (48u)
67#define PSA_INITIAL_ATTEST_CHALLENGE_SIZE_64 (64u)
68
Tamas Ban6dfa6eb2018-08-17 12:02:51 +010069/**
70 * The list of fixed claims in the initial attestation token is still evolving,
71 * you can expect slight changes in the future.
72 *
Tamas Ban52d4a8e2019-01-04 22:45:39 +000073 * The initial attestation token is planned to be aligned with future version of
Tamas Ban6dfa6eb2018-08-17 12:02:51 +010074 * Entity Attestation Token format:
Tamas Ban52d4a8e2019-01-04 22:45:39 +000075 * https://tools.ietf.org/html/draft-mandyam-eat-01
Tamas Ban6dfa6eb2018-08-17 12:02:51 +010076 *
77 * Current list of claims:
Tamas Ban52d4a8e2019-01-04 22:45:39 +000078 * - Challenge: Input object from caller. Can be a single nonce from server
79 * or hash of nonce and attested data. It is intended to provide
80 * freshness to reports and the caller has responsibility to
81 * arrange this. Allowed length: 32, 48, 64 bytes. The claim is
82 * modeled to be eventually represented by the EAT standard
83 * claim nonce. Until such a time as that standard exists,
84 * the claim will be represented by a custom claim. Value
85 * is encoded as byte string.
86 *
87 * - Instance ID: It represents the unique identifier of the instance. In the
88 * PSA definition it is a hash of the public attestation key
89 * of the instance. The claim is modeled to be eventually
90 * represented by the EAT standard claim UEID of type GUID.
91 * Until such a time as that standard exists, the claim will be
92 * represented by a custom claim Value is encoded as byte
93 * string.
94 *
95 * - Verification service indicator: Optional, recommended claim. It is used by
96 * a Relying Party to locate a validation service for the token.
97 * The value is a text string that can be used to locate the
98 * service or a URL specifying the address of the service. The
99 * claim is modeled to be eventually represented by the EAT
100 * standard claim origination. Until such a time as that
101 * standard exists, the claim will be represented by a custom
102 * claim. Value is encoded as text string.
103 *
104 * - Profile definition: Optional, recommended claim. It contains the name of
105 * a document that describes the 'profile' of the token, being
106 * a full description of the claims, their usage, verification
107 * and token signing. The document name may include versioning.
108 * Custom claim with a value encoded as text string.
109 *
110 * - Implementation ID: It represents the original implementation signer of the
111 * attestation key and identifies the contract between the
112 * report and verification. A verification service will use this
113 * claim to locate the details of the verification process.
114 * Custom claim with a value encoded as byte string.
115 *
116 * - Security lifecycle: It represents the current lifecycle state of the
117 * instance. Custom claim with a value encoded as integer that
118 * is divided to convey a major state and a minor state. The
119 * PSA state and implementation state are encoded as follows:
120 * - version[15:8] - PSA lifecycle state - major
121 * - version[7:0] - IMPLEMENTATION DEFINED state - minor
122 * Possible PSA lifecycle states:
123 * - Unknown (0x1000u),
124 * - PSA_RoT_Provisioning (0x2000u),
125 * - Secured (0x3000u),
126 * - Non_PSA_RoT_Debug(0x4000u),
127 * - Recoverable_PSA_RoT_Debug (0x5000u),
128 * - Decommissioned (0x6000u)
129 *
130 * - Client ID: The partition ID of that secure partition or non-secure
131 * thread who called the initial attestation API. Custom claim
132 * with a value encoded as a *signed* integer. Negative number
133 * represents non-secure caller, positive numbers represents
134 * secure callers, zero is invalid.
135 *
136 * - HW version: Optional claim. Globally unique number in EAN-13 format
137 * identifying the GDSII that went to fabrication, HW and ROM.
138 * It can be used to reference the security level of the PSA-ROT
139 * via a certification website. Custom claim with a value is
140 * encoded as text string.
141
142 * - Boot seed: It represents a random value created at system boot time that
143 * will allow differentiation of reports from different system
144 * sessions. The size is 32 bytes. Custom claim with a value is
145 * encoded as byte string.
146 *
147 * - Software components: Recommended claim. It represents the software state
148 * of the system. The value of the claim is an array of CBOR map
149 * entries, with one entry per software component within the
150 * device. Each map contains multiple claims that describe
151 * evidence about the details of the software component.
152 *
153 * - Measurement type: Optional claim. It represents the role of the
154 * software component. Value is encoded as short(!) text
155 * string.
156 *
157 * - Measurement value: It represents a hash of the invariant software
158 * component in memory at start-up time. The value must be a
159 * cryptographic hash of 256 bits or stronger.Value is
160 * encoded as byte string.
161 *
162 * - Security epoch: Optional claim. It represents the security control
163 * point of the software component. Value is encoded as
164 * unsigned integer.
165 *
166 * - Version: Optional claim. It represents the issued software version.
167 * Value is encoded as text string.
168 *
169 * - Signer ID: It represents the hash of a signing authority public key.
170 * Value is encoded as byte string.
171 *
172 * - Measurement description: Optional claim. It represents the way in which
173 * the measurement value of the software component is
174 * computed. Value is encoded as text string containing an
175 * abbreviated description (name) of the measurement method.
176 *
177 * - No software measurements: In the event that the implementation does not
178 * contain any software measurements then the software
179 * components claim above can be omitted but instead
180 * it is mandatory to include this claim to indicate this is a
181 * deliberate state. Custom claim a value is encoded as unsigned
182 * integer set to 1.
Tamas Ban6dfa6eb2018-08-17 12:02:51 +0100183 */
184
185/**
Tamas Ban6dfa6eb2018-08-17 12:02:51 +0100186 * \brief Get initial attestation token
187 *
188 * \param[in] challenge_obj Pointer to buffer where challenge input is
189 * stored. Nonce and / or hash of attested data.
190 * Must be always
191 * \ref PSA_INITIAL_ATTEST_CHALLENGE_SIZE bytes
192 * long.
193 * \param[in] challenge_size Size of challenge object in bytes.
194 * \param[out] token Pointer to the buffer where attestation token
195 * must be stored.
196 * \param[in/out] token_size Size of allocated buffer for token, which
197 * updated by initial attestation service with
198 * final token size.
199 *
200 * \return Returns error code as specified in \ref psa_attest_err_t
201 */
202enum psa_attest_err_t
203psa_initial_attest_get_token(const uint8_t *challenge_obj,
204 uint32_t challenge_size,
205 uint8_t *token,
206 uint32_t *token_size);
207
Tamas Ban52d4a8e2019-01-04 22:45:39 +0000208/**
209 * \brief Get the exact size of initial attestation token in bytes.
210 *
211 * It just returns with the size of the IAT token. It can be used if the caller
212 * dynamically allocates memory for the token buffer.
213 *
214 * \param[in] challenge_size Size of challenge object in bytes.
215 * \param[out] token_size Size of the token in bytes, which is created by
216 * initial attestation service.
217 *
218 * \return Returns error code as specified in \ref psa_attest_err_t
219 */
220enum psa_attest_err_t
221psa_initial_attest_get_token_size(uint32_t challenge_size,
222 uint32_t *token_size);
223
Tamas Ban6dfa6eb2018-08-17 12:02:51 +0100224#ifdef __cplusplus
225}
226#endif
227
228#endif /* __PSA_INITIAL_ATTESTATION_API_H__ */