@@ -71,6 +71,11 @@ libspdm_return_t libspdm_process_encap_response_digest(
71
71
libspdm_return_t status ;
72
72
uint32_t session_id ;
73
73
libspdm_session_info_t * session_info ;
74
+ size_t additional_size ;
75
+ spdm_key_pair_id_t * key_pair_id ;
76
+ spdm_certificate_info_t * cert_info ;
77
+ spdm_key_usage_bit_mask_t * key_usage_bit_mask ;
78
+ size_t slot_index ;
74
79
75
80
spdm_response = encap_response ;
76
81
spdm_response_size = encap_response_size ;
@@ -96,6 +101,17 @@ libspdm_return_t libspdm_process_encap_response_digest(
96
101
return LIBSPDM_STATUS_INVALID_MSG_SIZE ;
97
102
}
98
103
104
+ LIBSPDM_DEBUG ((LIBSPDM_DEBUG_INFO , "provisioned_slot_mask - 0x%02x\n" ,
105
+ spdm_response -> header .param2 ));
106
+ if (spdm_response -> header .spdm_version >= SPDM_MESSAGE_VERSION_13 ) {
107
+ LIBSPDM_DEBUG ((LIBSPDM_DEBUG_INFO , "supported_slot_mask - 0x%02x\n" ,
108
+ spdm_response -> header .param1 ));
109
+ if ((spdm_response -> header .param1 & spdm_response -> header .param2 ) !=
110
+ spdm_response -> header .param2 ) {
111
+ return LIBSPDM_STATUS_INVALID_MSG_FIELD ;
112
+ }
113
+ }
114
+
99
115
digest_size = libspdm_get_hash_size (
100
116
spdm_context -> connection_info .algorithm .base_hash_algo );
101
117
digest_count = 0 ;
@@ -107,12 +123,19 @@ libspdm_return_t libspdm_process_encap_response_digest(
107
123
if (digest_count == 0 ) {
108
124
return LIBSPDM_STATUS_INVALID_MSG_FIELD ;
109
125
}
126
+
127
+ additional_size = 0 ;
128
+ if ((spdm_response -> header .spdm_version >= SPDM_MESSAGE_VERSION_13 ) &&
129
+ spdm_context -> connection_info .multi_key_conn_req ) {
130
+ additional_size = sizeof (spdm_key_pair_id_t ) + sizeof (spdm_certificate_info_t ) +
131
+ sizeof (spdm_key_usage_bit_mask_t );
132
+ }
110
133
if (spdm_response_size <
111
- sizeof (spdm_digest_response_t ) + digest_count * digest_size ) {
134
+ sizeof (spdm_digest_response_t ) + digest_count * ( digest_size + additional_size ) ) {
112
135
return LIBSPDM_STATUS_INVALID_MSG_SIZE ;
113
136
}
114
137
spdm_response_size =
115
- sizeof (spdm_digest_response_t ) + digest_count * digest_size ;
138
+ sizeof (spdm_digest_response_t ) + digest_count * ( digest_size + additional_size ) ;
116
139
117
140
/* Cache data*/
118
141
@@ -142,12 +165,66 @@ libspdm_return_t libspdm_process_encap_response_digest(
142
165
}
143
166
}
144
167
168
+ key_pair_id =
169
+ (spdm_key_pair_id_t * )((uint8_t * )(spdm_response + 1 ) + digest_size * digest_count );
170
+ cert_info =
171
+ (spdm_certificate_info_t * )((uint8_t * )key_pair_id + sizeof (spdm_key_pair_id_t ) *
172
+ digest_count );
173
+ key_usage_bit_mask =
174
+ (spdm_key_usage_bit_mask_t * )((uint8_t * )cert_info + sizeof (spdm_certificate_info_t ) *
175
+ digest_count );
145
176
for (index = 0 ; index < digest_count ; index ++ ) {
146
177
LIBSPDM_DEBUG ((LIBSPDM_DEBUG_INFO , "digest (0x%x) - " , index ));
147
178
LIBSPDM_INTERNAL_DUMP_DATA (
148
179
(const uint8_t * )(spdm_response + 1 ) + (digest_size * index ), digest_size );
149
180
LIBSPDM_DEBUG ((LIBSPDM_DEBUG_INFO , "\n" ));
150
181
}
182
+ if ((spdm_response -> header .spdm_version >= SPDM_MESSAGE_VERSION_13 ) &&
183
+ spdm_context -> connection_info .multi_key_conn_req ) {
184
+ for (index = 0 ; index < digest_count ; index ++ ) {
185
+ LIBSPDM_DEBUG ((LIBSPDM_DEBUG_INFO , "key_pair_id (0x%x) - 0x%02x\n" , index ,
186
+ key_pair_id [index ]));
187
+ }
188
+ for (index = 0 ; index < digest_count ; index ++ ) {
189
+ LIBSPDM_DEBUG ((LIBSPDM_DEBUG_INFO , "cert_info (0x%x) - 0x%02x\n" , index ,
190
+ cert_info [index ]));
191
+ }
192
+ for (index = 0 ; index < digest_count ; index ++ ) {
193
+ LIBSPDM_DEBUG ((LIBSPDM_DEBUG_INFO , "key_usage_bit_mask (0x%x) - 0x%04x\n" , index ,
194
+ key_usage_bit_mask [index ]));
195
+ }
196
+ }
197
+
198
+ spdm_context -> connection_info .peer_provisioned_slot_mask = spdm_response -> header .param2 ;
199
+ if (spdm_response -> header .spdm_version >= SPDM_MESSAGE_VERSION_13 ) {
200
+ spdm_context -> connection_info .peer_supported_slot_mask = spdm_response -> header .param1 ;
201
+ } else {
202
+ spdm_context -> connection_info .peer_supported_slot_mask = spdm_response -> header .param2 ;
203
+ }
204
+ libspdm_copy_mem (
205
+ spdm_context -> connection_info .peer_total_digest_buffer ,
206
+ sizeof (spdm_context -> connection_info .peer_total_digest_buffer ),
207
+ spdm_response + 1 , digest_size * digest_count );
208
+ libspdm_zero_mem (spdm_context -> connection_info .peer_key_pair_id ,
209
+ sizeof (spdm_context -> connection_info .peer_key_pair_id ));
210
+ libspdm_zero_mem (spdm_context -> connection_info .peer_cert_info ,
211
+ sizeof (spdm_context -> connection_info .peer_cert_info ));
212
+ libspdm_zero_mem (spdm_context -> connection_info .peer_key_usage_bit_mask ,
213
+ sizeof (spdm_context -> connection_info .peer_key_usage_bit_mask ));
214
+ if ((spdm_response -> header .spdm_version >= SPDM_MESSAGE_VERSION_13 ) &&
215
+ spdm_context -> connection_info .multi_key_conn_req ) {
216
+ slot_index = 0 ;
217
+ for (index = 0 ; index < digest_count ; index ++ ) {
218
+ if (spdm_response -> header .param2 & (1 << index )) {
219
+ spdm_context -> connection_info .peer_key_pair_id [index ] = key_pair_id [slot_index ];
220
+ spdm_context -> connection_info .peer_cert_info [index ] =
221
+ cert_info [slot_index ] & SPDM_CERTIFICATE_INFO_CERT_MODEL_MASK ;
222
+ spdm_context -> connection_info .peer_key_usage_bit_mask [index ] =
223
+ key_usage_bit_mask [slot_index ];
224
+ slot_index ++ ;
225
+ }
226
+ }
227
+ }
151
228
152
229
* need_continue = false;
153
230
0 commit comments