TF-M Reference Manual  1.2.0
TrustedFirmware-M
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
attest_token.h
Go to the documentation of this file.
1 /*
2  * attest_token.h
3  *
4  * Copyright (c) 2018-2019, Laurence Lundblade.
5  * Copyright (c) 2020, Arm Limited.
6  *
7  * SPDX-License-Identifier: BSD-3-Clause
8  *
9  * See BSD-3-Clause license in README.md
10  */
11 
12 #ifndef __ATTEST_TOKEN_H__
13 #define __ATTEST_TOKEN_H__
14 
15 #include <stdint.h>
16 #include "qcbor.h"
17 #ifdef SYMMETRIC_INITIAL_ATTESTATION
18 #include "t_cose_mac0_sign.h"
19 #else
20 #include "t_cose_sign1_sign.h"
21 #endif
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 
97 };
98 
99 
100 
107 #define TOKEN_OPT_OMIT_CLAIMS 0x40000000
108 
109 
117 #define TOKEN_OPT_SHORT_CIRCUIT_SIGN 0x80000000
118 
119 
132  /* Private data structure */
133  QCBOREncodeContext cbor_enc_ctx;
134  uint32_t opt_flags;
135  int32_t key_select;
136 #ifdef SYMMETRIC_INITIAL_ATTESTATION
137  struct t_cose_mac0_sign_ctx mac_ctx;
138 #else
139  struct t_cose_sign1_sign_ctx signer_ctx;
140 #endif
141 };
142 
143 
175  uint32_t opt_flags,
176  int32_t key_select,
177  int32_t cose_alg_id,
178  const struct q_useful_buf *out_buffer);
179 
180 
181 
196 QCBOREncodeContext *
198 
207  int32_t label,
208  int64_t value);
209 
218  int32_t label,
219  const struct q_useful_buf_c *value);
220 
229  int32_t label,
230  const struct q_useful_buf_c *value);
231 
244  int32_t label,
245  const struct q_useful_buf_c *encoded);
246 
247 
262  struct q_useful_buf_c *completed_token);
263 
264 
265 #ifdef __cplusplus
266 }
267 #endif
268 
269 #endif /* __ATTEST_TOKEN_H__ */
enum attest_token_err_t attest_token_encode_finish(struct attest_token_encode_ctx *me, struct q_useful_buf_c *completed_token)
Finish the token, complete the signing and get the result.
QCBOREncodeContext cbor_enc_ctx
Definition: attest_token.h:133
void attest_token_encode_add_bstr(struct attest_token_encode_ctx *me, int32_t label, const struct q_useful_buf_c *value)
Add a binary string claim.
attest_token_err_t
Definition: attest_token.h:50
enum attest_token_err_t attest_token_encode_start(struct attest_token_encode_ctx *me, uint32_t opt_flags, int32_t key_select, int32_t cose_alg_id, const struct q_useful_buf *out_buffer)
Initialize a token creation context.
void attest_token_encode_add_integer(struct attest_token_encode_ctx *me, int32_t label, int64_t value)
Add a 64-bit signed integer claim.
void attest_token_encode_add_tstr(struct attest_token_encode_ctx *me, int32_t label, const struct q_useful_buf_c *value)
Add a text string claim.
QCBOREncodeContext * attest_token_encode_borrow_cbor_cntxt(struct attest_token_encode_ctx *me)
Get a copy of the CBOR encoding context.
void attest_token_encode_add_cbor(struct attest_token_encode_ctx *me, int32_t label, const struct q_useful_buf_c *encoded)
Add some already-encoded CBOR to payload.
struct t_cose_sign1_sign_ctx signer_ctx
Definition: attest_token.h:139