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