@@ -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+ }
0 commit comments