LCOV - code coverage report
Current view: top level - unit_test/test_spdm_requester - get_encapsulated_request.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 86.2 % 768 662
Test Date: 2026-01-18 08:10:21 Functions: 100.0 % 18 18

            Line data    Source code
       1              : /**
       2              :  *  Copyright Notice:
       3              :  *  Copyright 2021-2026 DMTF. All rights reserved.
       4              :  *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
       5              :  **/
       6              : 
       7              : #include "spdm_unit_test.h"
       8              : #include "internal/libspdm_requester_lib.h"
       9              : 
      10              : #if LIBSPDM_ENABLE_CAPABILITY_ENCAP_CAP
      11              : 
      12              : static uint8_t m_libspdm_local_certificate_chain[LIBSPDM_MAX_CERT_CHAIN_SIZE];
      13              : static uint8_t temp_buf[LIBSPDM_RECEIVER_BUFFER_SIZE];
      14              : static uint8_t temp_buff[LIBSPDM_MAX_SPDM_MSG_SIZE];
      15              : 
      16           21 : static libspdm_return_t send_message(
      17              :     void *spdm_context, size_t request_size, const void *request, uint64_t timeout)
      18              : {
      19              :     libspdm_test_context_t *spdm_test_context;
      20              : 
      21           21 :     spdm_test_context = libspdm_get_test_context();
      22              :     static uint8_t sub_index = 0;
      23              :     spdm_deliver_encapsulated_response_request_t *spdm_deliver_encapsulated_response_request;
      24              :     uint8_t send_temp_buf[LIBSPDM_SENDER_BUFFER_SIZE];
      25              :     size_t decode_message_size;
      26              :     spdm_error_response_t *spdm_response;
      27              :     libspdm_return_t status;
      28              :     uint32_t *message_session_id;
      29              :     bool is_message_app_message;
      30              :     uint8_t message_buffer[LIBSPDM_SENDER_BUFFER_SIZE];
      31              : 
      32           21 :     memcpy(message_buffer, request, request_size);
      33              : 
      34           21 :     switch (spdm_test_context->case_id)
      35              :     {
      36            1 :     case 0x1:
      37            1 :         return LIBSPDM_STATUS_SEND_FAIL;
      38            2 :     case 0x2:
      39            2 :         return LIBSPDM_STATUS_SUCCESS;
      40            0 :     case 0x3:
      41            0 :         return LIBSPDM_STATUS_SUCCESS;
      42            1 :     case 0x4:
      43            1 :         return LIBSPDM_STATUS_SUCCESS;
      44            2 :     case 0x5:
      45            2 :         return LIBSPDM_STATUS_SUCCESS;
      46            0 :     case 0x6:
      47            0 :         return LIBSPDM_STATUS_SUCCESS;
      48            2 :     case 0x7:
      49            2 :         return LIBSPDM_STATUS_SUCCESS;
      50            2 :     case 0x8:
      51            2 :         return LIBSPDM_STATUS_SUCCESS;
      52            2 :     case 0x9:
      53            2 :         return LIBSPDM_STATUS_SUCCESS;
      54            2 :     case 0xA:
      55              :     {
      56            2 :         if (sub_index == 0) {
      57            1 :             sub_index++;
      58            1 :         } else if (sub_index == 1) {
      59            1 :             sub_index = 0;
      60            1 :             message_session_id = NULL;
      61            1 :             is_message_app_message = false;
      62            1 :             spdm_deliver_encapsulated_response_request = (void *)send_temp_buf;
      63            1 :             decode_message_size = sizeof(spdm_deliver_encapsulated_response_request_t) +
      64              :                                   sizeof(spdm_error_response_t);
      65            1 :             status = libspdm_transport_test_decode_message(spdm_context, &message_session_id,
      66              :                                                            &is_message_app_message, true,
      67              :                                                            request_size, message_buffer,
      68              :                                                            &decode_message_size,
      69              :                                                            (void **)&spdm_deliver_encapsulated_response_request);
      70            1 :             if (LIBSPDM_STATUS_IS_ERROR(status)) {
      71            0 :                 LIBSPDM_DEBUG((LIBSPDM_DEBUG_ERROR, "transport_decode_message - %xu\n", status));
      72              :             }
      73            1 :             spdm_response = (void *)(spdm_deliver_encapsulated_response_request + 1);
      74              : 
      75            1 :             assert_int_equal(spdm_response->header.spdm_version, SPDM_MESSAGE_VERSION_11);
      76            1 :             assert_int_equal(spdm_response->header.request_response_code, SPDM_ERROR);
      77            1 :             assert_int_equal(spdm_response->header.param1, SPDM_ERROR_CODE_UNEXPECTED_REQUEST);
      78            1 :             assert_int_equal(spdm_response->header.param2, 0);
      79              :         }
      80            2 :         return LIBSPDM_STATUS_SUCCESS;
      81              :     }
      82            1 :     case 0xb:
      83            1 :         return LIBSPDM_STATUS_SUCCESS;
      84            1 :     case 0xc:
      85            1 :         return LIBSPDM_STATUS_SUCCESS;
      86            2 :     case 0xD:
      87            2 :         return LIBSPDM_STATUS_SUCCESS;
      88            1 :     case 0xE:
      89            1 :         return LIBSPDM_STATUS_SUCCESS;
      90            2 :     case 0xF:
      91            2 :         return LIBSPDM_STATUS_SUCCESS;
      92            0 :     default:
      93            0 :         return LIBSPDM_STATUS_SEND_FAIL;
      94              :     }
      95              : }
      96              : 
      97           20 : static libspdm_return_t receive_message(
      98              :     void *spdm_context, size_t *response_size, void **response, uint64_t timeout)
      99              : {
     100              : 
     101              :     libspdm_test_context_t *spdm_test_context;
     102              :     spdm_encapsulated_request_response_t *libspdm_encapsulated_request_response;
     103              :     uint8_t *digest;
     104              :     size_t temp_buf_size;
     105              :     uint8_t *temp_buf_ptr;
     106              : 
     107           20 :     spdm_test_context = libspdm_get_test_context();
     108              :     static uint8_t sub_index = 0;
     109           20 :     switch (spdm_test_context->case_id)
     110              :     {
     111            0 :     case 0x1:
     112            0 :         return LIBSPDM_STATUS_RECEIVE_FAIL;
     113              : 
     114            2 :     case 0x2:
     115              :     {
     116              :         spdm_digest_response_t *spdm_response;
     117              : 
     118            2 :         ((libspdm_context_t *)spdm_context)->connection_info.algorithm.base_hash_algo =
     119              :             m_libspdm_use_hash_algo;
     120            2 :         if (sub_index == 0) {
     121            1 :             temp_buf_size = sizeof(spdm_digest_response_t) +
     122            1 :                             libspdm_get_hash_size(m_libspdm_use_hash_algo) +
     123              :                             sizeof(spdm_encapsulated_request_response_t);
     124            1 :             libspdm_zero_mem(temp_buf, LIBSPDM_RECEIVER_BUFFER_SIZE);
     125            1 :             temp_buf_ptr = temp_buf + sizeof(libspdm_test_message_header_t);
     126            1 :             libspdm_encapsulated_request_response = (void *)temp_buf_ptr;
     127            1 :             libspdm_encapsulated_request_response->header.spdm_version = SPDM_MESSAGE_VERSION_11;
     128            1 :             libspdm_encapsulated_request_response->header.request_response_code =
     129              :                 SPDM_ENCAPSULATED_REQUEST;
     130            1 :             libspdm_encapsulated_request_response->header.param1 = 0;
     131            1 :             libspdm_encapsulated_request_response->header.param2 = 0;
     132              : 
     133            1 :             spdm_response = (void *)(temp_buf_ptr
     134              :                                      + sizeof(spdm_encapsulated_request_response_t));
     135            1 :             spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_11;
     136            1 :             spdm_response->header.request_response_code = SPDM_GET_DIGESTS;
     137            1 :             spdm_response->header.param1 = 0;
     138            1 :             spdm_response->header.param2 = 0;
     139            1 :             libspdm_set_mem(m_libspdm_local_certificate_chain,
     140              :                             sizeof(m_libspdm_local_certificate_chain),
     141              :                             (uint8_t)(0xFF));
     142              : 
     143            1 :             digest = (void *)(spdm_response + 1);
     144            1 :             libspdm_hash_all(m_libspdm_use_hash_algo, m_libspdm_local_certificate_chain,
     145              :                              sizeof(m_libspdm_local_certificate_chain), &digest[0]);
     146            1 :             spdm_response->header.param2 |= (0x01 << 0);
     147            1 :             sub_index++;
     148            1 :         } else if (sub_index == 1) {
     149              :             /* When the version is SPDM_MESSAGE_VERSION_12, use the following code. */
     150              :             spdm_message_header_t *spdm_encapsulated_response_ack_response;
     151            1 :             temp_buf_size = sizeof(spdm_message_header_t);
     152            1 :             libspdm_zero_mem(temp_buf, LIBSPDM_RECEIVER_BUFFER_SIZE);
     153            1 :             temp_buf_ptr = temp_buf + sizeof(libspdm_test_message_header_t);
     154            1 :             spdm_encapsulated_response_ack_response = (void *)temp_buf_ptr;
     155            1 :             spdm_encapsulated_response_ack_response->spdm_version = SPDM_MESSAGE_VERSION_11;
     156            1 :             spdm_encapsulated_response_ack_response->request_response_code =
     157              :                 SPDM_ENCAPSULATED_RESPONSE_ACK;
     158            1 :             spdm_encapsulated_response_ack_response->param1 = 0;
     159            1 :             spdm_encapsulated_response_ack_response->param2 =
     160              :                 SPDM_ENCAPSULATED_RESPONSE_ACK_RESPONSE_PAYLOAD_TYPE_ABSENT;
     161            1 :             sub_index = 0;
     162              :         } else {
     163            0 :             temp_buf_size = 0;
     164            0 :             temp_buf_ptr = NULL;
     165              :         }
     166            2 :         libspdm_transport_test_encode_message(spdm_context, NULL, false, false,
     167              :                                               temp_buf_size, temp_buf_ptr,
     168              :                                               response_size, response);
     169              :     }
     170            2 :         return LIBSPDM_STATUS_SUCCESS;
     171            0 :     case 0x3:
     172              :     {
     173              :         spdm_digest_response_t *spdm_response;
     174              : 
     175            0 :         ((libspdm_context_t *)spdm_context)->connection_info.algorithm.base_hash_algo =
     176              :             m_libspdm_use_hash_algo;
     177            0 :         if (sub_index == 0) {
     178            0 :             temp_buf_size = sizeof(spdm_digest_response_t) +
     179            0 :                             libspdm_get_hash_size(m_libspdm_use_hash_algo) +
     180              :                             sizeof(spdm_encapsulated_request_response_t);
     181            0 :             libspdm_zero_mem(temp_buf, LIBSPDM_RECEIVER_BUFFER_SIZE);
     182            0 :             temp_buf_ptr = temp_buf + sizeof(libspdm_test_message_header_t);
     183            0 :             libspdm_encapsulated_request_response = (void *) temp_buf_ptr;
     184            0 :             libspdm_encapsulated_request_response->header.spdm_version = SPDM_MESSAGE_VERSION_11;
     185            0 :             libspdm_encapsulated_request_response->header.request_response_code =
     186              :                 SPDM_ENCAPSULATED_REQUEST;
     187            0 :             libspdm_encapsulated_request_response->header.param1 = 0;
     188            0 :             libspdm_encapsulated_request_response->header.param2 = 0;
     189              : 
     190            0 :             spdm_response = (void *)(temp_buf_ptr + sizeof(spdm_encapsulated_request_response_t));
     191            0 :             spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_11;
     192            0 :             spdm_response->header.request_response_code = SPDM_GET_DIGESTS;
     193            0 :             spdm_response->header.param1 = 0;
     194            0 :             spdm_response->header.param2 = 0;
     195            0 :             libspdm_set_mem(m_libspdm_local_certificate_chain,
     196              :                             sizeof(m_libspdm_local_certificate_chain),
     197              :                             (uint8_t)(0xFF));
     198              : 
     199            0 :             digest = (void *)(spdm_response + 1);
     200            0 :             libspdm_hash_all(m_libspdm_use_hash_algo, m_libspdm_local_certificate_chain,
     201              :                              sizeof(m_libspdm_local_certificate_chain), &digest[0]);
     202            0 :             spdm_response->header.param2 |= (0x01 << 0);
     203            0 :             sub_index++;
     204            0 :         } else if (sub_index == 1) {
     205              :             /* When the version is SPDM_MESSAGE_VERSION_12, use the following code. */
     206              :             spdm_encapsulated_response_ack_response_t *spdm_encapsulated_response_ack_response;
     207            0 :             temp_buf_size = sizeof(spdm_encapsulated_response_ack_response_t);
     208            0 :             libspdm_zero_mem(temp_buf, LIBSPDM_RECEIVER_BUFFER_SIZE);
     209            0 :             temp_buf_ptr = temp_buf + sizeof(libspdm_test_message_header_t);
     210            0 :             spdm_encapsulated_response_ack_response = (void *) temp_buf_ptr;
     211            0 :             spdm_encapsulated_response_ack_response->header.spdm_version = SPDM_MESSAGE_VERSION_11;
     212            0 :             spdm_encapsulated_response_ack_response->header.request_response_code =
     213              :                 SPDM_ENCAPSULATED_RESPONSE_ACK;
     214            0 :             spdm_encapsulated_response_ack_response->header.param1 = 0;
     215            0 :             spdm_encapsulated_response_ack_response->header.param2 =
     216              :                 SPDM_ENCAPSULATED_RESPONSE_ACK_RESPONSE_PAYLOAD_TYPE_ABSENT;
     217            0 :             sub_index = 0;
     218              :         } else {
     219            0 :             temp_buf_size = 0;
     220            0 :             temp_buf_ptr = NULL;
     221              :         }
     222            0 :         libspdm_transport_test_encode_message(spdm_context, NULL, false, false,
     223              :                                               temp_buf_size, temp_buf_ptr,
     224              :                                               response_size, response);
     225              :     }
     226            0 :         return LIBSPDM_STATUS_SUCCESS;
     227            1 :     case 0x4:
     228              :     {
     229              :         spdm_digest_response_t *spdm_response;
     230              : 
     231            1 :         ((libspdm_context_t *)spdm_context)->connection_info.algorithm.base_hash_algo =
     232              :             m_libspdm_use_hash_algo;
     233            1 :         temp_buf_size = sizeof(spdm_encapsulated_request_response_t);
     234            1 :         libspdm_zero_mem(temp_buf, LIBSPDM_RECEIVER_BUFFER_SIZE);
     235            1 :         temp_buf_ptr = temp_buf + sizeof(libspdm_test_message_header_t);
     236            1 :         spdm_response = (void *) temp_buf_ptr;
     237            1 :         spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_11;
     238            1 :         spdm_response->header.request_response_code = SPDM_ENCAPSULATED_REQUEST;
     239            1 :         spdm_response->header.param1 = 0;
     240            1 :         spdm_response->header.param2 = 0;
     241              : 
     242            1 :         libspdm_transport_test_encode_message(spdm_context, NULL, false, false,
     243              :                                               temp_buf_size, temp_buf_ptr,
     244              :                                               response_size, response);
     245              :     }
     246            1 :         return LIBSPDM_STATUS_SUCCESS;
     247            2 :     case 0x5:
     248              :     {
     249              :         spdm_digest_response_t *spdm_response;
     250              : 
     251            2 :         ((libspdm_context_t *)spdm_context)->connection_info.algorithm.base_hash_algo =
     252              :             m_libspdm_use_hash_algo;
     253            2 :         if (sub_index == 0) {
     254            1 :             temp_buf_size = sizeof(spdm_digest_response_t) +
     255            1 :                             libspdm_get_hash_size(m_libspdm_use_hash_algo) +
     256              :                             sizeof(spdm_encapsulated_request_response_t);
     257            1 :             libspdm_zero_mem(temp_buf, LIBSPDM_RECEIVER_BUFFER_SIZE);
     258            1 :             temp_buf_ptr = temp_buf + sizeof(libspdm_test_message_header_t);
     259            1 :             libspdm_encapsulated_request_response = (void *)temp_buf_ptr;
     260            1 :             libspdm_encapsulated_request_response->header.spdm_version = SPDM_MESSAGE_VERSION_11;
     261            1 :             libspdm_encapsulated_request_response->header.request_response_code =
     262              :                 SPDM_ENCAPSULATED_REQUEST;
     263            1 :             libspdm_encapsulated_request_response->header.param1 = 0;
     264            1 :             libspdm_encapsulated_request_response->header.param2 = 0;
     265              : 
     266            1 :             spdm_response = (void *)(temp_buf_ptr + sizeof(spdm_encapsulated_request_response_t));
     267            1 :             spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_11;
     268            1 :             spdm_response->header.request_response_code = SPDM_GET_DIGESTS;
     269            1 :             spdm_response->header.param1 = 0;
     270            1 :             spdm_response->header.param2 = 0;
     271            1 :             libspdm_set_mem(m_libspdm_local_certificate_chain,
     272              :                             sizeof(m_libspdm_local_certificate_chain),
     273              :                             (uint8_t)(0xFF));
     274              : 
     275            1 :             digest = (void *)(spdm_response + 1);
     276            1 :             libspdm_hash_all(m_libspdm_use_hash_algo, m_libspdm_local_certificate_chain,
     277              :                              sizeof(m_libspdm_local_certificate_chain), &digest[0]);
     278            1 :             spdm_response->header.param2 |= (0x01 << 0);
     279              : 
     280            1 :             libspdm_transport_test_encode_message(spdm_context, NULL, false, false,
     281              :                                                   temp_buf_size, temp_buf_ptr,
     282              :                                                   response_size, response);
     283            1 :             sub_index++;
     284            1 :         } else if (sub_index == 1) {
     285              :             size_t temp_buff_size;
     286              :             uint8_t *temp_buff_ptr;
     287              : 
     288            1 :             temp_buff_size = sizeof(spdm_message_header_t);
     289            1 :             libspdm_zero_mem(temp_buff, LIBSPDM_MAX_SPDM_MSG_SIZE);
     290            1 :             temp_buff_ptr = temp_buff + sizeof(libspdm_test_message_header_t);
     291              : 
     292            1 :             sub_index = 0;
     293            1 :             libspdm_transport_test_encode_message(spdm_context, NULL, false, false,
     294              :                                                   temp_buff_size, temp_buff_ptr,
     295              :                                                   response_size, response);
     296              :         }
     297              :     }
     298            2 :         return LIBSPDM_STATUS_SUCCESS;
     299            0 :     case 0x6:
     300              :     {
     301              :         spdm_digest_response_t *spdm_response;
     302              : 
     303            0 :         ((libspdm_context_t *)spdm_context)->connection_info.algorithm.base_hash_algo =
     304              :             m_libspdm_use_hash_algo;
     305            0 :         if (sub_index == 0) {
     306            0 :             temp_buf_size = sizeof(spdm_digest_response_t) +
     307            0 :                             libspdm_get_hash_size(m_libspdm_use_hash_algo) +
     308              :                             sizeof(spdm_encapsulated_request_response_t);
     309            0 :             libspdm_zero_mem(temp_buf, LIBSPDM_RECEIVER_BUFFER_SIZE);
     310            0 :             temp_buf_ptr = temp_buf + sizeof(libspdm_test_message_header_t);
     311              : 
     312            0 :             libspdm_encapsulated_request_response = (void *)temp_buf_ptr;
     313            0 :             libspdm_encapsulated_request_response->header.spdm_version = SPDM_MESSAGE_VERSION_11;
     314            0 :             libspdm_encapsulated_request_response->header.request_response_code =
     315              :                 SPDM_ENCAPSULATED_REQUEST;
     316            0 :             libspdm_encapsulated_request_response->header.param1 = 0;
     317            0 :             libspdm_encapsulated_request_response->header.param2 = 0;
     318              : 
     319            0 :             spdm_response = (void *)(temp_buf_ptr + sizeof(spdm_encapsulated_request_response_t));
     320            0 :             spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_11;
     321            0 :             spdm_response->header.request_response_code = SPDM_GET_DIGESTS;
     322            0 :             spdm_response->header.param1 = 0;
     323            0 :             spdm_response->header.param2 = 0;
     324            0 :             libspdm_set_mem(m_libspdm_local_certificate_chain,
     325              :                             sizeof(m_libspdm_local_certificate_chain),
     326              :                             (uint8_t) (0xFF));
     327              : 
     328            0 :             digest = (void *)(spdm_response + 1);
     329            0 :             libspdm_hash_all(m_libspdm_use_hash_algo, m_libspdm_local_certificate_chain,
     330              :                              sizeof(m_libspdm_local_certificate_chain), &digest[0]);
     331            0 :             spdm_response->header.param2 |= (0x01 << 0);
     332            0 :             sub_index++;
     333            0 :         } else if (sub_index == 1) {
     334              :             spdm_encapsulated_response_ack_response_t* spdm_encapsulated_response_ack_response;
     335            0 :             temp_buf_size = sizeof(spdm_encapsulated_response_ack_response_t);
     336            0 :             libspdm_zero_mem(temp_buf, LIBSPDM_RECEIVER_BUFFER_SIZE);
     337            0 :             temp_buf_ptr = temp_buf + sizeof(libspdm_test_message_header_t);
     338            0 :             spdm_encapsulated_response_ack_response = (void *)temp_buf_ptr;
     339            0 :             spdm_encapsulated_response_ack_response->header.spdm_version = SPDM_MESSAGE_VERSION_11;
     340            0 :             spdm_encapsulated_response_ack_response->header.request_response_code =
     341              :                 SPDM_ENCAPSULATED_RESPONSE_ACK;
     342            0 :             spdm_encapsulated_response_ack_response->header.param1 = 0;
     343            0 :             spdm_encapsulated_response_ack_response->header.param2 = 0;
     344            0 :             sub_index = 0;
     345              :         } else {
     346            0 :             temp_buf_size = 0;
     347            0 :             temp_buf_ptr = NULL;
     348              :         }
     349            0 :         libspdm_transport_test_encode_message(spdm_context, NULL, false, false,
     350              :                                               temp_buf_size, temp_buf_ptr,
     351              :                                               response_size, response);
     352              :     }
     353            0 :         return LIBSPDM_STATUS_SUCCESS;
     354            2 :     case 0x7:
     355              :     {
     356              :         spdm_digest_response_t *spdm_response;
     357              : 
     358            2 :         ((libspdm_context_t *)spdm_context)->connection_info.algorithm.base_hash_algo =
     359              :             m_libspdm_use_hash_algo;
     360            2 :         if (sub_index == 0) {
     361            1 :             temp_buf_size = sizeof(spdm_digest_response_t) +
     362            1 :                             libspdm_get_hash_size(m_libspdm_use_hash_algo) +
     363              :                             sizeof(spdm_encapsulated_request_response_t);
     364            1 :             libspdm_zero_mem(temp_buf, LIBSPDM_RECEIVER_BUFFER_SIZE);
     365            1 :             temp_buf_ptr = temp_buf + sizeof(libspdm_test_message_header_t);
     366            1 :             libspdm_encapsulated_request_response = (void *)temp_buf_ptr;
     367            1 :             libspdm_encapsulated_request_response->header.spdm_version = SPDM_MESSAGE_VERSION_11;
     368            1 :             libspdm_encapsulated_request_response->header.request_response_code =
     369              :                 SPDM_ENCAPSULATED_REQUEST;
     370            1 :             libspdm_encapsulated_request_response->header.param1 = 0;
     371            1 :             libspdm_encapsulated_request_response->header.param2 = 0;
     372              : 
     373            1 :             spdm_response = (void *)(temp_buf_ptr + sizeof(spdm_encapsulated_request_response_t));
     374            1 :             spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_11;
     375            1 :             spdm_response->header.request_response_code = SPDM_GET_DIGESTS;
     376            1 :             spdm_response->header.param1 = 0;
     377            1 :             spdm_response->header.param2 = 0;
     378            1 :             libspdm_set_mem(m_libspdm_local_certificate_chain,
     379              :                             sizeof(m_libspdm_local_certificate_chain),
     380              :                             (uint8_t)(0xFF));
     381              : 
     382            1 :             digest = (void *)(spdm_response + 1);
     383            1 :             libspdm_hash_all(m_libspdm_use_hash_algo, m_libspdm_local_certificate_chain,
     384              :                              sizeof(m_libspdm_local_certificate_chain), &digest[0]);
     385            1 :             spdm_response->header.param2 |= (0x01 << 0);
     386            1 :             sub_index++;
     387            1 :         } else if (sub_index == 1) {
     388              :             spdm_encapsulated_response_ack_response_t *spdm_encapsulated_response_ack_response;
     389            1 :             temp_buf_size = sizeof(spdm_encapsulated_response_ack_response_t);
     390            1 :             libspdm_zero_mem(temp_buf, LIBSPDM_RECEIVER_BUFFER_SIZE);
     391            1 :             temp_buf_ptr = temp_buf + sizeof(libspdm_test_message_header_t);
     392            1 :             spdm_encapsulated_response_ack_response = (void *) temp_buf_ptr;
     393            1 :             spdm_encapsulated_response_ack_response->header.spdm_version = SPDM_MESSAGE_VERSION_11;
     394            1 :             spdm_encapsulated_response_ack_response->header.request_response_code =
     395              :                 SPDM_ENCAPSULATED_RESPONSE_ACK;
     396            1 :             spdm_encapsulated_response_ack_response->header.param1 = 0;
     397            1 :             spdm_encapsulated_response_ack_response->header.param2 =
     398              :                 SPDM_ENCAPSULATED_RESPONSE_ACK_RESPONSE_PAYLOAD_TYPE_REQ_SLOT_NUMBER;
     399            1 :             sub_index = 0;
     400              :         } else {
     401            0 :             temp_buf_size = 0;
     402            0 :             temp_buf_ptr = NULL;
     403              :         }
     404            2 :         libspdm_transport_test_encode_message(spdm_context, NULL, false, false,
     405              :                                               temp_buf_size, temp_buf_ptr,
     406              :                                               response_size, response);
     407              :     }
     408            2 :         return LIBSPDM_STATUS_SUCCESS;
     409            2 :     case 0x8:
     410              :     {
     411              :         spdm_get_certificate_request_t *spdm_response;
     412              : 
     413            2 :         ((libspdm_context_t *)spdm_context)->connection_info.algorithm.base_hash_algo =
     414              :             m_libspdm_use_hash_algo;
     415            2 :         if (sub_index == 0) {
     416            1 :             temp_buf_size = sizeof(spdm_get_certificate_request_t) +
     417              :                             sizeof(spdm_encapsulated_request_response_t);
     418            1 :             libspdm_zero_mem(temp_buf, LIBSPDM_RECEIVER_BUFFER_SIZE);
     419            1 :             temp_buf_ptr = temp_buf + sizeof(libspdm_test_message_header_t);
     420            1 :             libspdm_encapsulated_request_response = (void *)temp_buf_ptr;
     421            1 :             libspdm_encapsulated_request_response->header.spdm_version = SPDM_MESSAGE_VERSION_11;
     422            1 :             libspdm_encapsulated_request_response->header.request_response_code =
     423              :                 SPDM_ENCAPSULATED_REQUEST;
     424            1 :             libspdm_encapsulated_request_response->header.param1 = 0;
     425            1 :             libspdm_encapsulated_request_response->header.param2 = 0;
     426              : 
     427            1 :             spdm_response = (void *)(temp_buf_ptr + sizeof(spdm_encapsulated_request_response_t));
     428            1 :             spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_11;
     429            1 :             spdm_response->header.request_response_code = SPDM_GET_CERTIFICATE;
     430            1 :             spdm_response->header.param1 = 0;
     431            1 :             spdm_response->header.param2 = 0;
     432            1 :             spdm_response->offset = 0;
     433            1 :             spdm_response->length = LIBSPDM_MAX_CERT_CHAIN_BLOCK_LEN;
     434            1 :             sub_index++;
     435            1 :         } else if (sub_index == 1) {
     436              :             /* When the version is SPDM_MESSAGE_VERSION_12, use the following code. */
     437              :             spdm_message_header_t *spdm_encapsulated_response_ack_response;
     438            1 :             temp_buf_size = sizeof(spdm_message_header_t);
     439            1 :             libspdm_zero_mem(temp_buf, LIBSPDM_RECEIVER_BUFFER_SIZE);
     440            1 :             temp_buf_ptr = temp_buf + sizeof(libspdm_test_message_header_t);
     441            1 :             spdm_encapsulated_response_ack_response = (void *)temp_buf_ptr;
     442            1 :             spdm_encapsulated_response_ack_response->spdm_version = SPDM_MESSAGE_VERSION_11;
     443            1 :             spdm_encapsulated_response_ack_response->request_response_code =
     444              :                 SPDM_ENCAPSULATED_RESPONSE_ACK;
     445            1 :             spdm_encapsulated_response_ack_response->param1 = 0;
     446            1 :             spdm_encapsulated_response_ack_response->param2 =
     447              :                 SPDM_ENCAPSULATED_RESPONSE_ACK_RESPONSE_PAYLOAD_TYPE_ABSENT;
     448            1 :             sub_index = 0;
     449              :         } else {
     450            0 :             temp_buf_size = 0;
     451            0 :             temp_buf_ptr = NULL;
     452              :         }
     453            2 :         libspdm_transport_test_encode_message(spdm_context, NULL, false, false,
     454              :                                               temp_buf_size, temp_buf_ptr,
     455              :                                               response_size, response);
     456              :     }
     457            2 :         return LIBSPDM_STATUS_SUCCESS;
     458              : 
     459            2 :     case 0x9:
     460              :     {
     461              :         spdm_key_update_request_t *spdm_response;
     462              : 
     463            2 :         ((libspdm_context_t *)spdm_context)->connection_info.algorithm.base_hash_algo =
     464              :             m_libspdm_use_hash_algo;
     465            2 :         if (sub_index == 0) {
     466            1 :             temp_buf_size = sizeof(spdm_key_update_request_t) +
     467              :                             sizeof(spdm_encapsulated_request_response_t);
     468            1 :             libspdm_zero_mem(temp_buf, LIBSPDM_RECEIVER_BUFFER_SIZE);
     469            1 :             temp_buf_ptr = temp_buf + sizeof(libspdm_test_message_header_t);
     470            1 :             libspdm_encapsulated_request_response = (void *)temp_buf_ptr;
     471            1 :             libspdm_encapsulated_request_response->header.spdm_version = SPDM_MESSAGE_VERSION_11;
     472            1 :             libspdm_encapsulated_request_response->header.request_response_code =
     473              :                 SPDM_ENCAPSULATED_REQUEST;
     474            1 :             libspdm_encapsulated_request_response->header.param1 = 0;
     475            1 :             libspdm_encapsulated_request_response->header.param2 = 0;
     476              : 
     477            1 :             spdm_response = (void *)(temp_buf_ptr + sizeof(spdm_encapsulated_request_response_t));
     478            1 :             spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_11;
     479            1 :             spdm_response->header.request_response_code = SPDM_KEY_UPDATE;
     480            1 :             spdm_response->header.param1 = SPDM_KEY_UPDATE_OPERATIONS_TABLE_UPDATE_KEY;
     481            1 :             spdm_response->header.param2 = 0x3;
     482              : 
     483            1 :             sub_index++;
     484            1 :         } else if (sub_index == 1) {
     485              :             /* When the version is SPDM_MESSAGE_VERSION_12, use the following code. */
     486              :             spdm_message_header_t *spdm_encapsulated_response_ack_response;
     487            1 :             temp_buf_size = sizeof(spdm_message_header_t);
     488            1 :             libspdm_zero_mem(temp_buf, LIBSPDM_RECEIVER_BUFFER_SIZE);
     489            1 :             temp_buf_ptr = temp_buf + sizeof(libspdm_test_message_header_t);
     490            1 :             spdm_encapsulated_response_ack_response = (void *)temp_buf_ptr;
     491            1 :             spdm_encapsulated_response_ack_response->spdm_version = SPDM_MESSAGE_VERSION_11;
     492            1 :             spdm_encapsulated_response_ack_response->request_response_code =
     493              :                 SPDM_ENCAPSULATED_RESPONSE_ACK;
     494            1 :             spdm_encapsulated_response_ack_response->param1 = 0;
     495            1 :             spdm_encapsulated_response_ack_response->param2 =
     496              :                 SPDM_ENCAPSULATED_RESPONSE_ACK_RESPONSE_PAYLOAD_TYPE_ABSENT;
     497            1 :             sub_index = 0;
     498              :         } else {
     499            0 :             temp_buf_size = 0;
     500            0 :             temp_buf_ptr = NULL;
     501              :         }
     502            2 :         libspdm_transport_test_encode_message(spdm_context, NULL, false, false,
     503              :                                               temp_buf_size, temp_buf_ptr,
     504              :                                               response_size, response);
     505              :     }
     506            2 :         return LIBSPDM_STATUS_SUCCESS;
     507              : 
     508            2 :     case 0xA:
     509              :     {
     510              :         spdm_get_encapsulated_request_request_t *spdm_response;
     511              : 
     512            2 :         if (sub_index == 0) {
     513            1 :             temp_buf_size = sizeof(spdm_encapsulated_request_response_t) +
     514              :                             sizeof(spdm_get_encapsulated_request_request_t);
     515            1 :             libspdm_zero_mem(temp_buf, LIBSPDM_RECEIVER_BUFFER_SIZE);
     516            1 :             temp_buf_ptr = temp_buf + sizeof(libspdm_test_message_header_t);
     517              : 
     518              :             /* The following is ENCAPSULATED_REQUEST response message */
     519            1 :             libspdm_encapsulated_request_response = (void *) temp_buf_ptr;
     520            1 :             libspdm_encapsulated_request_response->header.spdm_version = SPDM_MESSAGE_VERSION_11;
     521            1 :             libspdm_encapsulated_request_response->header.request_response_code =
     522              :                 SPDM_ENCAPSULATED_REQUEST;
     523            1 :             libspdm_encapsulated_request_response->header.param1 = 0;
     524            1 :             libspdm_encapsulated_request_response->header.param2 = 0;
     525              : 
     526              :             /* The following is EncapsulatedRequest Field of the above ENCAPSULATED_REQUEST response message*/
     527            1 :             spdm_response =
     528              :                 (void *)(temp_buf_ptr + sizeof(spdm_get_encapsulated_request_request_t));
     529              : 
     530              :             /* Here invalid: GET_ENCAPSULATED_REQUEST is encapsulated. */
     531            1 :             spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_11;
     532            1 :             spdm_response->header.request_response_code = SPDM_GET_ENCAPSULATED_REQUEST;
     533            1 :             spdm_response->header.param1 = 0;
     534            1 :             spdm_response->header.param2 = 0;
     535              : 
     536            1 :             sub_index++;
     537            1 :         } else if (sub_index == 1) {
     538              :             spdm_message_header_t *spdm_encapsulated_response_ack_response;
     539            1 :             temp_buf_size = sizeof(spdm_message_header_t);
     540            1 :             libspdm_zero_mem(temp_buf, LIBSPDM_RECEIVER_BUFFER_SIZE);
     541            1 :             temp_buf_ptr = temp_buf + sizeof(libspdm_test_message_header_t);
     542            1 :             spdm_encapsulated_response_ack_response = (void *)temp_buf_ptr;
     543            1 :             spdm_encapsulated_response_ack_response->spdm_version = SPDM_MESSAGE_VERSION_11;
     544            1 :             spdm_encapsulated_response_ack_response->request_response_code =
     545              :                 SPDM_ENCAPSULATED_RESPONSE_ACK;
     546            1 :             spdm_encapsulated_response_ack_response->param1 = 0;
     547            1 :             spdm_encapsulated_response_ack_response->param2 =
     548              :                 SPDM_ENCAPSULATED_RESPONSE_ACK_RESPONSE_PAYLOAD_TYPE_ABSENT;
     549            1 :             sub_index = 0;
     550              :         } else {
     551            0 :             temp_buf_size = 0;
     552            0 :             temp_buf_ptr = NULL;
     553              :         }
     554            2 :         libspdm_transport_test_encode_message(spdm_context, NULL, false, false,
     555              :                                               temp_buf_size, temp_buf_ptr,
     556              :                                               response_size, response);
     557              :     }
     558            2 :         return LIBSPDM_STATUS_SUCCESS;
     559              : 
     560            1 :     case 0xB:
     561              :     {
     562              :         spdm_error_response_t *spdm_response;
     563              : 
     564            1 :         temp_buf_size = sizeof(spdm_error_response_t);
     565            1 :         libspdm_zero_mem(temp_buf, LIBSPDM_RECEIVER_BUFFER_SIZE);
     566            1 :         temp_buf_ptr = temp_buf + sizeof(libspdm_test_message_header_t);
     567            1 :         spdm_response = (void *) temp_buf_ptr;
     568            1 :         spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_11;
     569            1 :         spdm_response->header.request_response_code = SPDM_ERROR;
     570            1 :         spdm_response->header.param1 = SPDM_ERROR_CODE_UNEXPECTED_REQUEST;
     571            1 :         spdm_response->header.param2 = 0;
     572              : 
     573            1 :         libspdm_transport_test_encode_message(spdm_context, NULL, false, false,
     574              :                                               temp_buf_size, temp_buf_ptr,
     575              :                                               response_size, response);
     576              :     }
     577            1 :         return LIBSPDM_STATUS_SUCCESS;
     578              : 
     579            1 :     case 0xC:
     580              :     {
     581              :         spdm_error_response_t *spdm_response;
     582              : 
     583            1 :         temp_buf_size = sizeof(spdm_error_response_t);
     584            1 :         libspdm_zero_mem(temp_buf, LIBSPDM_RECEIVER_BUFFER_SIZE);
     585            1 :         temp_buf_ptr = temp_buf + sizeof(libspdm_test_message_header_t);
     586            1 :         spdm_response = (void *) temp_buf_ptr;
     587            1 :         spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_13;
     588            1 :         spdm_response->header.request_response_code = SPDM_ERROR;
     589            1 :         spdm_response->header.param1 = SPDM_ERROR_CODE_NO_PENDING_REQUESTS;
     590            1 :         spdm_response->header.param2 = 0;
     591              : 
     592            1 :         libspdm_transport_test_encode_message(spdm_context, NULL, false, false,
     593              :                                               temp_buf_size, temp_buf_ptr,
     594              :                                               response_size, response);
     595              :     }
     596            1 :         return LIBSPDM_STATUS_SUCCESS;
     597              : 
     598            2 :     case 0xD:
     599              :     {
     600              :         spdm_get_endpoint_info_request_t *spdm_response;
     601              :         uint8_t *spdm_nonce;
     602              : 
     603            2 :         ((libspdm_context_t *)spdm_context)->connection_info.algorithm.base_hash_algo =
     604              :             m_libspdm_use_hash_algo;
     605            2 :         if (sub_index == 0) {
     606            1 :             temp_buf_size = sizeof(spdm_encapsulated_request_response_t) +
     607              :                             sizeof(spdm_get_endpoint_info_request_t) + SPDM_NONCE_SIZE;
     608            1 :             libspdm_zero_mem(temp_buf, LIBSPDM_RECEIVER_BUFFER_SIZE);
     609            1 :             temp_buf_ptr = temp_buf + sizeof(libspdm_test_message_header_t);
     610            1 :             libspdm_encapsulated_request_response = (void *)temp_buf_ptr;
     611            1 :             libspdm_encapsulated_request_response->header.spdm_version = SPDM_MESSAGE_VERSION_13;
     612            1 :             libspdm_encapsulated_request_response->header.request_response_code =
     613              :                 SPDM_ENCAPSULATED_REQUEST;
     614            1 :             libspdm_encapsulated_request_response->header.param1 = 0;
     615            1 :             libspdm_encapsulated_request_response->header.param2 = 0;
     616              : 
     617            1 :             spdm_response = (void *)(temp_buf_ptr + sizeof(spdm_encapsulated_request_response_t));
     618            1 :             spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_13;
     619            1 :             spdm_response->header.request_response_code = SPDM_GET_ENDPOINT_INFO;
     620            1 :             spdm_response->header.param1 =
     621              :                 SPDM_GET_ENDPOINT_INFO_REQUEST_SUBCODE_DEVICE_CLASS_IDENTIFIER;
     622            1 :             spdm_response->header.param2 = 0; /* slot_id */
     623            1 :             spdm_response->request_attributes =
     624              :                 SPDM_GET_ENDPOINT_INFO_REQUEST_ATTRIBUTE_SIGNATURE_REQUESTED;
     625            1 :             libspdm_write_uint24(spdm_response->reserved, 0);
     626            1 :             spdm_nonce = (uint8_t *)(spdm_response + 1);
     627            1 :             libspdm_get_random_number(SPDM_NONCE_SIZE, spdm_nonce);
     628              : 
     629            1 :             sub_index++;
     630            1 :         } else if (sub_index == 1) {
     631              :             spdm_encapsulated_response_ack_response_t *spdm_encapsulated_response_ack_response;
     632            1 :             temp_buf_size = sizeof(spdm_encapsulated_response_ack_response_t);
     633            1 :             libspdm_zero_mem(temp_buf, LIBSPDM_RECEIVER_BUFFER_SIZE);
     634            1 :             temp_buf_ptr = temp_buf + sizeof(libspdm_test_message_header_t);
     635            1 :             spdm_encapsulated_response_ack_response = (void *)temp_buf_ptr;
     636            1 :             spdm_encapsulated_response_ack_response->header.spdm_version = SPDM_MESSAGE_VERSION_13;
     637            1 :             spdm_encapsulated_response_ack_response->header.request_response_code =
     638              :                 SPDM_ENCAPSULATED_RESPONSE_ACK;
     639            1 :             spdm_encapsulated_response_ack_response->header.param1 = 0;
     640            1 :             spdm_encapsulated_response_ack_response->header.param2 =
     641              :                 SPDM_ENCAPSULATED_RESPONSE_ACK_RESPONSE_PAYLOAD_TYPE_ABSENT;
     642            1 :             spdm_encapsulated_response_ack_response->ack_request_id = 0;
     643            1 :             libspdm_write_uint24(spdm_encapsulated_response_ack_response->reserved, 0);
     644              : 
     645            1 :             sub_index = 0;
     646              :         } else {
     647            0 :             temp_buf_size = 0;
     648            0 :             temp_buf_ptr = NULL;
     649              :         }
     650            2 :         libspdm_transport_test_encode_message(spdm_context, NULL, false, false,
     651              :                                               temp_buf_size, temp_buf_ptr,
     652              :                                               response_size, response);
     653              :     }
     654            2 :         return LIBSPDM_STATUS_SUCCESS;
     655            1 :     case 0xE:
     656              :     {
     657              :         spdm_error_response_t *spdm_response;
     658              : 
     659            1 :         temp_buf_size = sizeof(spdm_error_response_t);
     660            1 :         libspdm_zero_mem(temp_buf, LIBSPDM_RECEIVER_BUFFER_SIZE);
     661            1 :         temp_buf_ptr = temp_buf + sizeof(libspdm_test_message_header_t);
     662            1 :         spdm_response = (void *) temp_buf_ptr;
     663            1 :         spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
     664            1 :         spdm_response->header.request_response_code = SPDM_ERROR;
     665            1 :         spdm_response->header.param1 = SPDM_ERROR_CODE_REQUEST_RESYNCH;
     666            1 :         spdm_response->header.param2 = 0;
     667            1 :         libspdm_transport_test_encode_message(spdm_context, NULL, false, false,
     668              :                                               temp_buf_size, temp_buf_ptr,
     669              :                                               response_size, response);
     670              :     }
     671            1 :         return LIBSPDM_STATUS_SUCCESS;
     672            2 :     case 0xF:
     673              :     {
     674              :         spdm_digest_response_t *spdm_response;
     675              : 
     676            2 :         ((libspdm_context_t *)spdm_context)->connection_info.algorithm.base_hash_algo =
     677              :             m_libspdm_use_hash_algo;
     678            2 :         if (sub_index == 0) {
     679            1 :             temp_buf_size = sizeof(spdm_digest_response_t) +
     680            1 :                             libspdm_get_hash_size(m_libspdm_use_hash_algo) +
     681              :                             sizeof(spdm_encapsulated_request_response_t);
     682            1 :             libspdm_zero_mem(temp_buf, LIBSPDM_RECEIVER_BUFFER_SIZE);
     683            1 :             temp_buf_ptr = temp_buf + sizeof(libspdm_test_message_header_t);
     684            1 :             libspdm_encapsulated_request_response = (void *)temp_buf_ptr;
     685            1 :             libspdm_encapsulated_request_response->header.spdm_version = SPDM_MESSAGE_VERSION_11;
     686            1 :             libspdm_encapsulated_request_response->header.request_response_code =
     687              :                 SPDM_ENCAPSULATED_REQUEST;
     688            1 :             libspdm_encapsulated_request_response->header.param1 = 0;
     689            1 :             libspdm_encapsulated_request_response->header.param2 = 0;
     690              : 
     691            1 :             spdm_response = (void *)(temp_buf_ptr + sizeof(spdm_encapsulated_request_response_t));
     692            1 :             spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_11;
     693            1 :             spdm_response->header.request_response_code = SPDM_GET_DIGESTS;
     694            1 :             spdm_response->header.param1 = 0;
     695            1 :             spdm_response->header.param2 = 0;
     696            1 :             libspdm_set_mem(m_libspdm_local_certificate_chain,
     697              :                             sizeof(m_libspdm_local_certificate_chain),
     698              :                             (uint8_t)(0xFF));
     699              : 
     700            1 :             digest = (void *)(spdm_response + 1);
     701            1 :             libspdm_hash_all(m_libspdm_use_hash_algo, m_libspdm_local_certificate_chain,
     702              :                              sizeof(m_libspdm_local_certificate_chain), &digest[0]);
     703            1 :             spdm_response->header.param2 |= (0x01 << 0);
     704            1 :             sub_index++;
     705            1 :         } else if (sub_index == 1) {
     706            1 :             temp_buf_size = sizeof(spdm_error_response_t);
     707            1 :             libspdm_zero_mem(temp_buf, LIBSPDM_RECEIVER_BUFFER_SIZE);
     708            1 :             temp_buf_ptr = temp_buf + sizeof(libspdm_test_message_header_t);
     709            1 :             spdm_response = (void *) temp_buf_ptr;
     710            1 :             spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
     711            1 :             spdm_response->header.request_response_code = SPDM_ERROR;
     712            1 :             spdm_response->header.param1 = SPDM_ERROR_CODE_REQUEST_RESYNCH;
     713            1 :             spdm_response->header.param2 = 0;
     714            1 :             sub_index = 0;
     715              :         } else {
     716            0 :             temp_buf_size = 0;
     717            0 :             temp_buf_ptr = NULL;
     718              :         }
     719            2 :         libspdm_transport_test_encode_message(spdm_context, NULL, false, false,
     720              :                                               temp_buf_size, temp_buf_ptr,
     721              :                                               response_size, response);
     722              :     }
     723            2 :         return LIBSPDM_STATUS_SUCCESS;
     724            0 :     default:
     725            0 :         return LIBSPDM_STATUS_RECEIVE_FAIL;
     726              :     }
     727              : }
     728              : 
     729              : #if (LIBSPDM_ENABLE_CAPABILITY_MUT_AUTH_CAP) && (LIBSPDM_ENABLE_CAPABILITY_CERT_CAP)
     730            1 : static void req_get_encapsulated_request_case1(void **State)
     731              : {
     732              :     libspdm_return_t status;
     733              :     libspdm_test_context_t *spdm_test_context;
     734              :     libspdm_context_t *spdm_context;
     735              :     void *data;
     736              :     size_t data_size;
     737              :     void *hash;
     738              :     size_t hash_size;
     739              : 
     740            1 :     spdm_test_context = *State;
     741            1 :     spdm_context = spdm_test_context->spdm_context;
     742            1 :     spdm_test_context->case_id = 0x1;
     743              : 
     744            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_11 <<
     745              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
     746            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_NEGOTIATED;
     747            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP;
     748            1 :     spdm_context->connection_info.capability.flags |=
     749              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP;
     750            1 :     spdm_context->connection_info.capability.flags |=
     751              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCAP_CAP;
     752              : 
     753            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP;
     754            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP;
     755            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP;
     756            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP;
     757            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCAP_CAP;
     758            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CERT_CAP;
     759              : 
     760              : 
     761            1 :     if (!libspdm_read_responder_public_certificate_chain(m_libspdm_use_hash_algo,
     762              :                                                          m_libspdm_use_asym_algo, &data,
     763              :                                                          &data_size,
     764              :                                                          &hash, &hash_size)) {
     765            0 :         assert(false);
     766              :     }
     767            1 :     libspdm_reset_message_a(spdm_context);
     768            1 :     spdm_context->connection_info.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
     769            1 :     spdm_context->connection_info.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
     770            1 :     spdm_context->connection_info.algorithm.dhe_named_group = m_libspdm_use_dhe_algo;
     771            1 :     spdm_context->connection_info.algorithm.aead_cipher_suite = m_libspdm_use_aead_algo;
     772              : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
     773              :     spdm_context->connection_info.peer_used_cert_chain[0].buffer_size = data_size;
     774              :     libspdm_copy_mem(spdm_context->connection_info.peer_used_cert_chain[0].buffer,
     775              :                      sizeof(spdm_context->connection_info.peer_used_cert_chain[0].buffer),
     776              :                      data, data_size);
     777              : #endif
     778              : 
     779            1 :     libspdm_register_get_encap_response_func(spdm_context, libspdm_get_encap_response_digest);
     780            1 :     status = libspdm_encapsulated_request(spdm_context, NULL, 0, NULL);
     781            1 :     assert_int_equal(status, LIBSPDM_STATUS_SEND_FAIL);
     782            1 :     free(data);
     783            1 : }
     784              : 
     785            1 : static void req_get_encapsulated_request_case2(void **State)
     786              : {
     787              :     libspdm_return_t status;
     788              :     libspdm_test_context_t *spdm_test_context;
     789              :     libspdm_context_t *spdm_context;
     790              :     void *data;
     791              :     size_t data_size;
     792              :     void *hash;
     793              :     size_t hash_size;
     794              : 
     795            1 :     spdm_test_context = *State;
     796            1 :     spdm_context = spdm_test_context->spdm_context;
     797            1 :     spdm_test_context->case_id = 0x2;
     798              : 
     799            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_11 <<
     800              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
     801            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_NEGOTIATED;
     802            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP;
     803            1 :     spdm_context->connection_info.capability.flags |=
     804              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP;
     805            1 :     spdm_context->connection_info.capability.flags |=
     806              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCAP_CAP;
     807            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP;
     808              : 
     809            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP;
     810            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP;
     811            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP;
     812            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCAP_CAP;
     813            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CERT_CAP;
     814              : 
     815              : 
     816            1 :     if (!libspdm_read_responder_public_certificate_chain(m_libspdm_use_hash_algo,
     817              :                                                          m_libspdm_use_asym_algo, &data,
     818              :                                                          &data_size,
     819              :                                                          &hash, &hash_size)) {
     820            0 :         assert(false);
     821              :     }
     822            1 :     libspdm_reset_message_a(spdm_context);
     823            1 :     spdm_context->connection_info.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
     824            1 :     spdm_context->connection_info.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
     825            1 :     spdm_context->connection_info.algorithm.dhe_named_group = m_libspdm_use_dhe_algo;
     826            1 :     spdm_context->connection_info.algorithm.aead_cipher_suite = m_libspdm_use_aead_algo;
     827              : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
     828              :     spdm_context->connection_info.peer_used_cert_chain[0].buffer_size = data_size;
     829              :     libspdm_copy_mem(spdm_context->connection_info.peer_used_cert_chain[0].buffer,
     830              :                      sizeof(spdm_context->connection_info.peer_used_cert_chain[0].buffer),
     831              :                      data, data_size);
     832              : #endif
     833              : 
     834            1 :     libspdm_register_get_encap_response_func(spdm_context, libspdm_get_encap_response_digest);
     835            1 :     status = libspdm_encapsulated_request(spdm_context, NULL, 0, NULL);
     836            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
     837            1 :     free(data);
     838            1 : }
     839              : 
     840            1 : static void req_get_encapsulated_request_case3(void **State)
     841              : {
     842            1 : }
     843              : 
     844            1 : static void req_get_encapsulated_request_case4(void **State)
     845              : {
     846              :     libspdm_return_t status;
     847              :     libspdm_test_context_t *spdm_test_context;
     848              :     libspdm_context_t *spdm_context;
     849              :     void *data;
     850              :     size_t data_size;
     851              :     void *hash;
     852              :     size_t hash_size;
     853              : 
     854            1 :     spdm_test_context = *State;
     855            1 :     spdm_context = spdm_test_context->spdm_context;
     856            1 :     spdm_test_context->case_id = 0x4;
     857              : 
     858            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_11 <<
     859              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
     860            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_NEGOTIATED;
     861            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP;
     862            1 :     spdm_context->connection_info.capability.flags |=
     863              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP;
     864            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP;
     865            1 :     spdm_context->connection_info.capability.flags |=
     866              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCAP_CAP;
     867              : 
     868            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP;
     869            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP;
     870            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP;
     871            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCAP_CAP;
     872            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CERT_CAP;
     873              : 
     874            1 :     if (!libspdm_read_responder_public_certificate_chain(m_libspdm_use_hash_algo,
     875              :                                                          m_libspdm_use_asym_algo, &data,
     876              :                                                          &data_size,
     877              :                                                          &hash, &hash_size)) {
     878            0 :         assert(false);
     879              :     }
     880            1 :     libspdm_reset_message_a(spdm_context);
     881            1 :     spdm_context->connection_info.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
     882            1 :     spdm_context->connection_info.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
     883            1 :     spdm_context->connection_info.algorithm.dhe_named_group = m_libspdm_use_dhe_algo;
     884            1 :     spdm_context->connection_info.algorithm.aead_cipher_suite = m_libspdm_use_aead_algo;
     885              : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
     886              :     spdm_context->connection_info.peer_used_cert_chain[0].buffer_size = data_size;
     887              :     libspdm_copy_mem(spdm_context->connection_info.peer_used_cert_chain[0].buffer,
     888              :                      sizeof(spdm_context->connection_info.peer_used_cert_chain[0].buffer),
     889              :                      data, data_size);
     890              : #endif
     891              : 
     892            1 :     libspdm_register_get_encap_response_func(spdm_context, libspdm_get_encap_response_digest);
     893            1 :     status = libspdm_encapsulated_request(spdm_context, NULL, 0, NULL);
     894            1 :     assert_int_equal(status, LIBSPDM_STATUS_INVALID_MSG_SIZE);
     895            1 :     free(data);
     896            1 : }
     897              : 
     898            1 : static void req_get_encapsulated_request_case5(void **State)
     899              : {
     900              :     libspdm_return_t status;
     901              :     libspdm_test_context_t *spdm_test_context;
     902              :     libspdm_context_t *spdm_context;
     903              :     void *data;
     904              :     size_t data_size;
     905              :     void *hash;
     906              :     size_t hash_size;
     907              : 
     908            1 :     spdm_test_context = *State;
     909            1 :     spdm_context = spdm_test_context->spdm_context;
     910            1 :     spdm_test_context->case_id = 0x5;
     911              : 
     912            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_11 <<
     913              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
     914            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_NEGOTIATED;
     915            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP;
     916            1 :     spdm_context->connection_info.capability.flags |=
     917              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP;
     918            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP;
     919            1 :     spdm_context->connection_info.capability.flags |=
     920              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCAP_CAP;
     921              : 
     922            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP;
     923            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP;
     924            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP;
     925            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCAP_CAP;
     926            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CERT_CAP;
     927              : 
     928            1 :     if (!libspdm_read_responder_public_certificate_chain(m_libspdm_use_hash_algo,
     929              :                                                          m_libspdm_use_asym_algo, &data,
     930              :                                                          &data_size,
     931              :                                                          &hash, &hash_size)) {
     932            0 :         assert(false);
     933              :     }
     934            1 :     libspdm_reset_message_a(spdm_context);
     935            1 :     spdm_context->connection_info.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
     936            1 :     spdm_context->connection_info.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
     937            1 :     spdm_context->connection_info.algorithm.dhe_named_group = m_libspdm_use_dhe_algo;
     938            1 :     spdm_context->connection_info.algorithm.aead_cipher_suite = m_libspdm_use_aead_algo;
     939              : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
     940              :     spdm_context->connection_info.peer_used_cert_chain[0].buffer_size = data_size;
     941              :     libspdm_copy_mem(spdm_context->connection_info.peer_used_cert_chain[0].buffer,
     942              :                      sizeof(spdm_context->connection_info.peer_used_cert_chain[0].buffer),
     943              :                      data, data_size);
     944              : #endif
     945              : 
     946            1 :     libspdm_register_get_encap_response_func(spdm_context, libspdm_get_encap_response_digest);
     947            1 :     status = libspdm_encapsulated_request(spdm_context, NULL, 0, NULL);
     948            1 :     assert_int_equal(status, LIBSPDM_STATUS_INVALID_MSG_FIELD);
     949            1 :     free(data);
     950            1 : }
     951              : 
     952            1 : static void req_get_encapsulated_request_case6(void **State)
     953              : {
     954            1 : }
     955              : 
     956            1 : static void req_get_encapsulated_request_case7(void **State)
     957              : {
     958              :     libspdm_return_t status;
     959              :     libspdm_test_context_t *spdm_test_context;
     960              :     libspdm_context_t *spdm_context;
     961              :     void *data;
     962              :     size_t data_size;
     963              :     void *hash;
     964              :     size_t hash_size;
     965              : 
     966            1 :     spdm_test_context = *State;
     967            1 :     spdm_context = spdm_test_context->spdm_context;
     968            1 :     spdm_test_context->case_id = 0x7;
     969              : 
     970            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_11 <<
     971              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
     972            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_NEGOTIATED;
     973            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP;
     974            1 :     spdm_context->connection_info.capability.flags |=
     975              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP;
     976            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP;
     977            1 :     spdm_context->connection_info.capability.flags |=
     978              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCAP_CAP;
     979              : 
     980            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP;
     981            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP;
     982            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP;
     983            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCAP_CAP;
     984            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CERT_CAP;
     985              : 
     986            1 :     if (!libspdm_read_responder_public_certificate_chain(m_libspdm_use_hash_algo,
     987              :                                                          m_libspdm_use_asym_algo, &data,
     988              :                                                          &data_size,
     989              :                                                          &hash, &hash_size)) {
     990            0 :         assert(false);
     991              :     }
     992            1 :     libspdm_reset_message_a(spdm_context);
     993            1 :     spdm_context->connection_info.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
     994            1 :     spdm_context->connection_info.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
     995            1 :     spdm_context->connection_info.algorithm.dhe_named_group = m_libspdm_use_dhe_algo;
     996            1 :     spdm_context->connection_info.algorithm.aead_cipher_suite = m_libspdm_use_aead_algo;
     997              : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
     998              :     spdm_context->connection_info.peer_used_cert_chain[0].buffer_size = data_size;
     999              :     libspdm_copy_mem(spdm_context->connection_info.peer_used_cert_chain[0].buffer,
    1000              :                      sizeof(spdm_context->connection_info.peer_used_cert_chain[0].buffer),
    1001              :                      data, data_size);
    1002              : #endif
    1003              : 
    1004            1 :     libspdm_register_get_encap_response_func(spdm_context, libspdm_get_encap_response_digest);
    1005            1 :     status = libspdm_encapsulated_request(spdm_context, NULL, 0, NULL);
    1006            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
    1007            1 :     free(data);
    1008            1 : }
    1009              : 
    1010            1 : static void req_get_encapsulated_request_case8(void **State)
    1011              : {
    1012              :     libspdm_return_t status;
    1013              :     libspdm_test_context_t *spdm_test_context;
    1014              :     libspdm_context_t *spdm_context;
    1015              :     void *data;
    1016              :     size_t data_size;
    1017              :     void *hash;
    1018              :     size_t hash_size;
    1019              : 
    1020            1 :     spdm_test_context = *State;
    1021            1 :     spdm_context = spdm_test_context->spdm_context;
    1022            1 :     spdm_test_context->case_id = 0x8;
    1023              : 
    1024            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_11 <<
    1025              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1026            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_NEGOTIATED;
    1027            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP;
    1028            1 :     spdm_context->connection_info.capability.flags |=
    1029              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP;
    1030            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP;
    1031            1 :     spdm_context->connection_info.capability.flags |=
    1032              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCAP_CAP;
    1033              : 
    1034            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP;
    1035            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP;
    1036            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP;
    1037            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCAP_CAP;
    1038            1 :     spdm_context->local_context.capability.flags |=
    1039              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_CAP;
    1040              : 
    1041            1 :     if (!libspdm_read_responder_public_certificate_chain(m_libspdm_use_hash_algo,
    1042              :                                                          m_libspdm_use_asym_algo, &data,
    1043              :                                                          &data_size,
    1044              :                                                          &hash, &hash_size)) {
    1045            0 :         assert(false);
    1046              :     }
    1047            1 :     spdm_context->local_context.local_cert_chain_provision[0] = data;
    1048            1 :     spdm_context->local_context.local_cert_chain_provision_size[0] = data_size;
    1049              : 
    1050            1 :     libspdm_reset_message_a(spdm_context);
    1051            1 :     spdm_context->connection_info.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    1052            1 :     spdm_context->connection_info.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
    1053            1 :     spdm_context->connection_info.algorithm.dhe_named_group = m_libspdm_use_dhe_algo;
    1054            1 :     spdm_context->connection_info.algorithm.aead_cipher_suite = m_libspdm_use_aead_algo;
    1055              : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
    1056              :     spdm_context->connection_info.peer_used_cert_chain[0].buffer_size = data_size;
    1057              :     libspdm_copy_mem(spdm_context->connection_info.peer_used_cert_chain[0].buffer,
    1058              :                      sizeof(spdm_context->connection_info.peer_used_cert_chain[0].buffer),
    1059              :                      data, data_size);
    1060              : #endif
    1061              : 
    1062            1 :     libspdm_register_get_encap_response_func(spdm_context, libspdm_get_encap_response_certificate);
    1063            1 :     status = libspdm_encapsulated_request(spdm_context, NULL, 0, NULL);
    1064            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
    1065            1 :     free(data);
    1066            1 : }
    1067              : #endif /* (LIBSPDM_ENABLE_CAPABILITY_MUT_AUTH_CAP) && (LIBSPDM_ENABLE_CAPABILITY_CERT_CAP) */
    1068              : 
    1069              : #if ((LIBSPDM_ENABLE_CAPABILITY_KEY_EX_CAP) || (LIBSPDM_ENABLE_CAPABILITY_PSK_CAP))
    1070            1 : static void req_get_encapsulated_request_case9(void **State)
    1071              : {
    1072              :     libspdm_return_t status;
    1073              :     libspdm_test_context_t *spdm_test_context;
    1074              :     libspdm_context_t *spdm_context;
    1075              :     void *data;
    1076              :     size_t data_size;
    1077              :     void *hash;
    1078              :     size_t hash_size;
    1079              : 
    1080            1 :     spdm_test_context = *State;
    1081            1 :     spdm_context = spdm_test_context->spdm_context;
    1082            1 :     spdm_test_context->case_id = 0x9;
    1083              : 
    1084            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_11 <<
    1085              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1086            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_NEGOTIATED;
    1087            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP;
    1088            1 :     spdm_context->connection_info.capability.flags |=
    1089              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP;
    1090            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP;
    1091            1 :     spdm_context->connection_info.capability.flags |=
    1092              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_UPD_CAP;
    1093            1 :     spdm_context->local_context.capability.flags |=
    1094              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_UPD_CAP;
    1095            1 :     spdm_context->connection_info.capability.flags |=
    1096              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCAP_CAP;
    1097              : 
    1098            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP;
    1099            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP;
    1100            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP;
    1101            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCAP_CAP;
    1102              : 
    1103            1 :     if (!libspdm_read_responder_public_certificate_chain(m_libspdm_use_hash_algo,
    1104              :                                                          m_libspdm_use_asym_algo, &data,
    1105              :                                                          &data_size,
    1106              :                                                          &hash, &hash_size)) {
    1107            0 :         assert(false);
    1108              :     }
    1109            1 :     spdm_context->local_context.local_cert_chain_provision[0] = data;
    1110            1 :     spdm_context->local_context.local_cert_chain_provision_size[0] = data_size;
    1111              : 
    1112            1 :     libspdm_reset_message_a(spdm_context);
    1113            1 :     spdm_context->connection_info.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    1114            1 :     spdm_context->connection_info.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
    1115            1 :     spdm_context->connection_info.algorithm.dhe_named_group = m_libspdm_use_dhe_algo;
    1116            1 :     spdm_context->connection_info.algorithm.aead_cipher_suite = m_libspdm_use_aead_algo;
    1117              : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
    1118              :     spdm_context->connection_info.peer_used_cert_chain[0].buffer_size = data_size;
    1119              :     libspdm_copy_mem(spdm_context->connection_info.peer_used_cert_chain[0].buffer,
    1120              :                      sizeof(spdm_context->connection_info.peer_used_cert_chain[0].buffer),
    1121              :                      data, data_size);
    1122              : #endif
    1123              : 
    1124            1 :     libspdm_register_get_encap_response_func(spdm_context, libspdm_get_encap_response_key_update);
    1125            1 :     status = libspdm_encapsulated_request(spdm_context, NULL, 0, NULL);
    1126            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
    1127            1 :     free(data);
    1128            1 : }
    1129              : #endif /* ((LIBSPDM_ENABLE_CAPABILITY_KEY_EX_CAP) || (LIBSPDM_ENABLE_CAPABILITY_PSK_CAP)) */
    1130              : 
    1131              : /**
    1132              :  * Test 10: GET_ENCAPSULATED_REQUEST request message is encapsulated in ENCAPSULATED_REQUEST
    1133              :  *          response message.
    1134              :  * Expected Behavior: the Requester should respond with ErrorCode=UnexpectedRequest.
    1135              :  **/
    1136            1 : static void req_get_encapsulated_request_case10(void **State)
    1137              : {
    1138              :     libspdm_return_t status;
    1139              :     libspdm_test_context_t *spdm_test_context;
    1140              :     libspdm_context_t *spdm_context;
    1141              : 
    1142            1 :     spdm_test_context = *State;
    1143            1 :     spdm_context = spdm_test_context->spdm_context;
    1144            1 :     spdm_test_context->case_id = 0xA;
    1145              : 
    1146            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_11 <<
    1147              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1148            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_NEGOTIATED;
    1149            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCAP_CAP;
    1150            1 :     spdm_context->connection_info.capability.flags |=
    1151              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCAP_CAP;
    1152              : 
    1153            1 :     libspdm_register_get_encap_response_func(spdm_context, NULL);
    1154            1 :     status = libspdm_encapsulated_request(spdm_context, NULL, 0, NULL);
    1155            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
    1156            1 : }
    1157              : 
    1158              : /**
    1159              :  * Test 11: In a non-mutual-authentication context, Requester sends GET_ENCAPSULATED_REQUEST and
    1160              :  *          Responder replies with UnexpectedRequest.
    1161              :  * Expected Behavior: return LIBSPDM_STATUS_SUCCESS as Responder did not have a pending request for
    1162              :  *                    the Requester.
    1163              :  **/
    1164            1 : static void req_get_encapsulated_request_case11(void **State)
    1165              : {
    1166              :     libspdm_return_t status;
    1167              :     libspdm_test_context_t *spdm_test_context;
    1168              :     libspdm_context_t *spdm_context;
    1169              : 
    1170            1 :     spdm_test_context = *State;
    1171            1 :     spdm_context = spdm_test_context->spdm_context;
    1172            1 :     spdm_test_context->case_id = 0xB;
    1173              : 
    1174            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_11 <<
    1175              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1176            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_NEGOTIATED;
    1177            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCAP_CAP;
    1178            1 :     spdm_context->connection_info.capability.flags |=
    1179              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCAP_CAP;
    1180              : 
    1181            1 :     libspdm_register_get_encap_response_func(spdm_context, NULL);
    1182            1 :     status = libspdm_encapsulated_request(spdm_context, NULL, 0, NULL);
    1183            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
    1184            1 : }
    1185              : 
    1186              : /**
    1187              :  * Test 12: In a non-mutual-authentication context, Requester sends GET_ENCAPSULATED_REQUEST and
    1188              :  *          Responder replies with NoPendingRequests.
    1189              :  * Expected Behavior: return LIBSPDM_STATUS_SUCCESS as Responder did not have a pending request for
    1190              :  *                    the Requester.
    1191              :  **/
    1192            1 : static void req_get_encapsulated_request_case12(void **State)
    1193              : {
    1194              :     libspdm_return_t status;
    1195              :     libspdm_test_context_t *spdm_test_context;
    1196              :     libspdm_context_t *spdm_context;
    1197              : 
    1198            1 :     spdm_test_context = *State;
    1199            1 :     spdm_context = spdm_test_context->spdm_context;
    1200            1 :     spdm_test_context->case_id = 0xC;
    1201              : 
    1202            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_13 <<
    1203              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1204            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_NEGOTIATED;
    1205            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCAP_CAP;
    1206            1 :     spdm_context->connection_info.capability.flags |=
    1207              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCAP_CAP;
    1208              : 
    1209            1 :     libspdm_register_get_encap_response_func(spdm_context, NULL);
    1210            1 :     status = libspdm_encapsulated_request(spdm_context, NULL, 0, NULL);
    1211            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
    1212            1 : }
    1213              : 
    1214              : #if LIBSPDM_ENABLE_CAPABILITY_ENDPOINT_INFO_CAP
    1215            1 : static void req_get_encapsulated_request_case13(void **State)
    1216              : {
    1217              :     libspdm_return_t status;
    1218              :     libspdm_test_context_t *spdm_test_context;
    1219              :     libspdm_context_t *spdm_context;
    1220              :     void *data;
    1221              :     size_t data_size;
    1222              :     void *hash;
    1223              :     size_t hash_size;
    1224              : 
    1225            1 :     spdm_test_context = *State;
    1226            1 :     spdm_context = spdm_test_context->spdm_context;
    1227            1 :     spdm_test_context->case_id = 0xD;
    1228              : 
    1229            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_13 <<
    1230              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1231            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_NEGOTIATED;
    1232            1 :     spdm_context->connection_info.capability.flags = 0;
    1233            1 :     spdm_context->connection_info.capability.flags |=
    1234              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCAP_CAP;
    1235            1 :     spdm_context->local_context.capability.flags |=
    1236              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_EP_INFO_CAP_SIG;
    1237              : 
    1238            1 :     spdm_context->local_context.capability.flags = 0;
    1239            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCAP_CAP;
    1240              : 
    1241            1 :     libspdm_read_requester_public_certificate_chain(m_libspdm_use_hash_algo,
    1242              :                                                     m_libspdm_use_req_asym_algo, &data,
    1243              :                                                     &data_size,
    1244              :                                                     &hash, &hash_size);
    1245            1 :     spdm_context->local_context.local_cert_chain_provision[0] = data;
    1246            1 :     spdm_context->local_context.local_cert_chain_provision_size[0] = data_size;
    1247              : 
    1248            1 :     libspdm_reset_message_a(spdm_context);
    1249            1 :     libspdm_reset_message_encap_e(spdm_context, NULL);
    1250            1 :     spdm_context->connection_info.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    1251            1 :     spdm_context->connection_info.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
    1252            1 :     spdm_context->connection_info.algorithm.req_base_asym_alg = m_libspdm_use_req_asym_algo;
    1253              : 
    1254              : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
    1255              :     spdm_context->connection_info.peer_used_cert_chain[0].buffer_size = data_size;
    1256              :     libspdm_copy_mem(spdm_context->connection_info.peer_used_cert_chain[0].buffer,
    1257              :                      sizeof(spdm_context->connection_info.peer_used_cert_chain[0].buffer),
    1258              :                      data, data_size);
    1259              : #endif
    1260              : 
    1261            1 :     libspdm_register_get_encap_response_func(spdm_context,
    1262              :                                              libspdm_get_encap_response_endpoint_info);
    1263            1 :     status = libspdm_encapsulated_request(spdm_context, NULL, 0, NULL);
    1264            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
    1265            1 :     free(data);
    1266            1 : }
    1267              : #endif /* LIBSPDM_ENABLE_CAPABILITY_ENDPOINT_INFO_CAP */
    1268              : 
    1269            1 : static void req_get_encapsulated_request_case14(void **State)
    1270              : {
    1271              :     libspdm_return_t status;
    1272              :     libspdm_test_context_t *spdm_test_context;
    1273              :     libspdm_context_t *spdm_context;
    1274              :     void *data;
    1275              :     size_t data_size;
    1276              :     void *hash;
    1277              :     size_t hash_size;
    1278              : 
    1279            1 :     spdm_test_context = *State;
    1280            1 :     spdm_context = spdm_test_context->spdm_context;
    1281            1 :     spdm_test_context->case_id = 0xE;
    1282              : 
    1283            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_11 <<
    1284              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1285            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_NEGOTIATED;
    1286            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP;
    1287            1 :     spdm_context->connection_info.capability.flags |=
    1288              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP;
    1289            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP;
    1290            1 :     spdm_context->connection_info.capability.flags |=
    1291              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCAP_CAP;
    1292              : 
    1293            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP;
    1294            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP;
    1295            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP;
    1296            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCAP_CAP;
    1297            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CERT_CAP;
    1298              : 
    1299            1 :     spdm_context->local_context.local_cert_chain_provision[0] = NULL;
    1300            1 :     spdm_context->local_context.local_cert_chain_provision_size[0] = 0;
    1301              : 
    1302            1 :     if (!libspdm_read_responder_public_certificate_chain(m_libspdm_use_hash_algo,
    1303              :                                                          m_libspdm_use_asym_algo, &data,
    1304              :                                                          &data_size,
    1305              :                                                          &hash, &hash_size)) {
    1306            0 :         assert(false);
    1307              :     }
    1308            1 :     libspdm_reset_message_a(spdm_context);
    1309            1 :     spdm_context->connection_info.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    1310            1 :     spdm_context->connection_info.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
    1311            1 :     spdm_context->connection_info.algorithm.dhe_named_group = m_libspdm_use_dhe_algo;
    1312            1 :     spdm_context->connection_info.algorithm.aead_cipher_suite = m_libspdm_use_aead_algo;
    1313              : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
    1314              :     spdm_context->connection_info.peer_used_cert_chain[0].buffer_size = data_size;
    1315              :     libspdm_copy_mem(spdm_context->connection_info.peer_used_cert_chain[0].buffer,
    1316              :                      sizeof(spdm_context->connection_info.peer_used_cert_chain[0].buffer),
    1317              :                      data, data_size);
    1318              : #endif
    1319              : 
    1320            1 :     libspdm_register_get_encap_response_func(spdm_context, libspdm_get_encap_response_digest);
    1321            1 :     status = libspdm_encapsulated_request(spdm_context, NULL, 0, NULL);
    1322            1 :     assert_int_equal(status, LIBSPDM_STATUS_RESYNCH_PEER);
    1323            1 :     assert_int_equal(spdm_context->connection_info.connection_state,
    1324              :                      LIBSPDM_CONNECTION_STATE_NOT_STARTED);
    1325            1 :     free(data);
    1326            1 : }
    1327              : 
    1328            1 : static void req_get_encapsulated_request_case15(void **State)
    1329              : {
    1330              :     libspdm_return_t status;
    1331              :     libspdm_test_context_t *spdm_test_context;
    1332              :     libspdm_context_t *spdm_context;
    1333              :     void *data;
    1334              :     size_t data_size;
    1335              :     void *hash;
    1336              :     size_t hash_size;
    1337              : 
    1338            1 :     spdm_test_context = *State;
    1339            1 :     spdm_context = spdm_test_context->spdm_context;
    1340            1 :     spdm_test_context->case_id = 0xF;
    1341              : 
    1342            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_11 <<
    1343              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1344            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_NEGOTIATED;
    1345            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP;
    1346            1 :     spdm_context->connection_info.capability.flags |=
    1347              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP;
    1348            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP;
    1349            1 :     spdm_context->connection_info.capability.flags |=
    1350              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCAP_CAP;
    1351              : 
    1352            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP;
    1353            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP;
    1354            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP;
    1355            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCAP_CAP;
    1356            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CERT_CAP;
    1357              : 
    1358            1 :     spdm_context->local_context.local_cert_chain_provision[0] = NULL;
    1359            1 :     spdm_context->local_context.local_cert_chain_provision_size[0] = 0;
    1360              : 
    1361            1 :     if (!libspdm_read_responder_public_certificate_chain(m_libspdm_use_hash_algo,
    1362              :                                                          m_libspdm_use_asym_algo, &data,
    1363              :                                                          &data_size,
    1364              :                                                          &hash, &hash_size)) {
    1365            0 :         assert(false);
    1366              :     }
    1367            1 :     libspdm_reset_message_a(spdm_context);
    1368            1 :     spdm_context->connection_info.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    1369            1 :     spdm_context->connection_info.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
    1370            1 :     spdm_context->connection_info.algorithm.dhe_named_group = m_libspdm_use_dhe_algo;
    1371            1 :     spdm_context->connection_info.algorithm.aead_cipher_suite = m_libspdm_use_aead_algo;
    1372              : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
    1373              :     spdm_context->connection_info.peer_used_cert_chain[0].buffer_size = data_size;
    1374              :     libspdm_copy_mem(spdm_context->connection_info.peer_used_cert_chain[0].buffer,
    1375              :                      sizeof(spdm_context->connection_info.peer_used_cert_chain[0].buffer),
    1376              :                      data, data_size);
    1377              : #endif
    1378              : 
    1379            1 :     libspdm_register_get_encap_response_func(spdm_context, libspdm_get_encap_response_digest);
    1380            1 :     status = libspdm_encapsulated_request(spdm_context, NULL, 0, NULL);
    1381            1 :     assert_int_equal(status, LIBSPDM_STATUS_RESYNCH_PEER);
    1382            1 :     assert_int_equal(spdm_context->connection_info.connection_state,
    1383              :                      LIBSPDM_CONNECTION_STATE_NOT_STARTED);
    1384            1 :     free(data);
    1385            1 : }
    1386              : 
    1387            1 : int libspdm_req_get_encapsulated_request_test(void)
    1388              : {
    1389            1 :     const struct CMUnitTest test_cases[] = {
    1390              :         /* SendRequest failed*/
    1391              : #if (LIBSPDM_ENABLE_CAPABILITY_MUT_AUTH_CAP) && (LIBSPDM_ENABLE_CAPABILITY_CERT_CAP)
    1392              :         cmocka_unit_test(req_get_encapsulated_request_case1),
    1393              :         /* Success Case ,func :libspdm_get_encap_response_digest*/
    1394              :         cmocka_unit_test(req_get_encapsulated_request_case2),
    1395              :         cmocka_unit_test(req_get_encapsulated_request_case3),
    1396              :         /* Error response:Receive message only SPDM ENCAPSULATED_REQUEST response*/
    1397              :         cmocka_unit_test(req_get_encapsulated_request_case4),
    1398              :         /* Error response: spdm_encapsulated_response_ack_response == NULL*/
    1399              :         cmocka_unit_test(req_get_encapsulated_request_case5),
    1400              :         cmocka_unit_test(req_get_encapsulated_request_case6),
    1401              :         /* response: param2 == SPDM_ENCAPSULATED_RESPONSE_ACK_RESPONSE_PAYLOAD_TYPE_REQ_SLOT_NUMBER*/
    1402              :         cmocka_unit_test(req_get_encapsulated_request_case7),
    1403              :         /*Success Case ,func :libspdm_get_encap_response_certificate */
    1404              :         cmocka_unit_test(req_get_encapsulated_request_case8),
    1405              : #endif /* (LIBSPDM_ENABLE_CAPABILITY_MUT_AUTH_CAP) && (..) */
    1406              : 
    1407              :         /*Success Case ,func :libspdm_get_encap_response_key_update */
    1408              :         cmocka_unit_test(req_get_encapsulated_request_case9),
    1409              :         /*Error response: GET_ENCAPSULATED_REQUEST message is encapsulated */
    1410              :         cmocka_unit_test(req_get_encapsulated_request_case10),
    1411              :         cmocka_unit_test(req_get_encapsulated_request_case11),
    1412              :         cmocka_unit_test(req_get_encapsulated_request_case12),
    1413              : #if LIBSPDM_ENABLE_CAPABILITY_ENDPOINT_INFO_CAP
    1414              :         /*Success Case ,func :libspdm_get_encap_response_endpoint_info */
    1415              :         cmocka_unit_test(req_get_encapsulated_request_case13),
    1416              : #endif /* LIBSPDM_ENABLE_CAPABILITY_ENDPOINT_INFO_CAP */
    1417              :         /* Error response: send SPDM_GET_ENCAPSULATED_REQUEST and receive request resync */
    1418              :         cmocka_unit_test(req_get_encapsulated_request_case14),
    1419              :         /* Error response: send SPDM_DELIVER_ENCAPSULATED_RESPONSE and receive request resync */
    1420              :         cmocka_unit_test(req_get_encapsulated_request_case15),
    1421              :     };
    1422              : 
    1423            1 :     libspdm_test_context_t test_context = {
    1424              :         LIBSPDM_TEST_CONTEXT_VERSION,
    1425              :         true,
    1426              :         send_message,
    1427              :         receive_message,
    1428              :     };
    1429              : 
    1430            1 :     libspdm_setup_test_context(&test_context);
    1431              : 
    1432            1 :     return cmocka_run_group_tests(test_cases,
    1433              :                                   libspdm_unit_test_group_setup,
    1434              :                                   libspdm_unit_test_group_teardown);
    1435              : }
    1436              : 
    1437              : #endif /* LIBSPDM_ENABLE_CAPABILITY_ENCAP_CAP */
        

Generated by: LCOV version 2.0-1