LCOV - code coverage report
Current view: top level - unit_test/test_spdm_requester/error_test - get_capabilities_err.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 98.2 % 1071 1052
Test Date: 2025-06-29 08:09:00 Functions: 100.0 % 44 44

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

Generated by: LCOV version 2.0-1