Skip to content

Commit 0b38cd0

Browse files
TofMassilia13320Grom-
authored andcommitted
[api] Fix issue #11 (stse_compute_hash bug STSE_COMMAND_NOT_AUTHORIZED)
1 parent eb3d81c commit 0b38cd0

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

api/stse_hash.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,10 @@ stse_ReturnCode_t stse_compute_hash(
117117
return( STSE_API_INVALID_PARAMETER );
118118
}
119119

120-
PLAT_UI16 maximum_chunck_size = stsafea_maximum_command_length[pSTSE->device_type];
120+
PLAT_UI16 maximum_chunk_size = stsafea_maximum_command_length[pSTSE->device_type] - STSE_FRAME_CRC_SIZE - STSAFEA_CMD_EXTENSION_SIZE;
121121

122-
message_size = ((remaining_length + STSAFEA_HASH_ALGO_ID_SIZE) > maximum_chunck_size) ?
123-
maximum_chunck_size - STSAFEA_HASH_ALGO_ID_SIZE:
122+
message_size = ((remaining_length + STSAFEA_HASH_ALGO_ID_SIZE) > maximum_chunk_size) ?
123+
maximum_chunk_size - STSAFEA_HASH_ALGO_ID_SIZE:
124124
remaining_length;
125125
ret = stsafea_start_hash(pSTSE, sha_algorithm, pMessage, message_size);
126126
if(ret != STSE_OK)
@@ -132,8 +132,8 @@ stse_ReturnCode_t stse_compute_hash(
132132

133133
while(remaining_length > 0)
134134
{
135-
message_size = (remaining_length > maximum_chunck_size) ?
136-
maximum_chunck_size :
135+
message_size = (remaining_length > maximum_chunk_size) ?
136+
maximum_chunk_size :
137137
remaining_length;
138138
ret = stsafea_process_hash(pSTSE, pMessage, message_size);
139139
if(ret != STSE_OK)

services/stsafea/stsafea_commands.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343

4444
#define STSAFEA_EXT_HEADER_SIZE 2U
4545
#define STSAFEA_HEADER_SIZE 1U
46+
#define STSAFEA_CMD_EXTENSION_SIZE 1U
4647
#define STSAFEA_CMD_RSP_LEN_SIZE 2U
4748
#define STSAFEA_SLOT_NUMBER_ID_SIZE 1U
4849
#define STSAFEA_AES_KEY_SIZE 16U

0 commit comments

Comments
 (0)