TF-M Reference Manual  1.2.0
TrustedFirmware-M
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
tfm_audit_func_api.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #include "psa_audit_api.h"
9 #include "tfm_veneers.h"
10 #include "tfm_ns_interface.h"
11 
12 #define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(arr[0]))
13 
14 #define API_DISPATCH(sfn_name) \
15  tfm_ns_interface_dispatch((veneer_fn)tfm_##sfn_name##_veneer, \
16  (uint32_t)in_vec, (uint32_t)ARRAY_SIZE(in_vec), \
17  (uint32_t)out_vec, (uint32_t)ARRAY_SIZE(out_vec))
18 
19 #define API_DISPATCH_NO_INVEC(sfn_name) \
20  tfm_ns_interface_dispatch((veneer_fn)tfm_##sfn_name##_veneer, \
21  (uint32_t)NULL, 0, \
22  (uint32_t)out_vec, (uint32_t)ARRAY_SIZE(out_vec))
23 
24 #define API_DISPATCH_NO_OUTVEC(sfn_name) \
25  tfm_ns_interface_dispatch((veneer_fn)tfm_##sfn_name##_veneer, \
26  (uint32_t)in_vec, (uint32_t)ARRAY_SIZE(in_vec), \
27  (uint32_t)NULL, 0)
28 
29 psa_status_t psa_audit_retrieve_record(const uint32_t record_index,
30  const uint32_t buffer_size,
31  const uint8_t *token,
32  const uint32_t token_size,
33  uint8_t *buffer,
34  uint32_t *record_size)
35 {
36  psa_status_t status;
37  psa_invec in_vec[] = {
38  {.base = &record_index, .len = sizeof(uint32_t)},
39  {.base = token, .len = token_size},
40  };
41  psa_outvec out_vec[] = {
42  {.base = buffer, .len = buffer_size},
43  };
44 
46 
47  *record_size = out_vec[0].len;
48 
49  return status;
50 }
51 
52 psa_status_t psa_audit_get_info(uint32_t *num_records, uint32_t *size)
53 {
54  psa_status_t status;
55  psa_outvec out_vec[] = {
56  {.base = num_records, .len = sizeof(uint32_t)},
57  {.base = size, .len = sizeof(uint32_t)},
58  };
59 
61 
62  return status;
63 }
64 
65 psa_status_t psa_audit_get_record_info(const uint32_t record_index,
66  uint32_t *size)
67 {
68  psa_status_t status;
69  psa_invec in_vec[] = {
70  {.base = &record_index, .len = sizeof(uint32_t)},
71  };
72  psa_outvec out_vec[] = {
73  {.base = size, .len = sizeof(uint32_t)},
74  };
75 
77 
78  return status;
79 }
80 
81 psa_status_t psa_audit_delete_record(const uint32_t record_index,
82  const uint8_t *token,
83  const uint32_t token_size)
84 {
85  psa_status_t status;
86  psa_invec in_vec[] = {
87  {.base = &record_index, .len = sizeof(uint32_t)},
88  {.base = token, .len = token_size},
89  };
90 
92 
93  return status;
94 }
95 
97 {
98  /* This API supports only Secure world calls. As this is the implementation
99  * of the Non-Secure interface, always directly return an error without
100  * routing the call to TF-M in the Secure world.
101  */
102  (void)record;
104 }
void * base
Definition: client.h:75
psa_status_t psa_audit_get_info(uint32_t *num_records, uint32_t *size)
Returns the total number and size of the records stored.
psa_status_t audit_core_delete_record(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
Definition: audit_core.c:491
#define API_DISPATCH(sfn_name)
This structure contains the record that is added to the audit log by the requesting secure service...
#define PSA_ERROR_NOT_PERMITTED
Definition: crypto_values.h:65
psa_status_t psa_audit_delete_record(const uint32_t record_index, const uint8_t *token, const uint32_t token_size)
Deletes a record at the specified index.
size_t len
Definition: client.h:76
psa_status_t psa_audit_retrieve_record(const uint32_t record_index, const uint32_t buffer_size, const uint8_t *token, const uint32_t token_size, uint8_t *buffer, uint32_t *record_size)
Retrieves a record at the specified index.
psa_status_t audit_core_get_info(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
Definition: audit_core.c:560
#define API_DISPATCH_NO_OUTVEC(sfn_name)
psa_status_t audit_core_retrieve_record(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
Definition: audit_core.c:730
psa_status_t psa_audit_get_record_info(const uint32_t record_index, uint32_t *size)
Returns the size of the record at the specified index.
const void * base
Definition: client.h:67
int32_t psa_status_t
Function return status.
Definition: crypto_types.h:43
#define API_DISPATCH_NO_INVEC(sfn_name)
psa_status_t psa_audit_add_record(const struct psa_audit_record *record)
Adds a record.
psa_status_t audit_core_get_record_info(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
Definition: audit_core.c:586