LCOV - code coverage report
Current view: top level - unit_test/test_spdm_responder - capabilities.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 376 376
Test Date: 2026-02-22 08:11:49 Functions: 100.0 % 28 28

            Line data    Source code
       1              : /**
       2              :  *  Copyright Notice:
       3              :  *  Copyright 2021-2026 DMTF. All rights reserved.
       4              :  *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
       5              :  **/
       6              : 
       7              : #include "spdm_unit_test.h"
       8              : #include "internal/libspdm_responder_lib.h"
       9              : 
      10              : spdm_get_capabilities_request_t m_libspdm_get_capabilities_request1 = {
      11              :     {
      12              :         SPDM_MESSAGE_VERSION_10,
      13              :         SPDM_GET_CAPABILITIES,
      14              :     },
      15              : };
      16              : /* version 1.0 message consists of only header (size 0x04).
      17              :  * However, spdm_get_capabilities_request_t has a size of 0x0c.
      18              :  * Therefore, sending a v1.0 request with this structure results in a wrong size request.
      19              :  * size information was corrected to reflect the actual size of a get_capabilities 1.0 message.*/
      20              : size_t m_libspdm_get_capabilities_request1_size = sizeof(spdm_message_header_t);
      21              : 
      22              : spdm_get_capabilities_request_t m_libspdm_get_capabilities_request2 = {
      23              :     {
      24              :         SPDM_MESSAGE_VERSION_10,
      25              :         SPDM_GET_CAPABILITIES,
      26              :     },
      27              : };
      28              : size_t m_libspdm_get_capabilities_request2_size = LIBSPDM_MAX_SPDM_MSG_SIZE;
      29              : 
      30              : spdm_get_capabilities_request_t m_libspdm_get_capabilities_request4 = {
      31              :     {
      32              :         SPDM_MESSAGE_VERSION_11,
      33              :         SPDM_GET_CAPABILITIES,
      34              :     }, /*header*/
      35              :     0x00, /*reserved*/
      36              :     0x01, /*ct_exponent*/
      37              :     0x0000, /*reserved, 2 bytes*/
      38              :     (SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CERT_CAP | /*flags*/
      39              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHAL_CAP |
      40              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP |
      41              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP |
      42              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP |
      43              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP |
      44              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP_REQUESTER |
      45              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCAP_CAP |
      46              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HBEAT_CAP |
      47              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_UPD_CAP |
      48              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HANDSHAKE_IN_THE_CLEAR_CAP)
      49              : };
      50              : size_t m_libspdm_get_capabilities_request4_size =
      51              :     sizeof(m_libspdm_get_capabilities_request4) -
      52              :     sizeof(m_libspdm_get_capabilities_request4.data_transfer_size) -
      53              :     sizeof(m_libspdm_get_capabilities_request4.max_spdm_msg_size);
      54              : 
      55              : spdm_get_capabilities_request_t m_libspdm_get_capabilities_request5 = {
      56              :     {
      57              :         SPDM_MESSAGE_VERSION_11,
      58              :         SPDM_GET_CAPABILITIES,
      59              :     }, /*header*/
      60              :     0x00, /*reserved*/
      61              :     0x01, /*ct_exponent*/
      62              :     0x0000, /*reserved, 2 bytes*/
      63              :     (0x01 | SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CERT_CAP | /*flags*/
      64              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHAL_CAP |
      65              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP |
      66              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP |
      67              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP |
      68              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP |
      69              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP_REQUESTER |
      70              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCAP_CAP |
      71              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HBEAT_CAP |
      72              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_UPD_CAP |
      73              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HANDSHAKE_IN_THE_CLEAR_CAP)
      74              : };
      75              : size_t m_libspdm_get_capabilities_request5_size =
      76              :     sizeof(m_libspdm_get_capabilities_request5) -
      77              :     sizeof(m_libspdm_get_capabilities_request5.data_transfer_size) -
      78              :     sizeof(m_libspdm_get_capabilities_request5.max_spdm_msg_size);
      79              : 
      80              : spdm_get_capabilities_request_t m_libspdm_get_capabilities_request6 = {
      81              :     {
      82              :         SPDM_MESSAGE_VERSION_11,
      83              :         SPDM_GET_CAPABILITIES,
      84              :     }, /*header*/
      85              :     0x00, /*reserved*/
      86              :     0x01, /*ct_exponent*/
      87              :     0x0000, /*reserved, 2 bytes*/
      88              :     (SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP_NO_SIG |
      89              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CERT_CAP | /*flags*/
      90              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHAL_CAP |
      91              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP |
      92              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP |
      93              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP |
      94              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP |
      95              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP_REQUESTER |
      96              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCAP_CAP |
      97              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HBEAT_CAP |
      98              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_UPD_CAP |
      99              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HANDSHAKE_IN_THE_CLEAR_CAP)
     100              : };
     101              : size_t m_libspdm_get_capabilities_request6_size =
     102              :     sizeof(m_libspdm_get_capabilities_request6) -
     103              :     sizeof(m_libspdm_get_capabilities_request6.data_transfer_size) -
     104              :     sizeof(m_libspdm_get_capabilities_request6.max_spdm_msg_size);
     105              : 
     106              : spdm_get_capabilities_request_t m_libspdm_get_capabilities_request7 = {
     107              :     {
     108              :         SPDM_MESSAGE_VERSION_11,
     109              :         SPDM_GET_CAPABILITIES,
     110              :     }, /*header*/
     111              :     0x00, /*reserved*/
     112              :     LIBSPDM_MAX_CT_EXPONENT + 1, /*Illegal ct_exponent*/
     113              :     0x0000, /*reserved, 2 bytes*/
     114              :     (0x100000 | SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CERT_CAP | /*flags*/
     115              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHAL_CAP |
     116              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP |
     117              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP |
     118              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP |
     119              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP |
     120              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP_REQUESTER |
     121              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCAP_CAP |
     122              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HBEAT_CAP |
     123              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_UPD_CAP |
     124              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HANDSHAKE_IN_THE_CLEAR_CAP)
     125              : };
     126              : size_t m_libspdm_get_capabilities_request7_size =
     127              :     sizeof(m_libspdm_get_capabilities_request7) -
     128              :     sizeof(m_libspdm_get_capabilities_request7.data_transfer_size) -
     129              :     sizeof(m_libspdm_get_capabilities_request7.max_spdm_msg_size);
     130              : 
     131              : spdm_get_capabilities_request_t m_libspdm_get_capabilities_request8 = {
     132              :     {
     133              :         SPDM_MESSAGE_VERSION_11,
     134              :         SPDM_GET_CAPABILITIES,
     135              :     }, /*header*/
     136              :     0x00, /*reserved*/
     137              :     0x01, /*ct_exponent*/
     138              :     0x0000, /*reserved, 2 bytes*/
     139              :     (0x100000 | SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CERT_CAP | /*flags*/
     140              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHAL_CAP |
     141              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP |
     142              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP |
     143              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP |
     144              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP |
     145              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP_REQUESTER |
     146              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCAP_CAP |
     147              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HBEAT_CAP |
     148              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_UPD_CAP |
     149              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HANDSHAKE_IN_THE_CLEAR_CAP)
     150              : };
     151              : size_t m_libspdm_get_capabilities_request8_size =
     152              :     sizeof(m_libspdm_get_capabilities_request8) -
     153              :     sizeof(m_libspdm_get_capabilities_request8.data_transfer_size) -
     154              :     sizeof(m_libspdm_get_capabilities_request8.max_spdm_msg_size);
     155              : 
     156              : spdm_get_capabilities_request_t m_libspdm_get_capabilities_request9 = {
     157              :     {
     158              :         SPDM_MESSAGE_VERSION_11,
     159              :         SPDM_GET_CAPABILITIES,
     160              :     }, /*header*/
     161              :     0x00, /*reserved*/
     162              :     0x01, /*ct_exponent*/
     163              :     0x0000, /*reserved, 2 bytes*/
     164              :     (SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PUB_KEY_ID_CAP |
     165              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CERT_CAP | /*flags*/
     166              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHAL_CAP |
     167              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP |
     168              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP |
     169              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP |
     170              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP |
     171              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP_REQUESTER |
     172              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCAP_CAP |
     173              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HBEAT_CAP |
     174              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_UPD_CAP |
     175              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HANDSHAKE_IN_THE_CLEAR_CAP)
     176              : };
     177              : size_t m_libspdm_get_capabilities_request9_size =
     178              :     sizeof(m_libspdm_get_capabilities_request9) -
     179              :     sizeof(m_libspdm_get_capabilities_request9.data_transfer_size) -
     180              :     sizeof(m_libspdm_get_capabilities_request9.max_spdm_msg_size);
     181              : 
     182              : spdm_get_capabilities_request_t m_libspdm_get_capabilities_request10 = {
     183              :     {
     184              :         SPDM_MESSAGE_VERSION_11,
     185              :         SPDM_GET_CAPABILITIES,
     186              :     }, /*header*/
     187              :     0x00, /*reserved*/
     188              :     0x01, /*ct_exponent*/
     189              :     0x0000, /*reserved, 2 bytes*/
     190              :     (SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CERT_CAP | /*flags*/
     191              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHAL_CAP |
     192              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP |
     193              : 
     194              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP |
     195              : 
     196              : 
     197              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCAP_CAP |
     198              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HBEAT_CAP |
     199              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_UPD_CAP |
     200              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HANDSHAKE_IN_THE_CLEAR_CAP)
     201              : };
     202              : size_t m_libspdm_get_capabilities_request10_size =
     203              :     sizeof(m_libspdm_get_capabilities_request10) -
     204              :     sizeof(m_libspdm_get_capabilities_request10.data_transfer_size) -
     205              :     sizeof(m_libspdm_get_capabilities_request10.max_spdm_msg_size);
     206              : 
     207              : spdm_get_capabilities_request_t m_libspdm_get_capabilities_request11 = {
     208              :     {
     209              :         SPDM_MESSAGE_VERSION_11,
     210              :         SPDM_GET_CAPABILITIES,
     211              :     }, /*header*/
     212              :     0x00, /*reserved*/
     213              :     0x01, /*ct_exponent*/
     214              :     0x0000, /*reserved, 2 bytes*/
     215              :     (SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CERT_CAP | /*flags*/
     216              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHAL_CAP |
     217              : 
     218              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP |
     219              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP |
     220              : 
     221              : 
     222              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCAP_CAP |
     223              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HBEAT_CAP |
     224              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_UPD_CAP |
     225              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HANDSHAKE_IN_THE_CLEAR_CAP)
     226              : };
     227              : size_t m_libspdm_get_capabilities_request11_size =
     228              :     sizeof(m_libspdm_get_capabilities_request11) -
     229              :     sizeof(m_libspdm_get_capabilities_request11.data_transfer_size) -
     230              :     sizeof(m_libspdm_get_capabilities_request11.max_spdm_msg_size);
     231              : 
     232              : spdm_get_capabilities_request_t m_libspdm_get_capabilities_request12 = {
     233              :     {
     234              :         SPDM_MESSAGE_VERSION_11,
     235              :         SPDM_GET_CAPABILITIES,
     236              :     }, /*header*/
     237              :     0x00, /*reserved*/
     238              :     0x01, /*ct_exponent*/
     239              :     0x0000, /*reserved, 2 bytes*/
     240              :     (SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CERT_CAP | /*flags*/
     241              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHAL_CAP |
     242              : 
     243              : 
     244              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP |
     245              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP |
     246              : 
     247              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCAP_CAP |
     248              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HBEAT_CAP |
     249              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_UPD_CAP
     250              : 
     251              :     )
     252              : };
     253              : size_t m_libspdm_get_capabilities_request12_size =
     254              :     sizeof(m_libspdm_get_capabilities_request12) -
     255              :     sizeof(m_libspdm_get_capabilities_request12.data_transfer_size) -
     256              :     sizeof(m_libspdm_get_capabilities_request12.max_spdm_msg_size);
     257              : 
     258              : spdm_get_capabilities_request_t m_libspdm_get_capabilities_request13 = {
     259              :     {
     260              :         SPDM_MESSAGE_VERSION_11,
     261              :         SPDM_GET_CAPABILITIES,
     262              :     }, /*header*/
     263              :     0x00, /*reserved*/
     264              :     0x01, /*ct_exponent*/
     265              :     0x0000, /*reserved, 2 bytes*/
     266              :     (SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CERT_CAP | /*flags*/
     267              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHAL_CAP |
     268              : 
     269              : 
     270              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP |
     271              : 
     272              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP_REQUESTER |
     273              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCAP_CAP |
     274              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HBEAT_CAP |
     275              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_UPD_CAP
     276              : 
     277              :     )
     278              : };
     279              : size_t m_libspdm_get_capabilities_request13_size =
     280              :     sizeof(m_libspdm_get_capabilities_request13) -
     281              :     sizeof(m_libspdm_get_capabilities_request13.data_transfer_size) -
     282              :     sizeof(m_libspdm_get_capabilities_request13.max_spdm_msg_size);
     283              : 
     284              : spdm_get_capabilities_request_t m_libspdm_get_capabilities_request14 = {
     285              :     {
     286              :         SPDM_MESSAGE_VERSION_11,
     287              :         SPDM_GET_CAPABILITIES,
     288              :     }, /*header*/
     289              :     0x00, /*reserved*/
     290              :     0x01, /*ct_exponent*/
     291              :     0x0000, /*reserved, 2 bytes*/
     292              :     (SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CERT_CAP | /*flags*/
     293              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHAL_CAP |
     294              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP |
     295              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP |
     296              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP |
     297              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP |
     298              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP_REQUESTER |
     299              : 
     300              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HBEAT_CAP |
     301              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_UPD_CAP |
     302              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HANDSHAKE_IN_THE_CLEAR_CAP)
     303              : };
     304              : size_t m_libspdm_get_capabilities_request14_size =
     305              :     sizeof(m_libspdm_get_capabilities_request14) -
     306              :     sizeof(m_libspdm_get_capabilities_request14.data_transfer_size) -
     307              :     sizeof(m_libspdm_get_capabilities_request14.max_spdm_msg_size);
     308              : 
     309              : spdm_get_capabilities_request_t m_libspdm_get_capabilities_request15 = {
     310              :     {
     311              :         SPDM_MESSAGE_VERSION_11,
     312              :         SPDM_GET_CAPABILITIES,
     313              :     }, /*header*/
     314              :     0x00, /*reserved*/
     315              :     0x01, /*ct_exponent*/
     316              :     0x0000, /*reserved, 2 bytes*/
     317              :     (SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CERT_CAP | /*flags*/
     318              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHAL_CAP |
     319              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP |
     320              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP |
     321              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP |
     322              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP |
     323              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP_REQUESTER |
     324              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCAP_CAP |
     325              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HBEAT_CAP |
     326              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_UPD_CAP |
     327              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HANDSHAKE_IN_THE_CLEAR_CAP |
     328              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PUB_KEY_ID_CAP)
     329              : };
     330              : size_t m_libspdm_get_capabilities_request15_size =
     331              :     sizeof(m_libspdm_get_capabilities_request15) -
     332              :     sizeof(m_libspdm_get_capabilities_request15.data_transfer_size) -
     333              :     sizeof(m_libspdm_get_capabilities_request15.max_spdm_msg_size);
     334              : 
     335              : spdm_get_capabilities_request_t m_libspdm_get_capabilities_request16 = {
     336              :     {
     337              :         SPDM_MESSAGE_VERSION_11,
     338              :         SPDM_GET_CAPABILITIES,
     339              :     }, /*header*/
     340              :     0x00, /*reserved*/
     341              :     0x01, /*ct_exponent*/
     342              :     0x0000, /*reserved, 2 bytes*/
     343              :     (SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CERT_CAP | /*flags*/
     344              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHAL_CAP |
     345              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP |
     346              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP |
     347              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP |
     348              : 
     349              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP_REQUESTER |
     350              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCAP_CAP |
     351              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HBEAT_CAP |
     352              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_UPD_CAP |
     353              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HANDSHAKE_IN_THE_CLEAR_CAP)
     354              : };
     355              : size_t m_libspdm_get_capabilities_request16_size =
     356              :     sizeof(m_libspdm_get_capabilities_request16) -
     357              :     sizeof(m_libspdm_get_capabilities_request16.data_transfer_size) -
     358              :     sizeof(m_libspdm_get_capabilities_request16.max_spdm_msg_size);
     359              : 
     360              : spdm_get_capabilities_request_t m_libspdm_get_capabilities_request17 = {
     361              :     {
     362              :         SPDM_MESSAGE_VERSION_11,
     363              :         SPDM_GET_CAPABILITIES,
     364              :     }, /*header*/
     365              :     0x00, /*reserved*/
     366              :     0x01, /*ct_exponent*/
     367              :     0x0000, /*reserved, 2 bytes*/
     368              :     (SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CERT_CAP | /*flags*/
     369              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHAL_CAP |
     370              : 
     371              : 
     372              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP |
     373              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP |
     374              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP_REQUESTER |
     375              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCAP_CAP |
     376              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HBEAT_CAP |
     377              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_UPD_CAP |
     378              :      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HANDSHAKE_IN_THE_CLEAR_CAP)
     379              : };
     380              : size_t m_libspdm_get_capabilities_request17_size =
     381              :     sizeof(m_libspdm_get_capabilities_request17) -
     382              :     sizeof(m_libspdm_get_capabilities_request17.data_transfer_size) -
     383              :     sizeof(m_libspdm_get_capabilities_request17.max_spdm_msg_size);
     384              : 
     385              : spdm_get_capabilities_request_t m_libspdm_get_capabilities_request18 = {
     386              :     {
     387              :         SPDM_MESSAGE_VERSION_11,
     388              :         SPDM_GET_CAPABILITIES,
     389              :     }, /*header*/
     390              :     0x00, /*reserved*/
     391              :     0x01, /*ct_exponent*/
     392              :     0x0000, /*reserved, 2 bytes*/
     393              :     ( /*flags*/
     394              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHAL_CAP |
     395              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP |
     396              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP |
     397              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP |
     398              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP |
     399              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP_REQUESTER |
     400              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCAP_CAP |
     401              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HBEAT_CAP |
     402              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_UPD_CAP |
     403              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HANDSHAKE_IN_THE_CLEAR_CAP |
     404              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PUB_KEY_ID_CAP)
     405              : };
     406              : size_t m_libspdm_get_capabilities_request18_size =
     407              :     sizeof(m_libspdm_get_capabilities_request18) -
     408              :     sizeof(m_libspdm_get_capabilities_request18.data_transfer_size) -
     409              :     sizeof(m_libspdm_get_capabilities_request18.max_spdm_msg_size);
     410              : 
     411              : spdm_get_capabilities_request_t m_libspdm_get_capabilities_request19 = {
     412              :     {
     413              :         SPDM_MESSAGE_VERSION_12,
     414              :         SPDM_GET_CAPABILITIES,
     415              :     }, /*header*/
     416              :     0x00, /*reserved*/
     417              :     0x01, /*ct_exponent*/
     418              :     0x0000, /*reserved, 2 bytes*/
     419              :     (SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CHUNK_CAP|
     420              :      SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ALIAS_CERT_CAP),
     421              :     LIBSPDM_DATA_TRANSFER_SIZE,
     422              :     LIBSPDM_MAX_SPDM_MSG_SIZE,
     423              : };
     424              : size_t m_libspdm_get_capabilities_request19_size = sizeof(m_libspdm_get_capabilities_request19);
     425              : 
     426              : spdm_get_capabilities_request_t m_libspdm_get_capabilities_request25 = {
     427              :     {
     428              :         SPDM_MESSAGE_VERSION_12,
     429              :         SPDM_GET_CAPABILITIES,
     430              :     }, /*header*/
     431              :     0x00, /*reserved*/
     432              :     0x01, /*ct_exponent*/
     433              :     0x0000, /*reserved, 2 bytes*/
     434              :     0,
     435              :     LIBSPDM_DATA_TRANSFER_SIZE - 1,
     436              :     LIBSPDM_MAX_SPDM_MSG_SIZE,
     437              : };
     438              : size_t m_libspdm_get_capabilities_request25_size = sizeof(m_libspdm_get_capabilities_request25);
     439              : 
     440              : spdm_get_capabilities_request_t m_libspdm_get_capabilities_request26 = {
     441              :     {
     442              :         SPDM_MESSAGE_VERSION_12,
     443              :         SPDM_GET_CAPABILITIES,
     444              :     }, /*header*/
     445              :     0x00, /*reserved*/
     446              :     0x01, /*ct_exponent*/
     447              :     0x0000, /*reserved, 2 bytes*/
     448              :     (SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CHUNK_CAP|
     449              :      SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ALIAS_CERT_CAP),
     450              :     LIBSPDM_DATA_TRANSFER_SIZE,
     451              :     LIBSPDM_DATA_TRANSFER_SIZE - 1,
     452              : };
     453              : size_t m_libspdm_get_capabilities_request26_size = sizeof(m_libspdm_get_capabilities_request26);
     454              : 
     455              : 
     456              : spdm_get_capabilities_request_t m_libspdm_get_capabilities_request27 = {
     457              :     {
     458              :         SPDM_MESSAGE_VERSION_13,
     459              :         SPDM_GET_CAPABILITIES,
     460              :     },
     461              :     0x00, /*reserved*/
     462              :     0x01, /*ct_exponent*/
     463              :     0x0000, /*reserved, 2 bytes*/
     464              :     SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CERT_CAP |
     465              :     SPDM_GET_CAPABILITIES_REQUEST_FLAGS_EP_INFO_CAP_SIG |
     466              :     SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MULTI_KEY_CAP_ONLY,
     467              :     LIBSPDM_DATA_TRANSFER_SIZE,
     468              :     LIBSPDM_MAX_SPDM_MSG_SIZE,
     469              : };
     470              : size_t m_libspdm_get_capabilities_request27_size = sizeof(m_libspdm_get_capabilities_request27);
     471              : 
     472              : spdm_get_capabilities_request_t m_libspdm_get_capabilities_request28 = {
     473              :     {
     474              :         SPDM_MESSAGE_VERSION_13,
     475              :         SPDM_GET_CAPABILITIES,
     476              :         0x01,
     477              :     },
     478              :     0x00, /*reserved*/
     479              :     0x01, /*ct_exponent*/
     480              :     0x0000, /*reserved, 2 bytes*/
     481              :     SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHUNK_CAP |
     482              :     SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CERT_CAP |
     483              :     SPDM_GET_CAPABILITIES_REQUEST_FLAGS_EP_INFO_CAP_SIG |
     484              :     SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MULTI_KEY_CAP_ONLY,
     485              :     LIBSPDM_DATA_TRANSFER_SIZE,
     486              :     LIBSPDM_MAX_SPDM_MSG_SIZE,
     487              : };
     488              : size_t m_libspdm_get_capabilities_request28_size = sizeof(m_libspdm_get_capabilities_request28);
     489              : 
     490            1 : static void rsp_capabilities_case1(void **state)
     491              : {
     492              :     libspdm_return_t status;
     493              :     libspdm_test_context_t *spdm_test_context;
     494              :     libspdm_context_t *spdm_context;
     495              :     size_t response_size;
     496              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
     497              :     spdm_capabilities_response_t *spdm_response;
     498              : 
     499            1 :     spdm_test_context = *state;
     500            1 :     spdm_context = spdm_test_context->spdm_context;
     501            1 :     spdm_test_context->case_id = 0x1;
     502            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_VERSION;
     503              : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
     504              :     spdm_context->transcript.message_m.buffer_size =
     505              :         spdm_context->transcript.message_m.max_buffer_size;
     506              : #endif
     507              : 
     508            1 :     response_size = sizeof(response);
     509            1 :     status = libspdm_get_response_capabilities(
     510              :         spdm_context, m_libspdm_get_capabilities_request1_size,
     511              :         &m_libspdm_get_capabilities_request1, &response_size, response);
     512            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
     513            1 :     assert_int_equal(response_size, sizeof(spdm_capabilities_response_t) -
     514              :                      sizeof(spdm_response->data_transfer_size) -
     515              :                      sizeof(spdm_response->max_spdm_msg_size));
     516            1 :     spdm_response = (void *)response;
     517            1 :     assert_int_equal(m_libspdm_get_capabilities_request1.header.spdm_version,
     518              :                      spdm_response->header.spdm_version);
     519            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_CAPABILITIES);
     520              : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
     521              :     assert_int_equal(spdm_context->transcript.message_m.buffer_size, 0);
     522              : #endif
     523            1 : }
     524              : 
     525            1 : static void rsp_capabilities_case2(void **state)
     526              : {
     527              :     libspdm_return_t status;
     528              :     libspdm_test_context_t *spdm_test_context;
     529              :     libspdm_context_t *spdm_context;
     530              :     size_t response_size;
     531              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
     532              :     spdm_capabilities_response_t *spdm_response;
     533              : 
     534            1 :     spdm_test_context = *state;
     535            1 :     spdm_context = spdm_test_context->spdm_context;
     536            1 :     spdm_test_context->case_id = 0x2;
     537            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_VERSION;
     538              : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
     539              :     spdm_context->transcript.message_m.buffer_size =
     540              :         spdm_context->transcript.message_m.max_buffer_size;
     541              : #endif
     542              : 
     543            1 :     response_size = sizeof(response);
     544            1 :     status = libspdm_get_response_capabilities(
     545              :         spdm_context, m_libspdm_get_capabilities_request2_size,
     546              :         &m_libspdm_get_capabilities_request2, &response_size, response);
     547            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
     548            1 :     assert_int_equal(response_size, sizeof(spdm_capabilities_response_t) -
     549              :                      sizeof(spdm_response->data_transfer_size) -
     550              :                      sizeof(spdm_response->max_spdm_msg_size));
     551            1 :     spdm_response = (void *)response;
     552            1 :     assert_int_equal(m_libspdm_get_capabilities_request2.header.spdm_version,
     553              :                      spdm_response->header.spdm_version);
     554            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_CAPABILITIES);
     555              : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
     556              :     assert_int_equal(spdm_context->transcript.message_m.buffer_size, 0);
     557              : #endif
     558            1 : }
     559              : 
     560            1 : static void rsp_capabilities_case3(void **state)
     561              : {
     562              :     libspdm_return_t status;
     563              :     libspdm_test_context_t *spdm_test_context;
     564              :     libspdm_context_t *spdm_context;
     565              :     size_t response_size;
     566              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
     567              :     spdm_capabilities_response_t *spdm_response;
     568              : 
     569            1 :     spdm_test_context = *state;
     570            1 :     spdm_context = spdm_test_context->spdm_context;
     571            1 :     spdm_test_context->case_id = 0x3;
     572            1 :     spdm_context->response_state = LIBSPDM_RESPONSE_STATE_BUSY;
     573            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_VERSION;
     574              : 
     575            1 :     response_size = sizeof(response);
     576            1 :     status = libspdm_get_response_capabilities(
     577              :         spdm_context, m_libspdm_get_capabilities_request1_size,
     578              :         &m_libspdm_get_capabilities_request1, &response_size, response);
     579            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
     580            1 :     assert_int_equal(response_size, sizeof(spdm_error_response_t));
     581            1 :     spdm_response = (void *)response;
     582            1 :     assert_int_equal(m_libspdm_get_capabilities_request1.header.spdm_version,
     583              :                      spdm_response->header.spdm_version);
     584            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_ERROR);
     585            1 :     assert_int_equal(spdm_response->header.param1, SPDM_ERROR_CODE_BUSY);
     586            1 :     assert_int_equal(spdm_response->header.param2, 0);
     587            1 :     assert_int_equal(spdm_context->response_state, LIBSPDM_RESPONSE_STATE_BUSY);
     588            1 : }
     589              : 
     590            1 : static void rsp_capabilities_case4(void **state)
     591              : {
     592              :     libspdm_return_t status;
     593              :     libspdm_test_context_t *spdm_test_context;
     594              :     libspdm_context_t *spdm_context;
     595              :     size_t response_size;
     596              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
     597              :     spdm_capabilities_response_t *spdm_response;
     598              : 
     599            1 :     spdm_test_context = *state;
     600            1 :     spdm_context = spdm_test_context->spdm_context;
     601            1 :     spdm_test_context->case_id = 0x4;
     602            1 :     spdm_context->response_state = LIBSPDM_RESPONSE_STATE_NEED_RESYNC;
     603            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_VERSION;
     604              : 
     605            1 :     response_size = sizeof(response);
     606            1 :     status = libspdm_get_response_capabilities(
     607              :         spdm_context, m_libspdm_get_capabilities_request1_size,
     608              :         &m_libspdm_get_capabilities_request1, &response_size, response);
     609            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
     610            1 :     assert_int_equal(response_size, sizeof(spdm_error_response_t));
     611            1 :     spdm_response = (void *)response;
     612            1 :     assert_int_equal(m_libspdm_get_capabilities_request1.header.spdm_version,
     613              :                      spdm_response->header.spdm_version);
     614            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_ERROR);
     615            1 :     assert_int_equal(spdm_response->header.param1, SPDM_ERROR_CODE_REQUEST_RESYNCH);
     616            1 :     assert_int_equal(spdm_response->header.param2, 0);
     617            1 :     assert_int_equal(spdm_context->response_state, LIBSPDM_RESPONSE_STATE_NEED_RESYNC);
     618            1 : }
     619              : 
     620            1 : static void rsp_capabilities_case6(void **state)
     621              : {
     622              :     libspdm_return_t status;
     623              :     libspdm_test_context_t *spdm_test_context;
     624              :     libspdm_context_t *spdm_context;
     625              :     size_t response_size;
     626              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
     627              :     spdm_capabilities_response_t *spdm_response;
     628              : 
     629            1 :     spdm_test_context = *state;
     630            1 :     spdm_context = spdm_test_context->spdm_context;
     631            1 :     spdm_test_context->case_id = 0x6;
     632            1 :     spdm_context->response_state = LIBSPDM_RESPONSE_STATE_NORMAL;
     633            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_NOT_STARTED;
     634              : 
     635            1 :     response_size = sizeof(response);
     636            1 :     status = libspdm_get_response_capabilities(
     637              :         spdm_context, m_libspdm_get_capabilities_request1_size,
     638              :         &m_libspdm_get_capabilities_request1, &response_size, response);
     639            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
     640            1 :     assert_int_equal(response_size, sizeof(spdm_error_response_t));
     641            1 :     spdm_response = (void *)response;
     642            1 :     assert_int_equal(m_libspdm_get_capabilities_request1.header.spdm_version,
     643              :                      spdm_response->header.spdm_version);
     644            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_ERROR);
     645            1 :     assert_int_equal(spdm_response->header.param1, SPDM_ERROR_CODE_UNEXPECTED_REQUEST);
     646            1 :     assert_int_equal(spdm_response->header.param2, 0);
     647            1 : }
     648              : 
     649              : /**
     650              :  * Test 7: Requester sets a CTExponent value that is larger than LIBSPDM_MAX_CT_EXPONENT.
     651              :  * Expected behavior: returns with error code SPDM_ERROR_CODE_INVALID_REQUEST.
     652              :  **/
     653            1 : static void rsp_capabilities_case7(void **state)
     654              : {
     655              :     libspdm_return_t status;
     656              :     libspdm_test_context_t *spdm_test_context;
     657              :     libspdm_context_t *spdm_context;
     658              :     size_t response_size;
     659              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
     660              :     spdm_capabilities_response_t *spdm_response;
     661              : 
     662            1 :     spdm_test_context = *state;
     663            1 :     spdm_context = spdm_test_context->spdm_context;
     664            1 :     spdm_test_context->case_id = 0x7;
     665            1 :     spdm_context->response_state = LIBSPDM_RESPONSE_STATE_NORMAL;
     666            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_VERSION;
     667              : 
     668            1 :     response_size = sizeof(response);
     669            1 :     status = libspdm_get_response_capabilities(
     670              :         spdm_context, m_libspdm_get_capabilities_request7_size,
     671              :         &m_libspdm_get_capabilities_request7, &response_size, response);
     672            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
     673            1 :     assert_int_equal(response_size, sizeof(spdm_error_response_t));
     674            1 :     spdm_response = (void *)response;
     675            1 :     assert_int_equal(m_libspdm_get_capabilities_request7.header.spdm_version,
     676              :                      spdm_response->header.spdm_version);
     677            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_ERROR);
     678            1 :     assert_int_equal(spdm_response->header.param1, SPDM_ERROR_CODE_INVALID_REQUEST);
     679            1 :     assert_int_equal(spdm_response->header.param2, 0);
     680            1 : }
     681              : 
     682            1 : static void rsp_capabilities_case8(void **state)
     683              : {
     684              :     libspdm_return_t status;
     685              :     libspdm_test_context_t *spdm_test_context;
     686              :     libspdm_context_t *spdm_context;
     687              :     size_t response_size;
     688              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
     689              :     spdm_capabilities_response_t *spdm_response;
     690              : 
     691            1 :     spdm_test_context = *state;
     692            1 :     spdm_context = spdm_test_context->spdm_context;
     693            1 :     spdm_test_context->case_id = 0x8;
     694            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_VERSION;
     695              : 
     696            1 :     response_size = sizeof(response);
     697            1 :     status = libspdm_get_response_capabilities(
     698              :         spdm_context, m_libspdm_get_capabilities_request4_size,
     699              :         &m_libspdm_get_capabilities_request4, &response_size, response);
     700            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
     701            1 :     assert_int_equal(response_size, sizeof(spdm_capabilities_response_t) -
     702              :                      sizeof(spdm_response->data_transfer_size) -
     703              :                      sizeof(spdm_response->max_spdm_msg_size));
     704            1 :     spdm_response = (void *)response;
     705            1 :     assert_int_equal(m_libspdm_get_capabilities_request4.header.spdm_version,
     706              :                      spdm_response->header.spdm_version);
     707            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_CAPABILITIES);
     708            1 : }
     709              : 
     710            1 : static void rsp_capabilities_case9(void **state)
     711              : {
     712              :     libspdm_return_t status;
     713              :     libspdm_test_context_t *spdm_test_context;
     714              :     libspdm_context_t *spdm_context;
     715              :     size_t response_size;
     716              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
     717              :     spdm_capabilities_response_t *spdm_response;
     718              : 
     719            1 :     spdm_test_context = *state;
     720            1 :     spdm_context = spdm_test_context->spdm_context;
     721            1 :     spdm_test_context->case_id = 0x9;
     722            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_VERSION;
     723              : 
     724            1 :     response_size = sizeof(response);
     725            1 :     status = libspdm_get_response_capabilities(
     726              :         spdm_context, m_libspdm_get_capabilities_request5_size,
     727              :         &m_libspdm_get_capabilities_request5, &response_size, response);
     728            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
     729            1 :     assert_int_equal(response_size, sizeof(spdm_capabilities_response_t) -
     730              :                      sizeof(spdm_response->data_transfer_size) -
     731              :                      sizeof(spdm_response->max_spdm_msg_size));
     732            1 :     spdm_response = (void *)response;
     733            1 :     assert_int_equal(m_libspdm_get_capabilities_request4.header.spdm_version,
     734              :                      spdm_response->header.spdm_version);
     735            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_CAPABILITIES);
     736            1 : }
     737              : 
     738            1 : static void rsp_capabilities_case10(void **state)
     739              : {
     740            1 : }
     741              : 
     742            1 : static void rsp_capabilities_case11(void **state)
     743              : {
     744            1 : }
     745              : 
     746            1 : static void rsp_capabilities_case12(void **state)
     747              : {
     748            1 : }
     749              : 
     750            1 : static void rsp_capabilities_case13(void **state)
     751              : {
     752              :     libspdm_return_t status;
     753              :     libspdm_test_context_t *spdm_test_context;
     754              :     libspdm_context_t *spdm_context;
     755              :     size_t response_size;
     756              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
     757              :     spdm_capabilities_response_t *spdm_response;
     758              : 
     759            1 :     spdm_test_context = *state;
     760            1 :     spdm_context = spdm_test_context->spdm_context;
     761            1 :     spdm_test_context->case_id = 0xd;
     762            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_VERSION;
     763              : 
     764            1 :     response_size = sizeof(response);
     765            1 :     status = libspdm_get_response_capabilities(
     766              :         spdm_context, m_libspdm_get_capabilities_request9_size,
     767              :         &m_libspdm_get_capabilities_request9, &response_size, response);
     768            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
     769            1 :     assert_int_equal(response_size, sizeof(spdm_error_response_t));
     770            1 :     spdm_response = (void *)response;
     771            1 :     assert_int_equal(m_libspdm_get_capabilities_request9.header.spdm_version,
     772              :                      spdm_response->header.spdm_version);
     773            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_ERROR);
     774            1 :     assert_int_equal(spdm_response->header.param1, SPDM_ERROR_CODE_INVALID_REQUEST);
     775            1 :     assert_int_equal(spdm_response->header.param2, 0);
     776            1 : }
     777              : 
     778            1 : static void rsp_capabilities_case14(void **state)
     779              : {
     780              :     libspdm_return_t status;
     781              :     libspdm_test_context_t *spdm_test_context;
     782              :     libspdm_context_t *spdm_context;
     783              :     size_t response_size;
     784              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
     785              :     spdm_capabilities_response_t *spdm_response;
     786              : 
     787            1 :     spdm_test_context = *state;
     788            1 :     spdm_context = spdm_test_context->spdm_context;
     789            1 :     spdm_test_context->case_id = 0xe;
     790            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_VERSION;
     791              : 
     792            1 :     response_size = sizeof(response);
     793            1 :     status = libspdm_get_response_capabilities(
     794              :         spdm_context, m_libspdm_get_capabilities_request10_size,
     795              :         &m_libspdm_get_capabilities_request10, &response_size, response);
     796            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
     797            1 :     assert_int_equal(response_size, sizeof(spdm_error_response_t));
     798            1 :     spdm_response = (void *)response;
     799            1 :     assert_int_equal(m_libspdm_get_capabilities_request10.header.spdm_version,
     800              :                      spdm_response->header.spdm_version);
     801            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_ERROR);
     802            1 :     assert_int_equal(spdm_response->header.param1, SPDM_ERROR_CODE_INVALID_REQUEST);
     803            1 :     assert_int_equal(spdm_response->header.param2, 0);
     804            1 : }
     805              : 
     806            1 : static void rsp_capabilities_case15(void **state)
     807              : {
     808              :     libspdm_return_t status;
     809              :     libspdm_test_context_t *spdm_test_context;
     810              :     libspdm_context_t *spdm_context;
     811              :     size_t response_size;
     812              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
     813              :     spdm_capabilities_response_t *spdm_response;
     814              : 
     815            1 :     spdm_test_context = *state;
     816            1 :     spdm_context = spdm_test_context->spdm_context;
     817            1 :     spdm_test_context->case_id = 0xf;
     818            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_VERSION;
     819              : 
     820            1 :     response_size = sizeof(response);
     821            1 :     status = libspdm_get_response_capabilities(
     822              :         spdm_context, m_libspdm_get_capabilities_request11_size,
     823              :         &m_libspdm_get_capabilities_request11, &response_size, response);
     824            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
     825            1 :     assert_int_equal(response_size, sizeof(spdm_error_response_t));
     826            1 :     spdm_response = (void *)response;
     827            1 :     assert_int_equal(m_libspdm_get_capabilities_request11.header.spdm_version,
     828              :                      spdm_response->header.spdm_version);
     829            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_ERROR);
     830            1 :     assert_int_equal(spdm_response->header.param1, SPDM_ERROR_CODE_INVALID_REQUEST);
     831            1 :     assert_int_equal(spdm_response->header.param2, 0);
     832            1 : }
     833              : 
     834            1 : static void rsp_capabilities_case16(void **state)
     835              : {
     836              :     libspdm_return_t status;
     837              :     libspdm_test_context_t *spdm_test_context;
     838              :     libspdm_context_t *spdm_context;
     839              :     size_t response_size;
     840              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
     841              :     spdm_capabilities_response_t *spdm_response;
     842              : 
     843            1 :     spdm_test_context = *state;
     844            1 :     spdm_context = spdm_test_context->spdm_context;
     845            1 :     spdm_test_context->case_id = 0x10;
     846            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_VERSION;
     847              : 
     848            1 :     response_size = sizeof(response);
     849            1 :     status = libspdm_get_response_capabilities(
     850              :         spdm_context, m_libspdm_get_capabilities_request12_size,
     851              :         &m_libspdm_get_capabilities_request12, &response_size, response);
     852            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
     853            1 :     assert_int_equal(response_size, sizeof(spdm_error_response_t));
     854            1 :     spdm_response = (void *)response;
     855            1 :     assert_int_equal(m_libspdm_get_capabilities_request12.header.spdm_version,
     856              :                      spdm_response->header.spdm_version);
     857            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_ERROR);
     858            1 :     assert_int_equal(spdm_response->header.param1, SPDM_ERROR_CODE_INVALID_REQUEST);
     859            1 :     assert_int_equal(spdm_response->header.param2, 0);
     860            1 : }
     861              : 
     862            1 : static void rsp_capabilities_case17(void **state)
     863              : {
     864              :     libspdm_return_t status;
     865              :     libspdm_test_context_t *spdm_test_context;
     866              :     libspdm_context_t *spdm_context;
     867              :     size_t response_size;
     868              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
     869              :     spdm_capabilities_response_t *spdm_response;
     870              : 
     871            1 :     spdm_test_context = *state;
     872            1 :     spdm_context = spdm_test_context->spdm_context;
     873            1 :     spdm_test_context->case_id = 0x11;
     874            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_VERSION;
     875              : 
     876            1 :     response_size = sizeof(response);
     877            1 :     status = libspdm_get_response_capabilities(
     878              :         spdm_context, m_libspdm_get_capabilities_request13_size,
     879              :         &m_libspdm_get_capabilities_request13, &response_size, response);
     880            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
     881            1 :     assert_int_equal(response_size, sizeof(spdm_error_response_t));
     882            1 :     spdm_response = (void *)response;
     883            1 :     assert_int_equal(m_libspdm_get_capabilities_request13.header.spdm_version,
     884              :                      spdm_response->header.spdm_version);
     885            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_ERROR);
     886            1 :     assert_int_equal(spdm_response->header.param1, SPDM_ERROR_CODE_INVALID_REQUEST);
     887            1 :     assert_int_equal(spdm_response->header.param2, 0);
     888            1 : }
     889              : 
     890            1 : static void rsp_capabilities_case18(void **state)
     891              : {
     892              :     libspdm_return_t status;
     893              :     libspdm_test_context_t *spdm_test_context;
     894              :     libspdm_context_t *spdm_context;
     895              :     size_t response_size;
     896              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
     897              :     spdm_capabilities_response_t *spdm_response;
     898              : 
     899            1 :     spdm_test_context = *state;
     900            1 :     spdm_context = spdm_test_context->spdm_context;
     901            1 :     spdm_test_context->case_id = 0x12;
     902            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_VERSION;
     903              : 
     904            1 :     libspdm_reset_message_a(spdm_context);
     905              : 
     906            1 :     response_size = sizeof(response);
     907            1 :     status = libspdm_get_response_capabilities(
     908              :         spdm_context, m_libspdm_get_capabilities_request14_size,
     909              :         &m_libspdm_get_capabilities_request14, &response_size, response);
     910            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
     911            1 :     assert_int_equal(response_size, sizeof(spdm_error_response_t));
     912            1 :     spdm_response = (void *)response;
     913            1 :     assert_int_equal(m_libspdm_get_capabilities_request14.header.spdm_version,
     914              :                      spdm_response->header.spdm_version);
     915            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_ERROR);
     916            1 :     assert_int_equal(spdm_response->header.param1, SPDM_ERROR_CODE_INVALID_REQUEST);
     917            1 :     assert_int_equal(spdm_response->header.param2, 0);
     918            1 : }
     919              : 
     920            1 : static void rsp_capabilities_case19(void **state)
     921              : {
     922              :     libspdm_return_t status;
     923              :     libspdm_test_context_t *spdm_test_context;
     924              :     libspdm_context_t *spdm_context;
     925              :     size_t response_size;
     926              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
     927              :     spdm_capabilities_response_t *spdm_response;
     928              : 
     929            1 :     spdm_test_context = *state;
     930            1 :     spdm_context = spdm_test_context->spdm_context;
     931            1 :     spdm_test_context->case_id = 0x13;
     932            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_VERSION;
     933              : 
     934            1 :     response_size = sizeof(response);
     935            1 :     status = libspdm_get_response_capabilities(
     936              :         spdm_context, m_libspdm_get_capabilities_request15_size,
     937              :         &m_libspdm_get_capabilities_request15, &response_size, response);
     938            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
     939            1 :     assert_int_equal(response_size, sizeof(spdm_error_response_t));
     940            1 :     spdm_response = (void *)response;
     941            1 :     assert_int_equal(m_libspdm_get_capabilities_request15.header.spdm_version,
     942              :                      spdm_response->header.spdm_version);
     943            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_ERROR);
     944            1 :     assert_int_equal(spdm_response->header.param1, SPDM_ERROR_CODE_INVALID_REQUEST);
     945            1 :     assert_int_equal(spdm_response->header.param2, 0);
     946            1 : }
     947              : 
     948            1 : static void rsp_capabilities_case20(void **state)
     949              : {
     950              :     libspdm_return_t status;
     951              :     libspdm_test_context_t *spdm_test_context;
     952              :     libspdm_context_t *spdm_context;
     953              :     size_t response_size;
     954              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
     955              :     spdm_capabilities_response_t *spdm_response;
     956              : 
     957            1 :     spdm_test_context = *state;
     958            1 :     spdm_context = spdm_test_context->spdm_context;
     959            1 :     spdm_test_context->case_id = 0x14;
     960            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_VERSION;
     961              : 
     962            1 :     response_size = sizeof(response);
     963            1 :     status = libspdm_get_response_capabilities(
     964              :         spdm_context, m_libspdm_get_capabilities_request16_size,
     965              :         &m_libspdm_get_capabilities_request16, &response_size, response);
     966            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
     967            1 :     assert_int_equal(response_size, sizeof(spdm_error_response_t));
     968            1 :     spdm_response = (void *)response;
     969            1 :     assert_int_equal(m_libspdm_get_capabilities_request16.header.spdm_version,
     970              :                      spdm_response->header.spdm_version);
     971            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_ERROR);
     972            1 :     assert_int_equal(spdm_response->header.param1, SPDM_ERROR_CODE_INVALID_REQUEST);
     973            1 :     assert_int_equal(spdm_response->header.param2, 0);
     974            1 : }
     975              : 
     976            1 : static void rsp_capabilities_case21(void **state)
     977              : {
     978            1 : }
     979              : 
     980            1 : static void rsp_capabilities_case22(void **state)
     981              : {
     982              :     libspdm_return_t status;
     983              :     libspdm_test_context_t *spdm_test_context;
     984              :     libspdm_context_t *spdm_context;
     985              :     size_t response_size;
     986              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
     987              :     spdm_capabilities_response_t *spdm_response;
     988              : 
     989            1 :     spdm_test_context = *state;
     990            1 :     spdm_context = spdm_test_context->spdm_context;
     991            1 :     spdm_test_context->case_id = 0x16;
     992            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_VERSION;
     993              : 
     994            1 :     response_size = sizeof(response);
     995            1 :     status = libspdm_get_response_capabilities(
     996              :         spdm_context, m_libspdm_get_capabilities_request18_size,
     997              :         &m_libspdm_get_capabilities_request18, &response_size, response);
     998            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
     999            1 :     assert_int_equal(response_size, sizeof(spdm_capabilities_response_t) -
    1000              :                      sizeof(spdm_response->data_transfer_size) -
    1001              :                      sizeof(spdm_response->max_spdm_msg_size));
    1002            1 :     spdm_response = (void *)response;
    1003            1 :     assert_int_equal(m_libspdm_get_capabilities_request18.header.spdm_version,
    1004              :                      spdm_response->header.spdm_version);
    1005            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_CAPABILITIES);
    1006            1 : }
    1007              : 
    1008            1 : static void rsp_capabilities_case23(void **state)
    1009              : {
    1010              :     libspdm_return_t status;
    1011              :     libspdm_test_context_t *spdm_test_context;
    1012              :     libspdm_context_t *spdm_context;
    1013              :     size_t response_size;
    1014              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
    1015              :     spdm_capabilities_response_t *spdm_response;
    1016              :     size_t arbitrary_size;
    1017              : 
    1018            1 :     spdm_test_context = *state;
    1019            1 :     spdm_context = spdm_test_context->spdm_context;
    1020            1 :     spdm_test_context->case_id = 0x17;
    1021            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_VERSION;
    1022              : 
    1023              :     /*filling A with arbitrary data*/
    1024            1 :     arbitrary_size = 10;
    1025            1 :     libspdm_set_mem(spdm_context->transcript.message_a.buffer, arbitrary_size, (uint8_t) 0xFF);
    1026            1 :     spdm_context->transcript.message_a.buffer_size = arbitrary_size;
    1027              : 
    1028            1 :     response_size = sizeof(response);
    1029            1 :     status = libspdm_get_response_capabilities(
    1030              :         spdm_context, m_libspdm_get_capabilities_request4_size,
    1031              :         &m_libspdm_get_capabilities_request4, &response_size, response);
    1032            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
    1033            1 :     assert_int_equal(response_size, sizeof(spdm_capabilities_response_t) -
    1034              :                      sizeof(spdm_response->data_transfer_size) -
    1035              :                      sizeof(spdm_response->max_spdm_msg_size));
    1036            1 :     spdm_response = (void *)response;
    1037            1 :     assert_int_equal(m_libspdm_get_capabilities_request4.header.spdm_version,
    1038              :                      spdm_response->header.spdm_version);
    1039            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_CAPABILITIES);
    1040              : 
    1041            1 :     assert_int_equal(spdm_context->transcript.message_a.buffer_size,
    1042              :                      arbitrary_size + m_libspdm_get_capabilities_request4_size + response_size);
    1043            1 :     assert_memory_equal(spdm_context->transcript.message_a.buffer + arbitrary_size,
    1044              :                         &m_libspdm_get_capabilities_request4,
    1045              :                         m_libspdm_get_capabilities_request4_size);
    1046            1 :     assert_memory_equal(spdm_context->transcript.message_a.buffer + arbitrary_size +
    1047              :                         m_libspdm_get_capabilities_request4_size,
    1048              :                         response, response_size);
    1049            1 : }
    1050              : 
    1051            1 : static void rsp_capabilities_case24(void **state)
    1052              : {
    1053              :     libspdm_return_t status;
    1054              :     libspdm_test_context_t *spdm_test_context;
    1055              :     libspdm_context_t *spdm_context;
    1056              :     size_t response_size;
    1057              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
    1058              :     spdm_capabilities_response_t *spdm_response;
    1059              : 
    1060            1 :     spdm_test_context = *state;
    1061            1 :     spdm_context = spdm_test_context->spdm_context;
    1062            1 :     spdm_test_context->case_id = 0x18;
    1063            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_VERSION;
    1064              : 
    1065            1 :     response_size = sizeof(response);
    1066            1 :     status = libspdm_get_response_capabilities(
    1067              :         spdm_context, m_libspdm_get_capabilities_request19_size,
    1068              :         &m_libspdm_get_capabilities_request19, &response_size, response);
    1069            1 :     assert_int_equal(spdm_context->connection_info.capability.max_spdm_msg_size,
    1070              :                      m_libspdm_get_capabilities_request19.max_spdm_msg_size);
    1071            1 :     assert_int_equal(spdm_context->connection_info.capability.data_transfer_size,
    1072              :                      m_libspdm_get_capabilities_request19.data_transfer_size);
    1073            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
    1074            1 :     assert_int_equal(response_size, sizeof(spdm_capabilities_response_t));
    1075            1 :     spdm_response = (void *)response;
    1076            1 :     assert_int_equal(spdm_response->header.spdm_version, SPDM_MESSAGE_VERSION_12);
    1077            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_CAPABILITIES);
    1078            1 :     assert_int_equal(spdm_response->data_transfer_size, LIBSPDM_DATA_TRANSFER_SIZE);
    1079            1 :     assert_int_equal(spdm_response->max_spdm_msg_size, LIBSPDM_MAX_SPDM_MSG_SIZE);
    1080            1 : }
    1081              : 
    1082            1 : static void rsp_capabilities_case25(void **state)
    1083              : {
    1084              :     libspdm_return_t status;
    1085              :     libspdm_test_context_t *spdm_test_context;
    1086              :     libspdm_context_t *spdm_context;
    1087              :     size_t response_size;
    1088              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
    1089              :     spdm_capabilities_response_t *spdm_response;
    1090              : 
    1091            1 :     spdm_test_context = *state;
    1092            1 :     spdm_context = spdm_test_context->spdm_context;
    1093            1 :     spdm_test_context->case_id = 0x19;
    1094            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_VERSION;
    1095              : 
    1096            1 :     response_size = sizeof(response);
    1097            1 :     status = libspdm_get_response_capabilities(
    1098              :         spdm_context, m_libspdm_get_capabilities_request25_size,
    1099              :         &m_libspdm_get_capabilities_request25, &response_size, response);
    1100            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
    1101            1 :     assert_int_equal(response_size, sizeof(spdm_error_response_t));
    1102            1 :     spdm_response = (void *)response;
    1103            1 :     assert_int_equal(m_libspdm_get_capabilities_request25.header.spdm_version,
    1104              :                      spdm_response->header.spdm_version);
    1105            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_ERROR);
    1106            1 :     assert_int_equal(spdm_response->header.param1, SPDM_ERROR_CODE_INVALID_REQUEST);
    1107            1 :     assert_int_equal(spdm_response->header.param2, 0);
    1108            1 : }
    1109              : 
    1110            1 : static void rsp_capabilities_case26(void **state)
    1111              : {
    1112              :     libspdm_return_t status;
    1113              :     libspdm_test_context_t *spdm_test_context;
    1114              :     libspdm_context_t *spdm_context;
    1115              :     size_t response_size;
    1116              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
    1117              :     spdm_capabilities_response_t *spdm_response;
    1118              : 
    1119            1 :     spdm_test_context = *state;
    1120            1 :     spdm_context = spdm_test_context->spdm_context;
    1121            1 :     spdm_test_context->case_id = 0x1A;
    1122            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_VERSION;
    1123              : 
    1124            1 :     response_size = sizeof(response);
    1125            1 :     status = libspdm_get_response_capabilities(
    1126              :         spdm_context, m_libspdm_get_capabilities_request26_size,
    1127              :         &m_libspdm_get_capabilities_request26, &response_size, response);
    1128            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
    1129            1 :     assert_int_equal(response_size, sizeof(spdm_error_response_t));
    1130            1 :     spdm_response = (void *)response;
    1131            1 :     assert_int_equal(m_libspdm_get_capabilities_request26.header.spdm_version,
    1132              :                      spdm_response->header.spdm_version);
    1133            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_ERROR);
    1134            1 :     assert_int_equal(spdm_response->header.param1, SPDM_ERROR_CODE_INVALID_REQUEST);
    1135            1 :     assert_int_equal(spdm_response->header.param2, 0);
    1136            1 : }
    1137              : 
    1138            1 : static void rsp_capabilities_case27(void **state)
    1139              : {
    1140              :     libspdm_return_t status;
    1141              :     libspdm_test_context_t *spdm_test_context;
    1142              :     libspdm_context_t *spdm_context;
    1143              :     size_t response_size;
    1144              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
    1145              :     spdm_capabilities_response_t *spdm_response;
    1146              : 
    1147            1 :     spdm_test_context = *state;
    1148            1 :     spdm_context = spdm_test_context->spdm_context;
    1149            1 :     spdm_test_context->case_id = 0x1B;
    1150            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_VERSION;
    1151              : 
    1152            1 :     response_size = sizeof(response);
    1153            1 :     status = libspdm_get_response_capabilities(
    1154              :         spdm_context, m_libspdm_get_capabilities_request27_size,
    1155              :         &m_libspdm_get_capabilities_request27, &response_size, response);
    1156              : 
    1157            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
    1158            1 :     assert_int_equal(response_size, sizeof(spdm_capabilities_response_t));
    1159            1 :     spdm_response = (void *)response;
    1160            1 :     assert_int_equal(spdm_response->header.spdm_version, SPDM_MESSAGE_VERSION_13);
    1161            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_CAPABILITIES);
    1162            1 :     assert_int_equal(spdm_response->data_transfer_size, LIBSPDM_DATA_TRANSFER_SIZE);
    1163            1 :     assert_int_equal(spdm_response->max_spdm_msg_size, LIBSPDM_MAX_SPDM_MSG_SIZE);
    1164            1 :     assert_int_equal(spdm_context->connection_info.capability.flags,
    1165              :                      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CERT_CAP |
    1166              :                      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_EP_INFO_CAP_SIG |
    1167              :                      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MULTI_KEY_CAP_ONLY);
    1168            1 : }
    1169              : 
    1170            1 : static void rsp_capabilities_case28(void **state)
    1171              : {
    1172              :     libspdm_return_t status;
    1173              :     libspdm_test_context_t *spdm_test_context;
    1174              :     libspdm_context_t *spdm_context;
    1175              :     size_t response_size;
    1176              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
    1177              :     spdm_capabilities_response_t *spdm_response;
    1178              : 
    1179            1 :     spdm_test_context = *state;
    1180            1 :     spdm_context = spdm_test_context->spdm_context;
    1181            1 :     spdm_test_context->case_id = 0x1C;
    1182            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_VERSION;
    1183              : 
    1184            1 :     spdm_context->local_context.algorithm.measurement_spec = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
    1185            1 :     spdm_context->local_context.algorithm.other_params_support = 0;
    1186            1 :     spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
    1187            1 :     spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    1188            1 :     spdm_context->local_context.algorithm.mel_spec = SPDM_MEL_SPECIFICATION_DMTF;
    1189            1 :     spdm_context->local_context.capability.flags =
    1190              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CHUNK_CAP |
    1191              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MULTI_KEY_CAP_ONLY;
    1192              : 
    1193            1 :     spdm_context->connection_info.capability.flags |=
    1194              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP;
    1195            1 :     spdm_context->connection_info.capability.flags |=
    1196              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP;
    1197            1 :     spdm_context->connection_info.capability.flags |=
    1198              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
    1199              : 
    1200            1 :     spdm_context->local_context.algorithm.dhe_named_group = m_libspdm_use_dhe_algo;
    1201            1 :     spdm_context->local_context.algorithm.aead_cipher_suite = m_libspdm_use_aead_algo;
    1202            1 :     spdm_context->local_context.algorithm.req_base_asym_alg = m_libspdm_use_req_asym_algo;
    1203            1 :     spdm_context->local_context.algorithm.key_schedule = m_libspdm_use_key_schedule_algo;
    1204              : 
    1205            1 :     response_size = sizeof(response);
    1206            1 :     status = libspdm_get_response_capabilities(
    1207              :         spdm_context, m_libspdm_get_capabilities_request28_size,
    1208              :         &m_libspdm_get_capabilities_request28, &response_size, response);
    1209            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
    1210            1 :     assert_int_equal(response_size, sizeof(spdm_capabilities_response_t) +
    1211              :                      sizeof(spdm_supported_algorithms_block_t) +
    1212              :                      4 * sizeof(spdm_negotiate_algorithms_common_struct_table_t));
    1213            1 :     spdm_response = (void *)response;
    1214            1 :     assert_int_equal(spdm_response->header.spdm_version, SPDM_MESSAGE_VERSION_13);
    1215            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_CAPABILITIES);
    1216            1 :     assert_int_equal(spdm_response->data_transfer_size, LIBSPDM_DATA_TRANSFER_SIZE);
    1217            1 :     assert_int_equal(spdm_response->max_spdm_msg_size, LIBSPDM_MAX_SPDM_MSG_SIZE);
    1218            1 :     assert_int_equal(spdm_context->connection_info.capability.flags,
    1219              :                      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHUNK_CAP |
    1220              :                      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CERT_CAP |
    1221              :                      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_EP_INFO_CAP_SIG |
    1222              :                      SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MULTI_KEY_CAP_ONLY);
    1223            1 : }
    1224              : 
    1225            1 : int libspdm_rsp_capabilities_test(void)
    1226              : {
    1227            1 :     const struct CMUnitTest test_cases[] = {
    1228              :         /* Success Case*/
    1229              :         cmocka_unit_test(rsp_capabilities_case1),
    1230              :         /* Success case where request size is larger than actual message. */
    1231              :         cmocka_unit_test(rsp_capabilities_case2),
    1232              :         /* response_state: LIBSPDM_RESPONSE_STATE_BUSY*/
    1233              :         cmocka_unit_test(rsp_capabilities_case3),
    1234              :         /* response_state: LIBSPDM_RESPONSE_STATE_NEED_RESYNC*/
    1235              :         cmocka_unit_test(rsp_capabilities_case4),
    1236              :         /* connection_state Check*/
    1237              :         cmocka_unit_test(rsp_capabilities_case6),
    1238              :         /* Invalid requester capabilities flag (random flag)*/
    1239              :         cmocka_unit_test(rsp_capabilities_case7),
    1240              :         /* V1.1 Success case, all possible flags set*/
    1241              :         cmocka_unit_test(rsp_capabilities_case8),
    1242              :         /* Requester capabilities flag bit 0 is set. reserved value should ne ignored*/
    1243              :         cmocka_unit_test(rsp_capabilities_case9),
    1244              :         /* Can be populated with new test. */
    1245              :         cmocka_unit_test(rsp_capabilities_case10),
    1246              :         /* Can be populated with new test. */
    1247              :         cmocka_unit_test(rsp_capabilities_case11),
    1248              :         /* Can be populated with new test. */
    1249              :         cmocka_unit_test(rsp_capabilities_case12),
    1250              :         /* pub_key_id_cap and cert_cap set (flags are mutually exclusive)*/
    1251              :         cmocka_unit_test(rsp_capabilities_case13),
    1252              :         /* encrypt_cap set and key_ex_cap and psk_cap cleared (encrypt_cap demands key_ex_cap or psk_cap to be set)*/
    1253              :         cmocka_unit_test(rsp_capabilities_case14),
    1254              :         /* mac_cap set and key_ex_cap and psk_cap cleared (mac_cap demands key_ex_cap or psk_cap to be set)*/
    1255              :         cmocka_unit_test(rsp_capabilities_case15),
    1256              :         /* key_ex_cap set and encrypt_cap and mac_cap cleared (key_ex_cap demands encrypt_cap or mac_cap to be set)*/
    1257              :         cmocka_unit_test(rsp_capabilities_case16),
    1258              :         /* psk_cap set and encrypt_cap and mac_cap cleared (psk_cap demands encrypt_cap or mac_cap to be set)*/
    1259              :         cmocka_unit_test(rsp_capabilities_case17),
    1260              :         /* encap_cap cleared and MUT_AUTH set (MUT_AUTH demands encap_cap to be set)*/
    1261              :         cmocka_unit_test(rsp_capabilities_case18),
    1262              :         /* cert_cap set and pub_key_id_cap set (pub_key_id_cap demands cert_cap to be cleared)*/
    1263              :         cmocka_unit_test(rsp_capabilities_case19),
    1264              :         /* key_ex_cap cleared and handshake_in_the_clear_cap set (handshake_in_the_clear_cap demands key_ex_cap to be set)*/
    1265              :         cmocka_unit_test(rsp_capabilities_case20),
    1266              :         /* Open test case */
    1267              :         cmocka_unit_test(rsp_capabilities_case21),
    1268              :         /* cert_cap cleared and pub_key_id_cap set (pub_key_id_cap demands cert_cap to be cleared)*/
    1269              :         cmocka_unit_test(rsp_capabilities_case22),
    1270              :         /* Buffer verification*/
    1271              :         cmocka_unit_test(rsp_capabilities_case23),
    1272              :         /* V1.2 Success case, all possible flags set*/
    1273              :         cmocka_unit_test(rsp_capabilities_case24),
    1274              :         /* CHUNK_CAP == 0 and data_transfer_size != max_spdm_msg_size should result in error. */
    1275              :         cmocka_unit_test(rsp_capabilities_case25),
    1276              :         /* MaxSPDMmsgSize is less than DataTransferSize, then should result in error. */
    1277              :         cmocka_unit_test(rsp_capabilities_case26),
    1278              :         /* Success Case , capability supports MULTI_KEY_CAP */
    1279              :         cmocka_unit_test(rsp_capabilities_case27),
    1280              :         /* Success Case, GET_CAPABILITIES with param1[0] set and CHUNK_CAP enabled */
    1281              :         cmocka_unit_test(rsp_capabilities_case28),
    1282              :     };
    1283              : 
    1284            1 :     libspdm_test_context_t test_context = {
    1285              :         LIBSPDM_TEST_CONTEXT_VERSION,
    1286              :         false,
    1287              :     };
    1288              : 
    1289            1 :     libspdm_setup_test_context(&test_context);
    1290              : 
    1291            1 :     return cmocka_run_group_tests(test_cases,
    1292              :                                   libspdm_unit_test_group_setup,
    1293              :                                   libspdm_unit_test_group_teardown);
    1294              : }
        

Generated by: LCOV version 2.0-1