@@ -39,71 +39,39 @@ uint8_t libspdm_slot_id_to_key_pair_id (
3939 return context -> local_context .local_key_pair_id [slot_id ];
4040}
4141
42- /**
43- * This function returns peer certificate chain buffer including spdm_cert_chain_t header.
44- *
45- * @param spdm_context A pointer to the SPDM context.
46- * @param cert_chain_buffer Certificate chain buffer including spdm_cert_chain_t header.
47- * @param cert_chain_buffer_size size in bytes of the certificate chain buffer.
48- *
49- * @retval true Peer certificate chain buffer including spdm_cert_chain_t header is returned.
50- * @retval false Peer certificate chain buffer including spdm_cert_chain_t header is not found.
51- **/
52- bool libspdm_get_peer_cert_chain_buffer (void * spdm_context ,
42+ #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
43+ void libspdm_get_peer_cert_chain_buffer (void * spdm_context ,
44+ uint8_t slot_id ,
5345 const void * * cert_chain_buffer ,
5446 size_t * cert_chain_buffer_size )
5547{
56- #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
48+
5749 libspdm_context_t * context ;
58- uint8_t slot_id ;
5950
6051 context = spdm_context ;
61- slot_id = context -> connection_info . peer_used_cert_chain_slot_id ;
52+
6253 LIBSPDM_ASSERT (slot_id < SPDM_MAX_SLOT_COUNT );
63- if (context -> connection_info .peer_used_cert_chain [slot_id ].buffer_size != 0 ) {
64- * cert_chain_buffer = context -> connection_info .peer_used_cert_chain [slot_id ].buffer ;
65- * cert_chain_buffer_size = context -> connection_info
66- .peer_used_cert_chain [slot_id ].buffer_size ;
67- return true;
68- }
69- #endif
70- return false;
54+
55+ * cert_chain_buffer = context -> connection_info .peer_used_cert_chain [slot_id ].buffer ;
56+ * cert_chain_buffer_size = context -> connection_info .peer_used_cert_chain [slot_id ].buffer_size ;
7157}
7258
73- /**
74- * This function returns peer certificate chain data without spdm_cert_chain_t header.
75- *
76- * @param spdm_context A pointer to the SPDM context.
77- * @param cert_chain_data Certificate chain data without spdm_cert_chain_t header.
78- * @param cert_chain_data_size size in bytes of the certificate chain data.
79- *
80- * @retval true Peer certificate chain data without spdm_cert_chain_t header is returned.
81- * @retval false Peer certificate chain data without spdm_cert_chain_t header is not found.
82- **/
83- bool libspdm_get_peer_cert_chain_data (void * spdm_context ,
59+ void libspdm_get_peer_cert_chain_data (void * spdm_context ,
60+ uint8_t slot_id ,
8461 const void * * cert_chain_data ,
8562 size_t * cert_chain_data_size )
8663{
87- #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
8864 libspdm_context_t * context ;
8965 size_t hash_size ;
90- bool result ;
9166
9267 context = spdm_context ;
9368 hash_size = libspdm_get_hash_size (context -> connection_info .algorithm .base_hash_algo );
9469
95- result = libspdm_get_peer_cert_chain_buffer (context , cert_chain_data ,
96- cert_chain_data_size );
97- if (result ) {
98- * cert_chain_data =
99- (const uint8_t * )* cert_chain_data + sizeof (spdm_cert_chain_t ) + hash_size ;
100- * cert_chain_data_size =
101- * cert_chain_data_size - (sizeof (spdm_cert_chain_t ) + hash_size );
102- return true;
103- }
104- #endif
105- return false;
70+ libspdm_get_peer_cert_chain_buffer (context , slot_id , cert_chain_data , cert_chain_data_size );
71+ * cert_chain_data = (const uint8_t * )* cert_chain_data + sizeof (spdm_cert_chain_t ) + hash_size ;
72+ * cert_chain_data_size = * cert_chain_data_size - (sizeof (spdm_cert_chain_t ) + hash_size );
10673}
74+ #endif /* LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT */
10775
10876/**
10977 * This function returns local used certificate chain buffer including spdm_cert_chain_t header.
@@ -1038,6 +1006,7 @@ bool libspdm_generate_challenge_auth_signature(libspdm_context_t *spdm_context,
10381006 * @retval false hash verification fail.
10391007 **/
10401008bool libspdm_verify_certificate_chain_hash (libspdm_context_t * spdm_context ,
1009+ uint8_t slot_id ,
10411010 const void * certificate_chain_hash ,
10421011 size_t certificate_chain_hash_size )
10431012{
@@ -1047,17 +1016,11 @@ bool libspdm_verify_certificate_chain_hash(libspdm_context_t *spdm_context,
10471016 const uint8_t * cert_chain_buffer ;
10481017 size_t cert_chain_buffer_size ;
10491018 bool result ;
1050- #else
1051- uint8_t slot_id ;
1052- #endif
10531019
1054- #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
1055- result = libspdm_get_peer_cert_chain_buffer (spdm_context ,
1056- (const void * * )& cert_chain_buffer ,
1057- & cert_chain_buffer_size );
1058- if (!result ) {
1059- return false;
1060- }
1020+ libspdm_get_peer_cert_chain_buffer (spdm_context ,
1021+ slot_id ,
1022+ (const void * * )& cert_chain_buffer ,
1023+ & cert_chain_buffer_size );
10611024
10621025 hash_size = libspdm_get_hash_size (spdm_context -> connection_info .algorithm .base_hash_algo );
10631026
@@ -1080,9 +1043,6 @@ bool libspdm_verify_certificate_chain_hash(libspdm_context_t *spdm_context,
10801043 return false;
10811044 }
10821045#else
1083- slot_id = spdm_context -> connection_info .peer_used_cert_chain_slot_id ;
1084- LIBSPDM_ASSERT (slot_id < SPDM_MAX_SLOT_COUNT );
1085-
10861046 LIBSPDM_ASSERT (
10871047 spdm_context -> connection_info .peer_used_cert_chain [slot_id ].buffer_hash_size != 0 );
10881048
@@ -1160,12 +1120,12 @@ bool libspdm_verify_public_key_hash(libspdm_context_t *spdm_context,
11601120 **/
11611121bool libspdm_verify_challenge_auth_signature (libspdm_context_t * spdm_context ,
11621122 bool is_requester ,
1123+ uint8_t slot_id ,
11631124 const void * sign_data ,
11641125 size_t sign_data_size )
11651126{
11661127 bool result ;
11671128 void * context ;
1168- uint8_t slot_id ;
11691129#if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
11701130 libspdm_m1m2_managed_buffer_t m1m2 ;
11711131 uint8_t * m1m2_buffer ;
@@ -1198,9 +1158,6 @@ bool libspdm_verify_challenge_auth_signature(libspdm_context_t *spdm_context,
11981158 return false;
11991159 }
12001160
1201- slot_id = spdm_context -> connection_info .peer_used_cert_chain_slot_id ;
1202- LIBSPDM_ASSERT ((slot_id < SPDM_MAX_SLOT_COUNT ) || (slot_id == 0xFF ));
1203-
12041161 if (slot_id == 0xFF ) {
12051162 if (is_requester ) {
12061163 if (spdm_context -> connection_info .algorithm .pqc_asym_algo != 0 ) {
@@ -1236,11 +1193,8 @@ bool libspdm_verify_challenge_auth_signature(libspdm_context_t *spdm_context,
12361193 }
12371194 } else {
12381195#if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
1239- result = libspdm_get_peer_cert_chain_data (
1240- spdm_context , (const void * * )& cert_chain_data , & cert_chain_data_size );
1241- if (!result ) {
1242- return false;
1243- }
1196+ libspdm_get_peer_cert_chain_data (
1197+ spdm_context , slot_id , (const void * * )& cert_chain_data , & cert_chain_data_size );
12441198
12451199 /* Get leaf cert from cert chain*/
12461200 result = libspdm_x509_get_cert_from_cert_chain (
@@ -1543,12 +1497,12 @@ bool libspdm_generate_endpoint_info_signature(libspdm_context_t *spdm_context,
15431497bool libspdm_verify_endpoint_info_signature (libspdm_context_t * spdm_context ,
15441498 libspdm_session_info_t * session_info ,
15451499 bool is_requester ,
1500+ uint8_t slot_id ,
15461501 const void * sign_data ,
15471502 size_t sign_data_size )
15481503{
15491504 bool result ;
15501505 void * context ;
1551- uint8_t slot_id ;
15521506#if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
15531507 libspdm_il1il2_managed_buffer_t il1il2 ;
15541508 uint8_t * il1il2_buffer ;
@@ -1580,9 +1534,6 @@ bool libspdm_verify_endpoint_info_signature(libspdm_context_t *spdm_context,
15801534 return false;
15811535 }
15821536
1583- slot_id = spdm_context -> connection_info .peer_used_cert_chain_slot_id ;
1584- LIBSPDM_ASSERT ((slot_id < SPDM_MAX_SLOT_COUNT ) || (slot_id == 0xF ));
1585-
15861537 if (slot_id == 0xF ) {
15871538 if (is_requester ) {
15881539 if (spdm_context -> connection_info .algorithm .base_asym_algo != 0 ) {
@@ -1620,11 +1571,8 @@ bool libspdm_verify_endpoint_info_signature(libspdm_context_t *spdm_context,
16201571 }
16211572 } else {
16221573#if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
1623- result = libspdm_get_peer_cert_chain_data (
1624- spdm_context , (const void * * )& cert_chain_data , & cert_chain_data_size );
1625- if (!result ) {
1626- return false;
1627- }
1574+ libspdm_get_peer_cert_chain_data (
1575+ spdm_context , slot_id , (const void * * )& cert_chain_data , & cert_chain_data_size );
16281576
16291577 /* Get leaf cert from cert chain*/
16301578 result = libspdm_x509_get_cert_from_cert_chain (cert_chain_data ,
0 commit comments