blob: aa4a414da41ee9120d8d979f35766df4c5a6672b [file] [log] [blame]
Tamas Ban6dfa6eb2018-08-17 12:02:51 +01001/*
Raef Coles793574c2019-10-09 10:59:42 +01002 * Copyright (c) 2018-2020, 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
Jamie Foxcc31d402019-01-28 17:13:52 +000015#ifndef __PSA_INITIAL_ATTESTATION_H__
16#define __PSA_INITIAL_ATTESTATION_H__
Tamas Ban6dfa6eb2018-08-17 12:02:51 +010017
Tamas Ban6dfa6eb2018-08-17 12:02:51 +010018#include <limits.h>
Tamas Baneccae9d2019-01-09 15:54:56 +000019#include <stdint.h>
David Vincze20c3e4e2019-11-11 11:16:06 +010020#include <stddef.h>
21#include "psa/crypto.h"
Tamas Ban6dfa6eb2018-08-17 12:02:51 +010022
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27/**
28 * \brief PSA INITIAL ATTESTATION API version
Tamas Ban8bdd4582019-02-18 10:57:31 +000029 *
30 * Initial attestation API version is: 1.0-beta-0
Tamas Ban6dfa6eb2018-08-17 12:02:51 +010031 */
Tamas Ban8bdd4582019-02-18 10:57:31 +000032#define PSA_INITIAL_ATTEST_API_VERSION_MAJOR (1)
33#define PSA_INITIAL_ATTEST_API_VERSION_MINOR (0)
Tamas Ban6dfa6eb2018-08-17 12:02:51 +010034
Tamas Ban6dfa6eb2018-08-17 12:02:51 +010035/**
Tamas Ban52d4a8e2019-01-04 22:45:39 +000036 * The allowed size of input challenge in bytes: 32, 48, 64
37 * Challenge can be a nonce from server
38 * or the hash of some combined data : nonce + attested data by caller.
Tamas Ban6dfa6eb2018-08-17 12:02:51 +010039 */
Tamas Ban52d4a8e2019-01-04 22:45:39 +000040#define PSA_INITIAL_ATTEST_CHALLENGE_SIZE_32 (32u)
41#define PSA_INITIAL_ATTEST_CHALLENGE_SIZE_48 (48u)
42#define PSA_INITIAL_ATTEST_CHALLENGE_SIZE_64 (64u)
43
Tamas Ban6dfa6eb2018-08-17 12:02:51 +010044/**
45 * The list of fixed claims in the initial attestation token is still evolving,
46 * you can expect slight changes in the future.
47 *
Tamas Ban52d4a8e2019-01-04 22:45:39 +000048 * The initial attestation token is planned to be aligned with future version of
Tamas Ban6dfa6eb2018-08-17 12:02:51 +010049 * Entity Attestation Token format:
Tamas Ban52d4a8e2019-01-04 22:45:39 +000050 * https://tools.ietf.org/html/draft-mandyam-eat-01
Tamas Ban6dfa6eb2018-08-17 12:02:51 +010051 *
52 * Current list of claims:
Tamas Ban52d4a8e2019-01-04 22:45:39 +000053 * - Challenge: Input object from caller. Can be a single nonce from server
54 * or hash of nonce and attested data. It is intended to provide
55 * freshness to reports and the caller has responsibility to
56 * arrange this. Allowed length: 32, 48, 64 bytes. The claim is
57 * modeled to be eventually represented by the EAT standard
58 * claim nonce. Until such a time as that standard exists,
59 * the claim will be represented by a custom claim. Value
60 * is encoded as byte string.
61 *
62 * - Instance ID: It represents the unique identifier of the instance. In the
63 * PSA definition it is a hash of the public attestation key
64 * of the instance. The claim is modeled to be eventually
65 * represented by the EAT standard claim UEID of type GUID.
66 * Until such a time as that standard exists, the claim will be
67 * represented by a custom claim Value is encoded as byte
68 * string.
69 *
70 * - Verification service indicator: Optional, recommended claim. It is used by
71 * a Relying Party to locate a validation service for the token.
72 * The value is a text string that can be used to locate the
73 * service or a URL specifying the address of the service. The
74 * claim is modeled to be eventually represented by the EAT
75 * standard claim origination. Until such a time as that
76 * standard exists, the claim will be represented by a custom
77 * claim. Value is encoded as text string.
78 *
79 * - Profile definition: Optional, recommended claim. It contains the name of
80 * a document that describes the 'profile' of the token, being
81 * a full description of the claims, their usage, verification
82 * and token signing. The document name may include versioning.
83 * Custom claim with a value encoded as text string.
84 *
85 * - Implementation ID: It represents the original implementation signer of the
86 * attestation key and identifies the contract between the
87 * report and verification. A verification service will use this
88 * claim to locate the details of the verification process.
89 * Custom claim with a value encoded as byte string.
90 *
91 * - Security lifecycle: It represents the current lifecycle state of the
92 * instance. Custom claim with a value encoded as integer that
93 * is divided to convey a major state and a minor state. The
94 * PSA state and implementation state are encoded as follows:
95 * - version[15:8] - PSA lifecycle state - major
96 * - version[7:0] - IMPLEMENTATION DEFINED state - minor
97 * Possible PSA lifecycle states:
98 * - Unknown (0x1000u),
99 * - PSA_RoT_Provisioning (0x2000u),
100 * - Secured (0x3000u),
101 * - Non_PSA_RoT_Debug(0x4000u),
102 * - Recoverable_PSA_RoT_Debug (0x5000u),
103 * - Decommissioned (0x6000u)
104 *
105 * - Client ID: The partition ID of that secure partition or non-secure
106 * thread who called the initial attestation API. Custom claim
107 * with a value encoded as a *signed* integer. Negative number
108 * represents non-secure caller, positive numbers represents
109 * secure callers, zero is invalid.
110 *
111 * - HW version: Optional claim. Globally unique number in EAN-13 format
112 * identifying the GDSII that went to fabrication, HW and ROM.
113 * It can be used to reference the security level of the PSA-ROT
114 * via a certification website. Custom claim with a value is
115 * encoded as text string.
116
117 * - Boot seed: It represents a random value created at system boot time that
118 * will allow differentiation of reports from different system
119 * sessions. The size is 32 bytes. Custom claim with a value is
120 * encoded as byte string.
121 *
122 * - Software components: Recommended claim. It represents the software state
123 * of the system. The value of the claim is an array of CBOR map
124 * entries, with one entry per software component within the
125 * device. Each map contains multiple claims that describe
126 * evidence about the details of the software component.
127 *
128 * - Measurement type: Optional claim. It represents the role of the
129 * software component. Value is encoded as short(!) text
130 * string.
131 *
132 * - Measurement value: It represents a hash of the invariant software
133 * component in memory at start-up time. The value must be a
134 * cryptographic hash of 256 bits or stronger.Value is
135 * encoded as byte string.
136 *
Tamas Ban52d4a8e2019-01-04 22:45:39 +0000137 * - Version: Optional claim. It represents the issued software version.
138 * Value is encoded as text string.
139 *
140 * - Signer ID: It represents the hash of a signing authority public key.
141 * Value is encoded as byte string.
142 *
143 * - Measurement description: Optional claim. It represents the way in which
144 * the measurement value of the software component is
145 * computed. Value is encoded as text string containing an
146 * abbreviated description (name) of the measurement method.
147 *
148 * - No software measurements: In the event that the implementation does not
149 * contain any software measurements then the software
150 * components claim above can be omitted but instead
151 * it is mandatory to include this claim to indicate this is a
152 * deliberate state. Custom claim a value is encoded as unsigned
153 * integer set to 1.
Tamas Ban6dfa6eb2018-08-17 12:02:51 +0100154 */
155
156/**
Tamas Ban6dfa6eb2018-08-17 12:02:51 +0100157 * \brief Get initial attestation token
158 *
159 * \param[in] challenge_obj Pointer to buffer where challenge input is
160 * stored. Nonce and / or hash of attested data.
161 * Must be always
Gyorgy Szing40a7af02019-02-06 14:19:47 +0100162 * \ref PSA_INITIAL_ATTEST_TOKEN_SIZE bytes
Tamas Ban6dfa6eb2018-08-17 12:02:51 +0100163 * long.
164 * \param[in] challenge_size Size of challenge object in bytes.
165 * \param[out] token Pointer to the buffer where attestation token
166 * must be stored.
Gyorgy Szing40a7af02019-02-06 14:19:47 +0100167 * \param[in,out] token_size Size of allocated buffer for token, which
Tamas Ban6dfa6eb2018-08-17 12:02:51 +0100168 * updated by initial attestation service with
169 * final token size.
170 *
Raef Coles793574c2019-10-09 10:59:42 +0100171 * \return Returns error code as specified in \ref psa_status_t
Tamas Ban6dfa6eb2018-08-17 12:02:51 +0100172 */
Raef Coles793574c2019-10-09 10:59:42 +0100173psa_status_t
Tamas Ban6dfa6eb2018-08-17 12:02:51 +0100174psa_initial_attest_get_token(const uint8_t *challenge_obj,
175 uint32_t challenge_size,
176 uint8_t *token,
177 uint32_t *token_size);
178
Tamas Ban52d4a8e2019-01-04 22:45:39 +0000179/**
180 * \brief Get the exact size of initial attestation token in bytes.
181 *
182 * It just returns with the size of the IAT token. It can be used if the caller
183 * dynamically allocates memory for the token buffer.
184 *
185 * \param[in] challenge_size Size of challenge object in bytes.
186 * \param[out] token_size Size of the token in bytes, which is created by
187 * initial attestation service.
188 *
Raef Coles793574c2019-10-09 10:59:42 +0100189 * \return Returns error code as specified in \ref psa_status_t
Tamas Ban52d4a8e2019-01-04 22:45:39 +0000190 */
Raef Coles793574c2019-10-09 10:59:42 +0100191psa_status_t
Tamas Ban52d4a8e2019-01-04 22:45:39 +0000192psa_initial_attest_get_token_size(uint32_t challenge_size,
193 uint32_t *token_size);
194
David Vincze20c3e4e2019-11-11 11:16:06 +0100195/**
196 * \brief Get the initial attestation public key.
197 *
198 * \param[out] public_key Pointer to the buffer where the public key
199 * will be stored.
200 * \param[in] key_buf_size Size of allocated buffer for key, in bytes.
201 * \param[out] public_key_len Size of public key in bytes.
202 * \param[out] public_key_curve Type of the elliptic curve which the key
203 * belongs to.
204 *
205 * \note Currently only the ECDSA P-256 over SHA-256 algorithm is supported.
206 *
Raef Coles793574c2019-10-09 10:59:42 +0100207 * \return Returns error code as specified in \ref psa_status_t
David Vincze20c3e4e2019-11-11 11:16:06 +0100208 */
Raef Coles793574c2019-10-09 10:59:42 +0100209psa_status_t
David Vincze20c3e4e2019-11-11 11:16:06 +0100210tfm_initial_attest_get_public_key(uint8_t *public_key,
211 size_t public_key_buf_size,
212 size_t *public_key_len,
213 psa_ecc_curve_t *elliptic_curve_type);
214
Tamas Ban6dfa6eb2018-08-17 12:02:51 +0100215#ifdef __cplusplus
216}
217#endif
218
Jamie Foxcc31d402019-01-28 17:13:52 +0000219#endif /* __PSA_INITIAL_ATTESTATION_H__ */