LCOV - code coverage report
Current view: top level - unit_test/test_spdm_requester - negotiate_algorithms.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 50.4 % 1259 634
Test Date: 2025-11-02 08:10:32 Functions: 100.0 % 39 39

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

Generated by: LCOV version 2.0-1