blob: 35a18d0489f831205961104910384b3ddef1d50a [file] [log] [blame]
Julian Hall201ce462021-04-29 11:05:34 +01001/*
2 * Copyright (c) 2018-2021, 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#ifndef __PSA_INITIAL_ATTESTATION_H__
16#define __PSA_INITIAL_ATTESTATION_H__
17
18#include <limits.h>
19#include <stdint.h>
20#include <stddef.h>
Julian Hall201ce462021-04-29 11:05:34 +010021
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26/**
27 * \brief PSA INITIAL ATTESTATION API version
28 *
29 * Initial attestation API version is: 1.0.0
30 */
31#define PSA_INITIAL_ATTEST_API_VERSION_MAJOR (1)
32#define PSA_INITIAL_ATTEST_API_VERSION_MINOR (0)
33
34/**
35 * The allowed size of input challenge in bytes: 32, 48, 64
36 * Challenge can be a nonce from server
37 * or the hash of some combined data : nonce + attested data by caller.
38 */
39#define PSA_INITIAL_ATTEST_CHALLENGE_SIZE_32 (32u)
40#define PSA_INITIAL_ATTEST_CHALLENGE_SIZE_48 (48u)
41#define PSA_INITIAL_ATTEST_CHALLENGE_SIZE_64 (64u)
42
43/**
44 * The maximum size of an attestation token that can be generated by the
45 * attestation service. Used to configure buffers for services that verify the
46 * produced tokens.
47 */
Julian Hall700aa362021-05-13 15:30:39 +010048#define PSA_INITIAL_ATTEST_MAX_TOKEN_SIZE (4096)
Julian Hall201ce462021-04-29 11:05:34 +010049
50/**
51 * The list of fixed claims in the initial attestation token is still evolving,
52 * you can expect slight changes in the future.
53 *
54 * The initial attestation token is planned to be aligned with future version of
55 * Entity Attestation Token format:
56 * https://tools.ietf.org/html/draft-mandyam-eat-01
57 *
58 * Current list of claims:
59 * - Challenge: Input object from caller. Can be a single nonce from server
60 * or hash of nonce and attested data. It is intended to provide
61 * freshness to reports and the caller has responsibility to
62 * arrange this. Allowed length: 32, 48, 64 bytes. The claim is
63 * modeled to be eventually represented by the EAT standard
64 * claim nonce. Until such a time as that standard exists,
65 * the claim will be represented by a custom claim. Value
66 * is encoded as byte string.
67 *
68 * - Instance ID: It represents the unique identifier of the instance. In the
69 * PSA definition it is a hash of the public attestation key
70 * of the instance. The claim is modeled to be eventually
71 * represented by the EAT standard claim UEID of type GUID.
72 * Until such a time as that standard exists, the claim will be
73 * represented by a custom claim Value is encoded as byte
74 * string.
75 *
76 * - Verification service indicator: Optional, recommended claim. It is used by
77 * a Relying Party to locate a validation service for the token.
78 * The value is a text string that can be used to locate the
79 * service or a URL specifying the address of the service. The
80 * claim is modeled to be eventually represented by the EAT
81 * standard claim origination. Until such a time as that
82 * standard exists, the claim will be represented by a custom
83 * claim. Value is encoded as text string.
84 *
85 * - Profile definition: Optional, recommended claim. It contains the name of
86 * a document that describes the 'profile' of the token, being
87 * a full description of the claims, their usage, verification
88 * and token signing. The document name may include versioning.
89 * Custom claim with a value encoded as text string.
90 *
91 * - Implementation ID: It represents the original implementation signer of the
92 * attestation key and identifies the contract between the
93 * report and verification. A verification service will use this
94 * claim to locate the details of the verification process.
95 * Custom claim with a value encoded as byte string.
96 *
97 * - Security lifecycle: It represents the current lifecycle state of the
98 * instance. Custom claim with a value encoded as integer that
99 * is divided to convey a major state and a minor state. The
100 * PSA state and implementation state are encoded as follows:
101 * - version[15:8] - PSA lifecycle state - major
102 * - version[7:0] - IMPLEMENTATION DEFINED state - minor
103 * Possible PSA lifecycle states:
104 * - Unknown (0x1000u),
105 * - PSA_RoT_Provisioning (0x2000u),
106 * - Secured (0x3000u),
107 * - Non_PSA_RoT_Debug(0x4000u),
108 * - Recoverable_PSA_RoT_Debug (0x5000u),
109 * - Decommissioned (0x6000u)
110 *
111 * - Client ID: The partition ID of that secure partition or non-secure
112 * thread who called the initial attestation API. Custom claim
113 * with a value encoded as a *signed* integer. Negative number
114 * represents non-secure caller, positive numbers represents
115 * secure callers, zero is invalid.
116 *
117 * - HW version: Optional claim. Globally unique number in EAN-13 format
118 * identifying the GDSII that went to fabrication, HW and ROM.
119 * It can be used to reference the security level of the PSA-ROT
120 * via a certification website. Custom claim with a value is
121 * encoded as text string.
122
123 * - Boot seed: It represents a random value created at system boot time that
124 * will allow differentiation of reports from different system
125 * sessions. The size is 32 bytes. Custom claim with a value is
126 * encoded as byte string.
127 *
128 * - Software components: Recommended claim. It represents the software state
129 * of the system. The value of the claim is an array of CBOR map
130 * entries, with one entry per software component within the
131 * device. Each map contains multiple claims that describe
132 * evidence about the details of the software component.
133 *
134 * - Measurement type: Optional claim. It represents the role of the
135 * software component. Value is encoded as short(!) text
136 * string.
137 *
138 * - Measurement value: It represents a hash of the invariant software
139 * component in memory at start-up time. The value must be a
140 * cryptographic hash of 256 bits or stronger.Value is
141 * encoded as byte string.
142 *
143 * - Version: Optional claim. It represents the issued software version.
144 * Value is encoded as text string.
145 *
146 * - Signer ID: It represents the hash of a signing authority public key.
147 * Value is encoded as byte string.
148 *
149 * - Measurement description: Optional claim. It represents the way in which
150 * the measurement value of the software component is
151 * computed. Value is encoded as text string containing an
152 * abbreviated description (name) of the measurement method.
153 *
154 * - No software measurements: In the event that the implementation does not
155 * contain any software measurements then the software
156 * components claim above can be omitted but instead
157 * it is mandatory to include this claim to indicate this is a
158 * deliberate state. Custom claim a value is encoded as unsigned
159 * integer set to 1.
160 */
161
162/**
163 * \brief Get initial attestation token
164 *
165 * \param[in] auth_challenge Pointer to buffer where challenge input is
166 * stored. Nonce and / or hash of attested data.
167 * Must be always
168 * \ref PSA_INITIAL_ATTEST_TOKEN_SIZE bytes
169 * long.
170 * \param[in] challenge_size Size of challenge object in bytes.
171 * \param[out] token_buf Pointer to the buffer where attestation token
172 * will be stored.
173 * \param[in] token_buf_size Size of allocated buffer for token, in bytes.
174 * \param[out] token_size Size of the token that has been returned, in
175 * bytes.
176 *
177 * \return Returns error code as specified in \ref psa_status_t
178 */
179psa_status_t
180psa_initial_attest_get_token(const uint8_t *auth_challenge,
181 size_t challenge_size,
182 uint8_t *token_buf,
183 size_t token_buf_size,
184 size_t *token_size);
185
186/**
187 * \brief Get the exact size of initial attestation token in bytes.
188 *
189 * It just returns with the size of the IAT token. It can be used if the caller
190 * dynamically allocates memory for the token buffer.
191 *
192 * \param[in] challenge_size Size of challenge object in bytes. This must be
193 * a supported challenge size (as above).
194 * \param[out] token_size Size of the token in bytes, which is created by
195 * initial attestation service.
196 *
197 * \return Returns error code as specified in \ref psa_status_t
198 */
199psa_status_t
200psa_initial_attest_get_token_size(size_t challenge_size,
201 size_t *token_size);
202
Julian Hall201ce462021-04-29 11:05:34 +0100203#ifdef __cplusplus
204}
205#endif
206
207#endif /* __PSA_INITIAL_ATTESTATION_H__ */