Skip to content

Commit 05b73d2

Browse files
committed
[nrf noup] ITS: fix aad_size parameter spelling
This is a noup because the upstream commit 77aabb7 (from the main branch) does not apply cleanly. Fix the use of the aad_size struct parameter in Nordic's ITS encryption HAL. In addition, fix the remaining use of add/add_size as parameter names in the ITS partition code. Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
1 parent 6d82e72 commit 05b73d2

2 files changed

Lines changed: 16 additions & 18 deletions

File tree

platform/ext/target/nordic_nrf/common/core/tfm_hal_its_encryption_cracen.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ static bool ctx_is_valid(struct tfm_hal_its_auth_crypt_ctx *ctx)
103103
}
104104

105105
ret = (ctx->deriv_label == NULL && ctx->deriv_label_size != 0) ||
106-
(ctx->aad == NULL && ctx->add_size != 0) ||
106+
(ctx->aad == NULL && ctx->aad_size != 0) ||
107107
(ctx->nonce == NULL && ctx->nonce_size != 0);
108108

109109
return !ret;
@@ -166,7 +166,7 @@ psa_status_t tfm_hal_its_get_aead(struct tfm_hal_its_auth_crypt_ctx *ctx,
166166
return status;
167167
}
168168

169-
status = cracen_aead_update_ad(&operation, ctx->aad, ctx->add_size);
169+
status = cracen_aead_update_ad(&operation, ctx->aad, ctx->aad_size);
170170
if (status != PSA_SUCCESS) {
171171
return status;
172172
}

secure_fw/partitions/internal_trusted_storage/its_crypto_interface.c

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,25 @@
2020
/**
2121
* \brief Fills the AEAD additional data used for the encryption/decryption
2222
*
23-
* \details The additional data are not encypted their integrity is checked.
23+
* \details The additional data is not encrypted but its integrity is checked.
2424
* For the ITS encryption we use the file id, the file flags and the
2525
* data size of the file as addditional data.
2626
*
27-
* \param[out] add Additional data
28-
* \param[in] add_size Additional data size in bytes
27+
* \param[out] aad Additional authenticated data
28+
* \param[in] aad_size Additional authenticated data size in bytes
2929
* \param[in] fid Identifier of the file
3030
* \param[in] fid_size Identifier of the file size in bytes
3131
* \param[in] flags Flags of the file
3232
* \param[in] data_size Data size in bytes
3333
*
3434
* \retval PSA_SUCCESS On success
35-
* \retval PSA_ERROR_INVALID_ARGUMENT When the addditional data buffer does not
36-
* have the correct size of the add/fid
35+
* \retval PSA_ERROR_INVALID_ARGUMENT When the additional data buffer does not
36+
* have the correct size or the aad/fid
3737
* buffers are NULL
3838
*
3939
*/
40-
static psa_status_t tfm_its_fill_enc_add(uint8_t *add,
41-
const size_t add_size,
40+
static psa_status_t tfm_its_fill_enc_add(uint8_t *aad,
41+
const size_t aad_size,
4242
const uint8_t *fid,
4343
const size_t fid_size,
4444
const uint32_t flags,
@@ -49,22 +49,21 @@ static psa_status_t tfm_its_fill_enc_add(uint8_t *add,
4949
* gets the file info from ITS (see its_flash_fs_file_get_info).
5050
* We use the same flags for conformity.
5151
*/
52-
uint32_t user_flags = flags & ITS_FLASH_FS_USER_FLAGS_MASK;
52+
const uint32_t user_flags = flags & ITS_FLASH_FS_USER_FLAGS_MASK;
5353

5454
/* The additional data consist of the file id, the flags and the
5555
* data size of the file.
5656
*/
57-
size_t add_expected_size = ITS_FILE_ID_SIZE +
58-
sizeof(user_flags) +
59-
sizeof(data_size);
57+
const size_t aad_expected_size =
58+
ITS_FILE_ID_SIZE + sizeof(user_flags) + sizeof(data_size);
6059

61-
if (add_size != add_expected_size || add == NULL || fid == NULL) {
60+
if ((aad_size != aad_expected_size) || (aad == NULL) || (fid == NULL)) {
6261
return PSA_ERROR_INVALID_ARGUMENT;
6362
}
6463

65-
memcpy(add, fid, fid_size);
66-
memcpy(add + fid_size, &user_flags, sizeof(user_flags));
67-
memcpy(add + fid_size + sizeof(user_flags),
64+
memcpy(aad, fid, fid_size);
65+
memcpy(aad + fid_size, &user_flags, sizeof(user_flags));
66+
memcpy(aad + fid_size + sizeof(user_flags),
6867
&data_size,
6968
sizeof(data_size));
7069

@@ -163,4 +162,3 @@ psa_status_t tfm_its_crypt_file(struct its_flash_fs_file_info_t *finfo,
163162

164163
return PSA_SUCCESS;
165164
}
166-

0 commit comments

Comments
 (0)