19 #define PS_ENCRYPT_SIZE(plaintext_size) \
20 ((plaintext_size) + PS_OBJECT_HEADER_SIZE - sizeof(union ps_crypto_t))
22 #define PS_OBJECT_START_POSITION 0
26 #define PS_MAX_ENCRYPTED_OBJ_SIZE PS_ENCRYPT_SIZE(PS_MAX_OBJECT_DATA_SIZE)
31 #define PS_CRYPTO_BUF_LEN (PS_MAX_ENCRYPTED_OBJ_SIZE + PS_TAG_LEN_BYTES)
53 uint8_t *p_obj_data = (uint8_t *)&obj->
header.
info;
61 (void)
tfm_memcpy(ps_crypto_buf, p_obj_data, cur_size);
69 (
const uint8_t *)&fid,
74 sizeof(*obj) -
sizeof(obj->
header.crypto),
100 uint8_t *p_obj_data = (uint8_t *)&obj->
header.
info;
118 (
const uint8_t *)&fid,
123 sizeof(ps_crypto_buf),
130 (void)
tfm_memcpy(p_obj_data, ps_crypto_buf, cur_size);
138 uint32_t decrypt_size;
144 (
void *)obj->
header.crypto.ref.iv,
151 decrypt_size = data_length -
sizeof(obj->
header.crypto.ref.iv);
154 err = ps_object_auth_decrypt(fid, decrypt_size, obj);
170 err = ps_object_auth_encrypt(fid, wrt_size, obj);
175 wrt_size +=
sizeof(obj->
header.crypto.ref.iv);
#define PS_CRYPTO_BUF_LEN
psa_status_t ps_encrypted_object_read(uint32_t fid, struct ps_object_t *obj)
Reads object referenced by the object File ID.
#define PS_ENCRYPT_SIZE(plaintext_size)
#define PS_MAX_OBJECT_SIZE
psa_status_t ps_crypto_setkey(void)
Sets the key to use for crypto operations for the current client.
psa_status_t ps_crypto_encrypt_and_tag(union ps_crypto_t *crypto, const uint8_t *add, size_t add_len, const uint8_t *in, size_t in_len, uint8_t *out, size_t out_size, size_t *out_len)
Encrypts and tags the given plaintext data.
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 PSA_ERROR_GENERIC_ERROR
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_START_POSITION
psa_status_t ps_crypto_auth_and_decrypt(const union ps_crypto_t *crypto, const uint8_t *add, size_t add_len, uint8_t *in, size_t in_len, uint8_t *out, size_t out_size, size_t *out_len)
Decrypts and authenticates the given encrypted data.
__STATIC_INLINE void * tfm_memcpy(void *dest, const void *src, size_t num)
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...
struct ps_obj_header_t header
psa_status_t ps_crypto_destroykey(void)
Destroys the transient key used for crypto operations.
void ps_crypto_get_iv(union ps_crypto_t *crypto)
Gets a new IV value into the crypto union.
#define PSA_STORAGE_FLAG_NONE
int32_t psa_status_t
Function return status.
The object to be written to the file system below. Made up of the object header and the object data...