Line data Source code
1 : /**
2 : * Copyright Notice:
3 : * Copyright 2021-2026 DMTF. All rights reserved.
4 : * License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
5 : **/
6 :
7 : #include "spdm_unit_test.h"
8 : #include "internal/libspdm_requester_lib.h"
9 :
10 : #pragma pack(1)
11 : typedef struct {
12 : spdm_message_header_t header;
13 : uint16_t length;
14 : uint8_t measurement_specification_sel;
15 : uint8_t other_params_selection;
16 : uint32_t measurement_hash_algo;
17 : uint32_t base_asym_sel;
18 : uint32_t base_hash_sel;
19 : uint8_t reserved2[11];
20 : uint8_t mel_specification_sel;
21 : uint8_t ext_asym_sel_count;
22 : uint8_t ext_hash_sel_count;
23 : uint16_t reserved3;
24 : spdm_negotiate_algorithms_common_struct_table_t struct_table[4];
25 : } libspdm_algorithms_response_spdm11_t;
26 : #pragma pack()
27 :
28 : static size_t m_libspdm_local_buffer_size;
29 : static uint8_t m_libspdm_local_buffer[LIBSPDM_MAX_MESSAGE_VCA_BUFFER_SIZE];
30 :
31 : static uint8_t m_connection_other_params_support;
32 :
33 : static uint8_t m_mel_specification_sel;
34 :
35 : static uint8_t m_measurement_specification_sel;
36 :
37 30 : static libspdm_return_t send_message(
38 : void *spdm_context, size_t request_size, const void *request, uint64_t timeout)
39 : {
40 : libspdm_test_context_t *spdm_test_context;
41 :
42 30 : spdm_test_context = libspdm_get_test_context();
43 30 : switch (spdm_test_context->case_id) {
44 0 : case 0x1:
45 0 : return LIBSPDM_STATUS_SEND_FAIL;
46 1 : case 0x2:
47 1 : return LIBSPDM_STATUS_SUCCESS;
48 8 : case 0x3:
49 8 : return LIBSPDM_STATUS_SUCCESS;
50 0 : case 0x4:
51 0 : return LIBSPDM_STATUS_SUCCESS;
52 0 : case 0x5:
53 0 : return LIBSPDM_STATUS_SUCCESS;
54 2 : case 0x6:
55 2 : return LIBSPDM_STATUS_SUCCESS;
56 0 : case 0x7:
57 0 : return LIBSPDM_STATUS_SUCCESS;
58 0 : case 0x8:
59 0 : return LIBSPDM_STATUS_SUCCESS;
60 0 : case 0x9:
61 0 : return LIBSPDM_STATUS_SUCCESS;
62 0 : case 0xA:
63 0 : return LIBSPDM_STATUS_SUCCESS;
64 0 : case 0xB:
65 0 : return LIBSPDM_STATUS_SUCCESS;
66 0 : case 0xC:
67 0 : return LIBSPDM_STATUS_SUCCESS;
68 0 : case 0xD:
69 0 : return LIBSPDM_STATUS_SUCCESS;
70 0 : case 0xE:
71 0 : return LIBSPDM_STATUS_SUCCESS;
72 0 : case 0xF:
73 0 : return LIBSPDM_STATUS_SUCCESS;
74 0 : case 0x10:
75 0 : return LIBSPDM_STATUS_SUCCESS;
76 0 : case 0x11:
77 0 : return LIBSPDM_STATUS_SUCCESS;
78 0 : case 0x12:
79 0 : return LIBSPDM_STATUS_SUCCESS;
80 0 : case 0x13:
81 0 : return LIBSPDM_STATUS_SUCCESS;
82 0 : case 0x14:
83 0 : return LIBSPDM_STATUS_SUCCESS;
84 0 : case 0x15:
85 0 : return LIBSPDM_STATUS_SUCCESS;
86 0 : case 0x16:
87 0 : return LIBSPDM_STATUS_SUCCESS;
88 1 : case 0x17:
89 1 : return LIBSPDM_STATUS_SUCCESS;
90 0 : case 0x18:
91 0 : return LIBSPDM_STATUS_SUCCESS;
92 0 : case 0x19:
93 0 : return LIBSPDM_STATUS_SUCCESS;
94 0 : case 0x1A:
95 0 : return LIBSPDM_STATUS_SUCCESS;
96 0 : case 0x1B:
97 0 : return LIBSPDM_STATUS_SUCCESS;
98 0 : case 0x1C:
99 0 : return LIBSPDM_STATUS_SUCCESS;
100 0 : case 0x1D:
101 0 : return LIBSPDM_STATUS_SUCCESS;
102 0 : case 0x1E:
103 0 : return LIBSPDM_STATUS_SUCCESS;
104 0 : case 0x1F:
105 0 : return LIBSPDM_STATUS_SUCCESS;
106 1 : case 0x20: {
107 1 : const uint8_t *ptr = (const uint8_t *)request;
108 :
109 1 : m_libspdm_local_buffer_size = 0;
110 1 : libspdm_copy_mem(m_libspdm_local_buffer, sizeof(m_libspdm_local_buffer),
111 1 : &ptr[1], request_size - 1);
112 1 : m_libspdm_local_buffer_size += (request_size - 1);
113 : }
114 1 : return LIBSPDM_STATUS_SUCCESS;
115 2 : case 0x21: {
116 : const spdm_negotiate_algorithms_request_t *spdm_request;
117 2 : spdm_request =
118 : (const spdm_negotiate_algorithms_request_t *)((const uint8_t *)request +
119 : sizeof(libspdm_test_message_header_t));
120 :
121 2 : assert_int_equal (spdm_request->header.spdm_version, SPDM_MESSAGE_VERSION_12);
122 2 : assert_int_equal (spdm_request->header.request_response_code, SPDM_NEGOTIATE_ALGORITHMS);
123 2 : assert_int_equal (spdm_request->other_params_support, SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_1);
124 : }
125 2 : return LIBSPDM_STATUS_SUCCESS;
126 15 : case 0x22:
127 : case 0x23:
128 : case 0x24:
129 : case 0x25:
130 15 : return LIBSPDM_STATUS_SUCCESS;
131 0 : default:
132 0 : return LIBSPDM_STATUS_SEND_FAIL;
133 : }
134 : }
135 :
136 30 : static libspdm_return_t receive_message(
137 : void *spdm_context, size_t *response_size, void **response, uint64_t timeout)
138 : {
139 : libspdm_test_context_t *spdm_test_context;
140 :
141 30 : spdm_test_context = libspdm_get_test_context();
142 30 : switch (spdm_test_context->case_id) {
143 0 : case 0x1:
144 0 : return LIBSPDM_STATUS_RECEIVE_FAIL;
145 :
146 1 : case 0x2: {
147 : spdm_algorithms_response_t *spdm_response;
148 : size_t spdm_response_size;
149 : size_t transport_header_size;
150 :
151 1 : spdm_response_size = sizeof(spdm_algorithms_response_t);
152 1 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
153 1 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
154 :
155 1 : libspdm_zero_mem(spdm_response, spdm_response_size);
156 1 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
157 1 : spdm_response->header.request_response_code = SPDM_ALGORITHMS;
158 1 : spdm_response->header.param1 = 0;
159 1 : spdm_response->header.param2 = 0;
160 1 : spdm_response->length = sizeof(spdm_algorithms_response_t);
161 1 : spdm_response->measurement_specification_sel = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
162 1 : spdm_response->measurement_hash_algo = m_libspdm_use_measurement_hash_algo;
163 1 : spdm_response->base_asym_sel = m_libspdm_use_asym_algo;
164 1 : spdm_response->base_hash_sel = m_libspdm_use_hash_algo;
165 1 : spdm_response->ext_asym_sel_count = 0;
166 1 : spdm_response->ext_hash_sel_count = 0;
167 :
168 1 : libspdm_transport_test_encode_message(spdm_context, NULL, false,
169 : false, spdm_response_size,
170 : spdm_response,
171 : response_size, response);
172 : }
173 1 : return LIBSPDM_STATUS_SUCCESS;
174 :
175 8 : case 0x3: {
176 : spdm_algorithms_response_t *spdm_response;
177 : size_t spdm_response_size;
178 : size_t transport_header_size;
179 :
180 8 : spdm_response_size = sizeof(spdm_algorithms_response_t);
181 8 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
182 8 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
183 :
184 8 : libspdm_zero_mem(spdm_response, spdm_response_size);
185 8 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
186 8 : spdm_response->header.request_response_code = SPDM_ALGORITHMS;
187 8 : spdm_response->header.param1 = 0;
188 8 : spdm_response->header.param2 = 0;
189 8 : spdm_response->length = sizeof(spdm_algorithms_response_t);
190 8 : spdm_response->measurement_specification_sel = m_measurement_specification_sel;
191 8 : spdm_response->measurement_hash_algo = m_libspdm_use_measurement_hash_algo;
192 8 : spdm_response->base_asym_sel = m_libspdm_use_asym_algo;
193 8 : spdm_response->base_hash_sel = m_libspdm_use_hash_algo;
194 8 : spdm_response->ext_asym_sel_count = 0;
195 8 : spdm_response->ext_hash_sel_count = 0;
196 :
197 8 : libspdm_transport_test_encode_message(spdm_context, NULL, false,
198 : false, spdm_response_size,
199 : spdm_response,
200 : response_size, response);
201 : }
202 8 : return LIBSPDM_STATUS_SUCCESS;
203 :
204 0 : case 0x4: {
205 : spdm_error_response_t *spdm_response;
206 : size_t spdm_response_size;
207 : size_t transport_header_size;
208 :
209 0 : spdm_response_size = sizeof(spdm_error_response_t);
210 0 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
211 0 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
212 :
213 0 : libspdm_zero_mem(spdm_response, spdm_response_size);
214 0 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
215 0 : spdm_response->header.request_response_code = SPDM_ERROR;
216 0 : spdm_response->header.param1 = SPDM_ERROR_CODE_INVALID_REQUEST;
217 0 : spdm_response->header.param2 = 0;
218 :
219 0 : libspdm_transport_test_encode_message(spdm_context, NULL, false,
220 : false, spdm_response_size,
221 : spdm_response,
222 : response_size, response);
223 : }
224 0 : return LIBSPDM_STATUS_SUCCESS;
225 :
226 0 : case 0x5: {
227 : spdm_error_response_t *spdm_response;
228 : size_t spdm_response_size;
229 : size_t transport_header_size;
230 :
231 0 : spdm_response_size = sizeof(spdm_error_response_t);
232 0 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
233 0 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
234 :
235 0 : libspdm_zero_mem(spdm_response, spdm_response_size);
236 0 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
237 0 : spdm_response->header.request_response_code = SPDM_ERROR;
238 0 : spdm_response->header.param1 = SPDM_ERROR_CODE_BUSY;
239 0 : spdm_response->header.param2 = 0;
240 :
241 0 : libspdm_transport_test_encode_message(spdm_context, NULL, false,
242 : false, spdm_response_size,
243 : spdm_response,
244 : response_size, response);
245 : }
246 0 : return LIBSPDM_STATUS_SUCCESS;
247 :
248 2 : case 0x6: {
249 : static size_t sub_index1 = 0;
250 2 : if (sub_index1 == 0) {
251 : spdm_error_response_t *spdm_response;
252 : size_t spdm_response_size;
253 : size_t transport_header_size;
254 :
255 1 : spdm_response_size = sizeof(spdm_error_response_t);
256 1 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
257 1 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
258 :
259 1 : libspdm_zero_mem(spdm_response, spdm_response_size);
260 1 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
261 1 : spdm_response->header.request_response_code = SPDM_ERROR;
262 1 : spdm_response->header.param1 = SPDM_ERROR_CODE_BUSY;
263 1 : spdm_response->header.param2 = 0;
264 :
265 1 : libspdm_transport_test_encode_message(
266 : spdm_context, NULL, false, false,
267 : spdm_response_size, spdm_response,
268 : response_size, response);
269 1 : } else if (sub_index1 == 1) {
270 : spdm_algorithms_response_t *spdm_response;
271 : size_t spdm_response_size;
272 : size_t transport_header_size;
273 :
274 1 : spdm_response_size = sizeof(spdm_algorithms_response_t);
275 1 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
276 1 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
277 :
278 1 : libspdm_zero_mem(spdm_response, spdm_response_size);
279 1 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
280 1 : spdm_response->header.request_response_code = SPDM_ALGORITHMS;
281 1 : spdm_response->header.param1 = 0;
282 1 : spdm_response->header.param2 = 0;
283 1 : spdm_response->length = sizeof(spdm_algorithms_response_t);
284 1 : spdm_response->measurement_specification_sel = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
285 1 : spdm_response->measurement_hash_algo = m_libspdm_use_measurement_hash_algo;
286 1 : spdm_response->base_asym_sel = m_libspdm_use_asym_algo;
287 1 : spdm_response->base_hash_sel = m_libspdm_use_hash_algo;
288 1 : spdm_response->ext_asym_sel_count = 0;
289 1 : spdm_response->ext_hash_sel_count = 0;
290 :
291 1 : libspdm_transport_test_encode_message(
292 : spdm_context, NULL, false, false,
293 : spdm_response_size, spdm_response,
294 : response_size, response);
295 : }
296 2 : sub_index1++;
297 : }
298 2 : return LIBSPDM_STATUS_SUCCESS;
299 :
300 0 : case 0x7: {
301 : spdm_error_response_t *spdm_response;
302 : size_t spdm_response_size;
303 : size_t transport_header_size;
304 :
305 0 : spdm_response_size = sizeof(spdm_error_response_t);
306 0 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
307 0 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
308 :
309 0 : libspdm_zero_mem(spdm_response, spdm_response_size);
310 0 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
311 0 : spdm_response->header.request_response_code = SPDM_ERROR;
312 0 : spdm_response->header.param1 = SPDM_ERROR_CODE_REQUEST_RESYNCH;
313 0 : spdm_response->header.param2 = 0;
314 :
315 0 : libspdm_transport_test_encode_message(spdm_context, NULL, false,
316 : false, spdm_response_size,
317 : spdm_response,
318 : response_size, response);
319 : }
320 0 : return LIBSPDM_STATUS_SUCCESS;
321 :
322 0 : case 0x8: {
323 : spdm_error_response_data_response_not_ready_t *spdm_response;
324 : size_t spdm_response_size;
325 : size_t transport_header_size;
326 :
327 0 : spdm_response_size = sizeof(spdm_error_response_data_response_not_ready_t);
328 0 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
329 0 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
330 :
331 0 : libspdm_zero_mem(spdm_response, spdm_response_size);
332 0 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
333 0 : spdm_response->header.request_response_code = SPDM_ERROR;
334 0 : spdm_response->header.param1 = SPDM_ERROR_CODE_RESPONSE_NOT_READY;
335 0 : spdm_response->header.param2 = 0;
336 0 : spdm_response->extend_error_data.rd_exponent = 1;
337 0 : spdm_response->extend_error_data.rd_tm = 2;
338 0 : spdm_response->extend_error_data.request_code = SPDM_NEGOTIATE_ALGORITHMS;
339 0 : spdm_response->extend_error_data.token = 0;
340 :
341 0 : libspdm_transport_test_encode_message(spdm_context, NULL, false,
342 : false, spdm_response_size,
343 : spdm_response,
344 : response_size, response);
345 : }
346 0 : return LIBSPDM_STATUS_SUCCESS;
347 :
348 0 : case 0x9:
349 0 : return LIBSPDM_STATUS_SUCCESS;
350 :
351 0 : case 0xA: {
352 : spdm_algorithms_response_t *spdm_response;
353 : size_t spdm_response_size;
354 : size_t transport_header_size;
355 :
356 0 : spdm_response_size = sizeof(spdm_algorithms_response_t);
357 0 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
358 0 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
359 :
360 0 : libspdm_zero_mem(spdm_response, spdm_response_size);
361 0 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
362 0 : spdm_response->header.request_response_code = SPDM_ALGORITHMS;
363 0 : spdm_response->header.param1 = 0;
364 0 : spdm_response->header.param2 = 0;
365 0 : spdm_response->length = sizeof(spdm_algorithms_response_t);
366 0 : spdm_response->measurement_specification_sel = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
367 0 : spdm_response->measurement_hash_algo = 0;
368 0 : spdm_response->base_asym_sel = m_libspdm_use_asym_algo;
369 0 : spdm_response->base_hash_sel = m_libspdm_use_hash_algo;
370 0 : spdm_response->ext_asym_sel_count = 0;
371 0 : spdm_response->ext_hash_sel_count = 0;
372 :
373 0 : libspdm_transport_test_encode_message(spdm_context, NULL, false,
374 : false, spdm_response_size,
375 : spdm_response,
376 : response_size, response);
377 : }
378 0 : return LIBSPDM_STATUS_SUCCESS;
379 :
380 0 : case 0xB: {
381 : spdm_algorithms_response_t *spdm_response;
382 : size_t spdm_response_size;
383 : size_t transport_header_size;
384 :
385 0 : spdm_response_size = sizeof(spdm_algorithms_response_t);
386 0 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
387 0 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
388 :
389 0 : libspdm_zero_mem(spdm_response, spdm_response_size);
390 0 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
391 0 : spdm_response->header.request_response_code = SPDM_ALGORITHMS;
392 0 : spdm_response->header.param1 = 0;
393 0 : spdm_response->header.param2 = 0;
394 0 : spdm_response->length = sizeof(spdm_algorithms_response_t);
395 0 : spdm_response->measurement_specification_sel = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
396 0 : spdm_response->measurement_hash_algo = m_libspdm_use_measurement_hash_algo;
397 0 : spdm_response->base_asym_sel = 0;
398 0 : spdm_response->base_hash_sel = m_libspdm_use_hash_algo;
399 0 : spdm_response->ext_asym_sel_count = 0;
400 0 : spdm_response->ext_hash_sel_count = 0;
401 :
402 0 : libspdm_transport_test_encode_message(spdm_context, NULL, false,
403 : false, spdm_response_size,
404 : spdm_response,
405 : response_size, response);
406 : }
407 0 : return LIBSPDM_STATUS_SUCCESS;
408 :
409 0 : case 0xC: {
410 : spdm_algorithms_response_t *spdm_response;
411 : size_t spdm_response_size;
412 : size_t transport_header_size;
413 :
414 0 : spdm_response_size = sizeof(spdm_algorithms_response_t);
415 0 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
416 0 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
417 :
418 0 : libspdm_zero_mem(spdm_response, spdm_response_size);
419 0 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
420 0 : spdm_response->header.request_response_code = SPDM_ALGORITHMS;
421 0 : spdm_response->header.param1 = 0;
422 0 : spdm_response->header.param2 = 0;
423 0 : spdm_response->length = sizeof(spdm_algorithms_response_t);
424 0 : spdm_response->measurement_specification_sel = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
425 0 : spdm_response->measurement_hash_algo = m_libspdm_use_measurement_hash_algo;
426 0 : spdm_response->base_asym_sel = m_libspdm_use_asym_algo;
427 0 : spdm_response->base_hash_sel = 0;
428 0 : spdm_response->ext_asym_sel_count = 0;
429 0 : spdm_response->ext_hash_sel_count = 0;
430 :
431 0 : libspdm_transport_test_encode_message(spdm_context, NULL, false,
432 : false, spdm_response_size,
433 : spdm_response,
434 : response_size, response);
435 : }
436 0 : return LIBSPDM_STATUS_SUCCESS;
437 :
438 0 : case 0xD:
439 : {
440 : spdm_algorithms_response_t *spdm_response;
441 : size_t spdm_response_size;
442 : size_t transport_header_size;
443 :
444 0 : spdm_response_size = sizeof(spdm_algorithms_response_t);
445 0 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
446 0 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
447 :
448 0 : libspdm_zero_mem(spdm_response, spdm_response_size);
449 0 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
450 0 : spdm_response->header.request_response_code = SPDM_ALGORITHMS;
451 0 : spdm_response->header.param1 = 0;
452 0 : spdm_response->header.param2 = 0;
453 0 : spdm_response->length = sizeof(spdm_algorithms_response_t);
454 0 : spdm_response->measurement_specification_sel = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
455 0 : spdm_response->measurement_hash_algo = m_libspdm_use_measurement_hash_algo;
456 0 : spdm_response->base_asym_sel = m_libspdm_use_asym_algo;
457 0 : spdm_response->base_hash_sel = m_libspdm_use_hash_algo;
458 0 : spdm_response->ext_asym_sel_count = 0;
459 0 : spdm_response->ext_hash_sel_count = 0;
460 :
461 0 : libspdm_transport_test_encode_message (spdm_context, NULL, false, false,
462 : sizeof(spdm_message_header_t), spdm_response,
463 : response_size, response);
464 : }
465 0 : return LIBSPDM_STATUS_SUCCESS;
466 :
467 0 : case 0xE:
468 : {
469 : spdm_algorithms_response_t *spdm_response;
470 : size_t spdm_response_size;
471 : size_t transport_header_size;
472 :
473 0 : spdm_response_size = sizeof(spdm_algorithms_response_t);
474 0 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
475 0 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
476 :
477 0 : libspdm_zero_mem(spdm_response, spdm_response_size);
478 0 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
479 0 : spdm_response->header.request_response_code = SPDM_ALGORITHMS;
480 0 : spdm_response->header.param1 = 0;
481 0 : spdm_response->header.param2 = 0;
482 0 : spdm_response->length = sizeof(spdm_algorithms_response_t);
483 0 : spdm_response->measurement_specification_sel = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
484 0 : spdm_response->measurement_hash_algo = m_libspdm_use_measurement_hash_algo;
485 0 : spdm_response->base_asym_sel = m_libspdm_use_asym_algo;
486 0 : spdm_response->base_hash_sel = m_libspdm_use_hash_algo;
487 :
488 :
489 0 : libspdm_transport_test_encode_message (spdm_context, NULL, false, false,
490 : sizeof(spdm_algorithms_response_t)/2, spdm_response,
491 : response_size, response);
492 : }
493 0 : return LIBSPDM_STATUS_SUCCESS;
494 :
495 0 : case 0xF:
496 : {
497 : spdm_algorithms_response_t *spdm_response;
498 : size_t spdm_response_size;
499 : size_t transport_header_size;
500 :
501 0 : spdm_response_size = sizeof(spdm_algorithms_response_t);
502 0 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
503 0 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
504 :
505 0 : libspdm_zero_mem(spdm_response, spdm_response_size);
506 0 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
507 0 : spdm_response->header.request_response_code = SPDM_ALGORITHMS;
508 0 : spdm_response->header.param1 = 0;
509 0 : spdm_response->header.param2 = 0;
510 0 : spdm_response->length = sizeof(spdm_algorithms_response_t);
511 0 : spdm_response->measurement_specification_sel = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
512 0 : spdm_response->measurement_hash_algo = m_libspdm_use_measurement_hash_algo;
513 0 : spdm_response->base_asym_sel = m_libspdm_use_asym_algo;
514 0 : spdm_response->base_hash_sel = m_libspdm_use_hash_algo;
515 0 : spdm_response->ext_asym_sel_count = 2;
516 0 : spdm_response->ext_hash_sel_count = 0;
517 :
518 0 : libspdm_transport_test_encode_message (spdm_context, NULL, false, false,
519 : spdm_response_size,
520 : spdm_response, response_size, response);
521 : }
522 0 : return LIBSPDM_STATUS_SUCCESS;
523 :
524 0 : case 0x10:
525 : {
526 : spdm_algorithms_response_t *spdm_response;
527 : size_t spdm_response_size;
528 : size_t transport_header_size;
529 :
530 0 : spdm_response_size = sizeof(spdm_algorithms_response_t);
531 0 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
532 0 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
533 :
534 0 : libspdm_zero_mem(spdm_response, spdm_response_size);
535 0 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
536 0 : spdm_response->header.request_response_code = SPDM_ALGORITHMS;
537 0 : spdm_response->header.param1 = 0;
538 0 : spdm_response->header.param2 = 0;
539 0 : spdm_response->length = sizeof(spdm_algorithms_response_t);
540 0 : spdm_response->measurement_specification_sel = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
541 0 : spdm_response->measurement_hash_algo = m_libspdm_use_measurement_hash_algo;
542 0 : spdm_response->base_asym_sel = m_libspdm_use_asym_algo;
543 0 : spdm_response->base_hash_sel = m_libspdm_use_hash_algo;
544 0 : spdm_response->ext_asym_sel_count = 0;
545 0 : spdm_response->ext_hash_sel_count = 2;
546 :
547 0 : libspdm_transport_test_encode_message (spdm_context, NULL, false, false,
548 : spdm_response_size,
549 : spdm_response, response_size, response);
550 : }
551 0 : return LIBSPDM_STATUS_SUCCESS;
552 :
553 0 : case 0x11:
554 : {
555 : spdm_algorithms_response_t *spdm_response;
556 : size_t spdm_response_size;
557 : size_t transport_header_size;
558 :
559 0 : spdm_response_size = sizeof(spdm_algorithms_response_t);
560 0 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
561 0 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
562 :
563 0 : libspdm_zero_mem(spdm_response, spdm_response_size);
564 0 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
565 0 : spdm_response->header.request_response_code = SPDM_ALGORITHMS;
566 0 : spdm_response->header.param1 = 0;
567 0 : spdm_response->header.param2 = 0;
568 0 : spdm_response->length = sizeof(spdm_algorithms_response_t);
569 0 : spdm_response->measurement_specification_sel = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
570 0 : spdm_response->measurement_hash_algo = m_libspdm_use_measurement_hash_algo;
571 0 : spdm_response->base_asym_sel = SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_ECDSA_ECC_NIST_P521;
572 0 : spdm_response->base_hash_sel = m_libspdm_use_hash_algo;
573 0 : spdm_response->ext_asym_sel_count = 0;
574 0 : spdm_response->ext_hash_sel_count = 0;
575 :
576 0 : libspdm_transport_test_encode_message (spdm_context, NULL, false, false,
577 : spdm_response_size,
578 : spdm_response, response_size, response);
579 : }
580 0 : return LIBSPDM_STATUS_SUCCESS;
581 :
582 0 : case 0x12:
583 : {
584 : spdm_algorithms_response_t *spdm_response;
585 : size_t spdm_response_size;
586 : size_t transport_header_size;
587 :
588 0 : spdm_response_size = sizeof(spdm_algorithms_response_t);
589 0 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
590 0 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
591 :
592 0 : libspdm_zero_mem(spdm_response, spdm_response_size);
593 0 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
594 0 : spdm_response->header.request_response_code = SPDM_ALGORITHMS;
595 0 : spdm_response->header.param1 = 0;
596 0 : spdm_response->header.param2 = 0;
597 0 : spdm_response->length = sizeof(spdm_algorithms_response_t);
598 0 : spdm_response->measurement_specification_sel = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
599 0 : spdm_response->measurement_hash_algo = m_libspdm_use_measurement_hash_algo;
600 0 : spdm_response->base_asym_sel = m_libspdm_use_asym_algo;
601 0 : spdm_response->base_hash_sel = SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA3_512;
602 0 : spdm_response->ext_asym_sel_count = 0;
603 0 : spdm_response->ext_hash_sel_count = 0;
604 :
605 0 : libspdm_transport_test_encode_message (spdm_context, NULL, false, false,
606 : spdm_response_size,
607 : spdm_response, response_size, response);
608 : }
609 0 : return LIBSPDM_STATUS_SUCCESS;
610 :
611 0 : case 0x13:
612 : {
613 : spdm_algorithms_response_t *spdm_response;
614 : size_t spdm_response_size;
615 : size_t transport_header_size;
616 :
617 0 : spdm_response_size = sizeof(spdm_algorithms_response_t);
618 0 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
619 0 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
620 :
621 0 : libspdm_zero_mem(spdm_response, spdm_response_size);
622 0 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
623 0 : spdm_response->header.request_response_code = SPDM_ALGORITHMS;
624 0 : spdm_response->header.param1 = 0;
625 0 : spdm_response->header.param2 = 0;
626 0 : spdm_response->length = sizeof(spdm_algorithms_response_t);
627 0 : spdm_response->measurement_specification_sel = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
628 0 : spdm_response->measurement_hash_algo = m_libspdm_use_measurement_hash_algo|
629 : SPDM_ALGORITHMS_MEASUREMENT_HASH_ALGO_TPM_ALG_SHA3_512;
630 0 : spdm_response->base_asym_sel = m_libspdm_use_asym_algo;
631 0 : spdm_response->base_hash_sel = m_libspdm_use_hash_algo;
632 0 : spdm_response->ext_asym_sel_count = 0;
633 0 : spdm_response->ext_hash_sel_count = 0;
634 :
635 0 : libspdm_transport_test_encode_message (spdm_context, NULL, false, false,
636 : spdm_response_size,
637 : spdm_response, response_size, response);
638 : }
639 0 : return LIBSPDM_STATUS_SUCCESS;
640 :
641 0 : case 0x14:
642 : {
643 : spdm_algorithms_response_t *spdm_response;
644 : size_t spdm_response_size;
645 : size_t transport_header_size;
646 :
647 0 : spdm_response_size = sizeof(spdm_algorithms_response_t);
648 0 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
649 0 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
650 :
651 0 : libspdm_zero_mem(spdm_response, spdm_response_size);
652 0 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
653 0 : spdm_response->header.request_response_code = SPDM_ALGORITHMS;
654 0 : spdm_response->header.param1 = 0;
655 0 : spdm_response->header.param2 = 0;
656 0 : spdm_response->length = sizeof(spdm_algorithms_response_t);
657 0 : spdm_response->measurement_specification_sel = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
658 0 : spdm_response->measurement_hash_algo = m_libspdm_use_measurement_hash_algo;
659 0 : spdm_response->base_asym_sel = m_libspdm_use_asym_algo|
660 : SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_ECDSA_ECC_NIST_P521;
661 0 : spdm_response->base_hash_sel = m_libspdm_use_hash_algo;
662 0 : spdm_response->ext_asym_sel_count = 0;
663 0 : spdm_response->ext_hash_sel_count = 0;
664 :
665 0 : libspdm_transport_test_encode_message (spdm_context, NULL, false, false,
666 : spdm_response_size,
667 : spdm_response, response_size, response);
668 : }
669 0 : return LIBSPDM_STATUS_SUCCESS;
670 :
671 0 : case 0x15:
672 : {
673 : spdm_algorithms_response_t *spdm_response;
674 : size_t spdm_response_size;
675 : size_t transport_header_size;
676 :
677 0 : spdm_response_size = sizeof(spdm_algorithms_response_t);
678 0 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
679 0 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
680 :
681 0 : libspdm_zero_mem(spdm_response, spdm_response_size);
682 0 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
683 0 : spdm_response->header.request_response_code = SPDM_ALGORITHMS;
684 0 : spdm_response->header.param1 = 0;
685 0 : spdm_response->header.param2 = 0;
686 0 : spdm_response->length = sizeof(spdm_algorithms_response_t);
687 0 : spdm_response->measurement_specification_sel = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
688 0 : spdm_response->measurement_hash_algo = m_libspdm_use_measurement_hash_algo;
689 0 : spdm_response->base_asym_sel = m_libspdm_use_asym_algo;
690 0 : spdm_response->base_hash_sel = m_libspdm_use_hash_algo|
691 : SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA3_512;
692 0 : spdm_response->ext_asym_sel_count = 0;
693 0 : spdm_response->ext_hash_sel_count = 0;
694 :
695 0 : libspdm_transport_test_encode_message (spdm_context, NULL, false, false,
696 : spdm_response_size,
697 : spdm_response, response_size, response);
698 : }
699 0 : return LIBSPDM_STATUS_SUCCESS;
700 :
701 0 : case 0x16:
702 : {
703 : libspdm_algorithms_response_spdm11_t *spdm_response;
704 : size_t spdm_response_size;
705 : size_t transport_header_size;
706 :
707 0 : spdm_response_size = sizeof(libspdm_algorithms_response_spdm11_t);
708 0 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
709 0 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
710 :
711 0 : libspdm_zero_mem(spdm_response, spdm_response_size);
712 0 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_11;
713 0 : spdm_response->header.request_response_code = SPDM_ALGORITHMS;
714 0 : spdm_response->header.param1 = 4;
715 0 : spdm_response->header.param2 = 0;
716 0 : spdm_response->length = sizeof(libspdm_algorithms_response_spdm11_t);
717 0 : spdm_response->measurement_specification_sel = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
718 0 : spdm_response->measurement_hash_algo = m_libspdm_use_measurement_hash_algo;
719 0 : spdm_response->base_asym_sel = m_libspdm_use_asym_algo;
720 0 : spdm_response->base_hash_sel = m_libspdm_use_hash_algo;
721 0 : spdm_response->ext_asym_sel_count = 0;
722 0 : spdm_response->ext_hash_sel_count = 0;
723 0 : spdm_response->struct_table[0].alg_type =
724 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE;
725 0 : spdm_response->struct_table[0].alg_count = 0x20;
726 0 : spdm_response->struct_table[0].alg_supported = m_libspdm_use_dhe_algo;
727 0 : spdm_response->struct_table[1].alg_type =
728 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD;
729 0 : spdm_response->struct_table[1].alg_count = 0x20;
730 0 : spdm_response->struct_table[1].alg_supported = m_libspdm_use_aead_algo;
731 0 : spdm_response->struct_table[2].alg_type =
732 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG;
733 0 : spdm_response->struct_table[2].alg_count = 0x20;
734 0 : spdm_response->struct_table[2].alg_supported = m_libspdm_use_req_asym_algo;
735 0 : spdm_response->struct_table[3].alg_type =
736 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE;
737 0 : spdm_response->struct_table[3].alg_count = 0x20;
738 0 : spdm_response->struct_table[3].alg_supported = m_libspdm_use_key_schedule_algo;
739 :
740 0 : libspdm_transport_test_encode_message (spdm_context, NULL, false, false,
741 : spdm_response_size,
742 : spdm_response, response_size, response);
743 : }
744 0 : return LIBSPDM_STATUS_SUCCESS;
745 :
746 1 : case 0x17:
747 : {
748 : libspdm_algorithms_response_spdm11_t *spdm_response;
749 : size_t spdm_response_size;
750 : size_t transport_header_size;
751 :
752 1 : spdm_response_size = sizeof(libspdm_algorithms_response_spdm11_t);
753 1 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
754 1 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
755 :
756 1 : libspdm_zero_mem(spdm_response, spdm_response_size);
757 1 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_11;
758 1 : spdm_response->header.request_response_code = SPDM_ALGORITHMS;
759 1 : spdm_response->header.param1 = 4;
760 1 : spdm_response->header.param2 = 0;
761 1 : spdm_response->length = sizeof(libspdm_algorithms_response_spdm11_t);
762 1 : spdm_response->measurement_specification_sel = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
763 1 : spdm_response->measurement_hash_algo = m_libspdm_use_measurement_hash_algo;
764 1 : spdm_response->base_asym_sel = m_libspdm_use_asym_algo;
765 1 : spdm_response->base_hash_sel = m_libspdm_use_hash_algo;
766 1 : spdm_response->ext_asym_sel_count = 0;
767 1 : spdm_response->ext_hash_sel_count = 0;
768 1 : spdm_response->struct_table[0].alg_type =
769 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE;
770 1 : spdm_response->struct_table[0].alg_count = 0x20;
771 1 : spdm_response->struct_table[0].alg_supported = m_libspdm_use_dhe_algo;
772 1 : spdm_response->struct_table[1].alg_type =
773 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD;
774 1 : spdm_response->struct_table[1].alg_count = 0x20;
775 1 : spdm_response->struct_table[1].alg_supported = m_libspdm_use_aead_algo;
776 1 : spdm_response->struct_table[2].alg_type =
777 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG;
778 1 : spdm_response->struct_table[2].alg_count = 0x20;
779 1 : spdm_response->struct_table[2].alg_supported = m_libspdm_use_req_asym_algo;
780 1 : spdm_response->struct_table[3].alg_type =
781 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE;
782 1 : spdm_response->struct_table[3].alg_count = 0x20;
783 1 : spdm_response->struct_table[3].alg_supported = m_libspdm_use_key_schedule_algo;
784 :
785 1 : libspdm_transport_test_encode_message (spdm_context, NULL, false, false,
786 : spdm_response_size,
787 : spdm_response, response_size, response);
788 : }
789 1 : return LIBSPDM_STATUS_SUCCESS;
790 :
791 0 : case 0x18:
792 : {
793 : libspdm_algorithms_response_spdm11_t *spdm_response;
794 : size_t spdm_response_size;
795 : size_t transport_header_size;
796 :
797 0 : spdm_response_size = sizeof(libspdm_algorithms_response_spdm11_t);
798 0 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
799 0 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
800 :
801 0 : libspdm_zero_mem(spdm_response, spdm_response_size);
802 0 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_11;
803 0 : spdm_response->header.request_response_code = SPDM_ALGORITHMS;
804 0 : spdm_response->header.param1 = 4;
805 0 : spdm_response->header.param2 = 0;
806 0 : spdm_response->length = sizeof(libspdm_algorithms_response_spdm11_t);
807 0 : spdm_response->measurement_specification_sel = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
808 0 : spdm_response->measurement_hash_algo = m_libspdm_use_measurement_hash_algo;
809 0 : spdm_response->base_asym_sel = m_libspdm_use_asym_algo;
810 0 : spdm_response->base_hash_sel = m_libspdm_use_hash_algo;
811 0 : spdm_response->ext_asym_sel_count = 0;
812 0 : spdm_response->ext_hash_sel_count = 0;
813 0 : spdm_response->struct_table[0].alg_type =
814 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE;
815 0 : spdm_response->struct_table[0].alg_count = 0x20;
816 0 : spdm_response->struct_table[0].alg_supported = SPDM_ALGORITHMS_DHE_NAMED_GROUP_SECP_521_R1;
817 0 : spdm_response->struct_table[1].alg_type =
818 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD;
819 0 : spdm_response->struct_table[1].alg_count = 0x20;
820 0 : spdm_response->struct_table[1].alg_supported = m_libspdm_use_aead_algo;
821 0 : spdm_response->struct_table[2].alg_type =
822 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG;
823 0 : spdm_response->struct_table[2].alg_count = 0x20;
824 0 : spdm_response->struct_table[2].alg_supported = m_libspdm_use_req_asym_algo;
825 0 : spdm_response->struct_table[3].alg_type =
826 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE;
827 0 : spdm_response->struct_table[3].alg_count = 0x20;
828 0 : spdm_response->struct_table[3].alg_supported = m_libspdm_use_key_schedule_algo;
829 :
830 0 : libspdm_transport_test_encode_message (spdm_context, NULL, false, false,
831 : spdm_response_size,
832 : spdm_response, response_size, response);
833 : }
834 0 : return LIBSPDM_STATUS_SUCCESS;
835 :
836 0 : case 0x19:
837 : {
838 : libspdm_algorithms_response_spdm11_t *spdm_response;
839 : size_t spdm_response_size;
840 : size_t transport_header_size;
841 :
842 0 : spdm_response_size = sizeof(libspdm_algorithms_response_spdm11_t);
843 0 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
844 0 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
845 :
846 0 : libspdm_zero_mem(spdm_response, spdm_response_size);
847 0 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_11;
848 0 : spdm_response->header.request_response_code = SPDM_ALGORITHMS;
849 0 : spdm_response->header.param1 = 4;
850 0 : spdm_response->header.param2 = 0;
851 0 : spdm_response->length = sizeof(libspdm_algorithms_response_spdm11_t);
852 0 : spdm_response->measurement_specification_sel = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
853 0 : spdm_response->measurement_hash_algo = m_libspdm_use_measurement_hash_algo;
854 0 : spdm_response->base_asym_sel = m_libspdm_use_asym_algo;
855 0 : spdm_response->base_hash_sel = m_libspdm_use_hash_algo;
856 0 : spdm_response->ext_asym_sel_count = 0;
857 0 : spdm_response->ext_hash_sel_count = 0;
858 0 : spdm_response->struct_table[0].alg_type =
859 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE;
860 0 : spdm_response->struct_table[0].alg_count = 0x20;
861 0 : spdm_response->struct_table[0].alg_supported = m_libspdm_use_dhe_algo;
862 0 : spdm_response->struct_table[1].alg_type =
863 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD;
864 0 : spdm_response->struct_table[1].alg_count = 0x20;
865 0 : spdm_response->struct_table[1].alg_supported =
866 : SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_CHACHA20_POLY1305;
867 0 : spdm_response->struct_table[2].alg_type =
868 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG;
869 0 : spdm_response->struct_table[2].alg_count = 0x20;
870 0 : spdm_response->struct_table[2].alg_supported = m_libspdm_use_req_asym_algo;
871 0 : spdm_response->struct_table[3].alg_type =
872 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE;
873 0 : spdm_response->struct_table[3].alg_count = 0x20;
874 0 : spdm_response->struct_table[3].alg_supported = m_libspdm_use_key_schedule_algo;
875 :
876 0 : libspdm_transport_test_encode_message (spdm_context, NULL, false, false,
877 : spdm_response_size,
878 : spdm_response, response_size, response);
879 : }
880 0 : return LIBSPDM_STATUS_SUCCESS;
881 :
882 0 : case 0x1A:
883 : {
884 : libspdm_algorithms_response_spdm11_t *spdm_response;
885 : size_t spdm_response_size;
886 : size_t transport_header_size;
887 :
888 0 : spdm_response_size = sizeof(libspdm_algorithms_response_spdm11_t);
889 0 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
890 0 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
891 :
892 0 : libspdm_zero_mem(spdm_response, spdm_response_size);
893 0 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_11;
894 0 : spdm_response->header.request_response_code = SPDM_ALGORITHMS;
895 0 : spdm_response->header.param1 = 4;
896 0 : spdm_response->header.param2 = 0;
897 0 : spdm_response->length = sizeof(libspdm_algorithms_response_spdm11_t);
898 0 : spdm_response->measurement_specification_sel = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
899 0 : spdm_response->measurement_hash_algo = m_libspdm_use_measurement_hash_algo;
900 0 : spdm_response->base_asym_sel = m_libspdm_use_asym_algo;
901 0 : spdm_response->base_hash_sel = m_libspdm_use_hash_algo;
902 0 : spdm_response->ext_asym_sel_count = 0;
903 0 : spdm_response->ext_hash_sel_count = 0;
904 0 : spdm_response->struct_table[0].alg_type =
905 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE;
906 0 : spdm_response->struct_table[0].alg_count = 0x20;
907 0 : spdm_response->struct_table[0].alg_supported = m_libspdm_use_dhe_algo;
908 0 : spdm_response->struct_table[1].alg_type =
909 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD;
910 0 : spdm_response->struct_table[1].alg_count = 0x20;
911 0 : spdm_response->struct_table[1].alg_supported = m_libspdm_use_aead_algo;
912 0 : spdm_response->struct_table[2].alg_type =
913 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG;
914 0 : spdm_response->struct_table[2].alg_count = 0x20;
915 0 : spdm_response->struct_table[2].alg_supported =
916 : SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_ECDSA_ECC_NIST_P521;
917 0 : spdm_response->struct_table[3].alg_type =
918 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE;
919 0 : spdm_response->struct_table[3].alg_count = 0x20;
920 0 : spdm_response->struct_table[3].alg_supported = m_libspdm_use_key_schedule_algo;
921 :
922 0 : libspdm_transport_test_encode_message (spdm_context, NULL, false, false,
923 : spdm_response_size,
924 : spdm_response, response_size, response);
925 : }
926 0 : return LIBSPDM_STATUS_SUCCESS;
927 :
928 0 : case 0x1B:
929 : {
930 : libspdm_algorithms_response_spdm11_t *spdm_response;
931 : size_t spdm_response_size;
932 : size_t transport_header_size;
933 :
934 0 : spdm_response_size = sizeof(libspdm_algorithms_response_spdm11_t);
935 0 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
936 0 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
937 :
938 0 : libspdm_zero_mem(spdm_response, spdm_response_size);
939 0 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_11;
940 0 : spdm_response->header.request_response_code = SPDM_ALGORITHMS;
941 0 : spdm_response->header.param1 = 4;
942 0 : spdm_response->header.param2 = 0;
943 0 : spdm_response->length = sizeof(libspdm_algorithms_response_spdm11_t);
944 0 : spdm_response->measurement_specification_sel = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
945 0 : spdm_response->measurement_hash_algo = m_libspdm_use_measurement_hash_algo;
946 0 : spdm_response->base_asym_sel = m_libspdm_use_asym_algo;
947 0 : spdm_response->base_hash_sel = m_libspdm_use_hash_algo;
948 0 : spdm_response->ext_asym_sel_count = 0;
949 0 : spdm_response->ext_hash_sel_count = 0;
950 0 : spdm_response->struct_table[0].alg_type =
951 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE;
952 0 : spdm_response->struct_table[0].alg_count = 0x20;
953 0 : spdm_response->struct_table[0].alg_supported = m_libspdm_use_dhe_algo;
954 0 : spdm_response->struct_table[1].alg_type =
955 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD;
956 0 : spdm_response->struct_table[1].alg_count = 0x20;
957 0 : spdm_response->struct_table[1].alg_supported = m_libspdm_use_aead_algo;
958 0 : spdm_response->struct_table[2].alg_type =
959 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG;
960 0 : spdm_response->struct_table[2].alg_count = 0x20;
961 0 : spdm_response->struct_table[2].alg_supported = m_libspdm_use_req_asym_algo;
962 0 : spdm_response->struct_table[3].alg_type =
963 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE;
964 0 : spdm_response->struct_table[3].alg_count = 0x20;
965 0 : spdm_response->struct_table[3].alg_supported = 0x00000020;
966 :
967 0 : libspdm_transport_test_encode_message (spdm_context, NULL, false, false,
968 : spdm_response_size,
969 : spdm_response, response_size, response);
970 : }
971 0 : return LIBSPDM_STATUS_SUCCESS;
972 :
973 0 : case 0x1C:
974 : {
975 : libspdm_algorithms_response_spdm11_t *spdm_response;
976 : size_t spdm_response_size;
977 : size_t transport_header_size;
978 :
979 0 : spdm_response_size = sizeof(libspdm_algorithms_response_spdm11_t);
980 0 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
981 0 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
982 :
983 0 : libspdm_zero_mem(spdm_response, spdm_response_size);
984 0 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_11;
985 0 : spdm_response->header.request_response_code = SPDM_ALGORITHMS;
986 0 : spdm_response->header.param1 = 4;
987 0 : spdm_response->header.param2 = 0;
988 0 : spdm_response->length = sizeof(libspdm_algorithms_response_spdm11_t);
989 0 : spdm_response->measurement_specification_sel = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
990 0 : spdm_response->measurement_hash_algo = m_libspdm_use_measurement_hash_algo;
991 0 : spdm_response->base_asym_sel = m_libspdm_use_asym_algo;
992 0 : spdm_response->base_hash_sel = m_libspdm_use_hash_algo;
993 0 : spdm_response->ext_asym_sel_count = 0;
994 0 : spdm_response->ext_hash_sel_count = 0;
995 0 : spdm_response->struct_table[0].alg_type =
996 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE;
997 0 : spdm_response->struct_table[0].alg_count = 0x20;
998 0 : spdm_response->struct_table[0].alg_supported = m_libspdm_use_dhe_algo |
999 : SPDM_ALGORITHMS_DHE_NAMED_GROUP_SECP_521_R1;
1000 0 : spdm_response->struct_table[1].alg_type =
1001 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD;
1002 0 : spdm_response->struct_table[1].alg_count = 0x20;
1003 0 : spdm_response->struct_table[1].alg_supported = m_libspdm_use_aead_algo;
1004 0 : spdm_response->struct_table[2].alg_type =
1005 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG;
1006 0 : spdm_response->struct_table[2].alg_count = 0x20;
1007 0 : spdm_response->struct_table[2].alg_supported = m_libspdm_use_req_asym_algo;
1008 0 : spdm_response->struct_table[3].alg_type =
1009 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE;
1010 0 : spdm_response->struct_table[3].alg_count = 0x20;
1011 0 : spdm_response->struct_table[3].alg_supported = m_libspdm_use_key_schedule_algo;
1012 :
1013 0 : libspdm_transport_test_encode_message (spdm_context, NULL, false, false,
1014 : spdm_response_size,
1015 : spdm_response, response_size, response);
1016 : }
1017 0 : return LIBSPDM_STATUS_SUCCESS;
1018 :
1019 0 : case 0x1D:
1020 : {
1021 : libspdm_algorithms_response_spdm11_t *spdm_response;
1022 : size_t spdm_response_size;
1023 : size_t transport_header_size;
1024 :
1025 0 : spdm_response_size = sizeof(libspdm_algorithms_response_spdm11_t);
1026 0 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
1027 0 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
1028 :
1029 0 : libspdm_zero_mem(spdm_response, spdm_response_size);
1030 0 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_11;
1031 0 : spdm_response->header.request_response_code = SPDM_ALGORITHMS;
1032 0 : spdm_response->header.param1 = 4;
1033 0 : spdm_response->header.param2 = 0;
1034 0 : spdm_response->length = sizeof(libspdm_algorithms_response_spdm11_t);
1035 0 : spdm_response->measurement_specification_sel = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
1036 0 : spdm_response->measurement_hash_algo = m_libspdm_use_measurement_hash_algo;
1037 0 : spdm_response->base_asym_sel = m_libspdm_use_asym_algo;
1038 0 : spdm_response->base_hash_sel = m_libspdm_use_hash_algo;
1039 0 : spdm_response->ext_asym_sel_count = 0;
1040 0 : spdm_response->ext_hash_sel_count = 0;
1041 0 : spdm_response->struct_table[0].alg_type =
1042 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE;
1043 0 : spdm_response->struct_table[0].alg_count = 0x20;
1044 0 : spdm_response->struct_table[0].alg_supported = m_libspdm_use_dhe_algo;
1045 0 : spdm_response->struct_table[1].alg_type =
1046 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD;
1047 0 : spdm_response->struct_table[1].alg_count = 0x20;
1048 0 : spdm_response->struct_table[1].alg_supported = m_libspdm_use_aead_algo |
1049 : SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_CHACHA20_POLY1305;
1050 0 : spdm_response->struct_table[2].alg_type =
1051 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG;
1052 0 : spdm_response->struct_table[2].alg_count = 0x20;
1053 0 : spdm_response->struct_table[2].alg_supported = m_libspdm_use_req_asym_algo;
1054 0 : spdm_response->struct_table[3].alg_type =
1055 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE;
1056 0 : spdm_response->struct_table[3].alg_count = 0x20;
1057 0 : spdm_response->struct_table[3].alg_supported = m_libspdm_use_key_schedule_algo;
1058 :
1059 0 : libspdm_transport_test_encode_message (spdm_context, NULL, false, false,
1060 : spdm_response_size,
1061 : spdm_response, response_size, response);
1062 : }
1063 0 : return LIBSPDM_STATUS_SUCCESS;
1064 :
1065 0 : case 0x1E:
1066 : {
1067 : libspdm_algorithms_response_spdm11_t *spdm_response;
1068 : size_t spdm_response_size;
1069 : size_t transport_header_size;
1070 :
1071 0 : spdm_response_size = sizeof(libspdm_algorithms_response_spdm11_t);
1072 0 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
1073 0 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
1074 :
1075 0 : libspdm_zero_mem(spdm_response, spdm_response_size);
1076 0 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_11;
1077 0 : spdm_response->header.request_response_code = SPDM_ALGORITHMS;
1078 0 : spdm_response->header.param1 = 4;
1079 0 : spdm_response->header.param2 = 0;
1080 0 : spdm_response->length = sizeof(libspdm_algorithms_response_spdm11_t);
1081 0 : spdm_response->measurement_specification_sel = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
1082 0 : spdm_response->measurement_hash_algo = m_libspdm_use_measurement_hash_algo;
1083 0 : spdm_response->base_asym_sel = m_libspdm_use_asym_algo;
1084 0 : spdm_response->base_hash_sel = m_libspdm_use_hash_algo;
1085 0 : spdm_response->ext_asym_sel_count = 0;
1086 0 : spdm_response->ext_hash_sel_count = 0;
1087 0 : spdm_response->struct_table[0].alg_type =
1088 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE;
1089 0 : spdm_response->struct_table[0].alg_count = 0x20;
1090 0 : spdm_response->struct_table[0].alg_supported = m_libspdm_use_dhe_algo;
1091 0 : spdm_response->struct_table[1].alg_type =
1092 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD;
1093 0 : spdm_response->struct_table[1].alg_count = 0x20;
1094 0 : spdm_response->struct_table[1].alg_supported = m_libspdm_use_aead_algo;
1095 0 : spdm_response->struct_table[2].alg_type =
1096 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG;
1097 0 : spdm_response->struct_table[2].alg_count = 0x20;
1098 0 : spdm_response->struct_table[2].alg_supported = m_libspdm_use_req_asym_algo |
1099 : SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_ECDSA_ECC_NIST_P521;
1100 0 : spdm_response->struct_table[3].alg_type =
1101 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE;
1102 0 : spdm_response->struct_table[3].alg_count = 0x20;
1103 0 : spdm_response->struct_table[3].alg_supported = m_libspdm_use_key_schedule_algo;
1104 :
1105 0 : libspdm_transport_test_encode_message (spdm_context, NULL, false, false,
1106 : spdm_response_size,
1107 : spdm_response, response_size, response);
1108 : }
1109 0 : return LIBSPDM_STATUS_SUCCESS;
1110 :
1111 0 : case 0x1F:
1112 : {
1113 : libspdm_algorithms_response_spdm11_t *spdm_response;
1114 : size_t spdm_response_size;
1115 : size_t transport_header_size;
1116 :
1117 0 : spdm_response_size = sizeof(libspdm_algorithms_response_spdm11_t);
1118 0 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
1119 0 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
1120 :
1121 0 : libspdm_zero_mem(spdm_response, spdm_response_size);
1122 0 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_11;
1123 0 : spdm_response->header.request_response_code = SPDM_ALGORITHMS;
1124 0 : spdm_response->header.param1 = 4;
1125 0 : spdm_response->header.param2 = 0;
1126 0 : spdm_response->length = sizeof(libspdm_algorithms_response_spdm11_t);
1127 0 : spdm_response->measurement_specification_sel = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
1128 0 : spdm_response->measurement_hash_algo = m_libspdm_use_measurement_hash_algo;
1129 0 : spdm_response->base_asym_sel = m_libspdm_use_asym_algo;
1130 0 : spdm_response->base_hash_sel = m_libspdm_use_hash_algo;
1131 0 : spdm_response->ext_asym_sel_count = 0;
1132 0 : spdm_response->ext_hash_sel_count = 0;
1133 0 : spdm_response->struct_table[0].alg_type =
1134 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE;
1135 0 : spdm_response->struct_table[0].alg_count = 0x20;
1136 0 : spdm_response->struct_table[0].alg_supported = m_libspdm_use_dhe_algo;
1137 0 : spdm_response->struct_table[1].alg_type =
1138 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD;
1139 0 : spdm_response->struct_table[1].alg_count = 0x20;
1140 0 : spdm_response->struct_table[1].alg_supported = m_libspdm_use_aead_algo;
1141 0 : spdm_response->struct_table[2].alg_type =
1142 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG;
1143 0 : spdm_response->struct_table[2].alg_count = 0x20;
1144 0 : spdm_response->struct_table[2].alg_supported = m_libspdm_use_req_asym_algo;
1145 0 : spdm_response->struct_table[3].alg_type =
1146 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE;
1147 0 : spdm_response->struct_table[3].alg_count = 0x20;
1148 0 : spdm_response->struct_table[3].alg_supported = m_libspdm_use_key_schedule_algo | 0x00000020;
1149 :
1150 0 : libspdm_transport_test_encode_message (spdm_context, NULL, false, false,
1151 : spdm_response_size,
1152 : spdm_response, response_size, response);
1153 : }
1154 0 : return LIBSPDM_STATUS_SUCCESS;
1155 :
1156 1 : case 0x20:
1157 : {
1158 : libspdm_algorithms_response_spdm11_t *spdm_response;
1159 : size_t spdm_response_size;
1160 : size_t transport_header_size;
1161 :
1162 1 : spdm_response_size = sizeof(libspdm_algorithms_response_spdm11_t);
1163 1 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
1164 1 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
1165 :
1166 1 : libspdm_zero_mem(spdm_response, spdm_response_size);
1167 1 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_11;
1168 1 : spdm_response->header.request_response_code = SPDM_ALGORITHMS;
1169 1 : spdm_response->header.param1 = 4;
1170 1 : spdm_response->header.param2 = 0;
1171 1 : spdm_response->length = sizeof(libspdm_algorithms_response_spdm11_t);
1172 1 : spdm_response->measurement_specification_sel = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
1173 1 : spdm_response->measurement_hash_algo = m_libspdm_use_measurement_hash_algo;
1174 1 : spdm_response->base_asym_sel = m_libspdm_use_asym_algo;
1175 1 : spdm_response->base_hash_sel = m_libspdm_use_hash_algo;
1176 1 : spdm_response->ext_asym_sel_count = 0;
1177 1 : spdm_response->ext_hash_sel_count = 0;
1178 1 : spdm_response->struct_table[0].alg_type =
1179 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE;
1180 1 : spdm_response->struct_table[0].alg_count = 0x20;
1181 1 : spdm_response->struct_table[0].alg_supported = m_libspdm_use_dhe_algo;
1182 1 : spdm_response->struct_table[1].alg_type =
1183 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD;
1184 1 : spdm_response->struct_table[1].alg_count = 0x20;
1185 1 : spdm_response->struct_table[1].alg_supported = m_libspdm_use_aead_algo;
1186 1 : spdm_response->struct_table[2].alg_type =
1187 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG;
1188 1 : spdm_response->struct_table[2].alg_count = 0x20;
1189 1 : spdm_response->struct_table[2].alg_supported = m_libspdm_use_req_asym_algo;
1190 1 : spdm_response->struct_table[3].alg_type =
1191 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE;
1192 1 : spdm_response->struct_table[3].alg_count = 0x20;
1193 1 : spdm_response->struct_table[3].alg_supported = m_libspdm_use_key_schedule_algo;
1194 :
1195 1 : libspdm_copy_mem(&m_libspdm_local_buffer[m_libspdm_local_buffer_size],
1196 : sizeof(m_libspdm_local_buffer) - m_libspdm_local_buffer_size,
1197 : (uint8_t *)spdm_response, spdm_response_size);
1198 1 : m_libspdm_local_buffer_size += spdm_response_size;
1199 :
1200 1 : libspdm_transport_test_encode_message (spdm_context, NULL, false, false,
1201 : spdm_response_size,
1202 : spdm_response, response_size, response);
1203 : }
1204 1 : return LIBSPDM_STATUS_SUCCESS;
1205 :
1206 2 : case 0x21:
1207 : {
1208 : libspdm_algorithms_response_spdm11_t *spdm_response;
1209 : size_t spdm_response_size;
1210 : size_t transport_header_size;
1211 :
1212 2 : spdm_response_size = sizeof(libspdm_algorithms_response_spdm11_t);
1213 2 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
1214 2 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
1215 :
1216 2 : libspdm_zero_mem(spdm_response, spdm_response_size);
1217 2 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_12;
1218 2 : spdm_response->header.request_response_code = SPDM_ALGORITHMS;
1219 2 : spdm_response->header.param1 = 4;
1220 2 : spdm_response->header.param2 = 0;
1221 2 : spdm_response->length = sizeof(libspdm_algorithms_response_spdm11_t);
1222 2 : spdm_response->measurement_specification_sel = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
1223 2 : spdm_response->other_params_selection = SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_1;
1224 2 : spdm_response->measurement_hash_algo = m_libspdm_use_measurement_hash_algo;
1225 2 : spdm_response->base_asym_sel = m_libspdm_use_asym_algo;
1226 2 : spdm_response->base_hash_sel = m_libspdm_use_hash_algo;
1227 2 : spdm_response->ext_asym_sel_count = 0;
1228 2 : spdm_response->ext_hash_sel_count = 0;
1229 2 : spdm_response->struct_table[0].alg_type =
1230 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE;
1231 2 : spdm_response->struct_table[0].alg_count = 0x20;
1232 2 : spdm_response->struct_table[0].alg_supported = m_libspdm_use_dhe_algo;
1233 2 : spdm_response->struct_table[1].alg_type =
1234 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD;
1235 2 : spdm_response->struct_table[1].alg_count = 0x20;
1236 2 : spdm_response->struct_table[1].alg_supported = m_libspdm_use_aead_algo;
1237 2 : spdm_response->struct_table[2].alg_type =
1238 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG;
1239 2 : spdm_response->struct_table[2].alg_count = 0x20;
1240 2 : spdm_response->struct_table[2].alg_supported = m_libspdm_use_req_asym_algo;
1241 2 : spdm_response->struct_table[3].alg_type =
1242 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE;
1243 2 : spdm_response->struct_table[3].alg_count = 0x20;
1244 2 : spdm_response->struct_table[3].alg_supported = m_libspdm_use_key_schedule_algo;
1245 :
1246 2 : libspdm_transport_test_encode_message (spdm_context, NULL, false, false,
1247 : spdm_response_size,
1248 : spdm_response, response_size, response);
1249 : }
1250 2 : return LIBSPDM_STATUS_SUCCESS;
1251 :
1252 0 : case 0x22:
1253 : {
1254 : libspdm_algorithms_response_spdm11_t *spdm_response;
1255 : size_t spdm_response_size;
1256 : size_t transport_header_size;
1257 :
1258 0 : spdm_response_size = sizeof(libspdm_algorithms_response_spdm11_t);
1259 0 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
1260 0 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
1261 :
1262 0 : libspdm_zero_mem(spdm_response, spdm_response_size);
1263 0 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_12;
1264 0 : spdm_response->header.request_response_code = SPDM_ALGORITHMS;
1265 0 : spdm_response->header.param1 = 4;
1266 0 : spdm_response->header.param2 = 0;
1267 0 : spdm_response->length = sizeof(libspdm_algorithms_response_spdm11_t);
1268 0 : spdm_response->measurement_specification_sel = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
1269 0 : spdm_response->other_params_selection = 0;
1270 0 : spdm_response->measurement_hash_algo = m_libspdm_use_measurement_hash_algo;
1271 0 : spdm_response->base_asym_sel = m_libspdm_use_asym_algo;
1272 0 : spdm_response->base_hash_sel = m_libspdm_use_hash_algo;
1273 0 : spdm_response->ext_asym_sel_count = 0;
1274 0 : spdm_response->ext_hash_sel_count = 0;
1275 0 : spdm_response->struct_table[0].alg_type =
1276 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE;
1277 0 : spdm_response->struct_table[0].alg_count = 0x20;
1278 0 : spdm_response->struct_table[0].alg_supported = m_libspdm_use_dhe_algo;
1279 0 : spdm_response->struct_table[1].alg_type =
1280 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD;
1281 0 : spdm_response->struct_table[1].alg_count = 0x20;
1282 0 : spdm_response->struct_table[1].alg_supported = m_libspdm_use_aead_algo;
1283 0 : spdm_response->struct_table[2].alg_type =
1284 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG;
1285 0 : spdm_response->struct_table[2].alg_count = 0x20;
1286 0 : spdm_response->struct_table[2].alg_supported = m_libspdm_use_req_asym_algo;
1287 0 : spdm_response->struct_table[3].alg_type =
1288 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE;
1289 0 : spdm_response->struct_table[3].alg_count = 0x20;
1290 0 : spdm_response->struct_table[3].alg_supported = m_libspdm_use_key_schedule_algo;
1291 :
1292 0 : libspdm_transport_test_encode_message (spdm_context, NULL, false, false,
1293 : spdm_response_size,
1294 : spdm_response, response_size, response);
1295 : }
1296 0 : return LIBSPDM_STATUS_SUCCESS;
1297 :
1298 6 : case 0x23:
1299 : {
1300 : spdm_algorithms_response_t *spdm_response;
1301 : size_t spdm_response_size;
1302 : size_t transport_header_size;
1303 :
1304 6 : spdm_response_size = sizeof(spdm_algorithms_response_t);
1305 6 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
1306 6 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
1307 :
1308 6 : libspdm_zero_mem(spdm_response, spdm_response_size);
1309 6 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_13;
1310 6 : spdm_response->header.request_response_code = SPDM_ALGORITHMS;
1311 6 : spdm_response->header.param1 = 0;
1312 6 : spdm_response->header.param2 = 0;
1313 6 : spdm_response->length = sizeof(spdm_algorithms_response_t);
1314 6 : spdm_response->measurement_specification_sel = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
1315 6 : spdm_response->measurement_hash_algo = m_libspdm_use_measurement_hash_algo;
1316 6 : spdm_response->base_asym_sel = m_libspdm_use_asym_algo;
1317 6 : spdm_response->base_hash_sel = m_libspdm_use_hash_algo;
1318 6 : spdm_response->ext_asym_sel_count = 0;
1319 6 : spdm_response->ext_hash_sel_count = 0;
1320 6 : spdm_response->other_params_selection = m_connection_other_params_support;
1321 :
1322 6 : libspdm_transport_test_encode_message(spdm_context, NULL, false,
1323 : false, spdm_response_size,
1324 : spdm_response,
1325 : response_size, response);
1326 : }
1327 6 : return LIBSPDM_STATUS_SUCCESS;
1328 8 : case 0x24:
1329 : {
1330 : libspdm_algorithms_response_spdm11_t *spdm_response;
1331 : size_t spdm_response_size;
1332 : size_t transport_header_size;
1333 :
1334 8 : spdm_response_size = sizeof(libspdm_algorithms_response_spdm11_t);
1335 8 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
1336 8 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
1337 :
1338 8 : libspdm_zero_mem(spdm_response, spdm_response_size);
1339 8 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_13;
1340 8 : spdm_response->header.request_response_code = SPDM_ALGORITHMS;
1341 8 : spdm_response->header.param1 = 4;
1342 8 : spdm_response->header.param2 = 0;
1343 8 : spdm_response->length = sizeof(libspdm_algorithms_response_spdm11_t);
1344 8 : spdm_response->measurement_specification_sel = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
1345 8 : spdm_response->measurement_hash_algo = m_libspdm_use_measurement_hash_algo;
1346 8 : spdm_response->base_asym_sel = m_libspdm_use_asym_algo;
1347 8 : spdm_response->base_hash_sel = m_libspdm_use_hash_algo;
1348 8 : spdm_response->ext_asym_sel_count = 0;
1349 8 : spdm_response->ext_hash_sel_count = 0;
1350 8 : spdm_response->mel_specification_sel = m_mel_specification_sel;
1351 8 : spdm_response->other_params_selection = SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_1;
1352 :
1353 8 : spdm_response->struct_table[0].alg_type =
1354 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE;
1355 8 : spdm_response->struct_table[0].alg_count = 0x20;
1356 8 : spdm_response->struct_table[0].alg_supported = m_libspdm_use_dhe_algo;
1357 8 : spdm_response->struct_table[1].alg_type =
1358 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD;
1359 8 : spdm_response->struct_table[1].alg_count = 0x20;
1360 8 : spdm_response->struct_table[1].alg_supported = m_libspdm_use_aead_algo;
1361 8 : spdm_response->struct_table[2].alg_type =
1362 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG;
1363 8 : spdm_response->struct_table[2].alg_count = 0x20;
1364 8 : spdm_response->struct_table[2].alg_supported = m_libspdm_use_req_asym_algo;
1365 8 : spdm_response->struct_table[3].alg_type =
1366 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE;
1367 8 : spdm_response->struct_table[3].alg_count = 0x20;
1368 8 : spdm_response->struct_table[3].alg_supported = m_libspdm_use_key_schedule_algo;
1369 :
1370 8 : libspdm_transport_test_encode_message (spdm_context, NULL, false, false,
1371 : spdm_response_size,
1372 : spdm_response, response_size, response);
1373 :
1374 : }
1375 8 : return LIBSPDM_STATUS_SUCCESS;
1376 1 : case 0x25: {
1377 : /* EP_INFO_CAP_SIG negotiated: responder returns valid req_base_asym_alg */
1378 : libspdm_algorithms_response_spdm11_t *spdm_response;
1379 : size_t spdm_response_size;
1380 : size_t transport_header_size;
1381 :
1382 1 : spdm_response_size = sizeof(libspdm_algorithms_response_spdm11_t);
1383 1 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
1384 1 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
1385 :
1386 1 : libspdm_zero_mem(spdm_response, spdm_response_size);
1387 1 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_11;
1388 1 : spdm_response->header.request_response_code = SPDM_ALGORITHMS;
1389 1 : spdm_response->header.param1 = 4;
1390 1 : spdm_response->header.param2 = 0;
1391 1 : spdm_response->length = sizeof(libspdm_algorithms_response_spdm11_t);
1392 1 : spdm_response->measurement_specification_sel = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
1393 1 : spdm_response->measurement_hash_algo = m_libspdm_use_measurement_hash_algo;
1394 1 : spdm_response->base_asym_sel = m_libspdm_use_asym_algo;
1395 1 : spdm_response->base_hash_sel = m_libspdm_use_hash_algo;
1396 1 : spdm_response->ext_asym_sel_count = 0;
1397 1 : spdm_response->ext_hash_sel_count = 0;
1398 1 : spdm_response->struct_table[0].alg_type =
1399 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE;
1400 1 : spdm_response->struct_table[0].alg_count = 0x20;
1401 1 : spdm_response->struct_table[0].alg_supported = m_libspdm_use_dhe_algo;
1402 1 : spdm_response->struct_table[1].alg_type =
1403 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD;
1404 1 : spdm_response->struct_table[1].alg_count = 0x20;
1405 1 : spdm_response->struct_table[1].alg_supported = m_libspdm_use_aead_algo;
1406 1 : spdm_response->struct_table[2].alg_type =
1407 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG;
1408 1 : spdm_response->struct_table[2].alg_count = 0x20;
1409 1 : spdm_response->struct_table[2].alg_supported = m_libspdm_use_req_asym_algo;
1410 1 : spdm_response->struct_table[3].alg_type =
1411 : SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE;
1412 1 : spdm_response->struct_table[3].alg_count = 0x20;
1413 1 : spdm_response->struct_table[3].alg_supported = m_libspdm_use_key_schedule_algo;
1414 :
1415 1 : libspdm_transport_test_encode_message(spdm_context, NULL, false, false,
1416 : spdm_response_size,
1417 : spdm_response, response_size, response);
1418 : }
1419 1 : return LIBSPDM_STATUS_SUCCESS;
1420 0 : default:
1421 0 : return LIBSPDM_STATUS_RECEIVE_FAIL;
1422 : }
1423 : }
1424 :
1425 1 : static void req_negotiate_algorithms_case1(void **state)
1426 : {
1427 1 : }
1428 :
1429 1 : static void req_negotiate_algorithms_case2(void **state)
1430 : {
1431 : libspdm_return_t status;
1432 : libspdm_test_context_t *spdm_test_context;
1433 : libspdm_context_t *spdm_context;
1434 :
1435 1 : spdm_test_context = *state;
1436 1 : spdm_context = spdm_test_context->spdm_context;
1437 1 : spdm_test_context->case_id = 0x2;
1438 1 : spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_10 <<
1439 : SPDM_VERSION_NUMBER_SHIFT_BIT;
1440 1 : spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
1441 1 : spdm_context->local_context.algorithm.measurement_hash_algo =
1442 : m_libspdm_use_measurement_hash_algo;
1443 1 : spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
1444 1 : spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
1445 1 : spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP;
1446 1 : spdm_context->local_context.algorithm.measurement_spec = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
1447 :
1448 1 : libspdm_reset_message_a(spdm_context);
1449 :
1450 1 : status = libspdm_negotiate_algorithms(spdm_context);
1451 1 : assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
1452 : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
1453 : assert_int_equal(spdm_context->transcript.message_a.buffer_size,
1454 : sizeof(spdm_negotiate_algorithms_request_t) +
1455 : sizeof(spdm_algorithms_response_t));
1456 : #endif
1457 1 : }
1458 :
1459 : /**
1460 : * Case 3:
1461 : * +---------------+--------------------------+--------------------------+-----------------------------------+
1462 : * | MEAS_CAP | MeasurementSpecification | MeasurementSpecificationSel | Expected result |
1463 : * | | NEGOTIATE_ALGORITHMS | ALGORITHMS | |
1464 : * +----------+----------------------------+-----------------------------+-----------------------------------+
1465 : * | set | DMTFmeasSpec | DMTFmeasSpec | LIBSPDM_STATUS_SUCCESS |
1466 : * ---------------------------------------------------------------------------------------------------------+
1467 : * | set | DMTFmeasSpec | 0 | LIBSPDM_STATUS_INVALID_MSG_FIELD |
1468 : * ----------------------------------------------------------------------------------------------------------
1469 : * | set | 0 | DMTFmeasSpec | LIBSPDM_STATUS_INVALID_MSG_FIELD |
1470 : * ---------------------------------------------------------------------------------------------------------+
1471 : * | set | 0 | 0 | LIBSPDM_STATUS_SUCCESS |
1472 : * ----------------------------------------------------------------------------------------------------------
1473 : * | Not set | DMTFmeasSpec | DMTFmeasSpec | LIBSPDM_STATUS_INVALID_MSG_FIELD |
1474 : * ---------------------------------------------------------------------------------------------------------+
1475 : * | Not set | DMTFmeasSpec | 0 | LIBSPDM_STATUS_SUCCESS |
1476 : * ----------------------------------------------------------------------------------------------------------
1477 : * | Not set | 0 | DMTFmeasSpec | LIBSPDM_STATUS_INVALID_MSG_FIELD |
1478 : * ---------------------------------------------------------------------------------------------------------+
1479 : * | Not set | 0 | 0 | LIBSPDM_STATUS_SUCCESS |
1480 : * ----------------------------------------------------------------------------------------------------------
1481 : **/
1482 1 : static void req_negotiate_algorithms_case3(void **state)
1483 : {
1484 : libspdm_return_t status;
1485 : libspdm_test_context_t *spdm_test_context;
1486 : libspdm_context_t *spdm_context;
1487 1 : spdm_test_context = *state;
1488 1 : spdm_context = spdm_test_context->spdm_context;
1489 1 : spdm_test_context->case_id = 0x3;
1490 1 : spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_10 <<
1491 : SPDM_VERSION_NUMBER_SHIFT_BIT;
1492 1 : spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
1493 1 : spdm_context->local_context.algorithm.measurement_hash_algo =
1494 : m_libspdm_use_measurement_hash_algo;
1495 1 : spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
1496 1 : spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
1497 1 : spdm_context->connection_info.capability.flags = 0;
1498 :
1499 : /* Sub Case 1: MEAS_CAP set 1, measurement_spec_sel and measurement_spec set SPDM_MEASUREMENT_SPECIFICATION_DMTF*/
1500 1 : spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP;
1501 1 : libspdm_reset_message_a(spdm_context);
1502 1 : m_measurement_specification_sel = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
1503 1 : spdm_context->local_context.algorithm.measurement_spec = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
1504 1 : spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
1505 1 : status = libspdm_negotiate_algorithms(spdm_context);
1506 1 : assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
1507 :
1508 : /* Sub Case 2: MEAS_CAP set 1, measurement_spec_sel set 0 , measurement_spec set SPDM_MEASUREMENT_SPECIFICATION_DMTF*/
1509 1 : libspdm_reset_message_a(spdm_context);
1510 1 : m_measurement_specification_sel = 0;
1511 1 : spdm_context->local_context.algorithm.measurement_spec = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
1512 1 : spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
1513 1 : status = libspdm_negotiate_algorithms(spdm_context);
1514 1 : assert_int_equal(status, LIBSPDM_STATUS_INVALID_MSG_FIELD);
1515 :
1516 : /* Sub Case 3: MEAS_CAP set 1, measurement_spec_sel set SPDM_MEASUREMENT_SPECIFICATION_DMTF , measurement_spec set 0*/
1517 1 : libspdm_reset_message_a(spdm_context);
1518 1 : m_measurement_specification_sel = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
1519 1 : spdm_context->local_context.algorithm.measurement_spec = 0;
1520 1 : spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
1521 1 : status = libspdm_negotiate_algorithms(spdm_context);
1522 1 : assert_int_equal(status, LIBSPDM_STATUS_INVALID_MSG_FIELD);
1523 :
1524 : /* Sub Case 4: MEAS_CAP set 1,measurement_spec_sel set 0 , measurement_spec set 0*/
1525 1 : libspdm_reset_message_a(spdm_context);
1526 1 : m_measurement_specification_sel = 0;
1527 1 : spdm_context->local_context.algorithm.measurement_spec = 0;
1528 1 : spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
1529 1 : status = libspdm_negotiate_algorithms(spdm_context);
1530 1 : assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
1531 :
1532 : /* Sub Case 5:MEAS_CAP set 0, measurement_spec_sel and measurement_spec set SPDM_MEASUREMENT_SPECIFICATION_DMTF*/
1533 1 : spdm_context->connection_info.capability.flags = 0;
1534 1 : libspdm_reset_message_a(spdm_context);
1535 1 : m_measurement_specification_sel = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
1536 1 : spdm_context->local_context.algorithm.measurement_spec = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
1537 1 : spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
1538 1 : status = libspdm_negotiate_algorithms(spdm_context);
1539 1 : assert_int_equal(status, LIBSPDM_STATUS_INVALID_MSG_FIELD);
1540 :
1541 : /* Sub Case 6: MEAS_CAP set 0, measurement_spec_sel set 0 , measurement_spec set SPDM_MEASUREMENT_SPECIFICATION_DMTF*/
1542 1 : libspdm_reset_message_a(spdm_context);
1543 1 : m_measurement_specification_sel = 0;
1544 1 : spdm_context->local_context.algorithm.measurement_spec = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
1545 1 : spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
1546 1 : status = libspdm_negotiate_algorithms(spdm_context);
1547 1 : assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
1548 :
1549 : /* Sub Case 7: MEAS_CAP set 0,measurement_spec_sel set SPDM_MEASUREMENT_SPECIFICATION_DMTF , measurement_spec set 0*/
1550 1 : libspdm_reset_message_a(spdm_context);
1551 1 : m_measurement_specification_sel = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
1552 1 : spdm_context->local_context.algorithm.measurement_spec = 0;
1553 1 : spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
1554 1 : status = libspdm_negotiate_algorithms(spdm_context);
1555 1 : assert_int_equal(status, LIBSPDM_STATUS_INVALID_MSG_FIELD);
1556 :
1557 : /* Sub Case 8: MEAS_CAP set 0,measurement_spec_sel set 0 , measurement_spec set 0*/
1558 1 : libspdm_reset_message_a(spdm_context);
1559 1 : m_measurement_specification_sel = 0;
1560 1 : spdm_context->local_context.algorithm.measurement_spec = 0;
1561 1 : spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
1562 1 : status = libspdm_negotiate_algorithms(spdm_context);
1563 1 : assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
1564 1 : }
1565 :
1566 1 : static void req_negotiate_algorithms_case4(void **state)
1567 : {
1568 1 : }
1569 :
1570 1 : static void req_negotiate_algorithms_case5(void **state)
1571 : {
1572 1 : }
1573 :
1574 1 : static void req_negotiate_algorithms_case6(void **state)
1575 : {
1576 : libspdm_return_t status;
1577 : libspdm_test_context_t *spdm_test_context;
1578 : libspdm_context_t *spdm_context;
1579 :
1580 1 : spdm_test_context = *state;
1581 1 : spdm_context = spdm_test_context->spdm_context;
1582 1 : spdm_test_context->case_id = 0x6;
1583 1 : spdm_context->retry_times = 3;
1584 1 : spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_10 <<
1585 : SPDM_VERSION_NUMBER_SHIFT_BIT;
1586 1 : spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
1587 1 : spdm_context->local_context.algorithm.measurement_hash_algo =
1588 : m_libspdm_use_measurement_hash_algo;
1589 1 : spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
1590 1 : spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
1591 1 : spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP;
1592 1 : spdm_context->local_context.algorithm.measurement_spec = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
1593 1 : libspdm_reset_message_a(spdm_context);
1594 :
1595 1 : status = libspdm_negotiate_algorithms(spdm_context);
1596 1 : assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
1597 : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
1598 : assert_int_equal(spdm_context->transcript.message_a.buffer_size,
1599 : sizeof(spdm_negotiate_algorithms_request_t) +
1600 : sizeof(spdm_algorithms_response_t));
1601 : #endif
1602 1 : }
1603 :
1604 1 : static void req_negotiate_algorithms_case7(void **state)
1605 : {
1606 1 : }
1607 :
1608 1 : static void req_negotiate_algorithms_case8(void **state)
1609 : {
1610 1 : }
1611 :
1612 1 : static void req_negotiate_algorithms_case9(void **state)
1613 : {
1614 1 : }
1615 :
1616 1 : static void req_negotiate_algorithms_case10(void **state)
1617 : {
1618 1 : }
1619 :
1620 1 : static void req_negotiate_algorithms_case11(void **state)
1621 : {
1622 1 : }
1623 :
1624 1 : static void req_negotiate_algorithms_case12(void **state)
1625 : {
1626 1 : }
1627 :
1628 1 : static void req_negotiate_algorithms_case13(void **state)
1629 : {
1630 :
1631 1 : }
1632 :
1633 1 : static void req_negotiate_algorithms_case14(void **state)
1634 : {
1635 1 : }
1636 :
1637 1 : static void req_negotiate_algorithms_case15(void **state)
1638 : {
1639 1 : }
1640 :
1641 1 : static void req_negotiate_algorithms_case16(void **state)
1642 : {
1643 1 : }
1644 :
1645 1 : static void req_negotiate_algorithms_case17(void **state)
1646 : {
1647 1 : }
1648 :
1649 1 : static void req_negotiate_algorithms_case18(void **state)
1650 : {
1651 1 : }
1652 :
1653 1 : static void req_negotiate_algorithms_case19(void **state)
1654 : {
1655 1 : }
1656 :
1657 1 : static void req_negotiate_algorithms_case20(void **state)
1658 : {
1659 1 : }
1660 :
1661 1 : static void req_negotiate_algorithms_case21(void **state)
1662 : {
1663 1 : }
1664 :
1665 1 : static void req_negotiate_algorithms_case22(void **state)
1666 : {
1667 1 : }
1668 :
1669 1 : static void req_negotiate_algorithms_case23(void **state)
1670 : {
1671 : libspdm_return_t status;
1672 : libspdm_test_context_t *spdm_test_context;
1673 : libspdm_context_t *spdm_context;
1674 :
1675 1 : spdm_test_context = *state;
1676 1 : spdm_context = spdm_test_context->spdm_context;
1677 1 : spdm_test_context->case_id = 0x17;
1678 :
1679 1 : spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_11 <<
1680 : SPDM_VERSION_NUMBER_SHIFT_BIT;
1681 1 : spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
1682 1 : spdm_context->local_context.algorithm.measurement_hash_algo =
1683 : m_libspdm_use_measurement_hash_algo;
1684 1 : spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
1685 1 : spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
1686 1 : libspdm_reset_message_a(spdm_context);
1687 1 : spdm_context->local_context.algorithm.dhe_named_group = m_libspdm_use_dhe_algo;
1688 1 : spdm_context->local_context.algorithm.aead_cipher_suite = m_libspdm_use_aead_algo;
1689 1 : spdm_context->local_context.algorithm.req_base_asym_alg = m_libspdm_use_req_asym_algo;
1690 1 : spdm_context->local_context.algorithm.key_schedule = m_libspdm_use_key_schedule_algo;
1691 1 : spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP;
1692 1 : spdm_context->local_context.algorithm.measurement_spec = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
1693 :
1694 1 : spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP;
1695 1 : spdm_context->connection_info.capability.flags |=
1696 : SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_EX_CAP;
1697 :
1698 1 : spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP;
1699 1 : spdm_context->connection_info.capability.flags |=
1700 : SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP;
1701 :
1702 1 : spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP;
1703 1 : spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP;
1704 :
1705 1 : spdm_context->local_context.capability.flags |=
1706 : SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
1707 1 : spdm_context->connection_info.capability.flags |=
1708 : SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
1709 :
1710 1 : spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP;
1711 1 : spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP;
1712 :
1713 1 : status = libspdm_negotiate_algorithms (spdm_context);
1714 1 : assert_int_equal (status, LIBSPDM_STATUS_SUCCESS);
1715 : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
1716 : assert_int_equal (spdm_context->transcript.message_a.buffer_size,
1717 : sizeof(spdm_negotiate_algorithms_request_t) + 4*
1718 : sizeof(spdm_negotiate_algorithms_common_struct_table_t) +
1719 : sizeof(libspdm_algorithms_response_spdm11_t));
1720 : #endif
1721 1 : }
1722 :
1723 1 : static void req_negotiate_algorithms_case24(void **state)
1724 : {
1725 1 : }
1726 :
1727 1 : static void req_negotiate_algorithms_case25(void **state)
1728 : {
1729 1 : }
1730 :
1731 1 : static void req_negotiate_algorithms_case26(void **state)
1732 : {
1733 1 : }
1734 :
1735 1 : static void req_negotiate_algorithms_case27(void **state)
1736 : {
1737 1 : }
1738 :
1739 1 : static void req_negotiate_algorithms_case28(void **state)
1740 : {
1741 1 : }
1742 :
1743 1 : static void req_negotiate_algorithms_case29(void **state)
1744 : {
1745 1 : }
1746 :
1747 1 : static void req_negotiate_algorithms_case30(void **state)
1748 : {
1749 1 : }
1750 :
1751 1 : static void req_negotiate_algorithms_case31(void **state)
1752 : {
1753 1 : }
1754 :
1755 1 : static void req_negotiate_algorithms_case32(void **state) {
1756 : libspdm_return_t status;
1757 : libspdm_test_context_t *spdm_test_context;
1758 : libspdm_context_t *spdm_context;
1759 : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
1760 : size_t arbitrary_size;
1761 : #endif
1762 :
1763 1 : spdm_test_context = *state;
1764 1 : spdm_context = spdm_test_context->spdm_context;
1765 1 : spdm_test_context->case_id = 0x20;
1766 :
1767 1 : spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_11 <<
1768 : SPDM_VERSION_NUMBER_SHIFT_BIT;
1769 1 : spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
1770 1 : spdm_context->local_context.algorithm.measurement_hash_algo =
1771 : m_libspdm_use_measurement_hash_algo;
1772 1 : spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
1773 1 : spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
1774 1 : libspdm_reset_message_a(spdm_context);
1775 1 : spdm_context->local_context.algorithm.dhe_named_group = m_libspdm_use_dhe_algo;
1776 1 : spdm_context->local_context.algorithm.aead_cipher_suite = m_libspdm_use_aead_algo;
1777 1 : spdm_context->local_context.algorithm.req_base_asym_alg = m_libspdm_use_req_asym_algo;
1778 1 : spdm_context->local_context.algorithm.key_schedule = m_libspdm_use_key_schedule_algo;
1779 1 : spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP;
1780 1 : spdm_context->local_context.algorithm.measurement_spec = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
1781 :
1782 1 : spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP;
1783 1 : spdm_context->connection_info.capability.flags |=
1784 : SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_EX_CAP;
1785 :
1786 1 : spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP;
1787 1 : spdm_context->connection_info.capability.flags |=
1788 : SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP;
1789 :
1790 1 : spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP;
1791 1 : spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP;
1792 :
1793 1 : spdm_context->local_context.capability.flags |=
1794 : SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
1795 1 : spdm_context->connection_info.capability.flags |=
1796 : SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
1797 :
1798 1 : spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP;
1799 1 : spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP;
1800 :
1801 : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
1802 : /*filling A with arbitrary data*/
1803 : arbitrary_size = 10;
1804 : libspdm_set_mem(spdm_context->transcript.message_a.buffer, arbitrary_size, (uint8_t) 0xFF);
1805 : spdm_context->transcript.message_a.buffer_size = arbitrary_size;
1806 : #endif
1807 :
1808 1 : status = libspdm_negotiate_algorithms (spdm_context);
1809 1 : assert_int_equal (status, LIBSPDM_STATUS_SUCCESS);
1810 : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
1811 : assert_int_equal (spdm_context->transcript.message_a.buffer_size,
1812 : arbitrary_size + m_libspdm_local_buffer_size);
1813 : LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "m_libspdm_local_buffer (0x%x):\n",
1814 : m_libspdm_local_buffer_size));
1815 : libspdm_dump_hex(m_libspdm_local_buffer, m_libspdm_local_buffer_size);
1816 : assert_memory_equal(spdm_context->transcript.message_a.buffer + arbitrary_size,
1817 : m_libspdm_local_buffer, m_libspdm_local_buffer_size);
1818 : #endif
1819 1 : }
1820 :
1821 1 : static void req_negotiate_algorithms_case33(void **state) {
1822 : libspdm_return_t status;
1823 : libspdm_test_context_t *spdm_test_context;
1824 : libspdm_context_t *spdm_context;
1825 :
1826 1 : spdm_test_context = *state;
1827 1 : spdm_context = spdm_test_context->spdm_context;
1828 1 : spdm_test_context->case_id = 0x21;
1829 :
1830 1 : spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_12 <<
1831 : SPDM_VERSION_NUMBER_SHIFT_BIT;
1832 1 : spdm_context->local_context.algorithm.measurement_hash_algo =
1833 : m_libspdm_use_measurement_hash_algo;
1834 1 : spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
1835 1 : spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
1836 1 : libspdm_reset_message_a(spdm_context);
1837 1 : spdm_context->local_context.algorithm.dhe_named_group = m_libspdm_use_dhe_algo;
1838 1 : spdm_context->local_context.algorithm.aead_cipher_suite = m_libspdm_use_aead_algo;
1839 1 : spdm_context->local_context.algorithm.req_base_asym_alg = m_libspdm_use_req_asym_algo;
1840 1 : spdm_context->local_context.algorithm.key_schedule = m_libspdm_use_key_schedule_algo;
1841 1 : spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP;
1842 1 : spdm_context->connection_info.capability.flags |=
1843 : SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_EX_CAP;
1844 :
1845 1 : spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP;
1846 1 : spdm_context->connection_info.capability.flags |=
1847 : SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP;
1848 :
1849 1 : spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP;
1850 1 : spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP;
1851 :
1852 1 : spdm_context->local_context.capability.flags |=
1853 : SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
1854 1 : spdm_context->connection_info.capability.flags |=
1855 : SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
1856 :
1857 1 : spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP;
1858 1 : spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP;
1859 1 : spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP;
1860 1 : spdm_context->local_context.algorithm.measurement_spec = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
1861 :
1862 : /* Sub Case 1: other_params_support set OpaqueDataFmt1 */
1863 1 : spdm_context->local_context.algorithm.other_params_support =
1864 : SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_1;
1865 1 : spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
1866 1 : libspdm_reset_message_a(spdm_context);
1867 :
1868 1 : status = libspdm_negotiate_algorithms(spdm_context);
1869 1 : assert_int_equal (status, LIBSPDM_STATUS_SUCCESS);
1870 1 : assert_int_equal(spdm_context->connection_info.algorithm.other_params_support,
1871 : SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_1);
1872 :
1873 : /* Sub Case 2: Populate reserved field for version 1.2, field values marked as Reserved shall be written as zero ( 0 )*/
1874 1 : spdm_context->local_context.algorithm.other_params_support =
1875 : SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_1 |
1876 : SPDM_ALGORITHMS_MULTI_KEY_CONN;
1877 1 : spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
1878 1 : libspdm_reset_message_a(spdm_context);
1879 :
1880 1 : status = libspdm_negotiate_algorithms(spdm_context);
1881 1 : assert_int_equal (status, LIBSPDM_STATUS_SUCCESS);
1882 1 : assert_int_equal(spdm_context->connection_info.algorithm.other_params_support,
1883 : SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_1);
1884 : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
1885 : assert_int_equal (spdm_context->transcript.message_a.buffer_size,
1886 : sizeof(spdm_negotiate_algorithms_request_t) + 4*
1887 : sizeof(spdm_negotiate_algorithms_common_struct_table_t) +
1888 : sizeof(libspdm_algorithms_response_spdm11_t));
1889 : #endif
1890 1 : }
1891 :
1892 :
1893 1 : static void req_negotiate_algorithms_case34(void **state)
1894 : {
1895 1 : }
1896 :
1897 : /**
1898 : * Test 35: MULTI_KEY_CONN_REQ and MULTI_KEY_CONN_RSP value calculation
1899 : * +---------------+--------------------------+--------------------+
1900 : * | MULTI_KEY_CAP | RequesterMultiKeyConnSel | MULTI_KEY_CONN_REQ |
1901 : * +---------------+--------------------------+--------------------+
1902 : * | 00b | 0 | false |
1903 : * ----------------------------------------------------------------
1904 : * | 00b | 1 | invalid |
1905 : * ----------------------------------------------------------------
1906 : * | 01b | 0 | invalid |
1907 : * ----------------------------------------------------------------
1908 : * | 01b | 1 | true |
1909 : * ----------------------------------------------------------------
1910 : * | 10b | 0 | false |
1911 : * ----------------------------------------------------------------
1912 : * | 10b | 1 | true |
1913 : * +---------------+--------------------------+--------------------+
1914 : * | MULTI_KEY_CAP | ResponderMultiKeyConn | MULTI_KEY_CONN_RSP |
1915 : * +---------------+--------------------------+--------------------+
1916 : * | 00b | 0 | false |
1917 : * ----------------------------------------------------------------
1918 : * | 00b | 1 | invalid |
1919 : * ----------------------------------------------------------------
1920 : * | 01b | 0 | invalid |
1921 : * ----------------------------------------------------------------
1922 : * | 01b | 1 | true |
1923 : * ----------------------------------------------------------------
1924 : * | 10b | 0 | false |
1925 : * ----------------------------------------------------------------
1926 : * | 10b | 1 | true |
1927 : * ----------------------------------------------------------------
1928 : **/
1929 1 : static void req_negotiate_algorithms_case35(void **state)
1930 : {
1931 : libspdm_return_t status;
1932 : libspdm_test_context_t *spdm_test_context;
1933 : libspdm_context_t *spdm_context;
1934 :
1935 1 : spdm_test_context = *state;
1936 1 : spdm_context = spdm_test_context->spdm_context;
1937 1 : spdm_test_context->case_id = 0x23;
1938 1 : spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_13 <<
1939 : SPDM_VERSION_NUMBER_SHIFT_BIT;
1940 1 : spdm_context->local_context.algorithm.measurement_hash_algo =
1941 : m_libspdm_use_measurement_hash_algo;
1942 1 : spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
1943 1 : spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
1944 :
1945 1 : spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
1946 1 : spdm_context->local_context.algorithm.measurement_spec = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
1947 1 : libspdm_reset_message_a(spdm_context);
1948 :
1949 1 : spdm_context->connection_info.capability.flags = 0;
1950 1 : spdm_context->local_context.capability.flags = 0;
1951 1 : spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP;
1952 1 : spdm_context->local_context.algorithm.other_params_support = 0;
1953 1 : m_connection_other_params_support = 0;
1954 :
1955 1 : status = libspdm_negotiate_algorithms(spdm_context);
1956 1 : assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
1957 1 : assert_int_equal(spdm_context->connection_info.multi_key_conn_rsp, false);
1958 1 : assert_int_equal(spdm_context->connection_info.multi_key_conn_req, false);
1959 :
1960 1 : spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
1961 1 : libspdm_reset_message_a(spdm_context);
1962 :
1963 1 : spdm_context->connection_info.capability.flags = 0;
1964 1 : spdm_context->local_context.capability.flags = 0;
1965 1 : spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP;
1966 1 : spdm_context->local_context.algorithm.other_params_support = SPDM_ALGORITHMS_MULTI_KEY_CONN;
1967 1 : m_connection_other_params_support = SPDM_ALGORITHMS_MULTI_KEY_CONN;
1968 :
1969 1 : status = libspdm_negotiate_algorithms(spdm_context);
1970 : /* MULTI_KEY_CONN_REQ and MULTI_KEY_CONN_RSP invalid */
1971 1 : assert_int_equal(status, LIBSPDM_STATUS_NEGOTIATION_FAIL);
1972 :
1973 1 : spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
1974 1 : libspdm_reset_message_a(spdm_context);
1975 :
1976 1 : spdm_context->connection_info.capability.flags =
1977 : SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MULTI_KEY_CAP_ONLY;
1978 1 : spdm_context->local_context.capability.flags =
1979 : SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MULTI_KEY_CAP_ONLY;
1980 1 : spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP;
1981 1 : spdm_context->local_context.algorithm.other_params_support = 0;
1982 1 : m_connection_other_params_support = 0;
1983 :
1984 1 : status = libspdm_negotiate_algorithms(spdm_context);
1985 : /* MULTI_KEY_CONN_REQ and MULTI_KEY_CONN_RSP invalid */
1986 1 : assert_int_equal(status, LIBSPDM_STATUS_NEGOTIATION_FAIL);
1987 :
1988 1 : spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
1989 1 : libspdm_reset_message_a(spdm_context);
1990 :
1991 1 : spdm_context->connection_info.capability.flags =
1992 : SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MULTI_KEY_CAP_ONLY;
1993 1 : spdm_context->local_context.capability.flags =
1994 : SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MULTI_KEY_CAP_ONLY;
1995 1 : spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP;
1996 1 : spdm_context->local_context.algorithm.other_params_support = SPDM_ALGORITHMS_MULTI_KEY_CONN;
1997 1 : m_connection_other_params_support = SPDM_ALGORITHMS_MULTI_KEY_CONN;
1998 :
1999 1 : status = libspdm_negotiate_algorithms(spdm_context);
2000 1 : assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
2001 1 : assert_int_equal(spdm_context->connection_info.multi_key_conn_rsp, true);
2002 1 : assert_int_equal(spdm_context->connection_info.multi_key_conn_req, true);
2003 :
2004 1 : spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
2005 1 : libspdm_reset_message_a(spdm_context);
2006 :
2007 1 : spdm_context->connection_info.capability.flags =
2008 : SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MULTI_KEY_CAP_NEG;
2009 1 : spdm_context->local_context.capability.flags =
2010 : SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MULTI_KEY_CAP_NEG;
2011 1 : spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP;
2012 1 : spdm_context->local_context.algorithm.other_params_support = 0;
2013 1 : m_connection_other_params_support = 0;
2014 :
2015 1 : status = libspdm_negotiate_algorithms(spdm_context);
2016 1 : assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
2017 1 : assert_int_equal(spdm_context->connection_info.multi_key_conn_rsp, false);
2018 1 : assert_int_equal(spdm_context->connection_info.multi_key_conn_req, false);
2019 :
2020 1 : spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
2021 1 : libspdm_reset_message_a(spdm_context);
2022 :
2023 1 : spdm_context->connection_info.capability.flags =
2024 : SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MULTI_KEY_CAP_NEG;
2025 1 : spdm_context->local_context.capability.flags =
2026 : SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MULTI_KEY_CAP_NEG;
2027 1 : spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP;
2028 1 : spdm_context->local_context.algorithm.other_params_support = SPDM_ALGORITHMS_MULTI_KEY_CONN;
2029 1 : m_connection_other_params_support = SPDM_ALGORITHMS_MULTI_KEY_CONN;
2030 :
2031 1 : status = libspdm_negotiate_algorithms(spdm_context);
2032 1 : assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
2033 1 : assert_int_equal(spdm_context->connection_info.multi_key_conn_rsp, true);
2034 1 : assert_int_equal(spdm_context->connection_info.multi_key_conn_req, true);
2035 1 : }
2036 :
2037 : /**
2038 : * Test 36: ALGORITHMS message received with MEL
2039 : * +---------------+--------------------------+--------------------------+-----------------------------------+
2040 : * | MEAS_CAP | MELspecification | MELspecificationSel | Expected result |
2041 : * | | NEGOTIATE_ALGORITHMS | ALGORITHMS | |
2042 : * +----------+----------------------------+-----------------------------+-----------------------------------+
2043 : * | set | DMTFmeasSpec | DMTFmeasSpec | LIBSPDM_STATUS_SUCCESS |
2044 : * ---------------------------------------------------------------------------------------------------------+
2045 : * | set | DMTFmeasSpec | 0 | LIBSPDM_STATUS_INVALID_MSG_FIELD |
2046 : * ----------------------------------------------------------------------------------------------------------
2047 : * | set | 0 | DMTFmeasSpec | LIBSPDM_STATUS_INVALID_MSG_FIELD |
2048 : * ---------------------------------------------------------------------------------------------------------+
2049 : * | set | 0 | 0 | LIBSPDM_STATUS_SUCCESS |
2050 : * ----------------------------------------------------------------------------------------------------------
2051 : * | Not set | DMTFmeasSpec | DMTFmeasSpec | LIBSPDM_STATUS_INVALID_MSG_FIELD |
2052 : * ---------------------------------------------------------------------------------------------------------+
2053 : * | Not set | DMTFmeasSpec | 0 | LIBSPDM_STATUS_SUCCESS |
2054 : * ----------------------------------------------------------------------------------------------------------
2055 : * | Not set | 0 | DMTFmeasSpec | LIBSPDM_STATUS_INVALID_MSG_FIELD |
2056 : * ---------------------------------------------------------------------------------------------------------+
2057 : * | Not set | 0 | 0 | LIBSPDM_STATUS_SUCCESS |
2058 : * ----------------------------------------------------------------------------------------------------------
2059 : **/
2060 1 : static void req_negotiate_algorithms_case36(void **state)
2061 : {
2062 : libspdm_return_t status;
2063 : libspdm_test_context_t *spdm_test_context;
2064 : libspdm_context_t *spdm_context;
2065 : uint32_t local_capability_flags;
2066 : uint32_t connection_capability_flags;
2067 :
2068 1 : spdm_test_context = *state;
2069 1 : spdm_context = spdm_test_context->spdm_context;
2070 1 : spdm_test_context->case_id = 0x24;
2071 1 : spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_13 <<
2072 : SPDM_VERSION_NUMBER_SHIFT_BIT;
2073 1 : spdm_context->local_context.algorithm.measurement_hash_algo =
2074 : m_libspdm_use_measurement_hash_algo;
2075 1 : spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
2076 1 : spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
2077 1 : spdm_context->local_context.algorithm.dhe_named_group = m_libspdm_use_dhe_algo;
2078 1 : spdm_context->local_context.algorithm.aead_cipher_suite = m_libspdm_use_aead_algo;
2079 1 : spdm_context->local_context.algorithm.req_base_asym_alg = m_libspdm_use_req_asym_algo;
2080 1 : spdm_context->local_context.algorithm.key_schedule = m_libspdm_use_key_schedule_algo;
2081 1 : spdm_context->local_context.algorithm.other_params_support = 0;
2082 :
2083 1 : local_capability_flags = SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP |
2084 : SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP|
2085 : SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP|
2086 : SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP|
2087 : SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP;
2088 1 : connection_capability_flags =
2089 : SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_EX_CAP |
2090 : SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP |
2091 : SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP |
2092 : SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP |
2093 : SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP |
2094 : SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP;
2095 :
2096 1 : spdm_context->connection_info.capability.flags = connection_capability_flags;
2097 1 : spdm_context->local_context.capability.flags = local_capability_flags;
2098 :
2099 : /* Sub Case 1: MEL_CAP set 1, mel_specification_sel and mel_specification set SPDM_MEL_SPECIFICATION_DMTF*/
2100 1 : spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEL_CAP;
2101 1 : libspdm_reset_message_a(spdm_context);
2102 1 : m_mel_specification_sel = SPDM_MEL_SPECIFICATION_DMTF;
2103 1 : spdm_context->local_context.algorithm.mel_spec = SPDM_MEL_SPECIFICATION_DMTF;
2104 1 : spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
2105 1 : status = libspdm_negotiate_algorithms(spdm_context);
2106 1 : assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
2107 :
2108 : /* Sub Case 2: MEL_CAP set 1, mel_specification_sel set 0 , mel_specification set SPDM_MEL_SPECIFICATION_DMTF*/
2109 1 : spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEL_CAP;
2110 1 : libspdm_reset_message_a(spdm_context);
2111 1 : m_mel_specification_sel = 0;
2112 1 : spdm_context->local_context.algorithm.mel_spec = SPDM_MEL_SPECIFICATION_DMTF;
2113 1 : spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
2114 1 : status = libspdm_negotiate_algorithms(spdm_context);
2115 1 : assert_int_equal(status, LIBSPDM_STATUS_INVALID_MSG_FIELD);
2116 :
2117 : /* Sub Case 3: MEL_CAP set 1, mel_specification_sel set SPDM_MEL_SPECIFICATION_DMTF , mel_specification set 0*/
2118 1 : spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEL_CAP;
2119 1 : libspdm_reset_message_a(spdm_context);
2120 1 : m_mel_specification_sel = SPDM_MEL_SPECIFICATION_DMTF;
2121 1 : spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
2122 1 : spdm_context->local_context.algorithm.mel_spec = 0;
2123 1 : status = libspdm_negotiate_algorithms(spdm_context);
2124 1 : assert_int_equal(status, LIBSPDM_STATUS_INVALID_MSG_FIELD);
2125 :
2126 : /* Sub Case 4: MEL_CAP set 1,mel_specification_sel set 0 , mel_specification set 0*/
2127 1 : spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEL_CAP;
2128 1 : libspdm_reset_message_a(spdm_context);
2129 1 : m_mel_specification_sel = 0;
2130 1 : spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
2131 1 : spdm_context->local_context.algorithm.mel_spec = 0;
2132 1 : status = libspdm_negotiate_algorithms(spdm_context);
2133 1 : assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
2134 :
2135 : /* Sub Case 5:MEL_CAP set 0, mel_specification_sel and mel_specification set SPDM_MEL_SPECIFICATION_DMTF*/
2136 1 : spdm_context->connection_info.capability.flags = connection_capability_flags;
2137 1 : libspdm_reset_message_a(spdm_context);
2138 1 : m_mel_specification_sel = SPDM_MEL_SPECIFICATION_DMTF;
2139 1 : spdm_context->local_context.algorithm.mel_spec = SPDM_MEL_SPECIFICATION_DMTF;
2140 1 : spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
2141 1 : status = libspdm_negotiate_algorithms(spdm_context);
2142 1 : assert_int_equal(status, LIBSPDM_STATUS_INVALID_MSG_FIELD);
2143 :
2144 : /* Sub Case 6: MEL_CAP set 0, mel_specification_sel set 0 , mel_specification set SPDM_MEL_SPECIFICATION_DMTF*/
2145 1 : spdm_context->connection_info.capability.flags = connection_capability_flags;
2146 1 : libspdm_reset_message_a(spdm_context);
2147 1 : m_mel_specification_sel = 0;
2148 1 : spdm_context->local_context.algorithm.mel_spec = SPDM_MEL_SPECIFICATION_DMTF;
2149 1 : spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
2150 1 : status = libspdm_negotiate_algorithms(spdm_context);
2151 1 : assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
2152 :
2153 : /* Sub Case 7: MEL_CAP set 0,mel_specification_sel set SPDM_MEL_SPECIFICATION_DMTF , mel_specification set 0*/
2154 1 : spdm_context->connection_info.capability.flags = connection_capability_flags;
2155 1 : libspdm_reset_message_a(spdm_context);
2156 1 : m_mel_specification_sel = SPDM_MEL_SPECIFICATION_DMTF;
2157 1 : spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
2158 1 : spdm_context->local_context.algorithm.mel_spec = 0;
2159 1 : status = libspdm_negotiate_algorithms(spdm_context);
2160 1 : assert_int_equal(status, LIBSPDM_STATUS_INVALID_MSG_FIELD);
2161 :
2162 : /* Sub Case 8: MEL_CAP set 0,mel_specification_sel set 0 , mel_specification set 0*/
2163 1 : spdm_context->connection_info.capability.flags = connection_capability_flags;
2164 1 : libspdm_reset_message_a(spdm_context);
2165 1 : m_mel_specification_sel = 0;
2166 1 : spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
2167 1 : spdm_context->local_context.algorithm.mel_spec = 0;
2168 1 : status = libspdm_negotiate_algorithms(spdm_context);
2169 1 : assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
2170 1 : }
2171 :
2172 : /**
2173 : * Test 37: EP_INFO_CAP_SIG is negotiated and req_base_asym_alg in the ALGORITHMS response is valid.
2174 : * Expected behavior: returns with status LIBSPDM_STATUS_SUCCESS.
2175 : **/
2176 1 : static void req_negotiate_algorithms_case37(void **state)
2177 : {
2178 : libspdm_return_t status;
2179 : libspdm_test_context_t *spdm_test_context;
2180 : libspdm_context_t *spdm_context;
2181 :
2182 1 : spdm_test_context = *state;
2183 1 : spdm_context = spdm_test_context->spdm_context;
2184 1 : spdm_test_context->case_id = 0x25;
2185 :
2186 1 : spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_11 <<
2187 : SPDM_VERSION_NUMBER_SHIFT_BIT;
2188 1 : spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
2189 1 : spdm_context->local_context.algorithm.measurement_hash_algo =
2190 : m_libspdm_use_measurement_hash_algo;
2191 1 : spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
2192 1 : spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
2193 1 : spdm_context->local_context.algorithm.dhe_named_group = m_libspdm_use_dhe_algo;
2194 1 : spdm_context->local_context.algorithm.aead_cipher_suite = m_libspdm_use_aead_algo;
2195 1 : spdm_context->local_context.algorithm.req_base_asym_alg = m_libspdm_use_req_asym_algo;
2196 1 : spdm_context->local_context.algorithm.key_schedule = m_libspdm_use_key_schedule_algo;
2197 1 : libspdm_reset_message_a(spdm_context);
2198 :
2199 1 : spdm_context->local_context.capability.flags |=
2200 : SPDM_GET_CAPABILITIES_REQUEST_FLAGS_EP_INFO_CAP_SIG;
2201 :
2202 1 : status = libspdm_negotiate_algorithms(spdm_context);
2203 1 : assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
2204 1 : }
2205 :
2206 1 : int libspdm_req_negotiate_algorithms_test(void)
2207 : {
2208 1 : const struct CMUnitTest test_cases[] = {
2209 : cmocka_unit_test(req_negotiate_algorithms_case1),
2210 : cmocka_unit_test(req_negotiate_algorithms_case2),
2211 : cmocka_unit_test(req_negotiate_algorithms_case3),
2212 : cmocka_unit_test(req_negotiate_algorithms_case4),
2213 : cmocka_unit_test(req_negotiate_algorithms_case5),
2214 : cmocka_unit_test(req_negotiate_algorithms_case6),
2215 : cmocka_unit_test(req_negotiate_algorithms_case7),
2216 : cmocka_unit_test(req_negotiate_algorithms_case8),
2217 : cmocka_unit_test(req_negotiate_algorithms_case9),
2218 : cmocka_unit_test(req_negotiate_algorithms_case10),
2219 : cmocka_unit_test(req_negotiate_algorithms_case11),
2220 : cmocka_unit_test(req_negotiate_algorithms_case12),
2221 : cmocka_unit_test(req_negotiate_algorithms_case13),
2222 : cmocka_unit_test(req_negotiate_algorithms_case14),
2223 : cmocka_unit_test(req_negotiate_algorithms_case15),
2224 : cmocka_unit_test(req_negotiate_algorithms_case16),
2225 : cmocka_unit_test(req_negotiate_algorithms_case17),
2226 : cmocka_unit_test(req_negotiate_algorithms_case18),
2227 : cmocka_unit_test(req_negotiate_algorithms_case19),
2228 : cmocka_unit_test(req_negotiate_algorithms_case20),
2229 : cmocka_unit_test(req_negotiate_algorithms_case21),
2230 : cmocka_unit_test(req_negotiate_algorithms_case22),
2231 : cmocka_unit_test(req_negotiate_algorithms_case23),
2232 : cmocka_unit_test(req_negotiate_algorithms_case24),
2233 : cmocka_unit_test(req_negotiate_algorithms_case25),
2234 : cmocka_unit_test(req_negotiate_algorithms_case26),
2235 : cmocka_unit_test(req_negotiate_algorithms_case27),
2236 : cmocka_unit_test(req_negotiate_algorithms_case28),
2237 : cmocka_unit_test(req_negotiate_algorithms_case29),
2238 : cmocka_unit_test(req_negotiate_algorithms_case30),
2239 : cmocka_unit_test(req_negotiate_algorithms_case31),
2240 : cmocka_unit_test(req_negotiate_algorithms_case32),
2241 : cmocka_unit_test(req_negotiate_algorithms_case33),
2242 : cmocka_unit_test(req_negotiate_algorithms_case34),
2243 : cmocka_unit_test(req_negotiate_algorithms_case35),
2244 : cmocka_unit_test(req_negotiate_algorithms_case36),
2245 : cmocka_unit_test(req_negotiate_algorithms_case37),
2246 : };
2247 :
2248 1 : libspdm_test_context_t test_context = {
2249 : LIBSPDM_TEST_CONTEXT_VERSION,
2250 : true,
2251 : send_message,
2252 : receive_message,
2253 : };
2254 :
2255 1 : libspdm_setup_test_context(&test_context);
2256 :
2257 1 : return cmocka_run_group_tests(test_cases,
2258 : libspdm_unit_test_group_setup,
2259 : libspdm_unit_test_group_teardown);
2260 : }
|