21
21
#include "hal/library/responder/key_pair_info.h"
22
22
#include "hal/library/responder/psklib.h"
23
23
#include "hal/library/responder/setcertlib.h"
24
+ #include "hal/library/endpointinfolib.h"
24
25
#include "hal/library/eventlib.h"
25
26
#include "hal/library/cryptlib.h"
26
27
@@ -243,6 +244,15 @@ typedef struct {
243
244
#define LIBSPDM_MAX_MESSAGE_F_BUFFER_SIZE (8 + LIBSPDM_MAX_HASH_SIZE * 2 + \
244
245
LIBSPDM_MAX_ASYM_KEY_SIZE)
245
246
247
+ /*
248
+ * +--------------------------+------------------------------------------+---------+
249
+ * | GET_EP_INFO 1.3 | 8 + Nonce (0 or 32) = [8, 40] | 1 |
250
+ * | EP_INFO 1.3 | 12 + Nonce + EPInfoLen = [12, 1024] | [1, 25] |
251
+ * +--------------------------+------------------------------------------+---------+
252
+ */
253
+ #define LIBSPDM_MAX_MESSAGE_E_BUFFER_SIZE (20 + SPDM_NONCE_SIZE * 2 + \
254
+ LIBSPDM_MAX_ENDPOINT_INFO_LENGTH)
255
+
246
256
#define LIBSPDM_MAX_MESSAGE_L1L2_BUFFER_SIZE \
247
257
(LIBSPDM_MAX_MESSAGE_VCA_BUFFER_SIZE + LIBSPDM_MAX_MESSAGE_M_BUFFER_SIZE)
248
258
@@ -257,6 +267,9 @@ typedef struct {
257
267
LIBSPDM_MAX_MESSAGE_D_BUFFER_SIZE + \
258
268
LIBSPDM_MAX_HASH_SIZE + LIBSPDM_MAX_MESSAGE_F_BUFFER_SIZE)
259
269
270
+ #define LIBSPDM_MAX_MESSAGE_IL1IL2_BUFFER_SIZE \
271
+ (LIBSPDM_MAX_MESSAGE_VCA_BUFFER_SIZE + LIBSPDM_MAX_MESSAGE_E_BUFFER_SIZE)
272
+
260
273
typedef struct {
261
274
size_t max_buffer_size ;
262
275
size_t buffer_size ;
@@ -287,6 +300,12 @@ typedef struct {
287
300
uint8_t buffer [LIBSPDM_MAX_MESSAGE_F_BUFFER_SIZE ];
288
301
} libspdm_message_f_managed_buffer_t ;
289
302
303
+ typedef struct {
304
+ size_t max_buffer_size ;
305
+ size_t buffer_size ;
306
+ uint8_t buffer [LIBSPDM_MAX_MESSAGE_E_BUFFER_SIZE ];
307
+ } libspdm_message_e_managed_buffer_t ;
308
+
290
309
typedef struct {
291
310
size_t max_buffer_size ;
292
311
size_t buffer_size ;
@@ -299,6 +318,12 @@ typedef struct {
299
318
uint8_t buffer [LIBSPDM_MAX_MESSAGE_M1M2_BUFFER_SIZE ];
300
319
} libspdm_m1m2_managed_buffer_t ;
301
320
321
+ typedef struct {
322
+ size_t max_buffer_size ;
323
+ size_t buffer_size ;
324
+ uint8_t buffer [LIBSPDM_MAX_MESSAGE_IL1IL2_BUFFER_SIZE ];
325
+ } libspdm_il1il2_managed_buffer_t ;
326
+
302
327
typedef struct {
303
328
size_t max_buffer_size ;
304
329
size_t buffer_size ;
@@ -325,6 +350,12 @@ typedef struct {
325
350
/* L1/L2 = Concatenate (M)
326
351
* M = Concatenate (GET_MEASUREMENT, MEASUREMENT\signature)*/
327
352
353
+ /* IL1/IL2 = Concatenate (A, E)
354
+ * E = Concatenate (GET_ENDPOINT_INFO, ENDPOINT_INFO\signature)*/
355
+
356
+ /* Encap IL1/IL2 = Concatenate (A, Encap E)
357
+ * Encap E = Concatenate (GET_ENDPOINT_INFO, ENDPOINT_INFO\signature)*/
358
+
328
359
typedef struct {
329
360
/* the message_a must be plan text because we do not know the algorithm yet.*/
330
361
libspdm_vca_managed_buffer_t message_a ;
@@ -335,10 +366,14 @@ typedef struct {
335
366
libspdm_message_b_managed_buffer_t message_mut_b ;
336
367
libspdm_message_c_managed_buffer_t message_mut_c ;
337
368
libspdm_message_m_managed_buffer_t message_m ;
369
+ libspdm_message_e_managed_buffer_t message_e ;
370
+ libspdm_message_e_managed_buffer_t message_encap_e ;
338
371
#else
339
372
void * digest_context_m1m2 ;
340
373
void * digest_context_mut_m1m2 ;
341
374
void * digest_context_l1l2 ;
375
+ void * digest_context_il1il2 ;
376
+ void * digest_context_encap_il1il2 ;
342
377
#endif
343
378
} libspdm_transcript_t ;
344
379
@@ -405,10 +440,14 @@ typedef struct {
405
440
libspdm_message_k_managed_buffer_t message_k ;
406
441
libspdm_message_f_managed_buffer_t message_f ;
407
442
libspdm_message_m_managed_buffer_t message_m ;
443
+ libspdm_message_e_managed_buffer_t message_e ;
444
+ libspdm_message_e_managed_buffer_t message_encap_e ;
408
445
#else
409
446
bool message_f_initialized ;
410
447
void * digest_context_th ;
411
448
void * digest_context_l1l2 ;
449
+ void * digest_context_il1il2 ;
450
+ void * digest_context_encap_il1il2 ;
412
451
/* this is back up for message F reset.*/
413
452
void * digest_context_th_backup ;
414
453
#endif
@@ -1006,6 +1045,40 @@ uint32_t libspdm_get_measurement_summary_hash_size(libspdm_context_t *spdm_conte
1006
1045
bool is_requester ,
1007
1046
uint8_t measurement_summary_hash_type );
1008
1047
1048
+ /**
1049
+ * This function generates the endpoint info signature based upon il1il2 for authentication.
1050
+ *
1051
+ * @param spdm_context A pointer to the SPDM context.
1052
+ * @param session_info A pointer to the SPDM session context.
1053
+ * @param is_requester Indicate of the signature generation for a requester or a responder.
1054
+ * @param signature The buffer to store the endpoint info signature.
1055
+ *
1056
+ * @retval true challenge signature is generated.
1057
+ * @retval false challenge signature is not generated.
1058
+ **/
1059
+ bool libspdm_generate_endpoint_info_signature (libspdm_context_t * spdm_context ,
1060
+ libspdm_session_info_t * session_info ,
1061
+ bool is_requester ,
1062
+ uint8_t * signature );
1063
+
1064
+ /**
1065
+ * This function verifies the challenge signature based upon m1m2.
1066
+ *
1067
+ * @param spdm_context A pointer to the SPDM context.
1068
+ * @param session_info A pointer to the SPDM session context.
1069
+ * @param is_requester Indicate of the signature verification for a requester or a responder.
1070
+ * @param sign_data The signature data buffer.
1071
+ * @param sign_data_size size in bytes of the signature data buffer.
1072
+ *
1073
+ * @retval true signature verification pass.
1074
+ * @retval false signature verification fail.
1075
+ **/
1076
+ bool libspdm_verify_endpoint_info_signature (libspdm_context_t * spdm_context ,
1077
+ libspdm_session_info_t * session_info ,
1078
+ bool is_requester ,
1079
+ const void * sign_data ,
1080
+ size_t sign_data_size );
1081
+
1009
1082
#if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
1010
1083
/*
1011
1084
* This function calculates l1l2.
@@ -1306,6 +1379,26 @@ void libspdm_reset_message_encap_d(libspdm_context_t *spdm_context, void *spdm_s
1306
1379
**/
1307
1380
void libspdm_reset_message_f (libspdm_context_t * spdm_context , void * spdm_session_info );
1308
1381
1382
+ /**
1383
+ * Reset message E cache in SPDM context.
1384
+ * If session_info is NULL, this function will use E cache of SPDM context,
1385
+ * else will use E cache of SPDM session context.
1386
+ *
1387
+ * @param spdm_context A pointer to the SPDM context.
1388
+ * @param spdm_session_info A pointer to the SPDM session context.
1389
+ **/
1390
+ void libspdm_reset_message_e (libspdm_context_t * spdm_context , void * session_info );
1391
+
1392
+ /**
1393
+ * Reset message encap E cache in SPDM context.
1394
+ * If session_info is NULL, this function will use encap E cache of SPDM context,
1395
+ * else will use encap E cache of SPDM session context.
1396
+ *
1397
+ * @param spdm_context A pointer to the SPDM context.
1398
+ * @param spdm_session_info A pointer to the SPDM session context.
1399
+ **/
1400
+ void libspdm_reset_message_encap_e (libspdm_context_t * spdm_context , void * session_info );
1401
+
1309
1402
/**
1310
1403
* Append message A cache in SPDM context.
1311
1404
*
@@ -1452,6 +1545,38 @@ libspdm_return_t libspdm_append_message_f(libspdm_context_t *spdm_context,
1452
1545
bool is_requester , const void * message ,
1453
1546
size_t message_size );
1454
1547
1548
+ /**
1549
+ * Append message E cache in SPDM context.
1550
+ * If session_info is NULL, this function will use E cache of SPDM context,
1551
+ * else will use E cache of SPDM session context.
1552
+ *
1553
+ * @param spdm_context A pointer to the SPDM context.
1554
+ * @param session_info A pointer to the SPDM session context.
1555
+ * @param message message buffer.
1556
+ * @param message_size size in bytes of message buffer.
1557
+ *
1558
+ * @return RETURN_SUCCESS message is appended.
1559
+ * @return RETURN_OUT_OF_RESOURCES message is not appended because the internal cache is full.
1560
+ **/
1561
+ libspdm_return_t libspdm_append_message_e (libspdm_context_t * spdm_context , void * session_info ,
1562
+ const void * message , size_t message_size );
1563
+
1564
+ /**
1565
+ * Append message encap E cache in SPDM context.
1566
+ * If session_info is NULL, this function will use encap E cache of SPDM context,
1567
+ * else will use encap E cache of SPDM session context.
1568
+ *
1569
+ * @param spdm_context A pointer to the SPDM context.
1570
+ * @param session_info A pointer to the SPDM session context.
1571
+ * @param message message buffer.
1572
+ * @param message_size size in bytes of message buffer.
1573
+ *
1574
+ * @return RETURN_SUCCESS message is appended.
1575
+ * @return RETURN_OUT_OF_RESOURCES message is not appended because the internal cache is full.
1576
+ **/
1577
+ libspdm_return_t libspdm_append_message_encap_e (libspdm_context_t * spdm_context , void * session_info ,
1578
+ const void * message , size_t message_size );
1579
+
1455
1580
/**
1456
1581
* This function generates a session ID by concatenating req_session_id and rsp_session_id.
1457
1582
*
0 commit comments