TF-M Reference Manual  1.2.0
TrustedFirmware-M
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
tfm_its_func_api.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
9 #include "tfm_api.h"
10 
11 #include "tfm_ns_interface.h"
12 #include "tfm_veneers.h"
13 
14 #define IOVEC_LEN(x) (sizeof(x)/sizeof(x[0]))
15 
17  size_t data_length,
18  const void *p_data,
19  psa_storage_create_flags_t create_flags)
20 {
21  psa_status_t status;
22 
23  psa_invec in_vec[] = {
24  { .base = &uid, .len = sizeof(uid) },
25  { .base = p_data, .len = data_length },
26  { .base = &create_flags, .len = sizeof(create_flags) }
27  };
28 
29  status = tfm_ns_interface_dispatch((veneer_fn)tfm_tfm_its_set_req_veneer,
30  (uint32_t)in_vec, IOVEC_LEN(in_vec),
31  (uint32_t)NULL, 0);
32 
35  }
36 
37  return status;
38 }
39 
41  size_t data_offset,
42  size_t data_size,
43  void *p_data,
44  size_t *p_data_length)
45 {
46  psa_status_t status;
47 
48  psa_invec in_vec[] = {
49  { .base = &uid, .len = sizeof(uid) },
50  { .base = &data_offset, .len = sizeof(data_offset) }
51  };
52 
53  psa_outvec out_vec[] = {
54  { .base = p_data, .len = data_size }
55  };
56 
57  if (p_data_length == NULL) {
59  }
60 
61  status = tfm_ns_interface_dispatch((veneer_fn)tfm_tfm_its_get_req_veneer,
62  (uint32_t)in_vec, IOVEC_LEN(in_vec),
63  (uint32_t)out_vec, IOVEC_LEN(out_vec));
64 
67  }
68 
69  *p_data_length = out_vec[0].len;
70 
71  return status;
72 }
73 
75  struct psa_storage_info_t *p_info)
76 {
77  psa_status_t status;
78 
79  psa_invec in_vec[] = {
80  { .base = &uid, .len = sizeof(uid) }
81  };
82 
83  psa_outvec out_vec[] = {
84  { .base = p_info, .len = sizeof(*p_info) }
85  };
86 
88  (veneer_fn)tfm_tfm_its_get_info_req_veneer,
89  (uint32_t)in_vec, IOVEC_LEN(in_vec),
90  (uint32_t)out_vec, IOVEC_LEN(out_vec));
91 
94  }
95 
96  return status;
97 }
98 
100 {
101  psa_invec in_vec[] = {
102  { .base = &uid, .len = sizeof(uid) }
103  };
104 
105  return tfm_ns_interface_dispatch((veneer_fn)tfm_tfm_its_remove_req_veneer,
106  (uint32_t)in_vec, IOVEC_LEN(in_vec),
107  (uint32_t)NULL, 0);
108 }
psa_status_t psa_its_get(psa_storage_uid_t uid, size_t data_offset, size_t data_size, void *p_data, size_t *p_data_length)
Retrieve data associated with a provided UID.
void * base
Definition: client.h:75
psa_status_t psa_its_remove(psa_storage_uid_t uid)
Remove the provided uid and its associated data from the storage.
psa_status_t psa_its_get_info(psa_storage_uid_t uid, struct psa_storage_info_t *p_info)
Retrieve the metadata about the provided uid.
int32_t(* veneer_fn)(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint32_t arg3)
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.
#define PSA_ERROR_INVALID_ARGUMENT
psa_status_t psa_its_set(psa_storage_uid_t uid, size_t data_length, const void *p_data, psa_storage_create_flags_t create_flags)
Create a new, or modify an existing, uid/value pair.
#define IOVEC_LEN(x)
uint64_t psa_storage_uid_t
const void * base
Definition: client.h:67
uint32_t psa_storage_create_flags_t
int32_t psa_status_t
Function return status.
Definition: crypto_types.h:43