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