Skip to content

Commit 67d1db0

Browse files
[doc] clarify buffer sizing due to hidden overhead bytes
1 parent 6973f32 commit 67d1db0

8 files changed

Lines changed: 99 additions & 32 deletions

File tree

services/stsafea/stsafea_aes.h

Lines changed: 58 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@
4343
* \details This service format and send encrypt command in AES ECB mode
4444
* \param[in] pSTSE Pointer to STSE Handler
4545
* \param[in] slot_number Key slot in symmetric key table to be used
46-
* \param[in] message_length Length of the message
46+
* \param[in] message_length Length of the message<br>
47+
* message_length maximum value (in bytes):
48+
* - STSAFE-A110 : STSAFEA_MAX_FRAME_LENGTH_A110 - 5
49+
* - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 5
4750
* \param[in] pPlaintext_message Plaintext message to encrypt
4851
* \param[out] pEncrypted_message Encrypted message
4952
* \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise
@@ -60,7 +63,10 @@ stse_ReturnCode_t stsafea_aes_ecb_encrypt(
6063
* \details This service format and send decrypt command in AES ECB mode
6164
* \param[in] pSTSE Pointer to STSE Handler
6265
* \param[in] slot_number Key slot in symmetric key table to be used
63-
* \param[in] message_length Length of the message
66+
* \param[in] message_length Length of the message<br>
67+
* message_length maximum value (in bytes):
68+
* - STSAFE-A110 : STSAFEA_MAX_FRAME_LENGTH_A110 - 5
69+
* - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 5
6470
* \param[in] pEncrypted_message Encrypted message to decrypt
6571
* \param[out] pPlaintext_message Plaintext message
6672
* \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise
@@ -81,7 +87,10 @@ stse_ReturnCode_t stsafea_aes_ecb_decrypt(
8187
* \param[in] pNonce Buffer containing the nonce
8288
* \param[in] associated_data_length Length of the associated data
8389
* \param[in] pAssociated_data Buffer containing associated data
84-
* \param[in] message_length Length of the message to encrypt
90+
* \param[in] message_length Length of the message to encrypt<br>
91+
* message_length maximum value (in bytes):
92+
* - STSAFE-A110 : STSAFEA_MAX_FRAME_LENGTH_A110 - 22 - associated_data_length
93+
* - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 22 - associated_data_length
8594
* \param[in] pPlaintext_message Buffer containing the message to encrypt
8695
* \param[out] pEncrypted_message Buffer to store the encrypted message
8796
* \param[out] pEncrypted_authentication_tag Buffer to store the authentication tag
@@ -114,7 +123,9 @@ stse_ReturnCode_t stsafea_aes_ccm_encrypt(
114123
* \param[in] total_message_length Length of the complete message to be encrypted by chunks
115124
* \param[in] associated_data_chunk_length Length of the associated data chunk
116125
* \param[in] pAssociated_data_chunk Buffer containing associated data chunk
117-
* \param[in] message_chunk_length Length of the message chunk to encrypt
126+
* \param[in] message_chunk_length Length of the message chunk to encrypt<br>
127+
* message_chunk_length maximum value (in bytes):
128+
* - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 17 - Nonce_length - associated_data_chunk_length
118129
* \param[in] pPlaintext_message_chunk Buffer containing 1st piece of plaintext message chunk to encrypt
119130
* \param[out] pEncrypted_message_chunk Buffer to store the encrypted message chunk
120131
* \param[out] pCounter_presence Counter presence flag
@@ -142,7 +153,9 @@ stse_ReturnCode_t stsafea_aes_ccm_encrypt_start(
142153
* \param[in] pSTSE Pointer to STSE Handler
143154
* \param[in] associated_data_chunk_length Length of the associated data chunk
144155
* \param[in] pAssociated_data_chunk Buffer containing associated data chunk
145-
* \param[in] message_chunk_length Length of the message chunk to encrypt
156+
* \param[in] message_chunk_length Length of the message chunk to encrypt<br>
157+
* message_chunk_length maximum value (in bytes):
158+
* - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 8 - associated_data_chunk_length
146159
* \param[in] pPlaintext_message_chunk Buffer containing the message chunk to encrypt
147160
* \param[out] pEncrypted_message_chunk Buffer to store the encrypted message chunk
148161
* \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise
@@ -162,7 +175,9 @@ stse_ReturnCode_t stsafea_aes_ccm_encrypt_process(
162175
* \param[in] authentication_tag_length Length of the output authentication tag
163176
* \param[in] associated_data_chunk_length Length of the associated data chunk
164177
* \param[in] pAssociated_data_chunk Buffer containing associated data chunk
165-
* \param[in] message_chunk_length Length of the message chunk to encrypt
178+
* \param[in] message_chunk_length Length of the message chunk to encrypt<br>
179+
* message_chunk_length maximum value (in bytes):
180+
* - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 8 - associated_data_chunk_length
166181
* \param[in] pPlaintext_message_chunk Buffer containing the message chunk to encrypt
167182
* \param[out] pEncrypted_message_chunk Buffer to store the encrypted message chunk
168183
* \param[out] pEncrypted_authentication_tag Encrypted authentication tag
@@ -187,7 +202,10 @@ stse_ReturnCode_t stsafea_aes_ccm_encrypt_finish(
187202
* \param[in] pNonce Buffer containing the nonce
188203
* \param[in] associated_data_length Length of the associated data
189204
* \param[in] pAssociated_data Buffer containing associated data
190-
* \param[in] message_length Length of the message to encrypt
205+
* \param[in] message_length Length of the message to encrypt<br>
206+
* message_length maximum value (in bytes):
207+
* - STSAFE-A110 : STSAFEA_MAX_FRAME_LENGTH_A110 - 22 - authentication_tag_length - associated_data_length
208+
* - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 22 - authentication_tag_length - associated_data_length
191209
* \param[in] pEncrypted_message Buffer containing the message to decrypt
192210
* \param[in] pAuthentication_tag Buffer containing the authentication tag
193211
* \param[out] pVerification_result Verification result flag
@@ -218,7 +236,9 @@ stse_ReturnCode_t stsafea_aes_ccm_decrypt(
218236
* \param[in] total_ciphertext_length Length of the complete ciphertext
219237
* \param[in] associated_data_chunk_length Length of the associated data chunk
220238
* \param[in] pAssociated_data_chunk Buffer containing associated data chunk
221-
* \param[in] message_chunk_length Length of the message chunk to decrypt
239+
* \param[in] message_chunk_length Length of the message chunk to decrypt<br>
240+
* message_chunk_length maximum value (in bytes):
241+
* - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 17 - Nonce_length - associated_data_chunk_length
222242
* \param[in] pEncrypted_message_chunk Buffer containing the message chunk to decrypt
223243
* \param[out] pPlaintext_message_chunk Buffer to store the decrypted message chunk
224244
* \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise
@@ -242,7 +262,9 @@ stse_ReturnCode_t stsafea_aes_ccm_decrypt_start(
242262
* \param[in] pSTSE Pointer to STSE Handler
243263
* \param[in] associated_data_chunk_length Length of the associated data chunk
244264
* \param[in] pAssociated_data_chunk Buffer containing associated data chunk
245-
* \param[in] message_chunk_length Length of the message chunk to decrypt
265+
* \param[in] message_chunk_length Length of the message chunk to decrypt<br>
266+
* message_chunk_length maximum value (in bytes):
267+
* - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 8 - associated_data_chunk_length
246268
* \param[in] pEncrypted_message_chunk Buffer containing the message chunk to decrypt
247269
* \param[out] pPlaintext_message_chunk Buffer to store the decrypted message chunk
248270
* \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise
@@ -262,7 +284,9 @@ stse_ReturnCode_t stsafea_aes_ccm_decrypt_process(
262284
* \param[in] authentication_tag_length Length of the output authentication tag
263285
* \param[in] associated_data_chunk_length Length of the associated data chunk
264286
* \param[in] pAssociated_data_chunk Buffer containing associated data chunk
265-
* \param[in] message_chunk_length Length of the message chunk to decrypt
287+
* \param[in] message_chunk_length Length of the message chunk to decrypt<br>
288+
* message_chunk_length maximum value (in bytes):
289+
* - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 8 - authentication_tag_length - associated_data_chunk_length
266290
* \param[in] pEncrypted_message_chunk Buffer containing the message chunk to decrypt
267291
* \param[in] pAuthentication_tag Authentication tag
268292
* \param[out] pVerification_result Verification result flag
@@ -290,7 +314,9 @@ stse_ReturnCode_t stsafea_aes_ccm_decrypt_finish(
290314
* \param[in] pIV IV buffer
291315
* \param[in] associated_data_length Length of the associated data
292316
* \param[in] pAssociated_data Buffer containing associated data
293-
* \param[in] message_length Length of the message to encrypt
317+
* \param[in] message_length Length of the message to encrypt<br>
318+
* message_length maximum value (in bytes):
319+
* - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 11 - IV_length - associated_data_length
294320
* \param[in] pPlaintext_message Buffer containing the message to encrypt
295321
* \param[out] pEncrypted_message Buffer to store the encrypted message
296322
* \param[out] pAuthentication_tag Buffer to store the authentication tag
@@ -318,7 +344,9 @@ stse_ReturnCode_t stsafea_aes_gcm_encrypt(
318344
* \param[in] pIV IV buffer
319345
* \param[in] associated_data_chunk_length Length of the associated data chunk
320346
* \param[in] pAssociated_data_chunk Buffer containing associated data chunk
321-
* \param[in] message_chunk_length Length of the message chunk to encrypt
347+
* \param[in] message_chunk_length Length of the message chunk to encrypt<br>
348+
* message_chunk_length maximum value (in bytes):
349+
* - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 11 - IV_length - associated_data_chunk_length
322350
* \param[in] pPlaintext_message_chunk Buffer containing the message chunk to encrypt
323351
* \param[out] pEncrypted_message_chunk Buffer to store the encrypted message
324352
* \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise
@@ -340,7 +368,9 @@ stse_ReturnCode_t stsafea_aes_gcm_encrypt_start(
340368
* \param[in] pSTSE Pointer to STSE Handler
341369
* \param[in] associated_data_chunk_length Length of the associated data chunk
342370
* \param[in] pAssociated_data_chunk Buffer containing associated data chunk
343-
* \param[in] message_chunk_length Length of the message chunk to encrypt
371+
* \param[in] message_chunk_length Length of the message chunk to encrypt<br>
372+
* message_chunk_length maximum value (in bytes):
373+
* - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 8 - associated_data_chunk_length
344374
* \param[in] pPlaintext_message_chunk Buffer containing the message chunk to encrypt
345375
* \param[out] pEncrypted_message_chunk Buffer to store the encrypted message chunk
346376
* \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise
@@ -360,7 +390,9 @@ stse_ReturnCode_t stsafea_aes_gcm_encrypt_process(
360390
* \param[in] authentication_tag_length Length of the output authentication tag
361391
* \param[in] associated_data_chunk_length Length of the associated data chunk
362392
* \param[in] pAssociated_data_chunk Buffer containing associated data chunk
363-
* \param[in] message_chunk_length Length of the message chunk
393+
* \param[in] message_chunk_length Length of the message chunk<br>
394+
* message_chunk_length maximum value (in bytes):
395+
* - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 8 - associated_data_chunk_length
364396
* \param[in] pPlaintext_message_chunk Buffer containing the message chunk to encrypt
365397
* \param[out] pEncrypted_message_chunk Buffer to store the encrypted message chunk
366398
* \param[out] pAuthentication_tag Authentication tag
@@ -386,7 +418,9 @@ stse_ReturnCode_t stsafea_aes_gcm_encrypt_finish(
386418
* \param[in] pIV IV buffer
387419
* \param[in] associated_data_length Length of the associated data
388420
* \param[in] pAssociated_data Buffer containing associated data
389-
* \param[in] message_length Length of the message to decrypt
421+
* \param[in] message_length Length of the message to decrypt<br>
422+
* message_length maximum value (in bytes):
423+
* - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 11 - authentication_tag_length - IV_length - associated_data_length
390424
* \param[in] pEncrypted_message Buffer containing the message to decrypt
391425
* \param[in] pAuthentication_tag Buffer containing the authentication tag
392426
* \param[out] pVerification_result Verification result flag
@@ -416,7 +450,9 @@ stse_ReturnCode_t stsafea_aes_gcm_decrypt(
416450
* \param[in] pIV IV buffer
417451
* \param[in] associated_data_chunk_length Length of the associated data chunk
418452
* \param[in] pAssociated_data_chunk Buffer containing associated data chunk
419-
* \param[in] message_chunk_length Length of the message chunk to decrypt
453+
* \param[in] message_chunk_length Length of the message chunk to decrypt<br>
454+
* message_chunk_length maximum value (in bytes):
455+
* - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 11 - IV_length - associated_data_chunk_length
420456
* \param[in] pEncrypted_message_chunk Buffer containing the message chunk to decrypt
421457
* \param[out] pPlaintext_message_chunk Buffer to store the decrypted message chunk
422458
* \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise
@@ -438,7 +474,9 @@ stse_ReturnCode_t stsafea_aes_gcm_decrypt_start(
438474
* \param[in] pSTSE Pointer to STSE Handler
439475
* \param[in] associated_data_chunk_length Length of the associated data chunk
440476
* \param[in] pAssociated_data_chunk Buffer containing associated data chunk
441-
* \param[in] message_chunk_length Length of the message chunk to decrypt
477+
* \param[in] message_chunk_length Length of the message chunk to decrypt<br>
478+
* message_chunk_length maximum value (in bytes):
479+
* - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 8 - associated_data_chunk_length
442480
* \param[in] pEncrypted_message_chunk Buffer containing the message chunk to decrypt
443481
* \param[out] pPlaintext_message_chunk Buffer to store the decrypted message chunk
444482
* \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise
@@ -458,7 +496,9 @@ stse_ReturnCode_t stsafea_aes_gcm_decrypt_process(
458496
* \param[in] authentication_tag_length Length of the output authentication tag
459497
* \param[in] associated_data_chunk_length Length of the associated data chunk
460498
* \param[in] pAssociated_data_chunk Buffer containing associated data chunk
461-
* \param[in] message_chunk_length Length of the message chunk to decrypt
499+
* \param[in] message_chunk_length Length of the message chunk to decrypt<br>
500+
* message_chunk_length maximum value (in bytes):
501+
* - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 11 - authentication_tag_length - associated_data_chunk_length
462502
* \param[in] pEncrypted_message_chunk Buffer containing the message chunk to decrypt
463503
* \param[in] pAuthentication_tag Authentication tag
464504
* \param[out] pVerification_result Verification result flag

services/stsafea/stsafea_data_partition.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,11 @@ stse_ReturnCode_t stsafea_get_data_partitions_configuration(stse_Handler_t *pSTS
130130
* \param[in] amount Amount to decrement
131131
* \param[in] offset Associated data offset
132132
* \param[in] data Pointer to associated data
133-
* \param[in] data_length Length of associated data
133+
* \param[in] data_length Length of associated data<br>
134+
* data_length maximum value (in bytes):
135+
* - STSAFE-A100 : STSAFEA_MAX_FRAME_LENGTH_A100 - 11
136+
* - STSAFE-A110 : STSAFEA_MAX_FRAME_LENGTH_A110 - 11
137+
* - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 11
134138
* \param[out] new_counter_value Pointer to store new counter value
135139
* \param[in] protection Command protection type
136140
* \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise
@@ -195,7 +199,11 @@ stse_ReturnCode_t stsafea_read_data_zone(stse_Handler_t *pSTSE,
195199
* \param[in] option Update option
196200
* \param[in] offset Update offset
197201
* \param[in] data Pointer to data to write
198-
* \param[in] data_length Length of data to write
202+
* \param[in] data_length Length of data to write<br>
203+
* data_length maximum value (in bytes):
204+
* - STSAFE-A100 : STSAFEA_MAX_FRAME_LENGTH_A100 - 7
205+
* - STSAFE-A110 : STSAFEA_MAX_FRAME_LENGTH_A110 - 7
206+
* - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 7
199207
* \param[in] protection Command protection type
200208
* \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise
201209
*/

services/stsafea/stsafea_echo.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@
3838
* \param[in] pSTSE Pointer to STSE Handler
3939
* \param[in] message Message buffer to send the echo command
4040
* \param[in] echoed_message Message buffer to receive the echo response
41-
* \param[in] message_size Size of the echo message
41+
* \param[in] message_size Size of the echo message<br>
42+
* message_size maximum value (in bytes):
43+
* - STSAFE-A100 : STSAFEA_MAX_FRAME_LENGTH_A100 - 2
44+
* - STSAFE-A110 : STSAFEA_MAX_FRAME_LENGTH_A110 - 2
45+
* - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 2
4246
* \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise
4347
*/
4448
stse_ReturnCode_t stsafea_echo(

services/stsafea/stsafea_hash.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ stse_ReturnCode_t stsafea_start_hash(
9191
PLAT_UI16 message_size) {
9292
PLAT_UI8 cmd_header[STSAFEA_EXT_HEADER_SIZE] = {STSAFEA_EXTENDED_COMMAND_PREFIX, STSAFEA_EXTENDED_CMD_START_HASH};
9393
PLAT_UI8 rsp_header;
94-
PLAT_UI16 hash_algo_id_length = STSAFEA_HASH_ALGO_ID_SIZE;
9594

9695
if (pSTSE == NULL) {
9796
return (STSE_SERVICE_HANDLER_NOT_INITIALISED);
@@ -104,7 +103,7 @@ stse_ReturnCode_t stsafea_start_hash(
104103
/*- Create CMD frame and populate elements */
105104
stse_frame_allocate(CmdFrame);
106105
stse_frame_element_allocate_push(&CmdFrame, eCmd_header, STSAFEA_EXT_HEADER_SIZE, cmd_header);
107-
stse_frame_element_allocate_push(&CmdFrame, eHashAlgo, hash_algo_id_length, (PLAT_UI8 *)&stsafea_hash_info_table[sha_algorithm].id);
106+
stse_frame_element_allocate_push(&CmdFrame, eHashAlgo, STSAFEA_HASH_ALGO_ID_SIZE, (PLAT_UI8 *)&stsafea_hash_info_table[sha_algorithm].id);
108107
stse_frame_element_allocate_push(&CmdFrame, eMessage, message_size, pMessage);
109108

110109
/*- Create Rsp frame and populate elements*/

services/stsafea/stsafea_hash.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ extern const stsafea_hash_info_t stsafea_hash_info_table[];
111111
* \param[in] pSTSE Pointer to target SE handler
112112
* \param[in] sha_algorithm \ref stse_hash_algorithm_t SHA algorithm
113113
* \param[in] pMessage Pointer to message buffer
114-
* \param[in] message_size Input message length in bytes
114+
* \param[in] message_size Input message length in bytes<br>
115+
* message_size maximum value (in bytes):
116+
* - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 15
115117
* \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise
116118
*/
117119
stse_ReturnCode_t stsafea_start_hash(stse_Handler_t *pSTSE,
@@ -124,7 +126,9 @@ stse_ReturnCode_t stsafea_start_hash(stse_Handler_t *pSTSE,
124126
* \details This service format and send/receive STSAFE-Axxx process hash command/response
125127
* \param[in] pSTSE Pointer to target SE handler
126128
* \param[in] pMessage Pointer to message buffer
127-
* \param[in] message_size Input message length in bytes
129+
* \param[in] message_size Input message length in bytes<br>
130+
* message_size maximum value (in bytes):
131+
* - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 4
128132
* \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise
129133
*/
130134
stse_ReturnCode_t stsafea_process_hash(
@@ -138,7 +142,9 @@ stse_ReturnCode_t stsafea_process_hash(
138142
* \param[in] pSTSE Pointer to target SE handler
139143
* \param[in] sha_algorithm \ref stse_hash_algorithm_t SHA algorithm
140144
* \param[in] pMessage Pointer to message buffer
141-
* \param[in] message_size Input message length in bytes
145+
* \param[in] message_size Input message length in bytes<br>
146+
* message_size maximum value (in bytes):
147+
* - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 4
142148
* \param[out] pDigest Pointer to digest buffer
143149
* \param[out] pDigest_size Digest buffer length in bytes
144150
* \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise

0 commit comments

Comments
 (0)