blob: 1656615ca734c5a620cb1c323ff1728d3975d5b6 [file] [log] [blame]
Tamas Ban6dfa6eb2018-08-17 12:02:51 +01001/*
2 * Copyright (c) 2018, 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_API_H__
16#define __PSA_INITIAL_ATTESTATION_API_H__
17
18#include "tfm_api.h"
19#include <limits.h>
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25/**
26 * \brief PSA INITIAL ATTESTATION API version
27 */
28#define PSA_INITIAL_ATTEST_API_VERSION_MAJOR (0)
29#define PSA_INITIAL_ATTEST_API_VERSION_MINOR (1)
30
31/* The return value is shared with the TFM partition status value. The ATTEST
32 * return codes shouldn't overlap with predefined TFM status values.
33 */
34#define PSA_ATTEST_ERR_OFFSET (TFM_PARTITION_SPECIFIC_ERROR_MIN)
35
36/**
37 * \enum psa_attest_err_t
38 *
39 * \brief Initial attestation service error types
40 *
41 */
42enum psa_attest_err_t {
43 PSA_ATTEST_ERR_SUCCESS = 0,
44 PSA_ATTEST_ERR_INIT_FAILED = PSA_ATTEST_ERR_OFFSET,
45 PSA_ATTEST_ERR_TOKEN_BUFFER_OVERFLOW,
46 PSA_ATTEST_ERR_CLAIM_UNAVAILABLE,
47 PSA_ATTEST_ERR_INVALID_INPUT,
48 PSA_ATTEST_ERR_GENERAL,
49 /* Following entry is only to ensure the error code of int size */
50 PSA_ATTEST_ERR_FORCE_INT_SIZE = INT_MAX
51};
52
53/**
54 * Maximum size of input challenge in bytes. This can be a nonce from server or
55 * the hash of any data which must be attested to the server.
56 */
57#define PSA_INITIAL_ATTEST_MAX_CHALLENGE_SIZE (64u)
58
59/**
60 * The list of fixed claims in the initial attestation token is still evolving,
61 * you can expect slight changes in the future.
62 *
63 * The initial attestation token is planned to be aligned with later version of
64 * Entity Attestation Token format:
65 * https://tools.ietf.org/html/draft-mandyam-eat-00
66 *
67 * Current list of claims:
68 * - Challenge: Input object from caller. Can be nonce from server or hash of
69 * attested data.
70 * - Client ID: The ID of that secure partition or non-secure thread who
71 * called the initial attestation API.
72 * - Boot status: Measurements(hash) of firmware components by secure
73 * bootloader.
74 * - Boot seed: Random number, which is constant during the same boot cycle.
75 * - Device ID: Universally and globally unique ID of the device.
76 * - HW version: Uniquely identifies the GDSII that went to fabrication, HW
77 * and ROM.
78 */
79
80/**
81 * Calculated based on:
82 * - COSE header
83 * - Algorithm identifier
84 * - Key ID
85 * - Claims in initial attestation token:
86 * - COSE Signature
87 *
88 * This size (in bytes) is a maximum value, actual token size can be smaller.
89 */
90/* FixMe: Just initial value it must be updated if claims are fixed */
91#define PSA_INITIAL_ATTEST_TOKEN_SIZE (512u)
92
93/**
94 * \brief Get initial attestation token
95 *
96 * \param[in] challenge_obj Pointer to buffer where challenge input is
97 * stored. Nonce and / or hash of attested data.
98 * Must be always
99 * \ref PSA_INITIAL_ATTEST_CHALLENGE_SIZE bytes
100 * long.
101 * \param[in] challenge_size Size of challenge object in bytes.
102 * \param[out] token Pointer to the buffer where attestation token
103 * must be stored.
104 * \param[in/out] token_size Size of allocated buffer for token, which
105 * updated by initial attestation service with
106 * final token size.
107 *
108 * \return Returns error code as specified in \ref psa_attest_err_t
109 */
110enum psa_attest_err_t
111psa_initial_attest_get_token(const uint8_t *challenge_obj,
112 uint32_t challenge_size,
113 uint8_t *token,
114 uint32_t *token_size);
115
116#ifdef __cplusplus
117}
118#endif
119
120#endif /* __PSA_INITIAL_ATTESTATION_API_H__ */