12
12
typedef struct {
13
13
spdm_message_header_t header ;
14
14
uint8_t digest [LIBSPDM_MAX_HASH_SIZE * SPDM_MAX_SLOT_COUNT ];
15
+ spdm_key_pair_id_t key_pair_id [SPDM_MAX_SLOT_COUNT ];
16
+ spdm_certificate_info_t cert_info [SPDM_MAX_SLOT_COUNT ];
17
+ spdm_key_usage_bit_mask_t key_usage_bit_mask [SPDM_MAX_SLOT_COUNT ];
15
18
} libspdm_digests_response_max_t ;
16
19
#pragma pack()
17
20
@@ -59,6 +62,12 @@ static libspdm_return_t libspdm_try_get_digest(libspdm_context_t *spdm_context,
59
62
size_t transport_header_size ;
60
63
libspdm_session_info_t * session_info ;
61
64
libspdm_session_state_t session_state ;
65
+ size_t additional_size ;
66
+ spdm_key_pair_id_t * key_pair_id ;
67
+ spdm_certificate_info_t * cert_info ;
68
+ spdm_key_usage_bit_mask_t * key_usage_bit_mask ;
69
+ size_t slot_index ;
70
+ uint8_t cert_model ;
62
71
63
72
/* -=[Verify State Phase]=- */
64
73
if (!libspdm_is_capabilities_flag_supported (
@@ -159,6 +168,18 @@ static libspdm_return_t libspdm_try_get_digest(libspdm_context_t *spdm_context,
159
168
* slot_mask = spdm_response -> header .param2 ;
160
169
}
161
170
171
+ LIBSPDM_DEBUG ((LIBSPDM_DEBUG_INFO , "provisioned_slot_mask - 0x%02x\n" ,
172
+ spdm_response -> header .param2 ));
173
+ if (spdm_request -> header .spdm_version >= SPDM_MESSAGE_VERSION_13 ) {
174
+ LIBSPDM_DEBUG ((LIBSPDM_DEBUG_INFO , "supported_slot_mask - 0x%02x\n" ,
175
+ spdm_response -> header .param1 ));
176
+ if ((spdm_response -> header .param1 & spdm_response -> header .param2 ) !=
177
+ spdm_response -> header .param2 ) {
178
+ status = LIBSPDM_STATUS_INVALID_MSG_FIELD ;
179
+ goto receive_done ;
180
+ }
181
+ }
182
+
162
183
digest_count = 0 ;
163
184
for (index = 0 ; index < SPDM_MAX_SLOT_COUNT ; index ++ ) {
164
185
if (spdm_response -> header .param2 & (1 << index )) {
@@ -170,11 +191,19 @@ static libspdm_return_t libspdm_try_get_digest(libspdm_context_t *spdm_context,
170
191
goto receive_done ;
171
192
}
172
193
173
- if (spdm_response_size < sizeof (spdm_digest_response_t ) + digest_count * digest_size ) {
194
+ additional_size = 0 ;
195
+ if ((spdm_request -> header .spdm_version >= SPDM_MESSAGE_VERSION_13 ) &&
196
+ spdm_context -> connection_info .multi_key_conn_rsp ) {
197
+ additional_size = sizeof (spdm_key_pair_id_t ) + sizeof (spdm_certificate_info_t ) +
198
+ sizeof (spdm_key_usage_bit_mask_t );
199
+ }
200
+ if (spdm_response_size <
201
+ sizeof (spdm_digest_response_t ) + digest_count * (digest_size + additional_size )) {
174
202
status = LIBSPDM_STATUS_INVALID_MSG_SIZE ;
175
203
goto receive_done ;
176
204
}
177
- spdm_response_size = sizeof (spdm_digest_response_t ) + digest_count * digest_size ;
205
+ spdm_response_size =
206
+ sizeof (spdm_digest_response_t ) + digest_count * (digest_size + additional_size );
178
207
179
208
/* -=[Process Response Phase]=- */
180
209
if (session_id == NULL ) {
@@ -196,22 +225,74 @@ static libspdm_return_t libspdm_try_get_digest(libspdm_context_t *spdm_context,
196
225
}
197
226
}
198
227
228
+ key_pair_id =
229
+ (spdm_key_pair_id_t * )((uint8_t * )spdm_response -> digest + digest_size * digest_count );
230
+ cert_info =
231
+ (spdm_certificate_info_t * )((uint8_t * )key_pair_id + sizeof (spdm_key_pair_id_t ) *
232
+ digest_count );
233
+ key_usage_bit_mask =
234
+ (spdm_key_usage_bit_mask_t * )((uint8_t * )cert_info + sizeof (spdm_certificate_info_t ) *
235
+ digest_count );
199
236
for (index = 0 ; index < digest_count ; index ++ ) {
200
237
LIBSPDM_DEBUG ((LIBSPDM_DEBUG_INFO , "digest (0x%x) - " , index ));
201
238
LIBSPDM_INTERNAL_DUMP_DATA (& spdm_response -> digest [digest_size * index ], digest_size );
202
239
LIBSPDM_DEBUG ((LIBSPDM_DEBUG_INFO , "\n" ));
203
240
}
241
+ if ((spdm_request -> header .spdm_version >= SPDM_MESSAGE_VERSION_13 ) &&
242
+ spdm_context -> connection_info .multi_key_conn_rsp ) {
243
+ for (index = 0 ; index < digest_count ; index ++ ) {
244
+ LIBSPDM_DEBUG ((LIBSPDM_DEBUG_INFO , "key_pair_id (0x%x) - 0x%02x\n" , index ,
245
+ key_pair_id [index ]));
246
+ }
247
+ for (index = 0 ; index < digest_count ; index ++ ) {
248
+ LIBSPDM_DEBUG ((LIBSPDM_DEBUG_INFO , "cert_info (0x%x) - 0x%02x\n" , index ,
249
+ cert_info [index ]));
250
+ }
251
+ for (index = 0 ; index < digest_count ; index ++ ) {
252
+ LIBSPDM_DEBUG ((LIBSPDM_DEBUG_INFO , "key_usage_bit_mask (0x%x) - 0x%04x\n" , index ,
253
+ key_usage_bit_mask [index ]));
254
+ }
255
+ }
204
256
205
257
if (total_digest_buffer != NULL ) {
206
258
libspdm_copy_mem (total_digest_buffer , digest_size * digest_count ,
207
259
spdm_response -> digest , digest_size * digest_count );
208
260
}
209
261
210
- spdm_context -> connection_info .peer_digest_slot_mask = spdm_response -> header .param2 ;
262
+ spdm_context -> connection_info .peer_provisioned_slot_mask = spdm_response -> header .param2 ;
263
+ if (spdm_request -> header .spdm_version >= SPDM_MESSAGE_VERSION_13 ) {
264
+ spdm_context -> connection_info .peer_supported_slot_mask = spdm_response -> header .param1 ;
265
+ } else {
266
+ spdm_context -> connection_info .peer_supported_slot_mask = spdm_response -> header .param2 ;
267
+ }
211
268
libspdm_copy_mem (
212
269
spdm_context -> connection_info .peer_total_digest_buffer ,
213
270
sizeof (spdm_context -> connection_info .peer_total_digest_buffer ),
214
271
spdm_response -> digest , digest_size * digest_count );
272
+ libspdm_zero_mem (spdm_context -> connection_info .peer_key_pair_id ,
273
+ sizeof (spdm_context -> connection_info .peer_key_pair_id ));
274
+ libspdm_zero_mem (spdm_context -> connection_info .peer_cert_info ,
275
+ sizeof (spdm_context -> connection_info .peer_cert_info ));
276
+ libspdm_zero_mem (spdm_context -> connection_info .peer_key_usage_bit_mask ,
277
+ sizeof (spdm_context -> connection_info .peer_key_usage_bit_mask ));
278
+ if ((spdm_request -> header .spdm_version >= SPDM_MESSAGE_VERSION_13 ) &&
279
+ spdm_context -> connection_info .multi_key_conn_rsp ) {
280
+ slot_index = 0 ;
281
+ for (index = 0 ; index < SPDM_MAX_SLOT_COUNT ; index ++ ) {
282
+ if (spdm_response -> header .param2 & (1 << index )) {
283
+ spdm_context -> connection_info .peer_key_pair_id [index ] = key_pair_id [slot_index ];
284
+ cert_model = cert_info [slot_index ] & SPDM_CERTIFICATE_INFO_CERT_MODEL_MASK ;
285
+ if (cert_model > SPDM_CERTIFICATE_INFO_CERT_MODEL_GENERIC_CERT ) {
286
+ status = LIBSPDM_STATUS_INVALID_MSG_FIELD ;
287
+ goto receive_done ;
288
+ }
289
+ spdm_context -> connection_info .peer_cert_info [index ] = cert_model ;
290
+ spdm_context -> connection_info .peer_key_usage_bit_mask [index ] =
291
+ key_usage_bit_mask [slot_index ];
292
+ slot_index ++ ;
293
+ }
294
+ }
295
+ }
215
296
216
297
/* -=[Update State Phase]=- */
217
298
if (spdm_context -> connection_info .connection_state < LIBSPDM_CONNECTION_STATE_AFTER_DIGESTS ) {
0 commit comments