Skip to content

Commit bfd2015

Browse files
committed
[api][services][core] Code cleanup
1 parent 18da1e5 commit bfd2015

File tree

9 files changed

+259
-7
lines changed

9 files changed

+259
-7
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ __docbook
1616
.settings/
1717
*.xml
1818
*.pu
19+
_codeql_detected_source_root

api/stse_data_storage.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ stse_ReturnCode_t stse_data_storage_get_partitioning_table(
6868
* \param[in] length Read length in byte
6969
* \param[in] chunk_size Read chunk size in byte
7070
* \param[in] protection \ref stse_cmd_protection_t command response protection indicator
71-
* \result \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise
71+
* \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise
7272
* \note - A target STSE handler must be initialized using the \ref stse_init routine prior to execute this API function
7373
* \note - If command response protection is required an active session between Host/Companion and STSE must be open
7474
* \details \include{doc} stse_data_storage_read_zone.dox
@@ -91,7 +91,7 @@ stse_ReturnCode_t stse_data_storage_read_data_zone(
9191
* \param[in] length Update length in byte
9292
* \param[in] atomicity \ref stse_zone_update_atomicity_t atomicity of the update access
9393
* \param[in] protection \ref stse_cmd_protection_t command response protection indicator
94-
* \result \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise
94+
* \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise
9595
* \note - A target STSE handler must be initialized using the \ref stse_init routine prior to execute this API function
9696
* \note - If command response protection is required an active session between Host/Companion and STSE must be open
9797
* \details \include{doc} stse_data_storage_update_zone.dox
@@ -115,7 +115,7 @@ stse_ReturnCode_t stse_data_storage_update_data_zone(
115115
* \param[in] length Associated data update length in byte (optional : set to 0 if not used)
116116
* \param[out] new_counter_value Pointer to applicative counter value buffer
117117
* \param[in] protection \ref stse_cmd_protection_t command response protection indicator
118-
* \result \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise
118+
* \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise
119119
* \note - A target STSE handler must be initialized using the \ref stse_init routine prior to execute this API function
120120
* \note - If command response protection is required an active session between Host/Companion and STSE must be open
121121
* \details \include{doc} stse_data_storage_decrement_counter.dox
@@ -140,7 +140,7 @@ stse_ReturnCode_t stse_data_storage_decrement_counter_zone(
140140
* \param[in] chunk_size Associated data read chunk size in byte (optional : set to 0 if not used)
141141
* \param[out] counter_value Pointer to applicative counter value buffer
142142
* \param[in] protection \ref stse_cmd_protection_t command response protection indicator
143-
* \result \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise
143+
* \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise
144144
* \note - A target STSE handler must be initialized using the \ref stse_init routine prior to execute this API function
145145
* \note - If command response protection is required an active session between Host/Companion and STSE must be open
146146
* \details \include{doc} stse_data_storage_read_counter.dox
@@ -162,7 +162,7 @@ stse_ReturnCode_t stse_data_storage_read_counter_zone(
162162
* \param[in] ac \ref stse_zone_ac_t new access condition
163163
* \param[in] ac_change_right \ref stse_ac_change_right_t new access change right
164164
* \param[in] protection \ref stse_cmd_protection_t command response protection indicator
165-
* \result \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise
165+
* \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise
166166
* \note - A target STSE handler must be initialized using the \ref stse_init routine prior to execute this API function
167167
* \note - If command response protection is required an active session between Host/Companion and STSE must be open
168168
* \details \include{doc} stse_data_storage_change_read_access_condition.dox
@@ -185,7 +185,7 @@ stse_ReturnCode_t stse_data_storage_change_read_access_condition(
185185
* \param[in] length Update length in byte
186186
* \param[in] atomicity \ref stse_zone_update_atomicity_t atomicity of the update access
187187
* \param[in] protection \ref stse_cmd_protection_t command response protection indicator
188-
* \result \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise
188+
* \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise
189189
* \note - A target STSE handler must be initialized using the \ref stse_init routine prior to execute this API function
190190
* \note - If command response protection is required an active session between Host/Companion and STSE must be open
191191
* \details \include{doc} stse_data_storage_change_update_access_condition.dox
@@ -212,7 +212,7 @@ stse_ReturnCode_t stse_data_storage_change_update_access_condition(stse_Handler_
212212
* \param[in] length Associated data update length in byte (optional : set to 0 if not used)
213213
* \param[out] new_counter_value Pointer to applicative counter value buffer
214214
* \param[in] protection \ref stse_cmd_protection_t command response protection indicator
215-
* \result \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise
215+
* \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise
216216
* \note - A target STSE handler must be initialized using the \ref stse_init routine prior to execute this API function
217217
* \note - If command response protection is required an active session between Host/Companion and STSE must be open
218218
* \details \include{doc} stse_data_storage_change_decrement_access_condition.dox

core/stse_generic_typedef.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,14 @@ extern const stse_ecc_info_t stse_ecc_info_table[];
568568
defined(STSE_CONF_ECC_BRAINPOOL_P_256) || defined(STSE_CONF_ECC_BRAINPOOL_P_384) || defined(STSE_CONF_ECC_BRAINPOOL_P_512) || \
569569
defined(STSE_CONF_ECC_CURVE_25519) || defined(STSE_CONF_ECC_EDWARD_25519)
570570

571+
/**
572+
* \brief Get ECC key type from curve identifier
573+
* \details This function resolves the ECC key type from a given curve identifier value
574+
* \param[in] curve_id_length Length of the curve identifier
575+
* \param[in] pCurve_id_value Pointer to the curve identifier value
576+
* \param[out] pKey_type Pointer to store the resolved ECC key type
577+
* \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise
578+
*/
571579
stse_ReturnCode_t stse_get_ecc_key_type_from_curve_id(
572580
PLAT_UI8 curve_id_length,
573581
const PLAT_UI8 *pCurve_id_value,

core/stse_platform.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,17 @@ stse_ReturnCode_t stse_platform_ecc_ecdh(stse_ecc_key_type_t key_type,
203203
defined(STSE_CONF_USE_SYMMETRIC_KEY_PROVISIONING_WRAPPED) || \
204204
defined(STSE_CONF_USE_SYMMETRIC_KEY_PROVISIONING_WRAPPED_AUTHENTICATED)
205205

206+
/**
207+
* \brief Encrypt data using NIST AES Key Wrap algorithm
208+
* \details This platform function implements the NIST SP 800-38F AES Key Wrap encryption
209+
* \param[in] pPayload Pointer to the payload data to encrypt
210+
* \param[in] payload_length Length of the payload in bytes
211+
* \param[in] pKey Pointer to the encryption key
212+
* \param[in] key_length Length of the key in bytes
213+
* \param[out] pOutput Pointer to the output buffer for encrypted data
214+
* \param[out] pOutput_length Pointer to store the output length
215+
* \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise
216+
*/
206217
stse_ReturnCode_t stse_platform_nist_kw_encrypt(PLAT_UI8 *pPayload, PLAT_UI32 payload_length,
207218
PLAT_UI8 *pKey, PLAT_UI8 key_length,
208219
PLAT_UI8 *pOutput, PLAT_UI32 *pOutput_length);

services/stsafea/stsafea_asymmetric_key_slots.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,33 @@ stse_ReturnCode_t stsafea_query_private_key_slots_count(
8181
stse_Handler_t *pSTSE,
8282
PLAT_UI8 *pPrivate_key_slot_count);
8383

84+
/**
85+
* \brief Query private key table information
86+
* \details This service formats and sends the query private key table command
87+
* \param[in] pSTSE Pointer to STSE Handler
88+
* \param[in] private_key_slot_count Number of private key slots
89+
* \param[out] pChange_right Pointer to change right value
90+
* \param[out] pGlobal_usage_limit Pointer to global usage limit value
91+
* \param[out] private_key_table_info Pointer to private key table information structure
92+
* \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise
93+
*/
8494
stse_ReturnCode_t stsafea_query_private_key_table(
8595
stse_Handler_t *pSTSE,
8696
PLAT_UI8 private_key_slot_count,
8797
PLAT_UI8 *pChange_right,
8898
PLAT_UI16 *pGlobal_usage_limit,
8999
stsafea_private_key_slot_information_t *private_key_table_info);
90100

101+
/**
102+
* \brief Generate ECC key pair in specified slot
103+
* \details This service formats and sends the generate ECC key pair command
104+
* \param[in] pSTSE Pointer to STSE Handler
105+
* \param[in] slot_number Slot number where to generate the key pair
106+
* \param[in] key_type ECC key type to generate
107+
* \param[in] usage_limit Usage limit for the generated key
108+
* \param[out] pPublic_key Pointer to buffer for the public key
109+
* \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise
110+
*/
91111
stse_ReturnCode_t stsafea_generate_ecc_key_pair(
92112
stse_Handler_t *pSTSE,
93113
PLAT_UI8 slot_number,

services/stsafea/stsafea_commands.h

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,57 +134,150 @@ extern const PLAT_UI16 stsafea_maximum_command_length[4];
134134

135135
stse_ReturnCode_t stsafea_get_command_count(stse_Handler_t *pSTSE, PLAT_UI8 *pCommand_count);
136136

137+
/**
138+
* \brief Get command access control table
139+
* \details This service retrieves the command access control table from the device
140+
* \param[in] pSTSE Pointer to STSE Handler
141+
* \param[in] total_command_count Total number of commands
142+
* \param[out] pChange_rights Pointer to change rights structure
143+
* \param[out] pRecord_table Pointer to record table array
144+
* \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise
145+
*/
137146
stse_ReturnCode_t stsafea_get_command_AC_table(stse_Handler_t *pSTSE,
138147
PLAT_UI8 total_command_count,
139148
stse_cmd_authorization_CR_t *pChange_rights,
140149
stse_cmd_authorization_record_t *pRecord_table);
141150

142151
stse_ReturnCode_t stsafea_perso_info_update(stse_Handler_t *pSTSE);
143152

153+
/**
154+
* \brief Get command access conditions from personalization info
155+
* \details This function retrieves the access conditions for a specific command
156+
* \param[in] pPerso Pointer to personalization info structure
157+
* \param[in] command_code Command code to query
158+
* \param[out] pProtection Pointer to store access conditions
159+
*/
144160
void stsafea_perso_info_get_cmd_AC(stse_perso_info_t *pPerso,
145161
PLAT_UI8 command_code,
146162
stse_cmd_access_conditions_t *pProtection);
147163

164+
/**
165+
* \brief Get extended command access conditions from personalization info
166+
* \details This function retrieves the access conditions for a specific extended command
167+
* \param[in] pPerso Pointer to personalization info structure
168+
* \param[in] command_code Extended command code to query
169+
* \param[out] pProtection Pointer to store access conditions
170+
*/
148171
void stsafea_perso_info_get_ext_cmd_AC(stse_perso_info_t *pPerso,
149172
PLAT_UI8 command_code,
150173
stse_cmd_access_conditions_t *pProtection);
151174

175+
/**
176+
* \brief Get command encryption flag from personalization info
177+
* \details This function retrieves the encryption flag for a specific command
178+
* \param[in] pPerso Pointer to personalization info structure
179+
* \param[in] command_code Command code to query
180+
* \param[out] pEnc_flag Pointer to store encryption flag
181+
*/
152182
void stsafea_perso_info_get_cmd_encrypt_flag(stse_perso_info_t *pPerso,
153183
PLAT_UI8 command_code,
154184
PLAT_UI8 *pEnc_flag);
155185

186+
/**
187+
* \brief Get response encryption flag from personalization info
188+
* \details This function retrieves the encryption flag for a specific command response
189+
* \param[in] pPerso Pointer to personalization info structure
190+
* \param[in] command_code Command code to query
191+
* \param[out] pEnc_flag Pointer to store encryption flag
192+
*/
156193
void stsafea_perso_info_get_rsp_encrypt_flag(stse_perso_info_t *pPerso,
157194
PLAT_UI8 command_code,
158195
PLAT_UI8 *pEnc_flag);
159196

197+
/**
198+
* \brief Get extended command encryption flag from personalization info
199+
* \details This function retrieves the encryption flag for a specific extended command
200+
* \param[in] pPerso Pointer to personalization info structure
201+
* \param[in] command_code Extended command code to query
202+
* \param[out] pEnc_flag Pointer to store encryption flag
203+
*/
160204
void stsafea_perso_info_get_ext_cmd_encrypt_flag(stse_perso_info_t *pPerso,
161205
PLAT_UI8 command_code,
162206
PLAT_UI8 *pEnc_flag);
163207

208+
/**
209+
* \brief Get extended response encryption flag from personalization info
210+
* \details This function retrieves the encryption flag for a specific extended command response
211+
* \param[in] pPerso Pointer to personalization info structure
212+
* \param[in] command_code Extended command code to query
213+
* \param[out] pEnc_flag Pointer to store encryption flag
214+
*/
164215
void stsafea_perso_info_get_ext_rsp_encrypt_flag(stse_perso_info_t *pPerso,
165216
PLAT_UI8 command_code,
166217
PLAT_UI8 *pEnc_flag);
167218

219+
/**
220+
* \brief Set command access conditions in personalization info
221+
* \details This function sets the access conditions for a specific command
222+
* \param[in,out] pPerso Pointer to personalization info structure
223+
* \param[in] command_code Command code to configure
224+
* \param[in] protection Access conditions to set
225+
*/
168226
void stsafea_perso_info_set_cmd_AC(stse_perso_info_t *pPerso,
169227
PLAT_UI8 command_code,
170228
stse_cmd_access_conditions_t protection);
171229

230+
/**
231+
* \brief Set extended command access conditions in personalization info
232+
* \details This function sets the access conditions for a specific extended command
233+
* \param[in,out] pPerso Pointer to personalization info structure
234+
* \param[in] command_code Extended command code to configure
235+
* \param[in] protection Access conditions to set
236+
*/
172237
void stsafea_perso_info_set_ext_cmd_AC(stse_perso_info_t *pPerso,
173238
PLAT_UI8 command_code,
174239
stse_cmd_access_conditions_t protection);
175240

241+
/**
242+
* \brief Set command encryption flag in personalization info
243+
* \details This function sets the encryption flag for a specific command
244+
* \param[in,out] pPerso Pointer to personalization info structure
245+
* \param[in] command_code Command code to configure
246+
* \param[in] enc_flag Encryption flag to set
247+
*/
176248
void stsafea_perso_info_set_cmd_encrypt_flag(stse_perso_info_t *pPerso,
177249
PLAT_UI8 command_code,
178250
PLAT_UI8 enc_flag);
179251

252+
/**
253+
* \brief Set response encryption flag in personalization info
254+
* \details This function sets the encryption flag for a specific command response
255+
* \param[in,out] pPerso Pointer to personalization info structure
256+
* \param[in] command_code Command code to configure
257+
* \param[in] enc_flag Encryption flag to set
258+
*/
180259
void stsafea_perso_info_set_rsp_encrypt_flag(stse_perso_info_t *pPerso,
181260
PLAT_UI8 command_code,
182261
PLAT_UI8 enc_flag);
183262

263+
/**
264+
* \brief Set extended command encryption flag in personalization info
265+
* \details This function sets the encryption flag for a specific extended command
266+
* \param[in,out] pPerso Pointer to personalization info structure
267+
* \param[in] command_code Extended command code to configure
268+
* \param[in] enc_flag Encryption flag to set
269+
*/
184270
void stsafea_perso_info_set_ext_cmd_encrypt_flag(stse_perso_info_t *pPerso,
185271
PLAT_UI8 command_code,
186272
PLAT_UI8 enc_flag);
187273

274+
/**
275+
* \brief Set extended response encryption flag in personalization info
276+
* \details This function sets the encryption flag for a specific extended command response
277+
* \param[in,out] pPerso Pointer to personalization info structure
278+
* \param[in] command_code Extended command code to configure
279+
* \param[in] enc_flag Encryption flag to set
280+
*/
188281
void stsafea_perso_info_set_ext_rsp_encrypt_flag(stse_perso_info_t *pPerso,
189282
PLAT_UI8 command_code,
190283
PLAT_UI8 enc_flag);

0 commit comments

Comments
 (0)