Skip to content

Commit

Permalink
ITS: Fix checks for PS usage
Browse files Browse the repository at this point in the history
The check for whether file should be encrypted, and be fully written
missed some PS usage.

Signed-off-by: Vidar Lillebø <vidar.lillebo@nordicsemi.no>
Change-Id: Ifa7fe00e511a6071b2b5c455df84b8e4f0535c84
  • Loading branch information
vili-nordic authored and adeaarm committed Aug 6, 2024
1 parent 77d6b2f commit dc77905
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,20 @@ static psa_status_t buffer_size_check(int32_t client_id, size_t buffer_size)

static psa_status_t tfm_its_crypt_data(int32_t client_id,
uint8_t **input,
size_t input_size)
size_t input_size,
size_t offset)
{
psa_status_t status;
#ifdef TFM_PARTITION_PROTECTED_STORAGE
if (client_id != TFM_SP_PS) {
#else
{
#endif /* TFM_PARTITION_PROTECTED_STORAGE */
if (offset != 0) {
/* If the data will be encrypted the whole file needs to be written */
return PSA_ERROR_INVALID_ARGUMENT;
}

status = tfm_its_crypt_file(&g_file_info,
g_fid,
sizeof(g_fid),
Expand Down Expand Up @@ -392,11 +398,7 @@ static psa_status_t tfm_its_write_data_to_fs(const int32_t client_id,
psa_status_t status;
uint8_t *buffer_ptr = data;
#ifdef ITS_ENCRYPTION /* ITS_ENCRYPTION */
/* If the data will be encrypted the whole file needs to be written */
if (offset != 0) {
return PSA_ERROR_INVALID_ARGUMENT;
}
status = tfm_its_crypt_data(client_id, &buffer_ptr, data_size);
status = tfm_its_crypt_data(client_id, &buffer_ptr, data_size, offset);
if (status != PSA_SUCCESS) {
return status;
}
Expand Down

0 comments on commit dc77905

Please sign in to comment.