TF-M Reference Manual  1.2.0
TrustedFirmware-M
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
tfm_initial_attestation_func_api.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
9 #include "tfm_veneers.h"
10 #include "tfm_ns_interface.h"
11 #include "psa/client.h"
12 #include "psa/crypto_types.h"
13 
14 #define IOVEC_LEN(x) (sizeof(x)/sizeof(x[0]))
15 
17 psa_initial_attest_get_token(const uint8_t *auth_challenge,
18  size_t challenge_size,
19  uint8_t *token_buf,
20  size_t token_buf_size,
21  size_t *token_size)
22 {
23 
24  int32_t res;
25 
26  psa_invec in_vec[] = {
27  {auth_challenge, challenge_size}
28  };
29  psa_outvec out_vec[] = {
30  {token_buf, token_buf_size}
31  };
32 
34  (veneer_fn)tfm_initial_attest_get_token_veneer,
35  (uint32_t)in_vec, IOVEC_LEN(in_vec),
36  (uint32_t)out_vec, IOVEC_LEN(out_vec));
37 
38  if (res == (int32_t)PSA_SUCCESS) {
39  *token_size = out_vec[0].len;
40  }
41 
42  return res;
43 }
44 
46 psa_initial_attest_get_token_size(size_t challenge_size,
47  size_t *token_size)
48 {
49  psa_invec in_vec[] = {
50  {&challenge_size, sizeof(challenge_size)}
51  };
52  psa_outvec out_vec[] = {
53  {token_size, sizeof(size_t)}
54  };
55 
57  (veneer_fn)tfm_initial_attest_get_token_size_veneer,
58  (uint32_t)in_vec, IOVEC_LEN(in_vec),
59  (uint32_t)out_vec, IOVEC_LEN(out_vec));
60 }
61 
64  size_t public_key_buf_size,
65  size_t *public_key_len,
66  psa_ecc_family_t *elliptic_curve_type)
67 {
68  int32_t res;
69 
70  psa_outvec out_vec[] = {
71  {.base = public_key, .len = public_key_buf_size},
72  {.base = elliptic_curve_type, .len = sizeof(*elliptic_curve_type)},
73  {.base = public_key_len, .len = sizeof(*public_key_len)}
74  };
75 
77  (veneer_fn)tfm_initial_attest_get_public_key_veneer,
78  (uint32_t)NULL, 0,
79  (uint32_t)out_vec, IOVEC_LEN(out_vec));
80 
81  return (psa_status_t) res;
82 }
void * base
Definition: client.h:75
#define PSA_SUCCESS
Definition: crypto_values.h:35
PSA cryptography module: type aliases.
int32_t(* veneer_fn)(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint32_t arg3)
#define IOVEC_LEN(x)
int32_t tfm_ns_interface_dispatch(veneer_fn fn, uint32_t arg0, uint32_t arg1, uint32_t arg2, uint32_t arg3)
NS interface, veneer function dispatcher.
psa_status_t psa_initial_attest_get_token(const uint8_t *auth_challenge, size_t challenge_size, uint8_t *token_buf, size_t token_buf_size, size_t *token_size)
Get initial attestation token.
psa_status_t psa_initial_attest_get_token_size(size_t challenge_size, size_t *token_size)
Get the exact size of initial attestation token in bytes.
psa_status_t tfm_initial_attest_get_public_key(uint8_t *public_key, size_t public_key_buf_size, size_t *public_key_len, psa_ecc_family_t *elliptic_curve_type)
Get the initial attestation public key.
uint8_t psa_ecc_family_t
Definition: crypto_types.h:69
int32_t psa_status_t
Function return status.
Definition: crypto_types.h:43