#include "ps_object_table.h"
#include <stddef.h>
#include "cmsis_compiler.h"
#include "crypto/ps_crypto_interface.h"
#include "flash_layout.h"
#include "nv_counters/ps_nv_counters.h"
#include "psa/internal_trusted_storage.h"
#include "tfm_memory_utils.h"
#include "ps_utils.h"
#include "tfm_ps_defs.h"
Go to the source code of this file.
#define PS_CRYPTO_ASSOCIATED_DATA |
( |
|
crypto | ) |
|
Value:((uint8_t *)crypto + \
#define PS_NON_AUTH_OBJ_TABLE_SIZE
Definition at line 147 of file ps_object_table.c.
#define PS_CRYPTO_ASSOCIATED_DATA_LEN |
Value:
#define PS_OBJ_TABLE_SIZE
#define PS_NON_AUTH_OBJ_TABLE_SIZE
Definition at line 164 of file ps_object_table.c.
#define PS_FLASH_DEFAULT_VAL 0xFFU |
#define PS_INVALID_NVC_VALUE 0 |
#define PS_NON_AUTH_OBJ_TABLE_SIZE sizeof(union ps_crypto_t) |
#define PS_NUM_OBJ_TABLES 2 |
#define PS_OBJ_TABLE_ENTRIES (PS_NUM_ASSETS + 1) |
#define PS_OBJ_TABLE_IDX_0 0 |
#define PS_OBJ_TABLE_IDX_1 1 |
#define PS_OBJECT_FS_ID |
( |
|
idx | ) |
|
Value:((idx + 1) + \
#define PS_TABLE_FS_ID(idx)
File ID to be used in order to store the object table in the file system.
#define PS_OBJ_TABLE_IDX_1
File ID to be used in order to store an object in the file system.
- Parameters
-
[in] | idx | Object table index to convert into a file ID. |
- Returns
- Returns file ID
Definition at line 105 of file ps_object_table.c.
#define PS_OBJECT_FS_ID_TO_IDX |
( |
|
fid | ) |
|
Value:((fid - 1) - \
#define PS_TABLE_FS_ID(idx)
File ID to be used in order to store the object table in the file system.
#define PS_OBJ_TABLE_IDX_1
Gets object index in the table based on the file ID.
- Parameters
-
[in] | fid | File ID of an object in the object table |
- Returns
- Returns object table index
Definition at line 117 of file ps_object_table.c.
#define PS_OBJECT_SYSTEM_VERSION 0x01 |
#define PS_OBJECT_TABLE_OBJECT_OFFSET 0 |
#define PS_TABLE_FS_ID |
( |
|
idx | ) |
(idx + 1) |
File ID to be used in order to store the object table in the file system.
- Parameters
-
[in] | idx | Table index to convert into a file ID. |
- Returns
- Returns file ID
Definition at line 93 of file ps_object_table.c.
typedef char OBJ_TABLE_NOT_FIT_IN_STATIC_OBJ_DATA_BUF[(sizeof(struct ps_obj_table_t)<=PS_MAX_ASSET_SIZE)*2-1] |
Enumerator |
---|
PS_OBJ_TABLE_VALID |
Table content is valid
|
PS_OBJ_TABLE_INVALID |
Table content is invalid
|
PS_OBJ_TABLE_NVC_1_VALID |
Table content valid with NVC 1 value
|
PS_OBJ_TABLE_NVC_3_VALID |
Table content valid with NVC 3 value
|
Definition at line 180 of file ps_object_table.c.
Deletes the table entry for the provided UID and client ID pair.
- Parameters
-
[in] | uid | Identifier for the data. |
[in] | client_id | Identifier of the asset’s owner (client) |
- Returns
- Returns error code as specified in psa_status_t
Definition at line 1020 of file ps_object_table.c.
Reads object table from persistent memory.
- Parameters
-
[out] | init_ctx | Pointer to the init object table context |
Definition at line 218 of file ps_object_table.c.
Writes object table in persistent memory.
- Parameters
-
[in,out] | obj_table | Pointer to the object table to generate authentication |
- Returns
- Returns error code as specified in psa_status_t
Definition at line 255 of file ps_object_table.c.
psa_status_t ps_object_table_get_free_fid |
( |
uint32_t |
fid_num, |
|
|
uint32_t * |
p_fid |
|
) |
| |
Gets a not in use file ID.
- Parameters
-
[in] | fid_num | Amount of file IDs that the function will check are free before returning one. 0 is an invalid input and will error. Note that this function will only ever return 1 file ID. |
[out] | p_fid | Pointer to the location to store the file ID |
- Returns
- Returns PSA_SUCCESS if the fid is valid and fid_num - 1 entries are still free in the table. Otherwise, it returns an error code as specified in psa_status_t
Definition at line 908 of file ps_object_table.c.
Gets object table information from the object table for the provided UID and client ID pair.
- Parameters
-
[in] | uid | Identifier for the data. |
[in] | client_id | Identifier of the asset’s owner (client) |
[out] | obj_tbl_info | Pointer to the location to store object table information |
- Returns
- Returns PSA_SUCCESS if the object exists. Otherwise, it returns PSA_ERROR_DOES_NOT_EXIST.
Definition at line 995 of file ps_object_table.c.
Initializes object table.
- Parameters
-
[in,out] | obj_data | Pointer to the static object data allocated in other to reuse that memory to allocated a temporary object table. |
- Returns
- Returns error code as specified in psa_status_t
Definition at line 829 of file ps_object_table.c.
Checks if there is an entry in the table for the provided UID and client ID pair.
- Parameters
-
[in] | uid | Identifier for the data |
[in] | client_id | Identifier of the asset’s owner (client) |
- Returns
- Returns error code as specified in psa_status_t
- Return values
-
PSA_SUCCESS | If there is a table entry for the object |
PSA_ERROR_DOES_NOT_EXIST | If no table entry exists for the object |
Definition at line 900 of file ps_object_table.c.
Sets object table information in the object table and stores it persistently, for the provided UID and client ID pair.
- Parameters
-
[in] | uid | Identifier for the data. |
[in] | client_id | Identifier of the asset’s owner (client) |
[in] | obj_tbl_info | Pointer to the location to store object table information ps_obj_table_info_t |
- Note
- A call to this function results in writing the table to the file system.
- Returns
- Returns error code as specified in psa_status_t
Definition at line 939 of file ps_object_table.c.
Checks the validity of the table version.
- Parameters
-
[in,out] | init_ctx | Pointer to the init object table context |
Definition at line 597 of file ps_object_table.c.
__STATIC_INLINE psa_status_t ps_table_free_idx |
( |
uint32_t |
idx_num, |
|
|
uint32_t * |
idx |
|
) |
| |
Gets free index in the table.
- Parameters
-
[in] | idx_num | The number of indices required to be free before one can be allocated. Primarily used to prevent index exhaustion.Note that this function will only ever return 1 index. |
[out] | idx | Pointer to store the free index |
- Note
- The table is dimensioned to fit PS_NUM_ASSETS + 1
- Returns
- Returns PSA_SUCCESS and a table index if idx_num free indices are available. Otherwise, it returns PSA_ERROR_INSUFFICIENT_STORAGE.
Definition at line 770 of file ps_object_table.c.