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

Generated by: LCOV version 2.0-1