Skip to content

Commit 72b0870

Browse files
[All] Pre-commit
1 parent ded0275 commit 72b0870

17 files changed

Lines changed: 105 additions & 113 deletions

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Provides a set of product services that format all commands supported by the tar
1919
<b>- Core layer</b>
2020
Contains generic definition for ST Secure Element and functions for communicating with target secure element.
2121

22-
## Package documentation
22+
## Package documentation
2323

2424
HTML documentation can either be downloaded as standalone package from the STSELib github repository [release section](https://github.com/STMicroelectronics/STSELib/releases)
2525
or compiled from the library sources by executing following commands from the STSELib root directory:
@@ -31,9 +31,9 @@ or compiled from the library sources by executing following commands from the ST
3131

3232
> [!NOTE]
3333
>
34-
> Doxygen version 1.14.0 is required to build the documentation
34+
> Doxygen version 1.14.0 is required to build the documentation
3535
36-
## STSELib Integration
36+
## STSELib Integration
3737

3838
### 1. Add STSELib as a Git submodule
3939

api/stse_derive_keys.c

Lines changed: 27 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ stse_ReturnCode_t stse_derive_key(
2525
PLAT_UI8 *pContext,
2626
PLAT_UI16 context_len,
2727
PLAT_UI8 *pOutput_key,
28-
PLAT_UI16 key_length)
29-
{
28+
PLAT_UI16 key_length) {
3029
stsafea_hkdf_input_key_t input_key = {0};
3130
stsafea_hkdf_salt_t salt = {0};
3231
stsafea_hkdf_info_t info = {0};
@@ -64,7 +63,7 @@ stse_ReturnCode_t stse_derive_key(
6463
return stsafea_derive_keys(
6564
pSTSE,
6665
&input_key,
67-
1, 1, /* Extract=1, Expand=1 */
66+
1, 1, /* Extract=1, Expand=1 */
6867
&salt,
6968
&info,
7069
&okm_map,
@@ -78,14 +77,13 @@ stse_ReturnCode_t stse_derive_key_simple(
7877
PLAT_UI8 *pContext,
7978
PLAT_UI16 context_len,
8079
PLAT_UI8 *pOutput_key,
81-
PLAT_UI16 key_length)
82-
{
80+
PLAT_UI16 key_length) {
8381
/* Directly call the main function with NULL salt */
8482
return stse_derive_key(
8583
pSTSE,
8684
master_slot,
87-
NULL, /* No salt */
88-
0, /* Salt length 0 */
85+
NULL, /* No salt */
86+
0, /* Salt length 0 */
8987
pContext,
9088
context_len,
9189
pOutput_key,
@@ -97,8 +95,7 @@ stse_ReturnCode_t stse_derive_key_extract(
9795
PLAT_UI8 master_slot,
9896
PLAT_UI8 *pSalt,
9997
PLAT_UI16 salt_length,
100-
PLAT_UI8 *pPrk_slot)
101-
{
98+
PLAT_UI8 *pPrk_slot) {
10299
stsafea_hkdf_input_key_t input_key = {0};
103100
stsafea_hkdf_salt_t salt = {0};
104101
stsafea_hkdf_output_t output = {0};
@@ -122,7 +119,7 @@ stse_ReturnCode_t stse_derive_key_extract(
122119
ret = stsafea_derive_keys(
123120
pSTSE,
124121
&input_key,
125-
1, 0, /* Extract=1, Expand=0 */
122+
1, 0, /* Extract=1, Expand=0 */
126123
&salt,
127124
NULL,
128125
NULL,
@@ -142,8 +139,7 @@ stse_ReturnCode_t stse_derive_key_expand(
142139
PLAT_UI8 *pContext,
143140
PLAT_UI16 context_len,
144141
PLAT_UI8 *pOutput_key,
145-
PLAT_UI16 key_length)
146-
{
142+
PLAT_UI16 key_length) {
147143
stsafea_hkdf_input_key_t input_key = {0};
148144
stsafea_hkdf_info_t info = {0};
149145
stsafea_hkdf_okm_description_t okm_map = {0};
@@ -175,7 +171,7 @@ stse_ReturnCode_t stse_derive_key_expand(
175171
return stsafea_derive_keys(
176172
pSTSE,
177173
&input_key,
178-
0, 1, /* Extract=0, Expand=1 */
174+
0, 1, /* Extract=0, Expand=1 */
179175
NULL,
180176
&info,
181177
&okm_map,
@@ -190,12 +186,11 @@ stse_ReturnCode_t stse_derive_session_keys(
190186
PLAT_UI8 *pEnc_key,
191187
PLAT_UI16 enc_key_len,
192188
PLAT_UI8 *pMac_key,
193-
PLAT_UI16 mac_key_len)
194-
{
189+
PLAT_UI16 mac_key_len) {
195190
stse_ReturnCode_t ret;
196191
PLAT_UI8 prk_slot;
197192
PLAT_UI8 salt[4];
198-
193+
199194
/* Validate parameters */
200195
if (pSTSE == NULL || pEnc_key == NULL || pMac_key == NULL) {
201196
return STSE_SERVICE_INVALID_PARAMETER;
@@ -214,16 +209,16 @@ stse_ReturnCode_t stse_derive_session_keys(
214209
}
215210

216211
/* Step 2: Derive encryption key with context "ENC" */
217-
ret = stse_derive_key_expand(pSTSE, prk_slot, (PLAT_UI8*)"ENC", 3,
218-
pEnc_key, enc_key_len);
212+
ret = stse_derive_key_expand(pSTSE, prk_slot, (PLAT_UI8 *)"ENC", 3,
213+
pEnc_key, enc_key_len);
219214
if (ret != STSE_OK) {
220215
return ret;
221216
}
222217

223218
/* Step 3: Derive MAC key with context "MAC" */
224-
ret = stse_derive_key_expand(pSTSE, prk_slot, (PLAT_UI8*)"MAC", 3,
225-
pMac_key, mac_key_len);
226-
219+
ret = stse_derive_key_expand(pSTSE, prk_slot, (PLAT_UI8 *)"MAC", 3,
220+
pMac_key, mac_key_len);
221+
227222
return ret;
228223
}
229224

@@ -235,8 +230,7 @@ stse_ReturnCode_t stse_derive_key_to_slot(
235230
PLAT_UI8 *pContext,
236231
PLAT_UI16 context_len,
237232
stsafe_output_key_description_information_t *pKey_info,
238-
PLAT_UI8 *pOutput_slot)
239-
{
233+
PLAT_UI8 *pOutput_slot) {
240234
stsafea_hkdf_input_key_t input_key = {0};
241235
stsafea_hkdf_salt_t salt = {0};
242236
stsafea_hkdf_info_t info = {0};
@@ -274,7 +268,7 @@ stse_ReturnCode_t stse_derive_key_to_slot(
274268
ret = stsafea_derive_keys(
275269
pSTSE,
276270
&input_key,
277-
1, 1, /* Extract=1, Expand=1 */
271+
1, 1, /* Extract=1, Expand=1 */
278272
&salt,
279273
&info,
280274
&okm_map,
@@ -295,17 +289,16 @@ stse_ReturnCode_t stse_derive_key_expand_multiple(
295289
PLAT_UI16 *pContext_lens,
296290
PLAT_UI8 **pOutput_keys,
297291
PLAT_UI16 *pKey_lengths,
298-
PLAT_UI8 num_keys)
299-
{
292+
PLAT_UI8 num_keys) {
300293
stsafea_hkdf_input_key_t input_key = {0};
301294
stsafea_hkdf_info_t info = {0};
302-
stsafea_hkdf_okm_description_t okm_map[32];
295+
stsafea_hkdf_okm_description_t okm_map[32];
303296
stsafea_hkdf_output_t output = {0};
304297
stsafea_hkdf_derived_key_output_t derived_keys_out[32];
305298
PLAT_UI8 i;
306299

307300
/* Validate parameters */
308-
if (pSTSE == NULL || pOutput_keys == NULL || pKey_lengths == NULL ||
301+
if (pSTSE == NULL || pOutput_keys == NULL || pKey_lengths == NULL ||
309302
num_keys == 0 || num_keys > 32) {
310303
return STSE_SERVICE_INVALID_PARAMETER;
311304
}
@@ -327,7 +320,7 @@ stse_ReturnCode_t stse_derive_key_expand_multiple(
327320
for (i = 0; i < num_keys; i++) {
328321
okm_map[i].destination = STSAFEA_KEY_SOURCE_RESPONSE;
329322
okm_map[i].response.key_length = pKey_lengths[i];
330-
323+
331324
derived_keys_out[i].response.data = pOutput_keys[i];
332325
}
333326

@@ -338,7 +331,7 @@ stse_ReturnCode_t stse_derive_key_expand_multiple(
338331
return stsafea_derive_keys(
339332
pSTSE,
340333
&input_key,
341-
0, 1, /* Extract=0, Expand=1 */
334+
0, 1, /* Extract=0, Expand=1 */
342335
NULL,
343336
&info,
344337
okm_map,
@@ -355,8 +348,7 @@ stse_ReturnCode_t stse_derive_key_from_ikm(
355348
PLAT_UI8 *pContext,
356349
PLAT_UI16 context_len,
357350
PLAT_UI8 *pOutput_key,
358-
PLAT_UI16 key_length)
359-
{
351+
PLAT_UI16 key_length) {
360352
stsafea_hkdf_input_key_t input_key = {0};
361353
stsafea_hkdf_salt_t salt = {0};
362354
stsafea_hkdf_info_t info = {0};
@@ -365,7 +357,7 @@ stse_ReturnCode_t stse_derive_key_from_ikm(
365357
stsafea_hkdf_derived_key_output_t derived_key_out = {0};
366358

367359
/* Validate parameters */
368-
if (pSTSE == NULL || pIkm == NULL || pOutput_key == NULL ||
360+
if (pSTSE == NULL || pIkm == NULL || pOutput_key == NULL ||
369361
ikm_length == 0 || key_length == 0) {
370362
return STSE_SERVICE_INVALID_PARAMETER;
371363
}
@@ -397,10 +389,10 @@ stse_ReturnCode_t stse_derive_key_from_ikm(
397389
return stsafea_derive_keys(
398390
pSTSE,
399391
&input_key,
400-
1, 1, /* Extract=1, Expand=1 */
392+
1, 1, /* Extract=1, Expand=1 */
401393
&salt,
402394
&info,
403395
&okm_map,
404396
1,
405397
&output);
406-
}
398+
}

api/stse_derive_keys.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ stse_ReturnCode_t stse_derive_key_from_ikm(
212212
PLAT_UI8 *pOutput_key,
213213
PLAT_UI16 key_length);
214214

215-
216215
#endif /* STSE_DERIVE_KEYS_H */
217216

218-
/*! @}*/
217+
/*! @}*/

api/stse_ecc.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ stse_ReturnCode_t stse_ecc_verify_signature(
7777
* \param[in] message_length Message length
7878
* \param[out] pSignature Signature buffer (concatenation of R and S)
7979
* \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise
80-
*
80+
*
8181
* \note The signature output is the concatenation of R and S values (R|S as defined in ASN.1 DER encoding).
82-
*
82+
*
8383
* \details \include{doc} stse_ecc_generate_signature.dox
8484
*/
8585
stse_ReturnCode_t stse_ecc_generate_signature(
@@ -99,9 +99,9 @@ stse_ReturnCode_t stse_ecc_generate_signature(
9999
* \param[in] pPublic_key Remote public key
100100
* \param[out] pShared_secret Shared secret returned by the STSE
101101
* \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise
102-
*
102+
*
103103
* \details \include{doc} stse_ecc_establish_shared_secret.dox
104-
*
104+
*
105105
* \note The public key format must match the expected ECC representation (typically concatenation of X and Y coordinates for uncompressed, or X with a prefix for compressed).
106106
*/
107107
stse_ReturnCode_t stse_ecc_establish_shared_secret(

core/stse_generic_typedef.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,10 @@ typedef enum stse_zone_update_atomicity_t {
214214
* \brief STSE data storage access condition enumeration
215215
*/
216216
typedef enum stse_zone_ac_t {
217-
STSE_AC_ALWAYS = 0, /*!< Zone/counter access always granted */
218-
STSE_AC_HOST, /*!< Zone/counter access granted on Host C-MAC validation */
219-
STSE_AC_AUTH_AND_HOST = 6, /*!< Zone/counter access granted on true Authentic entity status (verify entity signature) + Host C-MAC validation */
220-
STSE_AC_NEVER = 7 /*!< Zone/counter access never granted */
217+
STSE_AC_ALWAYS = 0, /*!< Zone/counter access always granted */
218+
STSE_AC_HOST, /*!< Zone/counter access granted on Host C-MAC validation */
219+
STSE_AC_AUTH_AND_HOST = 6, /*!< Zone/counter access granted on true Authentic entity status (verify entity signature) + Host C-MAC validation */
220+
STSE_AC_NEVER = 7 /*!< Zone/counter access never granted */
221221
} stse_zone_ac_t;
222222

223223
/**

doc/resources/dox_files/APIs/derive_keys/stse_derive_key.dox

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ The following diagram illustrates the interactions performed between the Host an
2424
PLAT_UI8 derived_key[32];
2525
PLAT_UI8 salt[] = {0x01, 0x02, 0x03, 0x04};
2626
PLAT_UI8 context[] = "app-context";
27-
27+
2828
stse_ret = stse_derive_key(
2929
&stse_handler,
30-
STSE_MASTER_KEY_SLOT,
30+
STSE_MASTER_KEY_SLOT,
3131
salt, sizeof(salt),
3232
context, sizeof(context)-1,
3333
derived_key, 32
3434
);
35-
35+
3636
if (stse_ret != STSE_OK)
3737
{
3838
/* Handle Error */
@@ -41,4 +41,4 @@ The following diagram illustrates the interactions performed between the Host an
4141

4242
\sa stse_init
4343

44-
<div style="page-break-after: always;"></div>
44+
<div style="page-break-after: always;"></div>

doc/resources/dox_files/APIs/derive_keys/stse_derive_key_expand.dox

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ This command performs the HKDF-Expand step only. It takes a previously extracted
2222
/* ## HKDF Expand from PRK */
2323
PLAT_UI8 output_key[16];
2424
PLAT_UI8 context[] = "expansion-context";
25-
25+
2626
/* Assumes prk_slot was populated by a previous extract call */
2727
stse_ret = stse_derive_key_expand(
2828
&stse_handler,
@@ -34,4 +34,4 @@ This command performs the HKDF-Expand step only. It takes a previously extracted
3434

3535
\sa stse_init
3636

37-
<div style="page-break-after: always;"></div>
37+
<div style="page-break-after: always;"></div>

doc/resources/dox_files/APIs/derive_keys/stse_derive_key_expand_multiple.dox

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ This function uses the HKDF-Expand command to derive multiple keys (up to 32) in
2424
PLAT_UI8 *outputs[2];
2525
PLAT_UI16 lengths[2] = {16, 16};
2626
PLAT_UI8 key1[16], key2[16];
27-
27+
2828
outputs[0] = key1;
2929
outputs[1] = key2;
3030

@@ -40,4 +40,4 @@ This function uses the HKDF-Expand command to derive multiple keys (up to 32) in
4040

4141
\sa stse_init
4242

43-
<div style="page-break-after: always;"></div>
43+
<div style="page-break-after: always;"></div>

doc/resources/dox_files/APIs/derive_keys/stse_derive_key_extract.dox

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ This command performs the HKDF-Extract step only. It generates a Pseudo-Random K
2323
/* ## HKDF Extract PRK */
2424
PLAT_UI8 salt[] = {0xAA, 0xBB, 0xCC, 0xDD};
2525
PLAT_UI8 prk_slot;
26-
26+
2727
stse_ret = stse_derive_key_extract(
2828
&stse_handler,
2929
STSE_MASTER_KEY_SLOT,
@@ -34,4 +34,4 @@ This command performs the HKDF-Extract step only. It generates a Pseudo-Random K
3434

3535
\sa stse_init
3636

37-
<div style="page-break-after: always;"></div>
37+
<div style="page-break-after: always;"></div>

doc/resources/dox_files/APIs/derive_keys/stse_derive_key_from_ikm.dox

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ This function derives a key using raw Input Key Material (IKM) provided in the c
3434

3535
\sa stse_init
3636

37-
<div style="page-break-after: always;"></div>
37+
<div style="page-break-after: always;"></div>

0 commit comments

Comments
 (0)