TF-M Reference Manual  1.2.0
TrustedFirmware-M
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
tfm_its_ipc_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 "psa/client.h"
12 #include "psa_manifest/sid.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  psa_handle_t handle;
23 
24  psa_invec in_vec[] = {
25  { .base = &uid, .len = sizeof(uid) },
26  { .base = p_data, .len = data_length },
27  { .base = &create_flags, .len = sizeof(create_flags) }
28  };
29 
31  if (!PSA_HANDLE_IS_VALID(handle)) {
33  }
34 
35  status = psa_call(handle, PSA_IPC_CALL, in_vec, IOVEC_LEN(in_vec), NULL, 0);
36 
37  psa_close(handle);
38 
41  }
42 
43  return status;
44 }
45 
47  size_t data_offset,
48  size_t data_size,
49  void *p_data,
50  size_t *p_data_length)
51 {
52  psa_status_t status;
53  psa_handle_t handle;
54 
55  psa_invec in_vec[] = {
56  { .base = &uid, .len = sizeof(uid) },
57  { .base = &data_offset, .len = sizeof(data_offset) }
58  };
59 
60  psa_outvec out_vec[] = {
61  { .base = p_data, .len = data_size }
62  };
63 
64  if (p_data_length == NULL) {
66  }
67 
69  if (!PSA_HANDLE_IS_VALID(handle)) {
71  }
72 
73  status = psa_call(handle, PSA_IPC_CALL, in_vec, IOVEC_LEN(in_vec), out_vec,
74  IOVEC_LEN(out_vec));
75 
76  psa_close(handle);
77 
80  }
81 
82  *p_data_length = out_vec[0].len;
83 
84  return status;
85 }
86 
88  struct psa_storage_info_t *p_info)
89 {
90  psa_status_t status;
91  psa_handle_t handle;
92 
93  psa_invec in_vec[] = {
94  { .base = &uid, .len = sizeof(uid) }
95  };
96 
97  psa_outvec out_vec[] = {
98  { .base = p_info, .len = sizeof(*p_info) }
99  };
100 
102  if (!PSA_HANDLE_IS_VALID(handle)) {
104  }
105 
106  status = psa_call(handle, PSA_IPC_CALL, in_vec, IOVEC_LEN(in_vec), out_vec,
107  IOVEC_LEN(out_vec));
108 
109  psa_close(handle);
110 
111  if (status == (psa_status_t)TFM_ERROR_INVALID_PARAMETER) {
113  }
114 
115  return status;
116 }
117 
119 {
120  psa_status_t status;
121  psa_handle_t handle;
122 
123  psa_invec in_vec[] = {
124  { .base = &uid, .len = sizeof(uid) }
125  };
126 
128  if (!PSA_HANDLE_IS_VALID(handle)) {
130  }
131 
132  status = psa_call(handle, PSA_IPC_CALL, in_vec, IOVEC_LEN(in_vec), NULL, 0);
133 
134  psa_close(handle);
135 
136  return status;
137 }
#define TFM_ITS_GET_INFO_VERSION
Definition: sid.h:35
psa_status_t psa_its_remove(psa_storage_uid_t uid)
Remove the provided uid and its associated data from the storage.
void * base
Definition: client.h:75
#define TFM_ITS_REMOVE_SID
Definition: sid.h:36
void psa_close(psa_handle_t handle)
Close a connection to an RoT Service.
Definition: psa_client.c:63
#define TFM_ITS_GET_SID
Definition: sid.h:32
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 PSA_ERROR_GENERIC_ERROR
Definition: crypto_values.h:43
#define PSA_ERROR_INVALID_ARGUMENT
#define TFM_ITS_GET_INFO_SID
Definition: sid.h:34
#define TFM_ITS_SET_VERSION
Definition: sid.h:31
psa_handle_t psa_connect(uint32_t sid, uint32_t version)
Connect to an RoT Service by its SID.
Definition: psa_client.c:30
#define PSA_HANDLE_IS_VALID(handle)
Definition: client.h:43
#define TFM_ITS_SET_SID
Definition: sid.h:30
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.
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.
#define TFM_ITS_REMOVE_VERSION
Definition: sid.h:37
size_t len
Definition: client.h:76
int32_t psa_handle_t
Definition: client.h:61
uint64_t psa_storage_uid_t
#define IOVEC_LEN(x)
#define PSA_IPC_CALL
Definition: client.h:59
#define TFM_ITS_GET_VERSION
Definition: sid.h:33
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
psa_status_t psa_call(psa_handle_t handle, int32_t type, const psa_invec *in_vec, size_t in_len, psa_outvec *out_vec, size_t out_len)
Call an RoT Service on an established connection.
Definition: psa_client.c:47