Skip to content

Commit 99b0a3b

Browse files
TofMassilia13320Grom-
authored andcommitted
[api/core/services] Allocate personalization informations to device handler
1 parent de864c6 commit 99b0a3b

7 files changed

Lines changed: 29 additions & 44 deletions

File tree

api/stse_device_management.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,7 @@
2020

2121
/* Exported variables --------------------------------------------------------*/
2222

23-
stse_perso_info_t dynamic_product_perso = {
24-
.cmd_encryption_status = 0,
25-
.rsp_encryption_status = 0,
26-
.ext_cmd_encryption_status = 0,
27-
.ext_rsp_encryption_status = 0,
28-
.cmd_AC_status = 0x5555555555555555,
29-
.ext_cmd_AC_status = 0x5555555555555555};
30-
3123
/* Exported functions --------------------------------------------------------*/
32-
3324
stse_ReturnCode_t stse_init(stse_Handler_t *pSTSE) {
3425
stse_ReturnCode_t ret = STSE_API_INVALID_PARAMETER;
3526

@@ -101,10 +92,7 @@ stse_ReturnCode_t stse_init(stse_Handler_t *pSTSE) {
10192
stse_platform_Delay_ms(stsafea_boot_time[pSTSE->device_type]);
10293

10394
#ifndef STSE_CONF_USE_STATIC_PERSONALIZATION_INFORMATIONS
104-
if (pSTSE->pPerso_info == NULL) {
105-
pSTSE->pPerso_info = &dynamic_product_perso;
106-
ret = stsafea_perso_info_update(pSTSE);
107-
}
95+
ret = stsafea_perso_info_update(pSTSE);
10896
#endif /* STSE_CONF_USE_STATIC_PERSONALIZATION_INFORMATIONS */
10997
#ifdef STSE_CONF_STSAFE_L_SUPPORT
11098
}

core/stse_device.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ stse_ReturnCode_t stse_set_default_handler_value(stse_Handler_t *pStseHandler) {
2626
}
2727

2828
pStseHandler->device_type = (stse_device_t)0;
29-
pStseHandler->pPerso_info = NULL;
29+
memset(&pStseHandler->perso_info, 0, sizeof(pStseHandler->perso_info));
3030
pStseHandler->pActive_host_session = NULL;
3131
pStseHandler->pActive_other_session = NULL;
3232
pStseHandler->io.BusRecvStart = stse_platform_i2c_receive_start;

core/stse_device.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,16 +183,14 @@ struct stse_session_t {
183183
*/
184184
struct stse_Handler_t {
185185
stse_device_t device_type;
186-
stse_perso_info_t *pPerso_info;
186+
stse_perso_info_t perso_info;
187187
stse_session_t *pActive_host_session;
188188
stse_session_t *pActive_other_session;
189189
stse_io_t io;
190190
} PLAT_PACKED_STRUCT;
191191

192192
/* Exported variables --------------------------------------------------------*/
193193

194-
extern stse_perso_info_t dynamic_product_perso;
195-
196194
/**
197195
* \brief Initialise the STSE handler to default value
198196
* \details This core function initialise the handler to default value

core/stse_return_codes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ enum stse_ReturnCode_t {
101101
STSE_SERVICE_HANDLER_NOT_INITIALISED, /*!< STSE is not initialized please run stsafe_init function first */
102102
STSE_SERVICE_SESSION_ERROR,
103103
STSE_SERVICE_BUFFER_OVERFLOW,
104+
STSE_SERVICE_INVALID_CONFIGURATION,
104105

105106
/* - STSE API layer response code (MSB Mask 0x04xx)*/
106107
STSE_API_INVALID_PARAMETER = 0x0401,

services/stsafea/stsafea_asymmetric_key_slots.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,6 @@ stse_ReturnCode_t stsafea_generate_ECDHE_key_pair(
278278
&RspFrame);
279279
}
280280

281-
#if defined(STSE_CONF_USE_HOST_KEY_PROVISIONING_WRAPPED_AUTHENTICATED) || \
282-
defined(STSE_CONF_USE_SYMMETRIC_KEY_ESTABLISHMENT_AUTHENTICATED) || \
283-
defined(STSE_CONF_USE_SYMMETRIC_KEY_PROVISIONING_WRAPPED_AUTHENTICATED)
284-
285281
stse_ReturnCode_t stsafea_sign_for_generic_public_key_slot(
286282
stse_Handler_t *pSTSE,
287283
stse_ecc_key_type_t private_key_type,
@@ -291,6 +287,10 @@ stse_ReturnCode_t stsafea_sign_for_generic_public_key_slot(
291287
PLAT_UI8 *pPayload,
292288
PLAT_UI8 *pSignature) {
293289
(void)pSTSE;
290+
#if defined(STSE_CONF_USE_HOST_KEY_PROVISIONING_WRAPPED_AUTHENTICATED) || \
291+
defined(STSE_CONF_USE_SYMMETRIC_KEY_ESTABLISHMENT_AUTHENTICATED) || \
292+
defined(STSE_CONF_USE_SYMMETRIC_KEY_PROVISIONING_WRAPPED_AUTHENTICATED)
293+
294294
stse_ReturnCode_t ret;
295295
PLAT_UI8 tbs_data[payload_length];
296296
PLAT_UI32 hash_length = stsafea_hash_info_table[hash_algo].length;
@@ -326,9 +326,11 @@ stse_ReturnCode_t stsafea_sign_for_generic_public_key_slot(
326326
pSignature);
327327

328328
return (ret);
329-
}
329+
#else
330+
return STSE_SERVICE_INVALID_CONFIGURATION;
330331
#endif /* STSE_CONF_USE_HOST_KEY_PROVISIONING_WRAPPED_AUTHENTICATED ||
331332
STSE_CONF_USE_SYMMETRIC_KEY_ESTABLISHMENT_AUTHENTICATED ||
332333
STSE_CONF_USE_SYMMETRIC_KEY_PROVISIONING_WRAPPED_AUTHENTICATED */
334+
}
333335

334336
#endif /* STSE_CONF_STSAFE_A_SUPPORT */

services/stsafea/stsafea_commands.c

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,12 @@ stse_ReturnCode_t stsafea_perso_info_update(stse_Handler_t *pSTSE) {
119119
return STSE_SERVICE_HANDLER_NOT_INITIALISED;
120120
}
121121

122-
if (pSTSE->pPerso_info != &dynamic_product_perso) {
123-
return STSE_SERVICE_INVALID_PARAMETER;
124-
}
125-
126-
pSTSE->pPerso_info->cmd_AC_status = 0x5555555555555555;
127-
pSTSE->pPerso_info->cmd_encryption_status = 0,
128-
pSTSE->pPerso_info->rsp_encryption_status = 0;
129-
pSTSE->pPerso_info->ext_cmd_AC_status = 0x5555555555555555;
130-
pSTSE->pPerso_info->ext_cmd_encryption_status = 0;
131-
pSTSE->pPerso_info->ext_rsp_encryption_status = 0;
122+
pSTSE->perso_info.cmd_encryption_status = 0,
123+
pSTSE->perso_info.rsp_encryption_status = 0;
124+
pSTSE->perso_info.ext_cmd_encryption_status = 0;
125+
pSTSE->perso_info.ext_rsp_encryption_status = 0;
126+
pSTSE->perso_info.cmd_AC_status = 0x5555555555555555;
127+
pSTSE->perso_info.ext_cmd_AC_status = 0x5555555555555555;
132128

133129
ret = stsafea_get_command_count(pSTSE, &total_command_count);
134130
if (ret != STSE_OK) {
@@ -147,13 +143,13 @@ stse_ReturnCode_t stsafea_perso_info_update(stse_Handler_t *pSTSE) {
147143

148144
for (PLAT_UI8 i = 0; i < total_command_count; i++) {
149145
if (record_table[i].extended_header == 0) {
150-
stsafea_perso_info_set_cmd_AC(pSTSE->pPerso_info, record_table[i].header, record_table[i].command_AC);
151-
stsafea_perso_info_set_cmd_encrypt_flag(pSTSE->pPerso_info, record_table[i].header, record_table[i].host_encryption_flags.cmd);
152-
stsafea_perso_info_set_rsp_encrypt_flag(pSTSE->pPerso_info, record_table[i].header, record_table[i].host_encryption_flags.rsp);
146+
stsafea_perso_info_set_cmd_AC(&pSTSE->perso_info, record_table[i].header, record_table[i].command_AC);
147+
stsafea_perso_info_set_cmd_encrypt_flag(&pSTSE->perso_info, record_table[i].header, record_table[i].host_encryption_flags.cmd);
148+
stsafea_perso_info_set_rsp_encrypt_flag(&pSTSE->perso_info, record_table[i].header, record_table[i].host_encryption_flags.rsp);
153149
} else {
154-
stsafea_perso_info_set_ext_cmd_AC(pSTSE->pPerso_info, record_table[i].extended_header, record_table[i].command_AC);
155-
stsafea_perso_info_set_ext_cmd_encrypt_flag(pSTSE->pPerso_info, record_table[i].extended_header, record_table[i].host_encryption_flags.cmd);
156-
stsafea_perso_info_set_ext_rsp_encrypt_flag(pSTSE->pPerso_info, record_table[i].extended_header, record_table[i].host_encryption_flags.rsp);
150+
stsafea_perso_info_set_ext_cmd_AC(&pSTSE->perso_info, record_table[i].extended_header, record_table[i].command_AC);
151+
stsafea_perso_info_set_ext_cmd_encrypt_flag(&pSTSE->perso_info, record_table[i].extended_header, record_table[i].host_encryption_flags.cmd);
152+
stsafea_perso_info_set_ext_rsp_encrypt_flag(&pSTSE->perso_info, record_table[i].extended_header, record_table[i].host_encryption_flags.rsp);
157153
}
158154
}
159155

services/stsafea/stsafea_frame_transfer.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -349,18 +349,18 @@ stse_ReturnCode_t stsafea_frame_transfer(stse_Handler_t *pSTSE, stse_frame_t *pC
349349
cmd_header_extended = pCmdFrame->first_element->next->pData[0];
350350
inter_frame_delay = stsafea_extended_cmd_timings[pSTSE->device_type][cmd_header_extended];
351351
#ifdef STSE_CONF_USE_HOST_SESSION
352-
stsafea_perso_info_get_ext_cmd_AC(pSTSE->pPerso_info, cmd_header_extended, &cmd_ac_info);
353-
stsafea_perso_info_get_ext_cmd_encrypt_flag(pSTSE->pPerso_info, cmd_header_extended, &cmd_encryption_flag);
354-
stsafea_perso_info_get_ext_rsp_encrypt_flag(pSTSE->pPerso_info, cmd_header_extended, &rsp_encryption_flag);
352+
stsafea_perso_info_get_ext_cmd_AC(&pSTSE->perso_info, cmd_header_extended, &cmd_ac_info);
353+
stsafea_perso_info_get_ext_cmd_encrypt_flag(&pSTSE->perso_info, cmd_header_extended, &cmd_encryption_flag);
354+
stsafea_perso_info_get_ext_rsp_encrypt_flag(&pSTSE->perso_info, cmd_header_extended, &rsp_encryption_flag);
355355
#endif /* STSE_CONF_USE_HOST_SESSION */
356356
}
357357
} else {
358358
cmd_header = pCmdFrame->first_element->pData[0];
359359
inter_frame_delay = stsafea_extended_cmd_timings[pSTSE->device_type][cmd_header];
360360
#ifdef STSE_CONF_USE_HOST_SESSION
361-
stsafea_perso_info_get_cmd_AC(pSTSE->pPerso_info, cmd_header, &cmd_ac_info);
362-
stsafea_perso_info_get_cmd_encrypt_flag(pSTSE->pPerso_info, cmd_header, &cmd_encryption_flag);
363-
stsafea_perso_info_get_rsp_encrypt_flag(pSTSE->pPerso_info, cmd_header, &rsp_encryption_flag);
361+
stsafea_perso_info_get_cmd_AC(&pSTSE->perso_info, cmd_header, &cmd_ac_info);
362+
stsafea_perso_info_get_cmd_encrypt_flag(&pSTSE->perso_info, cmd_header, &cmd_encryption_flag);
363+
stsafea_perso_info_get_rsp_encrypt_flag(&pSTSE->perso_info, cmd_header, &rsp_encryption_flag);
364364
#endif /* STSE_CONF_USE_HOST_SESSION */
365365
}
366366
ret = STSE_OK;

0 commit comments

Comments
 (0)