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