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