Line data Source code
1 : /**
2 : * Copyright Notice:
3 : * Copyright 2025 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 : #include "internal/libspdm_secured_message_lib.h"
10 :
11 : #if LIBSPDM_SEND_GET_ENDPOINT_INFO_SUPPORT
12 :
13 : static size_t m_libspdm_local_buffer_size;
14 : static uint8_t m_libspdm_local_buffer[LIBSPDM_MAX_MESSAGE_IL1IL2_BUFFER_SIZE];
15 :
16 : #define LIBSPDM_TEST_ENDPOINT_INFO_BUFFER_SIZE 0x20
17 : static uint8_t m_endpoint_info_buffer[LIBSPDM_TEST_ENDPOINT_INFO_BUFFER_SIZE];
18 :
19 9 : static libspdm_return_t libspdm_requester_get_endpoint_info_test_send_message(
20 : void *spdm_context, size_t request_size, const void *request,
21 : uint64_t timeout)
22 : {
23 : libspdm_test_context_t *spdm_test_context;
24 : size_t header_size;
25 : uint8_t message_buffer[LIBSPDM_SENDER_BUFFER_SIZE];
26 :
27 9 : memcpy(message_buffer, request, request_size);
28 :
29 9 : spdm_test_context = libspdm_get_test_context();
30 9 : header_size = sizeof(libspdm_test_message_header_t);
31 9 : switch (spdm_test_context->case_id) {
32 3 : case 0x1:
33 : case 0x2:
34 3 : m_libspdm_local_buffer_size = 0;
35 3 : libspdm_copy_mem(m_libspdm_local_buffer, sizeof(m_libspdm_local_buffer),
36 : (const uint8_t *)request + header_size, request_size - header_size);
37 3 : m_libspdm_local_buffer_size += request_size - header_size;
38 3 : return LIBSPDM_STATUS_SUCCESS;
39 2 : case 0x3: {
40 : static size_t sub_index = 0;
41 2 : if (sub_index == 0) {
42 1 : m_libspdm_local_buffer_size = 0;
43 1 : libspdm_copy_mem(m_libspdm_local_buffer, sizeof(m_libspdm_local_buffer),
44 : (const uint8_t *)request + header_size, request_size - header_size);
45 1 : m_libspdm_local_buffer_size += request_size - header_size;
46 1 : sub_index++;
47 : }
48 : }
49 2 : return LIBSPDM_STATUS_SUCCESS;
50 2 : case 0x4:
51 : case 0x5:
52 2 : m_libspdm_local_buffer_size = 0;
53 2 : libspdm_copy_mem(m_libspdm_local_buffer, sizeof(m_libspdm_local_buffer),
54 : (const uint8_t *)request + header_size, request_size - header_size);
55 2 : m_libspdm_local_buffer_size += request_size - header_size;
56 2 : return LIBSPDM_STATUS_SUCCESS;
57 1 : case 0x6:
58 1 : return LIBSPDM_STATUS_SUCCESS;
59 1 : case 0x7: {
60 : uint32_t *session_id;
61 : libspdm_session_info_t *session_info;
62 : bool is_app_message;
63 : uint8_t *app_message;
64 : size_t app_message_size;
65 :
66 1 : m_libspdm_local_buffer_size = 0;
67 1 : session_id = NULL;
68 1 : session_info = libspdm_get_session_info_via_session_id(spdm_context, 0xFFFFFFFF);
69 1 : LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "Request (0x%zx):\n", request_size));
70 1 : libspdm_dump_hex(request, request_size);
71 1 : libspdm_get_scratch_buffer (spdm_context, (void **)&app_message, &app_message_size);
72 1 : libspdm_transport_test_decode_message(
73 : spdm_context, &session_id, &is_app_message,
74 : false, request_size, message_buffer,
75 : &app_message_size, (void **)&app_message);
76 : ((libspdm_secured_message_context_t
77 1 : *)(session_info->secured_message_context))
78 1 : ->application_secret.response_data_sequence_number--;
79 1 : libspdm_copy_mem(m_libspdm_local_buffer, sizeof(m_libspdm_local_buffer),
80 : app_message, app_message_size);
81 1 : m_libspdm_local_buffer_size += app_message_size;
82 : }
83 1 : return LIBSPDM_STATUS_SUCCESS;
84 0 : default:
85 0 : return LIBSPDM_STATUS_SEND_FAIL;
86 : }
87 : }
88 :
89 9 : static libspdm_return_t libspdm_requester_get_endpoint_info_test_receive_message(
90 : void *spdm_context, size_t *response_size,
91 : void **response, uint64_t timeout)
92 : {
93 : libspdm_test_context_t *spdm_test_context;
94 : uint32_t endpoint_info_buffer_size;
95 :
96 9 : endpoint_info_buffer_size = LIBSPDM_TEST_ENDPOINT_INFO_BUFFER_SIZE;
97 9 : spdm_test_context = libspdm_get_test_context();
98 9 : libspdm_generate_device_endpoint_info(
99 : spdm_context, SPDM_GET_ENDPOINT_INFO_REQUEST_SUBCODE_DEVICE_CLASS_IDENTIFIER,
100 : SPDM_GET_ENDPOINT_INFO_REQUEST_ATTRIBUTE_SIGNATURE_REQUESTED,
101 : &endpoint_info_buffer_size, m_endpoint_info_buffer);
102 9 : switch (spdm_test_context->case_id) {
103 1 : case 0x1: { /*correct ENDPOINT_INFO message with signature*/
104 : spdm_endpoint_info_response_t *spdm_response;
105 : uint8_t *ptr;
106 : uint8_t hash_data[LIBSPDM_MAX_HASH_SIZE];
107 : size_t sig_size;
108 : size_t spdm_response_size;
109 : size_t transport_header_size;
110 :
111 : ((libspdm_context_t *)spdm_context)
112 1 : ->connection_info.algorithm.base_asym_algo =
113 : m_libspdm_use_asym_algo;
114 : ((libspdm_context_t *)spdm_context)
115 1 : ->connection_info.algorithm.base_hash_algo =
116 : m_libspdm_use_hash_algo;
117 :
118 1 : spdm_response_size = sizeof(spdm_endpoint_info_response_t) +
119 : SPDM_NONCE_SIZE + sizeof(uint32_t) +
120 2 : endpoint_info_buffer_size +
121 1 : libspdm_get_asym_signature_size(m_libspdm_use_asym_algo);
122 :
123 1 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
124 1 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
125 :
126 1 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_13;
127 1 : spdm_response->header.request_response_code = SPDM_ENDPOINT_INFO;
128 1 : spdm_response->header.param1 = 0;
129 1 : spdm_response->header.param2 = 0; /* slot_id */
130 1 : ptr = (uint8_t *)(spdm_response + 1);
131 :
132 1 : libspdm_get_random_number(SPDM_NONCE_SIZE, ptr);
133 1 : ptr += SPDM_NONCE_SIZE;
134 :
135 1 : *(uint32_t *)ptr = endpoint_info_buffer_size; /* ep_info_len */
136 1 : ptr += sizeof(uint32_t);
137 :
138 1 : libspdm_copy_mem(ptr, endpoint_info_buffer_size,
139 : m_endpoint_info_buffer, endpoint_info_buffer_size);
140 1 : ptr += endpoint_info_buffer_size;
141 :
142 1 : libspdm_copy_mem(&m_libspdm_local_buffer[m_libspdm_local_buffer_size],
143 : sizeof(m_libspdm_local_buffer) -
144 1 : (&m_libspdm_local_buffer[m_libspdm_local_buffer_size] -
145 : m_libspdm_local_buffer),
146 1 : spdm_response, (size_t)ptr - (size_t)spdm_response);
147 1 : m_libspdm_local_buffer_size += ((size_t)ptr - (size_t)spdm_response);
148 1 : LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "m_libspdm_local_buffer_size (0x%zx):\n",
149 : m_libspdm_local_buffer_size));
150 1 : libspdm_dump_hex(m_libspdm_local_buffer, m_libspdm_local_buffer_size);
151 1 : libspdm_hash_all(m_libspdm_use_hash_algo, m_libspdm_local_buffer,
152 : m_libspdm_local_buffer_size, hash_data);
153 1 : LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "HashDataSize (0x%x):\n",
154 : libspdm_get_hash_size(m_libspdm_use_hash_algo)));
155 1 : libspdm_dump_hex(hash_data, libspdm_get_hash_size(m_libspdm_use_hash_algo));
156 1 : sig_size = libspdm_get_asym_signature_size(m_libspdm_use_asym_algo);
157 1 : libspdm_responder_data_sign(
158 : #if LIBSPDM_HAL_PASS_SPDM_CONTEXT
159 : spdm_context,
160 : #endif
161 1 : spdm_response->header.spdm_version << SPDM_VERSION_NUMBER_SHIFT_BIT,
162 : SPDM_ENDPOINT_INFO,
163 : m_libspdm_use_asym_algo, m_libspdm_use_hash_algo,
164 : false, m_libspdm_local_buffer, m_libspdm_local_buffer_size,
165 : ptr, &sig_size);
166 1 : ptr += sig_size;
167 :
168 1 : libspdm_transport_test_encode_message(spdm_context, NULL, false,
169 : false, spdm_response_size,
170 : spdm_response, response_size,
171 : response);
172 : }
173 1 : return LIBSPDM_STATUS_SUCCESS;
174 :
175 2 : case 0x2: { /*ERROR BUSY + ENDPOINT_INFO w/ signature*/
176 : static size_t sub_index1 = 0;
177 2 : if (sub_index1 == 0) {
178 : /*SPDM_ERROR with SPDM_ERROR_CODE_BUSY*/
179 : spdm_error_response_t *spdm_response;
180 : size_t spdm_response_size;
181 : size_t transport_header_size;
182 :
183 1 : spdm_response_size = sizeof(spdm_error_response_t);
184 1 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
185 1 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
186 :
187 1 : spdm_response->header.spdm_version =
188 : SPDM_MESSAGE_VERSION_13;
189 1 : spdm_response->header.request_response_code = SPDM_ERROR;
190 1 : spdm_response->header.param1 = SPDM_ERROR_CODE_BUSY;
191 1 : spdm_response->header.param2 = 0;
192 :
193 1 : libspdm_transport_test_encode_message(
194 : spdm_context, NULL, false, false,
195 : spdm_response_size, spdm_response,
196 : response_size, response);
197 1 : sub_index1++;
198 1 : } else if (sub_index1 == 1) {
199 : /*correct ENDPOINT_INFO message with signature*/
200 : spdm_endpoint_info_response_t *spdm_response;
201 : uint8_t *ptr;
202 : uint8_t hash_data[LIBSPDM_MAX_HASH_SIZE];
203 : size_t sig_size;
204 : size_t spdm_response_size;
205 : size_t transport_header_size;
206 :
207 : ((libspdm_context_t *)spdm_context)
208 1 : ->connection_info.algorithm.base_asym_algo =
209 : m_libspdm_use_asym_algo;
210 : ((libspdm_context_t *)spdm_context)
211 1 : ->connection_info.algorithm.base_hash_algo =
212 : m_libspdm_use_hash_algo;
213 :
214 1 : spdm_response_size = sizeof(spdm_endpoint_info_response_t) +
215 : SPDM_NONCE_SIZE + sizeof(uint32_t) +
216 2 : endpoint_info_buffer_size +
217 1 : libspdm_get_asym_signature_size(m_libspdm_use_asym_algo);
218 :
219 1 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
220 1 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
221 :
222 1 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_13;
223 1 : spdm_response->header.request_response_code = SPDM_ENDPOINT_INFO;
224 1 : spdm_response->header.param1 = 0;
225 1 : spdm_response->header.param2 = 0; /* slot_id */
226 1 : ptr = (uint8_t *)(spdm_response + 1);
227 :
228 1 : libspdm_get_random_number(SPDM_NONCE_SIZE, ptr);
229 1 : ptr += SPDM_NONCE_SIZE;
230 :
231 1 : *(uint32_t *)ptr = endpoint_info_buffer_size; /* ep_info_len */
232 1 : ptr += sizeof(uint32_t);
233 :
234 1 : libspdm_copy_mem(ptr, endpoint_info_buffer_size,
235 : m_endpoint_info_buffer, endpoint_info_buffer_size);
236 1 : ptr += endpoint_info_buffer_size;
237 :
238 1 : libspdm_copy_mem(&m_libspdm_local_buffer[m_libspdm_local_buffer_size],
239 : sizeof(m_libspdm_local_buffer) -
240 1 : (&m_libspdm_local_buffer[m_libspdm_local_buffer_size] -
241 : m_libspdm_local_buffer),
242 1 : spdm_response, (size_t)ptr - (size_t)spdm_response);
243 1 : m_libspdm_local_buffer_size += ((size_t)ptr - (size_t)spdm_response);
244 1 : LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "m_libspdm_local_buffer_size (0x%zx):\n",
245 : m_libspdm_local_buffer_size));
246 1 : libspdm_dump_hex(m_libspdm_local_buffer, m_libspdm_local_buffer_size);
247 1 : libspdm_hash_all(m_libspdm_use_hash_algo, m_libspdm_local_buffer,
248 : m_libspdm_local_buffer_size, hash_data);
249 1 : LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "HashDataSize (0x%x):\n",
250 : libspdm_get_hash_size(m_libspdm_use_hash_algo)));
251 1 : libspdm_dump_hex(hash_data, libspdm_get_hash_size(m_libspdm_use_hash_algo));
252 1 : sig_size = libspdm_get_asym_signature_size(m_libspdm_use_asym_algo);
253 1 : libspdm_responder_data_sign(
254 : #if LIBSPDM_HAL_PASS_SPDM_CONTEXT
255 : spdm_context,
256 : #endif
257 1 : spdm_response->header.spdm_version << SPDM_VERSION_NUMBER_SHIFT_BIT,
258 : SPDM_ENDPOINT_INFO,
259 : m_libspdm_use_asym_algo, m_libspdm_use_hash_algo,
260 : false, m_libspdm_local_buffer, m_libspdm_local_buffer_size,
261 : ptr, &sig_size);
262 1 : ptr += sig_size;
263 :
264 1 : libspdm_transport_test_encode_message(spdm_context, NULL, false,
265 : false, spdm_response_size,
266 : spdm_response, response_size,
267 : response);
268 : }
269 : }
270 2 : return LIBSPDM_STATUS_SUCCESS;
271 :
272 2 : case 0x3: { /*ERROR NOT_READY + ENDPOINT_INFO w/ signature*/
273 : static size_t sub_index2 = 0;
274 2 : if (sub_index2 == 0) {
275 : /*SPDM_ERROR with SPDM_ERROR_CODE_RESPONSE_NOT_READY*/
276 : spdm_error_response_data_response_not_ready_t *spdm_response;
277 : size_t spdm_response_size;
278 : size_t transport_header_size;
279 :
280 1 : spdm_response_size = sizeof(spdm_error_response_data_response_not_ready_t);
281 1 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
282 1 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
283 :
284 1 : spdm_response->header.spdm_version =
285 : SPDM_MESSAGE_VERSION_13;
286 1 : spdm_response->header.request_response_code = SPDM_ERROR;
287 1 : spdm_response->header.param1 =
288 : SPDM_ERROR_CODE_RESPONSE_NOT_READY;
289 1 : spdm_response->header.param2 = 0;
290 1 : spdm_response->extend_error_data.rd_exponent = 1;
291 1 : spdm_response->extend_error_data.rd_tm = 2;
292 1 : spdm_response->extend_error_data.request_code =
293 : SPDM_GET_ENDPOINT_INFO;
294 1 : spdm_response->extend_error_data.token = 1;
295 :
296 1 : libspdm_transport_test_encode_message(
297 : spdm_context, NULL, false, false,
298 : spdm_response_size, spdm_response,
299 : response_size, response);
300 1 : sub_index2++;
301 1 : } else if (sub_index2 == 1) {
302 : /*correct ENDPOINT_INFO message with signature*/
303 : spdm_endpoint_info_response_t *spdm_response;
304 : uint8_t *ptr;
305 : uint8_t hash_data[LIBSPDM_MAX_HASH_SIZE];
306 : size_t sig_size;
307 : size_t spdm_response_size;
308 : size_t transport_header_size;
309 :
310 : ((libspdm_context_t *)spdm_context)
311 1 : ->connection_info.algorithm.base_asym_algo =
312 : m_libspdm_use_asym_algo;
313 : ((libspdm_context_t *)spdm_context)
314 1 : ->connection_info.algorithm.base_hash_algo =
315 : m_libspdm_use_hash_algo;
316 :
317 1 : spdm_response_size = sizeof(spdm_endpoint_info_response_t) +
318 : SPDM_NONCE_SIZE + sizeof(uint32_t) +
319 2 : endpoint_info_buffer_size +
320 1 : libspdm_get_asym_signature_size(m_libspdm_use_asym_algo);
321 :
322 1 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
323 1 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
324 :
325 1 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_13;
326 1 : spdm_response->header.request_response_code = SPDM_ENDPOINT_INFO;
327 1 : spdm_response->header.param1 = 0;
328 1 : spdm_response->header.param2 = 0; /* slot_id */
329 1 : ptr = (uint8_t *)(spdm_response + 1);
330 :
331 1 : libspdm_get_random_number(SPDM_NONCE_SIZE, ptr);
332 1 : ptr += SPDM_NONCE_SIZE;
333 :
334 1 : *(uint32_t *)ptr = endpoint_info_buffer_size; /* ep_info_len */
335 1 : ptr += sizeof(uint32_t);
336 :
337 1 : libspdm_copy_mem(ptr, endpoint_info_buffer_size,
338 : m_endpoint_info_buffer, endpoint_info_buffer_size);
339 1 : ptr += endpoint_info_buffer_size;
340 :
341 1 : libspdm_copy_mem(&m_libspdm_local_buffer[m_libspdm_local_buffer_size],
342 : sizeof(m_libspdm_local_buffer) -
343 1 : (&m_libspdm_local_buffer[m_libspdm_local_buffer_size] -
344 : m_libspdm_local_buffer),
345 1 : spdm_response, (size_t)ptr - (size_t)spdm_response);
346 1 : m_libspdm_local_buffer_size += ((size_t)ptr - (size_t)spdm_response);
347 1 : LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "m_libspdm_local_buffer_size (0x%zx):\n",
348 : m_libspdm_local_buffer_size));
349 1 : libspdm_dump_hex(m_libspdm_local_buffer, m_libspdm_local_buffer_size);
350 1 : libspdm_hash_all(m_libspdm_use_hash_algo, m_libspdm_local_buffer,
351 : m_libspdm_local_buffer_size, hash_data);
352 1 : LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "HashDataSize (0x%x):\n",
353 : libspdm_get_hash_size(m_libspdm_use_hash_algo)));
354 1 : libspdm_dump_hex(hash_data, libspdm_get_hash_size(m_libspdm_use_hash_algo));
355 1 : sig_size = libspdm_get_asym_signature_size(m_libspdm_use_asym_algo);
356 1 : libspdm_responder_data_sign(
357 : #if LIBSPDM_HAL_PASS_SPDM_CONTEXT
358 : spdm_context,
359 : #endif
360 1 : spdm_response->header.spdm_version << SPDM_VERSION_NUMBER_SHIFT_BIT,
361 : SPDM_ENDPOINT_INFO,
362 : m_libspdm_use_asym_algo, m_libspdm_use_hash_algo,
363 : false, m_libspdm_local_buffer, m_libspdm_local_buffer_size,
364 : ptr, &sig_size);
365 1 : ptr += sig_size;
366 :
367 1 : libspdm_transport_test_encode_message(spdm_context, NULL, false,
368 : false, spdm_response_size,
369 : spdm_response, response_size,
370 : response);
371 : }
372 : }
373 2 : return LIBSPDM_STATUS_SUCCESS;
374 :
375 1 : case 0x4: { /*correct ENDPOINT_INFO message with signature and slot_id = 1*/
376 : spdm_endpoint_info_response_t *spdm_response;
377 : uint8_t *ptr;
378 : uint8_t hash_data[LIBSPDM_MAX_HASH_SIZE];
379 : size_t sig_size;
380 : size_t spdm_response_size;
381 : size_t transport_header_size;
382 :
383 : ((libspdm_context_t *)spdm_context)
384 1 : ->connection_info.algorithm.base_asym_algo =
385 : m_libspdm_use_asym_algo;
386 : ((libspdm_context_t *)spdm_context)
387 1 : ->connection_info.algorithm.base_hash_algo =
388 : m_libspdm_use_hash_algo;
389 :
390 1 : spdm_response_size = sizeof(spdm_endpoint_info_response_t) +
391 : SPDM_NONCE_SIZE + sizeof(uint32_t) +
392 2 : endpoint_info_buffer_size +
393 1 : libspdm_get_asym_signature_size(m_libspdm_use_asym_algo);
394 :
395 1 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
396 1 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
397 :
398 1 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_13;
399 1 : spdm_response->header.request_response_code = SPDM_ENDPOINT_INFO;
400 1 : spdm_response->header.param1 = 0;
401 1 : spdm_response->header.param2 = 1; /* slot_id */
402 1 : ptr = (uint8_t *)(spdm_response + 1);
403 :
404 1 : libspdm_get_random_number(SPDM_NONCE_SIZE, ptr);
405 1 : ptr += SPDM_NONCE_SIZE;
406 :
407 1 : *(uint32_t *)ptr = endpoint_info_buffer_size; /* ep_info_len */
408 1 : ptr += sizeof(uint32_t);
409 :
410 1 : libspdm_copy_mem(ptr, endpoint_info_buffer_size,
411 : m_endpoint_info_buffer, endpoint_info_buffer_size);
412 1 : ptr += endpoint_info_buffer_size;
413 :
414 1 : libspdm_copy_mem(&m_libspdm_local_buffer[m_libspdm_local_buffer_size],
415 : sizeof(m_libspdm_local_buffer) -
416 1 : (&m_libspdm_local_buffer[m_libspdm_local_buffer_size] -
417 : m_libspdm_local_buffer),
418 1 : spdm_response, (size_t)ptr - (size_t)spdm_response);
419 1 : m_libspdm_local_buffer_size += ((size_t)ptr - (size_t)spdm_response);
420 1 : LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "m_libspdm_local_buffer_size (0x%zx):\n",
421 : m_libspdm_local_buffer_size));
422 1 : libspdm_dump_hex(m_libspdm_local_buffer, m_libspdm_local_buffer_size);
423 1 : libspdm_hash_all(m_libspdm_use_hash_algo, m_libspdm_local_buffer,
424 : m_libspdm_local_buffer_size, hash_data);
425 1 : LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "HashDataSize (0x%x):\n",
426 : libspdm_get_hash_size(m_libspdm_use_hash_algo)));
427 1 : libspdm_dump_hex(hash_data, libspdm_get_hash_size(m_libspdm_use_hash_algo));
428 1 : sig_size = libspdm_get_asym_signature_size(m_libspdm_use_asym_algo);
429 1 : libspdm_responder_data_sign(
430 : #if LIBSPDM_HAL_PASS_SPDM_CONTEXT
431 : spdm_context,
432 : #endif
433 1 : spdm_response->header.spdm_version << SPDM_VERSION_NUMBER_SHIFT_BIT,
434 : SPDM_ENDPOINT_INFO,
435 : m_libspdm_use_asym_algo, m_libspdm_use_hash_algo,
436 : false, m_libspdm_local_buffer, m_libspdm_local_buffer_size,
437 : ptr, &sig_size);
438 1 : ptr += sig_size;
439 :
440 1 : libspdm_transport_test_encode_message(spdm_context, NULL, false,
441 : false, spdm_response_size,
442 : spdm_response, response_size,
443 : response);
444 : }
445 1 : return LIBSPDM_STATUS_SUCCESS;
446 :
447 1 : case 0x5: { /*correct ENDPOINT_INFO message with signature and use provisioned key*/
448 : spdm_endpoint_info_response_t *spdm_response;
449 : uint8_t *ptr;
450 : uint8_t hash_data[LIBSPDM_MAX_HASH_SIZE];
451 : size_t sig_size;
452 : size_t spdm_response_size;
453 : size_t transport_header_size;
454 :
455 : ((libspdm_context_t *)spdm_context)
456 1 : ->connection_info.algorithm.base_asym_algo =
457 : m_libspdm_use_asym_algo;
458 : ((libspdm_context_t *)spdm_context)
459 1 : ->connection_info.algorithm.base_hash_algo =
460 : m_libspdm_use_hash_algo;
461 :
462 1 : spdm_response_size = sizeof(spdm_endpoint_info_response_t) +
463 : SPDM_NONCE_SIZE + sizeof(uint32_t) +
464 2 : endpoint_info_buffer_size +
465 1 : libspdm_get_asym_signature_size(m_libspdm_use_asym_algo);
466 :
467 1 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
468 1 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
469 :
470 1 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_13;
471 1 : spdm_response->header.request_response_code = SPDM_ENDPOINT_INFO;
472 1 : spdm_response->header.param1 = 0;
473 1 : spdm_response->header.param2 = 0xF; /* slot_id */
474 1 : ptr = (uint8_t *)(spdm_response + 1);
475 :
476 1 : libspdm_get_random_number(SPDM_NONCE_SIZE, ptr);
477 1 : ptr += SPDM_NONCE_SIZE;
478 :
479 1 : *(uint32_t *)ptr = endpoint_info_buffer_size; /* ep_info_len */
480 1 : ptr += sizeof(uint32_t);
481 :
482 1 : libspdm_copy_mem(ptr, endpoint_info_buffer_size,
483 : m_endpoint_info_buffer, endpoint_info_buffer_size);
484 1 : ptr += endpoint_info_buffer_size;
485 :
486 1 : libspdm_copy_mem(&m_libspdm_local_buffer[m_libspdm_local_buffer_size],
487 : sizeof(m_libspdm_local_buffer) -
488 1 : (&m_libspdm_local_buffer[m_libspdm_local_buffer_size] -
489 : m_libspdm_local_buffer),
490 1 : spdm_response, (size_t)ptr - (size_t)spdm_response);
491 1 : m_libspdm_local_buffer_size += ((size_t)ptr - (size_t)spdm_response);
492 1 : LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "m_libspdm_local_buffer_size (0x%zx):\n",
493 : m_libspdm_local_buffer_size));
494 1 : libspdm_dump_hex(m_libspdm_local_buffer, m_libspdm_local_buffer_size);
495 1 : libspdm_hash_all(m_libspdm_use_hash_algo, m_libspdm_local_buffer,
496 : m_libspdm_local_buffer_size, hash_data);
497 1 : LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "HashDataSize (0x%x):\n",
498 : libspdm_get_hash_size(m_libspdm_use_hash_algo)));
499 1 : libspdm_dump_hex(hash_data, libspdm_get_hash_size(m_libspdm_use_hash_algo));
500 1 : sig_size = libspdm_get_asym_signature_size(m_libspdm_use_asym_algo);
501 1 : libspdm_responder_data_sign(
502 : #if LIBSPDM_HAL_PASS_SPDM_CONTEXT
503 : spdm_context,
504 : #endif
505 1 : spdm_response->header.spdm_version << SPDM_VERSION_NUMBER_SHIFT_BIT,
506 : SPDM_ENDPOINT_INFO,
507 : m_libspdm_use_asym_algo, m_libspdm_use_hash_algo,
508 : false, m_libspdm_local_buffer, m_libspdm_local_buffer_size,
509 : ptr, &sig_size);
510 1 : ptr += sig_size;
511 :
512 1 : libspdm_transport_test_encode_message(spdm_context, NULL, false,
513 : false, spdm_response_size,
514 : spdm_response, response_size,
515 : response);
516 : }
517 1 : return LIBSPDM_STATUS_SUCCESS;
518 :
519 1 : case 0x6: { /*correct ENDPOINT_INFO message without signature*/
520 : spdm_endpoint_info_response_t *spdm_response;
521 : uint8_t *ptr;
522 : size_t spdm_response_size;
523 : size_t transport_header_size;
524 :
525 : ((libspdm_context_t *)spdm_context)
526 1 : ->connection_info.algorithm.base_asym_algo =
527 : m_libspdm_use_asym_algo;
528 : ((libspdm_context_t *)spdm_context)
529 1 : ->connection_info.algorithm.base_hash_algo =
530 : m_libspdm_use_hash_algo;
531 :
532 1 : spdm_response_size = sizeof(spdm_endpoint_info_response_t) +
533 1 : +sizeof(uint32_t) +
534 : endpoint_info_buffer_size;
535 :
536 1 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
537 1 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
538 :
539 1 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_13;
540 1 : spdm_response->header.request_response_code = SPDM_ENDPOINT_INFO;
541 1 : spdm_response->header.param1 = 0;
542 1 : spdm_response->header.param2 = 0; /* slot_id */
543 1 : ptr = (uint8_t *)(spdm_response + 1);
544 :
545 1 : *(uint32_t *)ptr = endpoint_info_buffer_size; /* ep_info_len */
546 1 : ptr += sizeof(uint32_t);
547 :
548 1 : libspdm_copy_mem(ptr, endpoint_info_buffer_size,
549 : m_endpoint_info_buffer, endpoint_info_buffer_size);
550 1 : ptr += endpoint_info_buffer_size;
551 :
552 1 : libspdm_transport_test_encode_message(spdm_context, NULL, false,
553 : false, spdm_response_size,
554 : spdm_response, response_size,
555 : response);
556 : }
557 1 : return LIBSPDM_STATUS_SUCCESS;
558 :
559 1 : case 0x7: { /*correct session based ENDPOINT_INFO message with signature*/
560 : spdm_endpoint_info_response_t *spdm_response;
561 : uint8_t *ptr;
562 : uint8_t hash_data[LIBSPDM_MAX_HASH_SIZE];
563 : size_t sig_size;
564 : size_t spdm_response_size;
565 : size_t transport_header_size;
566 : uint32_t session_id;
567 : libspdm_session_info_t *session_info;
568 : uint8_t *scratch_buffer;
569 : size_t scratch_buffer_size;
570 :
571 1 : session_id = 0xFFFFFFFF;
572 : ((libspdm_context_t *)spdm_context)
573 1 : ->connection_info.algorithm.base_asym_algo =
574 : m_libspdm_use_asym_algo;
575 : ((libspdm_context_t *)spdm_context)
576 1 : ->connection_info.algorithm.base_hash_algo =
577 : m_libspdm_use_hash_algo;
578 :
579 1 : spdm_response_size = sizeof(spdm_endpoint_info_response_t) +
580 : SPDM_NONCE_SIZE + sizeof(uint32_t) +
581 2 : endpoint_info_buffer_size +
582 1 : libspdm_get_asym_signature_size(m_libspdm_use_asym_algo);
583 :
584 1 : transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
585 1 : spdm_response = (void *)((uint8_t *)*response + transport_header_size);
586 :
587 1 : spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_13;
588 1 : spdm_response->header.request_response_code = SPDM_ENDPOINT_INFO;
589 1 : spdm_response->header.param1 = 0;
590 1 : spdm_response->header.param2 = 0; /* slot_id */
591 1 : ptr = (uint8_t *)(spdm_response + 1);
592 :
593 1 : libspdm_get_random_number(SPDM_NONCE_SIZE, ptr);
594 1 : ptr += SPDM_NONCE_SIZE;
595 :
596 1 : *(uint32_t *)ptr = endpoint_info_buffer_size; /* ep_info_len */
597 1 : ptr += sizeof(uint32_t);
598 :
599 1 : libspdm_copy_mem(ptr, endpoint_info_buffer_size,
600 : m_endpoint_info_buffer, endpoint_info_buffer_size);
601 1 : ptr += endpoint_info_buffer_size;
602 :
603 1 : libspdm_copy_mem(&m_libspdm_local_buffer[m_libspdm_local_buffer_size],
604 : sizeof(m_libspdm_local_buffer) -
605 1 : (&m_libspdm_local_buffer[m_libspdm_local_buffer_size] -
606 : m_libspdm_local_buffer),
607 1 : spdm_response, (size_t)ptr - (size_t)spdm_response);
608 1 : m_libspdm_local_buffer_size += ((size_t)ptr - (size_t)spdm_response);
609 1 : LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "m_libspdm_local_buffer_size (0x%zx):\n",
610 : m_libspdm_local_buffer_size));
611 1 : libspdm_dump_hex(m_libspdm_local_buffer, m_libspdm_local_buffer_size);
612 1 : libspdm_hash_all(m_libspdm_use_hash_algo, m_libspdm_local_buffer,
613 : m_libspdm_local_buffer_size, hash_data);
614 1 : LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "HashDataSize (0x%x):\n",
615 : libspdm_get_hash_size(m_libspdm_use_hash_algo)));
616 1 : libspdm_dump_hex(hash_data, libspdm_get_hash_size(m_libspdm_use_hash_algo));
617 1 : sig_size = libspdm_get_asym_signature_size(m_libspdm_use_asym_algo);
618 1 : libspdm_responder_data_sign(
619 : #if LIBSPDM_HAL_PASS_SPDM_CONTEXT
620 : spdm_context,
621 : #endif
622 1 : spdm_response->header.spdm_version << SPDM_VERSION_NUMBER_SHIFT_BIT,
623 : SPDM_ENDPOINT_INFO,
624 : m_libspdm_use_asym_algo, m_libspdm_use_hash_algo,
625 : false, m_libspdm_local_buffer, m_libspdm_local_buffer_size,
626 : ptr, &sig_size);
627 1 : ptr += sig_size;
628 :
629 : /* For secure message, message is in sender buffer, we need copy it to scratch buffer.
630 : * transport_message is always in sender buffer. */
631 1 : libspdm_get_scratch_buffer (spdm_context, (void **)&scratch_buffer, &scratch_buffer_size);
632 1 : libspdm_copy_mem (scratch_buffer + transport_header_size,
633 : scratch_buffer_size - transport_header_size,
634 : spdm_response, spdm_response_size);
635 1 : spdm_response = (void *)(scratch_buffer + transport_header_size);
636 :
637 1 : libspdm_transport_test_encode_message(spdm_context, &session_id, false,
638 : false, spdm_response_size,
639 : spdm_response, response_size,
640 : response);
641 1 : session_info = libspdm_get_session_info_via_session_id(
642 : spdm_context, session_id);
643 1 : if (session_info == NULL) {
644 0 : return LIBSPDM_STATUS_RECEIVE_FAIL;
645 : }
646 : /* WALKAROUND: If just use single context to encode message and then decode message */
647 1 : ((libspdm_secured_message_context_t *)(session_info->secured_message_context))
648 1 : ->application_secret.response_data_sequence_number--;
649 : }
650 1 : return LIBSPDM_STATUS_SUCCESS;
651 0 : default:
652 0 : return LIBSPDM_STATUS_RECEIVE_FAIL;
653 : }
654 : }
655 :
656 : /**
657 : * Test 1: Successful response to get a endpoint info with signature
658 : * Expected Behavior: get a RETURN_SUCCESS return code, with an empty transcript.message_e
659 : **/
660 1 : static void libspdm_test_requester_get_endpoint_info_case1(void **state)
661 : {
662 : libspdm_return_t status;
663 : libspdm_test_context_t *spdm_test_context;
664 : libspdm_context_t *spdm_context;
665 : void *data;
666 : size_t data_size;
667 : void *hash;
668 : size_t hash_size;
669 : uint8_t sub_code;
670 : uint8_t request_attributes;
671 : uint8_t slot_id;
672 : uint32_t ep_info_length;
673 : uint8_t ep_info_record[LIBSPDM_MAX_ENDPOINT_INFO_LENGTH];
674 : uint8_t requester_nonce_in[SPDM_NONCE_SIZE];
675 : uint8_t requester_nonce[SPDM_NONCE_SIZE];
676 : uint8_t responder_nonce[SPDM_NONCE_SIZE];
677 :
678 1 : spdm_test_context = *state;
679 1 : spdm_context = spdm_test_context->spdm_context;
680 1 : spdm_test_context->case_id = 0x1;
681 1 : spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_13 <<
682 : SPDM_VERSION_NUMBER_SHIFT_BIT;
683 1 : spdm_context->connection_info.connection_state =
684 : LIBSPDM_CONNECTION_STATE_NEGOTIATED;
685 1 : spdm_context->connection_info.capability.flags = 0;
686 1 : spdm_context->connection_info.capability.flags |=
687 : SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_EP_INFO_CAP_SIG;
688 1 : libspdm_read_responder_public_certificate_chain(m_libspdm_use_hash_algo,
689 : m_libspdm_use_asym_algo, &data,
690 : &data_size, &hash, &hash_size);
691 1 : libspdm_reset_message_a(spdm_context);
692 1 : libspdm_reset_message_e(spdm_context, NULL);
693 :
694 1 : spdm_context->connection_info.algorithm.base_hash_algo =
695 : m_libspdm_use_hash_algo;
696 1 : spdm_context->connection_info.algorithm.base_asym_algo =
697 : m_libspdm_use_asym_algo;
698 :
699 : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
700 : spdm_context->connection_info.peer_used_cert_chain[0].buffer_size =
701 : data_size;
702 : libspdm_copy_mem(spdm_context->connection_info.peer_used_cert_chain[0].buffer,
703 : sizeof(spdm_context->connection_info.peer_used_cert_chain[0].buffer),
704 : data, data_size);
705 : #else
706 1 : libspdm_hash_all(
707 : spdm_context->connection_info.algorithm.base_hash_algo,
708 : data, data_size,
709 1 : spdm_context->connection_info.peer_used_cert_chain[0].buffer_hash);
710 1 : spdm_context->connection_info.peer_used_cert_chain[0].buffer_hash_size =
711 1 : libspdm_get_hash_size(spdm_context->connection_info.algorithm.base_hash_algo);
712 1 : libspdm_get_leaf_cert_public_key_from_cert_chain(
713 : spdm_context->connection_info.algorithm.base_hash_algo,
714 : spdm_context->connection_info.algorithm.base_asym_algo,
715 : data, data_size,
716 : &spdm_context->connection_info.peer_used_cert_chain[0].leaf_cert_public_key);
717 : #endif
718 :
719 1 : slot_id = 0;
720 1 : sub_code = SPDM_GET_ENDPOINT_INFO_REQUEST_SUBCODE_DEVICE_CLASS_IDENTIFIER;
721 1 : request_attributes =
722 : SPDM_GET_ENDPOINT_INFO_REQUEST_ATTRIBUTE_SIGNATURE_REQUESTED;
723 1 : ep_info_length = LIBSPDM_MAX_ENDPOINT_INFO_LENGTH;
724 :
725 1 : libspdm_get_random_number(SPDM_NONCE_SIZE, requester_nonce_in);
726 33 : for (int index = 0; index < SPDM_NONCE_SIZE; index++) {
727 32 : requester_nonce[index] = 0x00;
728 32 : responder_nonce[index] = 0x00;
729 : }
730 :
731 1 : status = libspdm_get_endpoint_info(spdm_context, NULL, request_attributes,
732 : sub_code, slot_id,
733 : &ep_info_length, ep_info_record,
734 : requester_nonce_in, requester_nonce,
735 : responder_nonce);
736 :
737 1 : assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
738 33 : for (int index = 0; index < SPDM_NONCE_SIZE; index++) {
739 32 : assert_int_equal (requester_nonce_in[index], requester_nonce[index]);
740 : }
741 : /* Completion of GET_ENDPOINT_INFO sets IL1/IL2 to null. */
742 : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
743 : assert_int_equal(spdm_context->transcript.message_e.buffer_size, 0);
744 : #else
745 1 : assert_null(spdm_context->transcript.digest_context_il1il2);
746 : #endif
747 1 : free(data);
748 1 : }
749 :
750 : /**
751 : * Test 2: Successful response to get a endpoint info with signature,
752 : * after getting SPDM_ERROR_CODE_BUSY on first attempt
753 : * Expected Behavior: get a RETURN_SUCCESS return code, with an empty transcript.message_e
754 : **/
755 1 : static void libspdm_test_requester_get_endpoint_info_case2(void **state)
756 : {
757 : libspdm_return_t status;
758 : libspdm_test_context_t *spdm_test_context;
759 : libspdm_context_t *spdm_context;
760 : void *data;
761 : size_t data_size;
762 : void *hash;
763 : size_t hash_size;
764 : uint8_t sub_code;
765 : uint8_t request_attributes;
766 : uint8_t slot_id;
767 : uint32_t ep_info_length;
768 : uint8_t ep_info_record[LIBSPDM_MAX_ENDPOINT_INFO_LENGTH];
769 : uint8_t requester_nonce_in[SPDM_NONCE_SIZE];
770 : uint8_t requester_nonce[SPDM_NONCE_SIZE];
771 : uint8_t responder_nonce[SPDM_NONCE_SIZE];
772 :
773 1 : spdm_test_context = *state;
774 1 : spdm_context = spdm_test_context->spdm_context;
775 1 : spdm_test_context->case_id = 0x2;
776 1 : spdm_context->retry_times = 3;
777 1 : spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_13 <<
778 : SPDM_VERSION_NUMBER_SHIFT_BIT;
779 1 : spdm_context->connection_info.connection_state =
780 : LIBSPDM_CONNECTION_STATE_NEGOTIATED;
781 1 : spdm_context->connection_info.capability.flags = 0;
782 1 : spdm_context->connection_info.capability.flags |=
783 : SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_EP_INFO_CAP_SIG;
784 1 : libspdm_read_responder_public_certificate_chain(m_libspdm_use_hash_algo,
785 : m_libspdm_use_asym_algo, &data,
786 : &data_size, &hash, &hash_size);
787 1 : libspdm_reset_message_a(spdm_context);
788 1 : libspdm_reset_message_e(spdm_context, NULL);
789 :
790 1 : spdm_context->connection_info.algorithm.base_hash_algo =
791 : m_libspdm_use_hash_algo;
792 1 : spdm_context->connection_info.algorithm.base_asym_algo =
793 : m_libspdm_use_asym_algo;
794 :
795 : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
796 : spdm_context->connection_info.peer_used_cert_chain[0].buffer_size =
797 : data_size;
798 : libspdm_copy_mem(spdm_context->connection_info.peer_used_cert_chain[0].buffer,
799 : sizeof(spdm_context->connection_info.peer_used_cert_chain[0].buffer),
800 : data, data_size);
801 : #else
802 1 : libspdm_hash_all(
803 : spdm_context->connection_info.algorithm.base_hash_algo,
804 : data, data_size,
805 1 : spdm_context->connection_info.peer_used_cert_chain[0].buffer_hash);
806 1 : spdm_context->connection_info.peer_used_cert_chain[0].buffer_hash_size =
807 1 : libspdm_get_hash_size(spdm_context->connection_info.algorithm.base_hash_algo);
808 1 : libspdm_get_leaf_cert_public_key_from_cert_chain(
809 : spdm_context->connection_info.algorithm.base_hash_algo,
810 : spdm_context->connection_info.algorithm.base_asym_algo,
811 : data, data_size,
812 : &spdm_context->connection_info.peer_used_cert_chain[0].leaf_cert_public_key);
813 : #endif
814 :
815 1 : slot_id = 0;
816 1 : sub_code = SPDM_GET_ENDPOINT_INFO_REQUEST_SUBCODE_DEVICE_CLASS_IDENTIFIER;
817 1 : request_attributes =
818 : SPDM_GET_ENDPOINT_INFO_REQUEST_ATTRIBUTE_SIGNATURE_REQUESTED;
819 1 : ep_info_length = LIBSPDM_MAX_ENDPOINT_INFO_LENGTH;
820 :
821 1 : libspdm_get_random_number(SPDM_NONCE_SIZE, requester_nonce_in);
822 33 : for (int index = 0; index < SPDM_NONCE_SIZE; index++) {
823 32 : requester_nonce[index] = 0x00;
824 32 : responder_nonce[index] = 0x00;
825 : }
826 :
827 1 : status = libspdm_get_endpoint_info(spdm_context, NULL, request_attributes,
828 : sub_code, slot_id,
829 : &ep_info_length, ep_info_record,
830 : requester_nonce_in, requester_nonce,
831 : responder_nonce);
832 :
833 1 : assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
834 33 : for (int index = 0; index < SPDM_NONCE_SIZE; index++) {
835 32 : assert_int_equal (requester_nonce_in[index], requester_nonce[index]);
836 : }
837 : /* Completion of GET_ENDPOINT_INFO sets IL1/IL2 to null. */
838 : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
839 : assert_int_equal(spdm_context->transcript.message_e.buffer_size, 0);
840 : #else
841 1 : assert_null(spdm_context->transcript.digest_context_il1il2);
842 : #endif
843 1 : free(data);
844 1 : }
845 :
846 : /**
847 : * Test 3: Successful response to get a endpoint info with signature,
848 : * after getting SPDM_ERROR_CODE_RESPONSE_NOT_READY on first attempt
849 : * Expected Behavior: get a RETURN_SUCCESS return code, with an empty transcript.message_e
850 : **/
851 1 : static void libspdm_test_requester_get_endpoint_info_case3(void **state)
852 : {
853 : libspdm_return_t status;
854 : libspdm_test_context_t *spdm_test_context;
855 : libspdm_context_t *spdm_context;
856 : void *data;
857 : size_t data_size;
858 : void *hash;
859 : size_t hash_size;
860 : uint8_t sub_code;
861 : uint8_t request_attributes;
862 : uint8_t slot_id;
863 : uint32_t ep_info_length;
864 : uint8_t ep_info_record[LIBSPDM_MAX_ENDPOINT_INFO_LENGTH];
865 : uint8_t requester_nonce_in[SPDM_NONCE_SIZE];
866 : uint8_t requester_nonce[SPDM_NONCE_SIZE];
867 : uint8_t responder_nonce[SPDM_NONCE_SIZE];
868 :
869 1 : spdm_test_context = *state;
870 1 : spdm_context = spdm_test_context->spdm_context;
871 1 : spdm_test_context->case_id = 0x3;
872 1 : spdm_context->retry_times = 3;
873 1 : spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_13 <<
874 : SPDM_VERSION_NUMBER_SHIFT_BIT;
875 1 : spdm_context->connection_info.connection_state =
876 : LIBSPDM_CONNECTION_STATE_NEGOTIATED;
877 1 : spdm_context->connection_info.capability.flags = 0;
878 1 : spdm_context->connection_info.capability.flags |=
879 : SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_EP_INFO_CAP_SIG;
880 1 : libspdm_read_responder_public_certificate_chain(m_libspdm_use_hash_algo,
881 : m_libspdm_use_asym_algo, &data,
882 : &data_size, &hash, &hash_size);
883 1 : libspdm_reset_message_a(spdm_context);
884 1 : libspdm_reset_message_e(spdm_context, NULL);
885 :
886 1 : spdm_context->connection_info.algorithm.base_hash_algo =
887 : m_libspdm_use_hash_algo;
888 1 : spdm_context->connection_info.algorithm.base_asym_algo =
889 : m_libspdm_use_asym_algo;
890 :
891 : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
892 : spdm_context->connection_info.peer_used_cert_chain[0].buffer_size =
893 : data_size;
894 : libspdm_copy_mem(spdm_context->connection_info.peer_used_cert_chain[0].buffer,
895 : sizeof(spdm_context->connection_info.peer_used_cert_chain[0].buffer),
896 : data, data_size);
897 : #else
898 1 : libspdm_hash_all(
899 : spdm_context->connection_info.algorithm.base_hash_algo,
900 : data, data_size,
901 1 : spdm_context->connection_info.peer_used_cert_chain[0].buffer_hash);
902 1 : spdm_context->connection_info.peer_used_cert_chain[0].buffer_hash_size =
903 1 : libspdm_get_hash_size(spdm_context->connection_info.algorithm.base_hash_algo);
904 1 : libspdm_get_leaf_cert_public_key_from_cert_chain(
905 : spdm_context->connection_info.algorithm.base_hash_algo,
906 : spdm_context->connection_info.algorithm.base_asym_algo,
907 : data, data_size,
908 : &spdm_context->connection_info.peer_used_cert_chain[0].leaf_cert_public_key);
909 : #endif
910 :
911 1 : slot_id = 0;
912 1 : sub_code = SPDM_GET_ENDPOINT_INFO_REQUEST_SUBCODE_DEVICE_CLASS_IDENTIFIER;
913 1 : request_attributes =
914 : SPDM_GET_ENDPOINT_INFO_REQUEST_ATTRIBUTE_SIGNATURE_REQUESTED;
915 1 : ep_info_length = LIBSPDM_MAX_ENDPOINT_INFO_LENGTH;
916 :
917 1 : libspdm_get_random_number(SPDM_NONCE_SIZE, requester_nonce_in);
918 33 : for (int index = 0; index < SPDM_NONCE_SIZE; index++) {
919 32 : requester_nonce[index] = 0x00;
920 32 : responder_nonce[index] = 0x00;
921 : }
922 :
923 1 : status = libspdm_get_endpoint_info(spdm_context, NULL, request_attributes,
924 : sub_code, slot_id,
925 : &ep_info_length, ep_info_record,
926 : requester_nonce_in, requester_nonce,
927 : responder_nonce);
928 :
929 : if (LIBSPDM_RESPOND_IF_READY_SUPPORT) {
930 1 : assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
931 33 : for (int index = 0; index < SPDM_NONCE_SIZE; index++) {
932 32 : assert_int_equal (requester_nonce_in[index], requester_nonce[index]);
933 : }
934 : /* Completion of GET_ENDPOINT_INFO sets IL1/IL2 to null. */
935 : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
936 : assert_int_equal(spdm_context->transcript.message_e.buffer_size, 0);
937 : #else
938 1 : assert_null(spdm_context->transcript.digest_context_il1il2);
939 : #endif
940 : } else {
941 : assert_int_equal(status, LIBSPDM_STATUS_NOT_READY_PEER);
942 : }
943 1 : free(data);
944 1 : }
945 :
946 : /**
947 : * Test 4: Successful response to get a endpoint info with signature with slot_id = 1
948 : * Expected Behavior: get a RETURN_SUCCESS return code, with an empty transcript.message_e
949 : **/
950 1 : static void libspdm_test_requester_get_endpoint_info_case4(void **state)
951 : {
952 : libspdm_return_t status;
953 : libspdm_test_context_t *spdm_test_context;
954 : libspdm_context_t *spdm_context;
955 : void *data;
956 : size_t data_size;
957 : void *hash;
958 : size_t hash_size;
959 : uint8_t sub_code;
960 : uint8_t request_attributes;
961 : uint8_t slot_id;
962 : uint32_t ep_info_length;
963 : uint8_t ep_info_record[LIBSPDM_MAX_ENDPOINT_INFO_LENGTH];
964 : uint8_t requester_nonce_in[SPDM_NONCE_SIZE];
965 : uint8_t requester_nonce[SPDM_NONCE_SIZE];
966 : uint8_t responder_nonce[SPDM_NONCE_SIZE];
967 :
968 1 : spdm_test_context = *state;
969 1 : spdm_context = spdm_test_context->spdm_context;
970 1 : spdm_test_context->case_id = 0x4;
971 1 : spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_13 <<
972 : SPDM_VERSION_NUMBER_SHIFT_BIT;
973 1 : spdm_context->connection_info.connection_state =
974 : LIBSPDM_CONNECTION_STATE_NEGOTIATED;
975 1 : spdm_context->connection_info.capability.flags = 0;
976 1 : spdm_context->connection_info.capability.flags |=
977 : SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_EP_INFO_CAP_SIG;
978 1 : spdm_context->connection_info.capability.flags |=
979 : SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MULTI_KEY_CAP;
980 1 : libspdm_read_responder_public_certificate_chain_per_slot(1, m_libspdm_use_hash_algo,
981 : m_libspdm_use_asym_algo, &data,
982 : &data_size, &hash, &hash_size);
983 1 : libspdm_reset_message_a(spdm_context);
984 1 : libspdm_reset_message_e(spdm_context, NULL);
985 :
986 1 : spdm_context->connection_info.algorithm.base_hash_algo =
987 : m_libspdm_use_hash_algo;
988 1 : spdm_context->connection_info.algorithm.base_asym_algo =
989 : m_libspdm_use_asym_algo;
990 :
991 : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
992 : spdm_context->connection_info.peer_used_cert_chain[1].buffer_size =
993 : data_size;
994 : libspdm_copy_mem(spdm_context->connection_info.peer_used_cert_chain[1].buffer,
995 : sizeof(spdm_context->connection_info.peer_used_cert_chain[1].buffer),
996 : data, data_size);
997 : #else
998 1 : libspdm_hash_all(
999 : spdm_context->connection_info.algorithm.base_hash_algo,
1000 : data, data_size,
1001 1 : spdm_context->connection_info.peer_used_cert_chain[1].buffer_hash);
1002 1 : spdm_context->connection_info.peer_used_cert_chain[1].buffer_hash_size =
1003 1 : libspdm_get_hash_size(spdm_context->connection_info.algorithm.base_hash_algo);
1004 1 : libspdm_get_leaf_cert_public_key_from_cert_chain(
1005 : spdm_context->connection_info.algorithm.base_hash_algo,
1006 : spdm_context->connection_info.algorithm.base_asym_algo,
1007 : data, data_size,
1008 : &spdm_context->connection_info.peer_used_cert_chain[1].leaf_cert_public_key);
1009 : #endif
1010 :
1011 1 : slot_id = 1;
1012 1 : sub_code = SPDM_GET_ENDPOINT_INFO_REQUEST_SUBCODE_DEVICE_CLASS_IDENTIFIER;
1013 1 : request_attributes =
1014 : SPDM_GET_ENDPOINT_INFO_REQUEST_ATTRIBUTE_SIGNATURE_REQUESTED;
1015 1 : ep_info_length = LIBSPDM_MAX_ENDPOINT_INFO_LENGTH;
1016 :
1017 1 : libspdm_get_random_number(SPDM_NONCE_SIZE, requester_nonce_in);
1018 33 : for (int index = 0; index < SPDM_NONCE_SIZE; index++) {
1019 32 : requester_nonce[index] = 0x00;
1020 32 : responder_nonce[index] = 0x00;
1021 : }
1022 :
1023 1 : status = libspdm_get_endpoint_info(spdm_context, NULL, request_attributes,
1024 : sub_code, slot_id,
1025 : &ep_info_length, ep_info_record,
1026 : requester_nonce_in, requester_nonce,
1027 : responder_nonce);
1028 :
1029 1 : assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
1030 33 : for (int index = 0; index < SPDM_NONCE_SIZE; index++) {
1031 32 : assert_int_equal (requester_nonce_in[index], requester_nonce[index]);
1032 : }
1033 : /* Completion of GET_ENDPOINT_INFO sets IL1/IL2 to null. */
1034 : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
1035 : assert_int_equal(spdm_context->transcript.message_e.buffer_size, 0);
1036 : #else
1037 1 : assert_null(spdm_context->transcript.digest_context_il1il2);
1038 : #endif
1039 1 : free(data);
1040 1 : }
1041 :
1042 : /**
1043 : * Test 5: Successful response to get a endpoint info with signature
1044 : * Using provisioned public key (slot_id = 0xF)
1045 : * Expected Behavior: get a RETURN_SUCCESS return code, with an empty transcript.message_e
1046 : **/
1047 1 : static void libspdm_test_requester_get_endpoint_info_case5(void **state)
1048 : {
1049 : libspdm_return_t status;
1050 : libspdm_test_context_t *spdm_test_context;
1051 : libspdm_context_t *spdm_context;
1052 : void *data;
1053 : size_t data_size;
1054 : uint8_t sub_code;
1055 : uint8_t request_attributes;
1056 : uint8_t slot_id;
1057 : uint32_t ep_info_length;
1058 : uint8_t ep_info_record[LIBSPDM_MAX_ENDPOINT_INFO_LENGTH];
1059 : uint8_t requester_nonce_in[SPDM_NONCE_SIZE];
1060 : uint8_t requester_nonce[SPDM_NONCE_SIZE];
1061 : uint8_t responder_nonce[SPDM_NONCE_SIZE];
1062 :
1063 1 : spdm_test_context = *state;
1064 1 : spdm_context = spdm_test_context->spdm_context;
1065 1 : spdm_test_context->case_id = 0x5;
1066 1 : spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_13 <<
1067 : SPDM_VERSION_NUMBER_SHIFT_BIT;
1068 1 : spdm_context->connection_info.connection_state =
1069 : LIBSPDM_CONNECTION_STATE_NEGOTIATED;
1070 1 : spdm_context->connection_info.capability.flags = 0;
1071 1 : spdm_context->connection_info.capability.flags |=
1072 : SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_EP_INFO_CAP_SIG;
1073 1 : spdm_context->connection_info.capability.flags |=
1074 : SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PUB_KEY_ID_CAP;
1075 1 : libspdm_read_responder_public_key(m_libspdm_use_asym_algo, &data, &data_size);
1076 1 : spdm_context->local_context.peer_public_key_provision = data;
1077 1 : spdm_context->local_context.peer_public_key_provision_size = data_size;
1078 :
1079 1 : libspdm_reset_message_a(spdm_context);
1080 1 : libspdm_reset_message_e(spdm_context, NULL);
1081 :
1082 1 : spdm_context->connection_info.algorithm.base_hash_algo =
1083 : m_libspdm_use_hash_algo;
1084 1 : spdm_context->connection_info.algorithm.base_asym_algo =
1085 : m_libspdm_use_asym_algo;
1086 :
1087 1 : slot_id = 0xF;
1088 1 : sub_code = SPDM_GET_ENDPOINT_INFO_REQUEST_SUBCODE_DEVICE_CLASS_IDENTIFIER;
1089 1 : request_attributes =
1090 : SPDM_GET_ENDPOINT_INFO_REQUEST_ATTRIBUTE_SIGNATURE_REQUESTED;
1091 1 : ep_info_length = LIBSPDM_MAX_ENDPOINT_INFO_LENGTH;
1092 :
1093 1 : libspdm_get_random_number(SPDM_NONCE_SIZE, requester_nonce_in);
1094 33 : for (int index = 0; index < SPDM_NONCE_SIZE; index++) {
1095 32 : requester_nonce[index] = 0x00;
1096 32 : responder_nonce[index] = 0x00;
1097 : }
1098 :
1099 1 : status = libspdm_get_endpoint_info(spdm_context, NULL, request_attributes,
1100 : sub_code, slot_id,
1101 : &ep_info_length, ep_info_record,
1102 : requester_nonce_in, requester_nonce,
1103 : responder_nonce);
1104 :
1105 1 : assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
1106 33 : for (int index = 0; index < SPDM_NONCE_SIZE; index++) {
1107 32 : assert_int_equal (requester_nonce_in[index], requester_nonce[index]);
1108 : }
1109 : /* Completion of GET_ENDPOINT_INFO sets IL1/IL2 to null. */
1110 : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
1111 : assert_int_equal(spdm_context->transcript.message_e.buffer_size, 0);
1112 : #else
1113 1 : assert_null(spdm_context->transcript.digest_context_il1il2);
1114 : #endif
1115 1 : free(data);
1116 1 : }
1117 :
1118 : /**
1119 : * Test 6: Successful response to get a endpoint info without signature
1120 : * Expected Behavior: get a RETURN_SUCCESS return code
1121 : **/
1122 1 : static void libspdm_test_requester_get_endpoint_info_case6(void **state)
1123 : {
1124 : libspdm_return_t status;
1125 : libspdm_test_context_t *spdm_test_context;
1126 : libspdm_context_t *spdm_context;
1127 : uint8_t sub_code;
1128 : uint8_t request_attributes;
1129 : uint8_t slot_id;
1130 : uint32_t ep_info_length;
1131 : uint8_t ep_info_record[LIBSPDM_MAX_ENDPOINT_INFO_LENGTH];
1132 :
1133 1 : spdm_test_context = *state;
1134 1 : spdm_context = spdm_test_context->spdm_context;
1135 1 : spdm_test_context->case_id = 0x6;
1136 1 : spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_13 <<
1137 : SPDM_VERSION_NUMBER_SHIFT_BIT;
1138 1 : spdm_context->connection_info.connection_state =
1139 : LIBSPDM_CONNECTION_STATE_NEGOTIATED;
1140 1 : spdm_context->connection_info.capability.flags = 0;
1141 1 : spdm_context->connection_info.capability.flags |=
1142 : SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_EP_INFO_CAP_NO_SIG;
1143 :
1144 1 : slot_id = 0;
1145 1 : sub_code = SPDM_GET_ENDPOINT_INFO_REQUEST_SUBCODE_DEVICE_CLASS_IDENTIFIER;
1146 1 : request_attributes = 0;
1147 1 : ep_info_length = LIBSPDM_MAX_ENDPOINT_INFO_LENGTH;
1148 :
1149 1 : status = libspdm_get_endpoint_info(spdm_context, NULL, request_attributes,
1150 : sub_code, slot_id,
1151 : &ep_info_length, ep_info_record,
1152 : NULL, NULL, NULL);
1153 :
1154 1 : assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
1155 1 : }
1156 :
1157 : /**
1158 : * Test 7: Successful response to get a session based endpoint info with signature
1159 : * Expected Behavior: get a RETURN_SUCCESS return code, with an empty session_transcript.message_e
1160 : **/
1161 1 : static void libspdm_test_requester_get_endpoint_info_case7(void **state)
1162 : {
1163 : libspdm_return_t status;
1164 : libspdm_test_context_t *spdm_test_context;
1165 : libspdm_context_t *spdm_context;
1166 : uint32_t session_id;
1167 : libspdm_session_info_t *session_info;
1168 : void *data;
1169 : size_t data_size;
1170 : void *hash;
1171 : size_t hash_size;
1172 : uint8_t sub_code;
1173 : uint8_t request_attributes;
1174 : uint8_t slot_id;
1175 : uint32_t ep_info_length;
1176 : uint8_t ep_info_record[LIBSPDM_MAX_ENDPOINT_INFO_LENGTH];
1177 : uint8_t requester_nonce_in[SPDM_NONCE_SIZE];
1178 : uint8_t requester_nonce[SPDM_NONCE_SIZE];
1179 : uint8_t responder_nonce[SPDM_NONCE_SIZE];
1180 :
1181 1 : spdm_test_context = *state;
1182 1 : spdm_context = spdm_test_context->spdm_context;
1183 1 : spdm_test_context->case_id = 0x7;
1184 1 : spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_13 <<
1185 : SPDM_VERSION_NUMBER_SHIFT_BIT;
1186 1 : spdm_context->connection_info.connection_state =
1187 : LIBSPDM_CONNECTION_STATE_AUTHENTICATED;
1188 1 : spdm_context->connection_info.capability.flags = 0;
1189 1 : spdm_context->connection_info.capability.flags |=
1190 : SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_EP_INFO_CAP_SIG;
1191 1 : libspdm_read_responder_public_certificate_chain(m_libspdm_use_hash_algo,
1192 : m_libspdm_use_asym_algo, &data,
1193 : &data_size, &hash, &hash_size);
1194 :
1195 1 : spdm_context->connection_info.capability.flags |=
1196 : SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP;
1197 1 : spdm_context->connection_info.capability.flags |=
1198 : SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP;
1199 1 : spdm_context->connection_info.capability.flags |=
1200 : SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP;
1201 1 : spdm_context->local_context.capability.flags = 0;
1202 1 : spdm_context->local_context.capability.flags |=
1203 : SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP;
1204 1 : spdm_context->local_context.capability.flags |=
1205 : SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP;
1206 1 : spdm_context->local_context.capability.flags |=
1207 : SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP;
1208 1 : spdm_context->connection_info.algorithm.dhe_named_group =
1209 : m_libspdm_use_dhe_algo;
1210 1 : spdm_context->connection_info.algorithm.aead_cipher_suite =
1211 : m_libspdm_use_aead_algo;
1212 :
1213 1 : session_id = 0xFFFFFFFF;
1214 1 : session_info = &spdm_context->session_info[0];
1215 1 : libspdm_session_info_init(spdm_context, session_info, session_id, true);
1216 1 : libspdm_secured_message_set_session_state(
1217 : session_info->secured_message_context,
1218 : LIBSPDM_SESSION_STATE_ESTABLISHED);
1219 :
1220 1 : libspdm_reset_message_a(spdm_context);
1221 1 : libspdm_reset_message_e(spdm_context, session_info);
1222 :
1223 1 : spdm_context->connection_info.algorithm.base_hash_algo =
1224 : m_libspdm_use_hash_algo;
1225 1 : spdm_context->connection_info.algorithm.base_asym_algo =
1226 : m_libspdm_use_asym_algo;
1227 :
1228 : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
1229 : spdm_context->connection_info.peer_used_cert_chain[0].buffer_size =
1230 : data_size;
1231 : libspdm_copy_mem(spdm_context->connection_info.peer_used_cert_chain[0].buffer,
1232 : sizeof(spdm_context->connection_info.peer_used_cert_chain[0].buffer),
1233 : data, data_size);
1234 : #else
1235 1 : libspdm_hash_all(
1236 : spdm_context->connection_info.algorithm.base_hash_algo,
1237 : data, data_size,
1238 1 : spdm_context->connection_info.peer_used_cert_chain[0].buffer_hash);
1239 1 : spdm_context->connection_info.peer_used_cert_chain[0].buffer_hash_size =
1240 1 : libspdm_get_hash_size(spdm_context->connection_info.algorithm.base_hash_algo);
1241 1 : libspdm_get_leaf_cert_public_key_from_cert_chain(
1242 : spdm_context->connection_info.algorithm.base_hash_algo,
1243 : spdm_context->connection_info.algorithm.base_asym_algo,
1244 : data, data_size,
1245 : &spdm_context->connection_info.peer_used_cert_chain[0].leaf_cert_public_key);
1246 : #endif
1247 :
1248 1 : slot_id = 0;
1249 1 : sub_code = SPDM_GET_ENDPOINT_INFO_REQUEST_SUBCODE_DEVICE_CLASS_IDENTIFIER;
1250 1 : request_attributes =
1251 : SPDM_GET_ENDPOINT_INFO_REQUEST_ATTRIBUTE_SIGNATURE_REQUESTED;
1252 1 : ep_info_length = LIBSPDM_MAX_ENDPOINT_INFO_LENGTH;
1253 :
1254 1 : libspdm_get_random_number(SPDM_NONCE_SIZE, requester_nonce_in);
1255 33 : for (int index = 0; index < SPDM_NONCE_SIZE; index++) {
1256 32 : requester_nonce[index] = 0x00;
1257 32 : responder_nonce[index] = 0x00;
1258 : }
1259 :
1260 1 : status = libspdm_get_endpoint_info(spdm_context, &session_id, request_attributes,
1261 : sub_code, slot_id,
1262 : &ep_info_length, ep_info_record,
1263 : requester_nonce_in, requester_nonce,
1264 : responder_nonce);
1265 :
1266 1 : assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
1267 33 : for (int index = 0; index < SPDM_NONCE_SIZE; index++) {
1268 32 : assert_int_equal (requester_nonce_in[index], requester_nonce[index]);
1269 : }
1270 : /* Completion of GET_ENDPOINT_INFO sets IL1/IL2 to null. */
1271 : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
1272 : assert_int_equal(session_info->session_transcript.message_e.buffer_size, 0);
1273 : #else
1274 1 : assert_null(session_info->session_transcript.digest_context_il1il2);
1275 : #endif
1276 1 : free(data);
1277 1 : }
1278 :
1279 1 : int libspdm_requester_get_endpoint_info_test_main(void)
1280 : {
1281 1 : const struct CMUnitTest spdm_requester_get_endpoint_info_tests[] = {
1282 : cmocka_unit_test(libspdm_test_requester_get_endpoint_info_case1),
1283 : cmocka_unit_test(libspdm_test_requester_get_endpoint_info_case2),
1284 : cmocka_unit_test(libspdm_test_requester_get_endpoint_info_case3),
1285 : cmocka_unit_test(libspdm_test_requester_get_endpoint_info_case4),
1286 : cmocka_unit_test(libspdm_test_requester_get_endpoint_info_case5),
1287 : cmocka_unit_test(libspdm_test_requester_get_endpoint_info_case6),
1288 : cmocka_unit_test(libspdm_test_requester_get_endpoint_info_case7),
1289 : };
1290 :
1291 1 : libspdm_test_context_t test_context = {
1292 : LIBSPDM_TEST_CONTEXT_VERSION,
1293 : true,
1294 : libspdm_requester_get_endpoint_info_test_send_message,
1295 : libspdm_requester_get_endpoint_info_test_receive_message,
1296 : };
1297 :
1298 1 : libspdm_setup_test_context(&test_context);
1299 :
1300 1 : return cmocka_run_group_tests(spdm_requester_get_endpoint_info_tests,
1301 : libspdm_unit_test_group_setup,
1302 : libspdm_unit_test_group_teardown);
1303 : }
1304 :
1305 : #endif /* LIBSPDM_SEND_GET_ENDPOINT_INFO_SUPPORT */
|