12 #include "cmsis_compiler.h"
25 #define PS_OBJECT_SIZE(max_size) (PS_OBJECT_HEADER_SIZE + (max_size))
26 #define PS_OBJECT_START_POSITION 0
41 __attribute__ ((always_inline))
52 obj->header.version = 0;
56 obj->header.info.max_size = size;
57 obj->header.info.create_flags = create_flags;
104 (
void *)&g_ps_object.
header,
123 (
void *)g_ps_object.
data,
151 (
const void *)&g_ps_object,
169 g_obj_tbl_info.tag = g_ps_object.
header.crypto.ref.tag;
176 uint32_t offset, uint32_t size,
177 size_t *p_data_length)
197 goto clear_data_and_return;
203 goto clear_data_and_return;
212 *p_data_length = size;
214 clear_data_and_return:
228 uint32_t fid_am_reserved = 1;
230 #ifndef PS_ENCRYPTION
235 if (size > PS_MAX_ASSET_SIZE) {
252 goto clear_data_and_return;
261 goto clear_data_and_return;
269 old_fid = g_obj_tbl_info.
fid;
277 goto clear_data_and_return;
283 goto clear_data_and_return;
291 &g_obj_tbl_info.
fid);
293 goto clear_data_and_return;
302 err = ps_write_object(wrt_size);
305 goto clear_data_and_return;
318 goto clear_data_and_return;
326 err = ps_remove_old_data(old_fid);
329 clear_data_and_return:
338 uint32_t offset, uint32_t size)
343 #ifndef PS_ENCRYPTION
362 goto clear_data_and_return;
368 goto clear_data_and_return;
376 goto clear_data_and_return;
383 goto clear_data_and_return;
389 goto clear_data_and_return;
398 old_fid = g_obj_tbl_info.
fid;
403 goto clear_data_and_return;
412 err = ps_write_object(wrt_size);
415 goto clear_data_and_return;
428 goto clear_data_and_return;
432 err = ps_remove_old_data(old_fid);
434 clear_data_and_return:
461 goto clear_data_and_return;
468 clear_data_and_return:
494 goto clear_data_and_return;
500 goto clear_data_and_return;
508 goto clear_data_and_return;
512 err = ps_remove_old_data(g_obj_tbl_info.
fid);
514 clear_data_and_return:
psa_status_t ps_encrypted_object_read(uint32_t fid, struct ps_object_t *obj)
Reads object referenced by the object File ID.
psa_status_t ps_object_table_init(uint8_t *obj_data)
Initializes object table.
__STATIC_INLINE void * tfm_memset(void *ptr, int value, size_t num)
#define PS_OBJECT_HEADER_SIZE
uint8_t data[PS_MAX_ASSET_SIZE]
#define PS_MAX_OBJECT_SIZE
__STATIC_INLINE void ps_init_empty_object(psa_storage_create_flags_t create_flags, uint32_t size, struct ps_object_t *obj)
Initialize g_ps_object based on the input parameters and empty data.
#define PSA_STORAGE_FLAG_WRITE_ONCE
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.
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 ps_object_get_info(psa_storage_uid_t uid, int32_t client_id, struct psa_storage_info_t *info)
Gets the asset information for the object with the provided UID and client ID.
psa_status_t ps_object_table_delete_object(psa_storage_uid_t uid, int32_t client_id)
Deletes the table entry for the provided UID and client ID pair.
psa_status_t ps_utils_check_contained_in(uint32_t superset_size, uint32_t subset_offset, uint32_t subset_size)
Checks if a subset region is fully contained within a superset region.
psa_status_t ps_object_table_delete_old_table(void)
Deletes old object table from the persistent area.
#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 PS_OBJECT_SIZE(max_size)
#define PSA_ERROR_NOT_PERMITTED
psa_status_t ps_req_mngr_read_asset_data(uint8_t *out_data, uint32_t size)
Writes the asset data of a client iovec onto an output buffer.
void ps_req_mngr_write_asset_data(const uint8_t *in_data, uint32_t size)
Takes an input buffer containing asset data and writes its contents to the client iovec...
psa_status_t ps_object_table_get_obj_tbl_info(psa_storage_uid_t uid, int32_t client_id, struct ps_obj_table_info_t *obj_tbl_info)
Gets object table information from the object table for the provided UID and client ID pair...
psa_status_t ps_object_delete(psa_storage_uid_t uid, int32_t client_id)
Deletes the object with the provided UID and client ID.
psa_status_t ps_encrypted_object_write(uint32_t fid, struct ps_object_t *obj)
Creates and writes a new encrypted object based on the given ps_object_t structure data...
psa_status_t ps_object_table_get_free_fid(uint32_t fid_num, uint32_t *p_fid)
Gets a not in use file ID.
struct ps_obj_header_t header
uint64_t psa_storage_uid_t
psa_status_t ps_object_create(psa_storage_uid_t uid, int32_t client_id, psa_storage_create_flags_t create_flags, uint32_t size)
Creates a new object with the provided UID and client ID.
#define PS_OBJECT_START_POSITION
psa_status_t ps_object_read(psa_storage_uid_t uid, int32_t client_id, uint32_t offset, uint32_t size, size_t *p_data_length)
Gets the data of the object with the provided UID and client ID.
psa_status_t ps_object_write(psa_storage_uid_t uid, int32_t client_id, uint32_t offset, uint32_t size)
Writes data into the object with the provided UID and client ID.
psa_storage_create_flags_t flags
psa_storage_create_flags_t create_flags
#define PSA_STORAGE_FLAG_NONE
#define PS_UTILS_MIN(x, y)
Evaluates to the minimum of the two parameters.
#define PSA_ERROR_DOES_NOT_EXIST
uint32_t psa_storage_create_flags_t
psa_status_t ps_object_table_create(void)
Creates object table.
int32_t psa_status_t
Function return status.
#define PSA_ERROR_DATA_CORRUPT
psa_status_t ps_object_table_set_obj_tbl_info(psa_storage_uid_t uid, int32_t client_id, const struct ps_obj_table_info_t *obj_tbl_info)
Sets object table information in the object table and stores it persistently, for the provided UID an...
The object to be written to the file system below. Made up of the object header and the object data...
psa_status_t ps_system_wipe_all(void)
Wipes the protected storage system and all object data.
Object table information structure.
#define PS_DEFAULT_EMPTY_BUFF_VAL
psa_status_t ps_system_prepare(void)
Prepares the protected storage system for usage, populating internal structures. It identifies and va...