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

            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              : #pragma pack(1)
      11              : typedef struct {
      12              :     spdm_negotiate_algorithms_request_t spdm_request_version10;
      13              :     spdm_negotiate_algorithms_common_struct_table_t struct_table[4];
      14              : } libspdm_negotiate_algorithms_request_spdm11_t;
      15              : 
      16              : typedef struct {
      17              :     spdm_negotiate_algorithms_request_t spdm_request_version10;
      18              :     uint32_t extra[21];
      19              :     spdm_negotiate_algorithms_common_struct_table_t struct_table[4];
      20              : } libspdm_negotiate_algorithms_request_spdm11_oversized_t;
      21              : 
      22              : typedef struct {
      23              :     spdm_negotiate_algorithms_request_t spdm_request_version10;
      24              :     spdm_negotiate_algorithms_common_struct_table_t struct_table[12];
      25              : } libspdm_negotiate_algorithms_request_spdm11_multiple_tables_t;
      26              : 
      27              : typedef struct {
      28              :     spdm_negotiate_algorithms_request_t spdm_request_version10;
      29              :     spdm_negotiate_algorithms_common_struct_table_t struct_table[4];
      30              : } libspdm_negotiate_algorithms_request_spdm12_t;
      31              : 
      32              : typedef struct {
      33              :     spdm_negotiate_algorithms_request_t spdm_request_version10;
      34              :     spdm_negotiate_algorithms_common_struct_table_t struct_table[5];
      35              : } libspdm_negotiate_algorithms_request_spdm12_more_algo_t;
      36              : 
      37              : typedef struct {
      38              :     spdm_message_header_t header;
      39              :     uint16_t length;
      40              :     uint8_t measurement_specification_sel;
      41              :     uint8_t reserved;
      42              :     uint32_t measurement_hash_algo;
      43              :     uint32_t base_asym_sel;
      44              :     uint32_t base_hash_sel;
      45              :     uint8_t reserved2[12];
      46              :     uint8_t ext_asym_sel_count;
      47              :     uint8_t ext_hash_sel_count;
      48              :     uint16_t reserved3;
      49              :     spdm_negotiate_algorithms_common_struct_table_t struct_table[4];
      50              : } libspdm_algorithms_response_mine_t;
      51              : #pragma pack()
      52              : 
      53              : spdm_negotiate_algorithms_request_t m_libspdm_negotiate_algorithms_request1 = {
      54              :     { SPDM_MESSAGE_VERSION_10, SPDM_NEGOTIATE_ALGORITHMS, 0, 0 },
      55              :     sizeof(spdm_negotiate_algorithms_request_t),
      56              :     SPDM_MEASUREMENT_SPECIFICATION_DMTF,
      57              : };
      58              : size_t m_libspdm_negotiate_algorithms_request1_size =
      59              :     sizeof(m_libspdm_negotiate_algorithms_request1);
      60              : 
      61              : spdm_negotiate_algorithms_request_t m_libspdm_negotiate_algorithms_request2 = {
      62              :     { SPDM_MESSAGE_VERSION_10, SPDM_NEGOTIATE_ALGORITHMS, 0, 0 },
      63              :     sizeof(spdm_negotiate_algorithms_request_t),
      64              :     SPDM_MEASUREMENT_SPECIFICATION_DMTF,
      65              : };
      66              : size_t m_libspdm_negotiate_algorithms_request2_size = sizeof(spdm_message_header_t);
      67              : 
      68              : libspdm_negotiate_algorithms_request_spdm11_t m_libspdm_negotiate_algorithm_request3 = {
      69              :     {
      70              :         {
      71              :             SPDM_MESSAGE_VERSION_11,
      72              :             SPDM_NEGOTIATE_ALGORITHMS,
      73              :             4,
      74              :             0
      75              :         },
      76              :         sizeof(libspdm_negotiate_algorithms_request_spdm11_t),
      77              :         SPDM_MEASUREMENT_SPECIFICATION_DMTF,
      78              :     },
      79              :     {
      80              :         {
      81              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE,
      82              :             0x20,
      83              :             SPDM_ALGORITHMS_DHE_NAMED_GROUP_SECP_256_R1
      84              :         },
      85              :         {
      86              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD,
      87              :             0x20,
      88              :             SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_AES_256_GCM
      89              :         },
      90              :         {
      91              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG,
      92              :             0x20,
      93              :             SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_RSASSA_2048
      94              :         },
      95              :         {
      96              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE,
      97              :             0x20,
      98              :             SPDM_ALGORITHMS_KEY_SCHEDULE_SPDM
      99              :         }
     100              :     }
     101              : };
     102              : size_t m_libspdm_negotiate_algorithm_request3_size = sizeof(m_libspdm_negotiate_algorithm_request3);
     103              : 
     104              : libspdm_negotiate_algorithms_request_spdm11_t m_libspdm_negotiate_algorithm_request4 = {
     105              :     {
     106              :         {
     107              :             SPDM_MESSAGE_VERSION_11,
     108              :             SPDM_NEGOTIATE_ALGORITHMS,
     109              :             4,
     110              :             0
     111              :         },
     112              :         sizeof(libspdm_negotiate_algorithms_request_spdm11_t),
     113              :         SPDM_MEASUREMENT_SPECIFICATION_DMTF,
     114              :     },
     115              :     {
     116              :         {
     117              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE,
     118              :             0x20,
     119              :             SPDM_ALGORITHMS_DHE_NAMED_GROUP_SECP_256_R1
     120              :         },
     121              :         {
     122              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD,
     123              :             0x20,
     124              :             SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_AES_256_GCM
     125              :         },
     126              :         {
     127              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG,
     128              :             0x20,
     129              :             SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_RSASSA_2048
     130              :         },
     131              :         {
     132              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE,
     133              :             0x20,
     134              :             SPDM_ALGORITHMS_KEY_SCHEDULE_SPDM
     135              :         }
     136              :     }
     137              : };
     138              : size_t m_libspdm_negotiate_algorithm_request4_size = sizeof(m_libspdm_negotiate_algorithm_request4);
     139              : 
     140              : libspdm_negotiate_algorithms_request_spdm11_t m_libspdm_negotiate_algorithm_request5 = {
     141              :     {
     142              :         {
     143              :             SPDM_MESSAGE_VERSION_11,
     144              :             SPDM_NEGOTIATE_ALGORITHMS,
     145              :             4,
     146              :             0
     147              :         },
     148              :         sizeof(libspdm_negotiate_algorithms_request_spdm11_t),
     149              :         SPDM_MEASUREMENT_SPECIFICATION_DMTF,
     150              :     },
     151              :     {
     152              :         {
     153              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE,
     154              :             0x20,
     155              :             SPDM_ALGORITHMS_DHE_NAMED_GROUP_SECP_256_R1
     156              :         },
     157              :         {
     158              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD,
     159              :             0x20,
     160              :             SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_AES_256_GCM
     161              :         },
     162              :         {
     163              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG,
     164              :             0x20,
     165              :             SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_RSASSA_2048
     166              :         },
     167              :         {
     168              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE,
     169              :             0x20,
     170              :             SPDM_ALGORITHMS_KEY_SCHEDULE_SPDM
     171              :         }
     172              :     }
     173              : };
     174              : size_t m_libspdm_negotiate_algorithm_request5_size = sizeof(m_libspdm_negotiate_algorithm_request5);
     175              : 
     176              : libspdm_negotiate_algorithms_request_spdm11_t m_libspdm_negotiate_algorithm_request6 = {
     177              :     {
     178              :         {
     179              :             SPDM_MESSAGE_VERSION_11,
     180              :             SPDM_NEGOTIATE_ALGORITHMS,
     181              :             4,
     182              :             0
     183              :         },
     184              :         sizeof(libspdm_negotiate_algorithms_request_spdm11_t),
     185              :         SPDM_MEASUREMENT_SPECIFICATION_DMTF,
     186              :     },
     187              :     {
     188              :         {
     189              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE,
     190              :             0x20,
     191              :             SPDM_ALGORITHMS_DHE_NAMED_GROUP_SECP_521_R1
     192              :         },
     193              :         {
     194              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD,
     195              :             0x20,
     196              :             SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_AES_256_GCM
     197              :         },
     198              :         {
     199              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG,
     200              :             0x20,
     201              :             SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_RSASSA_2048
     202              :         },
     203              :         {
     204              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE,
     205              :             0x20,
     206              :             SPDM_ALGORITHMS_KEY_SCHEDULE_SPDM
     207              :         }
     208              :     }
     209              : };
     210              : size_t m_libspdm_negotiate_algorithm_request6_size = sizeof(m_libspdm_negotiate_algorithm_request6);
     211              : 
     212              : libspdm_negotiate_algorithms_request_spdm11_t m_libspdm_negotiate_algorithm_request7 = {
     213              :     {
     214              :         {
     215              :             SPDM_MESSAGE_VERSION_11,
     216              :             SPDM_NEGOTIATE_ALGORITHMS,
     217              :             4,
     218              :             0
     219              :         },
     220              :         sizeof(libspdm_negotiate_algorithms_request_spdm11_t),
     221              :         SPDM_MEASUREMENT_SPECIFICATION_DMTF,
     222              :     },
     223              :     {
     224              :         {
     225              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE,
     226              :             0x20,
     227              :             SPDM_ALGORITHMS_DHE_NAMED_GROUP_SECP_256_R1
     228              :         },
     229              :         {
     230              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD,
     231              :             0x20,
     232              :             SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_CHACHA20_POLY1305
     233              :         },
     234              :         {
     235              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG,
     236              :             0x20,
     237              :             SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_RSASSA_2048
     238              :         },
     239              :         {
     240              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE,
     241              :             0x20,
     242              :             SPDM_ALGORITHMS_KEY_SCHEDULE_SPDM
     243              :         }
     244              :     }
     245              : };
     246              : size_t m_libspdm_negotiate_algorithm_request7_size = sizeof(m_libspdm_negotiate_algorithm_request7);
     247              : 
     248              : libspdm_negotiate_algorithms_request_spdm11_t m_libspdm_negotiate_algorithm_request8 = {
     249              :     {
     250              :         {
     251              :             SPDM_MESSAGE_VERSION_11,
     252              :             SPDM_NEGOTIATE_ALGORITHMS,
     253              :             4,
     254              :             0
     255              :         },
     256              :         sizeof(libspdm_negotiate_algorithms_request_spdm11_t),
     257              :         SPDM_MEASUREMENT_SPECIFICATION_DMTF,
     258              :     },
     259              :     {
     260              :         {
     261              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE,
     262              :             0x20,
     263              :             SPDM_ALGORITHMS_DHE_NAMED_GROUP_SECP_256_R1
     264              :         },
     265              :         {
     266              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD,
     267              :             0x20,
     268              :             SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_AES_256_GCM
     269              :         },
     270              :         {
     271              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG,
     272              :             0x20,
     273              :             SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_ECDSA_ECC_NIST_P521
     274              :         },
     275              :         {
     276              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE,
     277              :             0x20,
     278              :             SPDM_ALGORITHMS_KEY_SCHEDULE_SPDM
     279              :         }
     280              :     }
     281              : };
     282              : size_t m_libspdm_negotiate_algorithm_request8_size = sizeof(m_libspdm_negotiate_algorithm_request8);
     283              : 
     284              : libspdm_negotiate_algorithms_request_spdm11_t m_libspdm_negotiate_algorithm_request9 = {
     285              :     {
     286              :         {
     287              :             SPDM_MESSAGE_VERSION_11,
     288              :             SPDM_NEGOTIATE_ALGORITHMS,
     289              :             4,
     290              :             0
     291              :         },
     292              :         sizeof(libspdm_negotiate_algorithms_request_spdm11_t),
     293              :         SPDM_MEASUREMENT_SPECIFICATION_DMTF,
     294              :     },
     295              :     {
     296              :         {
     297              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE,
     298              :             0x20,
     299              :             SPDM_ALGORITHMS_DHE_NAMED_GROUP_SECP_256_R1
     300              :         },
     301              :         {
     302              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD,
     303              :             0x20,
     304              :             SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_AES_256_GCM
     305              :         },
     306              :         {
     307              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG,
     308              :             0x20,
     309              :             SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_RSASSA_2048
     310              :         },
     311              :         {
     312              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE,
     313              :             0x20,
     314              :             0x00000020
     315              :         }
     316              :     }
     317              : };
     318              : size_t m_libspdm_negotiate_algorithm_request9_size = sizeof(m_libspdm_negotiate_algorithm_request9);
     319              : 
     320              : spdm_negotiate_algorithms_request_t m_libspdm_negotiate_algorithm_request10 = {
     321              :     {
     322              :         SPDM_MESSAGE_VERSION_10,
     323              :         SPDM_NEGOTIATE_ALGORITHMS,
     324              :         0,
     325              :         0
     326              :     },
     327              :     0x44,
     328              :     SPDM_MEASUREMENT_SPECIFICATION_DMTF,
     329              : };
     330              : size_t m_libspdm_negotiate_algorithm_request10_size = 0x44;
     331              : 
     332              : libspdm_negotiate_algorithms_request_spdm11_oversized_t m_libspdm_negotiate_algorithm_request11 = {
     333              :     {
     334              :         {
     335              :             SPDM_MESSAGE_VERSION_11,
     336              :             SPDM_NEGOTIATE_ALGORITHMS,
     337              :             4,
     338              :             0
     339              :         },
     340              :         sizeof(libspdm_negotiate_algorithms_request_spdm11_oversized_t),
     341              :         SPDM_MEASUREMENT_SPECIFICATION_DMTF,
     342              :     },
     343              :     {0},
     344              :     {
     345              :         {
     346              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE,
     347              :             0x20,
     348              :             SPDM_ALGORITHMS_DHE_NAMED_GROUP_SECP_256_R1
     349              :         },
     350              :         {
     351              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD,
     352              :             0x20,
     353              :             SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_AES_256_GCM
     354              :         },
     355              :         {
     356              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG,
     357              :             0x20,
     358              :             SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_RSASSA_2048
     359              :         },
     360              :         {
     361              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE,
     362              :             0x20,
     363              :             SPDM_ALGORITHMS_KEY_SCHEDULE_SPDM
     364              :         }
     365              :     }
     366              : };
     367              : size_t m_libspdm_negotiate_algorithm_request11_size =
     368              :     sizeof(m_libspdm_negotiate_algorithm_request11);
     369              : 
     370              : libspdm_negotiate_algorithms_request_spdm11_multiple_tables_t
     371              :     m_libspdm_negotiate_algorithm_request12 = {
     372              :     {
     373              :         {
     374              :             SPDM_MESSAGE_VERSION_11,
     375              :             SPDM_NEGOTIATE_ALGORITHMS,
     376              :             12,
     377              :             0
     378              :         },
     379              :         sizeof(libspdm_negotiate_algorithms_request_spdm11_multiple_tables_t),
     380              :         SPDM_MEASUREMENT_SPECIFICATION_DMTF,
     381              :     },
     382              :     {
     383              :         {
     384              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE,
     385              :             0x20,
     386              :             SPDM_ALGORITHMS_DHE_NAMED_GROUP_FFDHE_2048
     387              :         },
     388              :         {
     389              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD,
     390              :             0x20,
     391              :             SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_AES_128_GCM
     392              :         },
     393              :         {
     394              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG,
     395              :             0x20,
     396              :             SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_ECDSA_ECC_NIST_P256
     397              :         },
     398              :         {
     399              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE,
     400              :             0x20,
     401              :             SPDM_ALGORITHMS_KEY_SCHEDULE_SPDM
     402              :         },
     403              :         {
     404              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE,
     405              :             0x20,
     406              :             SPDM_ALGORITHMS_DHE_NAMED_GROUP_FFDHE_3072
     407              :         },
     408              :         {
     409              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD,
     410              :             0x20,
     411              :             SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_CHACHA20_POLY1305
     412              :         },
     413              :         {
     414              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG,
     415              :             0x20,
     416              :             SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_ECDSA_ECC_NIST_P384
     417              :         },
     418              :         {
     419              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE,
     420              :             0x20,
     421              :             SPDM_ALGORITHMS_KEY_SCHEDULE_SPDM
     422              :         },
     423              :         {
     424              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE,
     425              :             0x20,
     426              :             SPDM_ALGORITHMS_DHE_NAMED_GROUP_SECP_256_R1
     427              :         },
     428              :         {
     429              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD,
     430              :             0x20,
     431              :             SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_AES_256_GCM
     432              :         },
     433              :         {
     434              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG,
     435              :             0x20,
     436              :             SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_RSASSA_2048
     437              :         },
     438              :         {
     439              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE,
     440              :             0x20,
     441              :             SPDM_ALGORITHMS_KEY_SCHEDULE_SPDM
     442              :         }
     443              :     }
     444              : };
     445              : size_t m_libspdm_negotiate_algorithm_request12_size =
     446              :     sizeof(m_libspdm_negotiate_algorithm_request12);
     447              : 
     448              : libspdm_negotiate_algorithms_request_spdm11_t
     449              :     m_libspdm_negotiate_algorithm_request13 = {
     450              :     {
     451              :         {
     452              :             SPDM_MESSAGE_VERSION_11,
     453              :             SPDM_NEGOTIATE_ALGORITHMS,
     454              :             3,
     455              :             0
     456              :         },
     457              :         sizeof(libspdm_negotiate_algorithms_request_spdm11_t)-
     458              :         sizeof(spdm_negotiate_algorithms_common_struct_table_t),
     459              :         SPDM_MEASUREMENT_SPECIFICATION_DMTF,
     460              :     },
     461              :     {
     462              :         {
     463              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE,
     464              :             0x20,
     465              :             SPDM_ALGORITHMS_DHE_NAMED_GROUP_SECP_256_R1
     466              :         },
     467              :         {
     468              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD,
     469              :             0x20,
     470              :             SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_AES_256_GCM
     471              :         },
     472              :         {
     473              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG,
     474              :             0x20,
     475              :             SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_RSASSA_2048
     476              :         },
     477              :         {
     478              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE,
     479              :             0x20,
     480              :             SPDM_ALGORITHMS_KEY_SCHEDULE_SPDM
     481              :         }
     482              :     }
     483              : };
     484              : size_t m_libspdm_negotiate_algorithm_request13_size =
     485              :     sizeof(m_libspdm_negotiate_algorithm_request13)-
     486              :     sizeof( spdm_negotiate_algorithms_common_struct_table_t);
     487              : 
     488              : libspdm_negotiate_algorithms_request_spdm11_t
     489              :     m_libspdm_negotiate_algorithm_request14 = {
     490              :     {
     491              :         {
     492              :             SPDM_MESSAGE_VERSION_11,
     493              :             SPDM_NEGOTIATE_ALGORITHMS,
     494              :             5,
     495              :             0
     496              :         },
     497              :         sizeof(libspdm_negotiate_algorithms_request_spdm11_t)+
     498              :         sizeof(spdm_negotiate_algorithms_common_struct_table_t),
     499              :         SPDM_MEASUREMENT_SPECIFICATION_DMTF,
     500              :     },
     501              :     {
     502              :         {
     503              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE,
     504              :             0x20,
     505              :             SPDM_ALGORITHMS_DHE_NAMED_GROUP_FFDHE_2048
     506              :         },
     507              :         {
     508              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD,
     509              :             0x20,
     510              :             SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_AES_128_GCM
     511              :         },
     512              :         {
     513              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG,
     514              :             0x20,
     515              :             SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_ECDSA_ECC_NIST_P256
     516              :         },
     517              :         {
     518              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE,
     519              :             0x20,
     520              :             SPDM_ALGORITHMS_KEY_SCHEDULE_SPDM
     521              :         },
     522              :     }
     523              : };
     524              : size_t m_libspdm_negotiate_algorithm_request14_size =
     525              :     sizeof(m_libspdm_negotiate_algorithm_request14)+
     526              :     sizeof( spdm_negotiate_algorithms_common_struct_table_t);
     527              : 
     528              : libspdm_negotiate_algorithms_request_spdm11_t
     529              :     m_libspdm_negotiate_algorithm_request15 = {
     530              :     {
     531              :         {
     532              :             SPDM_MESSAGE_VERSION_11,
     533              :             SPDM_NEGOTIATE_ALGORITHMS,
     534              :             12,
     535              :             0
     536              :         },
     537              :         sizeof(libspdm_negotiate_algorithms_request_spdm11_t),
     538              :         SPDM_MEASUREMENT_SPECIFICATION_DMTF,
     539              :     },
     540              :     {
     541              :         {
     542              :             1,
     543              :             0x20,
     544              :             SPDM_ALGORITHMS_DHE_NAMED_GROUP_SECP_256_R1
     545              :         },
     546              :         {
     547              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD,
     548              :             0x20,
     549              :             SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_AES_256_GCM
     550              :         },
     551              :         {
     552              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG,
     553              :             0x20,
     554              :             SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_RSASSA_2048
     555              :         },
     556              :         {
     557              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE,
     558              :             0x20,
     559              :             SPDM_ALGORITHMS_KEY_SCHEDULE_SPDM
     560              :         }
     561              :     }
     562              : };
     563              : size_t m_libspdm_negotiate_algorithm_request15_size =
     564              :     sizeof(m_libspdm_negotiate_algorithm_request15);
     565              : 
     566              : libspdm_negotiate_algorithms_request_spdm11_t m_libspdm_negotiate_algorithm_request16 = {
     567              :     {
     568              :         {
     569              :             SPDM_MESSAGE_VERSION_11,
     570              :             SPDM_NEGOTIATE_ALGORITHMS,
     571              :             4,
     572              :             0
     573              :         },
     574              :         sizeof(libspdm_negotiate_algorithms_request_spdm11_t),
     575              :         SPDM_MEASUREMENT_SPECIFICATION_DMTF,
     576              :     },
     577              :     {
     578              :         {
     579              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE,
     580              :             0x20,
     581              :             SPDM_ALGORITHMS_DHE_NAMED_GROUP_SECP_256_R1 |
     582              :             SPDM_ALGORITHMS_DHE_NAMED_GROUP_SECP_384_R1
     583              :         },
     584              :         {
     585              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD,
     586              :             0x20,
     587              :             SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_AES_256_GCM
     588              :         },
     589              :         {
     590              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG,
     591              :             0x20,
     592              :             SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_RSASSA_2048
     593              :         },
     594              :         {
     595              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE,
     596              :             0x20,
     597              :             SPDM_ALGORITHMS_KEY_SCHEDULE_SPDM
     598              :         }
     599              :     }
     600              : };
     601              : size_t m_libspdm_negotiate_algorithm_request16_size =
     602              :     sizeof(m_libspdm_negotiate_algorithm_request16);
     603              : 
     604              : libspdm_negotiate_algorithms_request_spdm12_t
     605              :     m_libspdm_negotiate_algorithm_request17 = {
     606              :     {
     607              :         {
     608              :             SPDM_MESSAGE_VERSION_12,
     609              :             SPDM_NEGOTIATE_ALGORITHMS,
     610              :             4,
     611              :             0
     612              :         },
     613              :         sizeof(libspdm_negotiate_algorithms_request_spdm12_t),
     614              :         SPDM_MEASUREMENT_SPECIFICATION_DMTF,
     615              :         SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_1,
     616              :     },
     617              :     {
     618              :         {
     619              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE,
     620              :             0x20,
     621              :             SPDM_ALGORITHMS_DHE_NAMED_GROUP_SECP_256_R1
     622              :         },
     623              :         {
     624              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD,
     625              :             0x20,
     626              :             SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_AES_256_GCM
     627              :         },
     628              :         {
     629              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG,
     630              :             0x20,
     631              :             SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_RSASSA_2048
     632              :         },
     633              :         {
     634              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE,
     635              :             0x20,
     636              :             SPDM_ALGORITHMS_KEY_SCHEDULE_SPDM
     637              :         }
     638              :     }
     639              : };
     640              : size_t m_libspdm_negotiate_algorithm_request17_size =
     641              :     sizeof(m_libspdm_negotiate_algorithm_request17);
     642              : 
     643              : libspdm_negotiate_algorithms_request_spdm12_t
     644              :     m_libspdm_negotiate_algorithm_request18 = {
     645              :     {
     646              :         {
     647              :             SPDM_MESSAGE_VERSION_12,
     648              :             SPDM_NEGOTIATE_ALGORITHMS,
     649              :             4,
     650              :             0
     651              :         },
     652              :         sizeof(libspdm_negotiate_algorithms_request_spdm12_t),
     653              :         SPDM_MEASUREMENT_SPECIFICATION_DMTF,
     654              :         /* Illegal OpaqueDataFmt. */
     655              :         0x04,
     656              :     },
     657              :     {
     658              :         {
     659              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE,
     660              :             0x20,
     661              :             SPDM_ALGORITHMS_DHE_NAMED_GROUP_SECP_256_R1
     662              :         },
     663              :         {
     664              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD,
     665              :             0x20,
     666              :             SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_AES_256_GCM
     667              :         },
     668              :         {
     669              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG,
     670              :             0x20,
     671              :             SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_RSASSA_2048
     672              :         },
     673              :         {
     674              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE,
     675              :             0x20,
     676              :             SPDM_ALGORITHMS_KEY_SCHEDULE_SPDM
     677              :         }
     678              :     }
     679              : };
     680              : size_t m_libspdm_negotiate_algorithm_request18_size =
     681              :     sizeof(m_libspdm_negotiate_algorithm_request18);
     682              : 
     683              : libspdm_negotiate_algorithms_request_spdm11_t m_libspdm_negotiate_algorithm_request24 = {
     684              :     {
     685              :         {
     686              :             SPDM_MESSAGE_VERSION_12,
     687              :             SPDM_NEGOTIATE_ALGORITHMS,
     688              :             4,
     689              :             0
     690              :         },
     691              :         sizeof(libspdm_negotiate_algorithms_request_spdm11_t),
     692              :         0, /* SPDM_MEASUREMENT_SPECIFICATION_DMTF */
     693              :         SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_1,
     694              :         SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_ECDSA_ECC_NIST_P256,
     695              :         SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA_256,
     696              :     },
     697              :     {
     698              :         {
     699              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE,
     700              :             0x20,
     701              :             SPDM_ALGORITHMS_DHE_NAMED_GROUP_SECP_256_R1
     702              :         },
     703              :         {
     704              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD,
     705              :             0x20,
     706              :             SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_AES_256_GCM
     707              :         },
     708              :         {
     709              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG,
     710              :             0x20,
     711              :             SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_RSASSA_2048
     712              :         },
     713              :         {
     714              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE,
     715              :             0x20,
     716              :             SPDM_ALGORITHMS_KEY_SCHEDULE_SPDM
     717              :         }
     718              :     }
     719              : };
     720              : size_t m_libspdm_negotiate_algorithm_request24_size =
     721              :     sizeof(m_libspdm_negotiate_algorithm_request24);
     722              : 
     723              : libspdm_negotiate_algorithms_request_spdm12_t
     724              :     m_libspdm_negotiate_algorithm_request25 = {
     725              :     {
     726              :         {
     727              :             SPDM_MESSAGE_VERSION_12,
     728              :             SPDM_NEGOTIATE_ALGORITHMS,
     729              :             4,
     730              :             0
     731              :         },
     732              :         sizeof(libspdm_negotiate_algorithms_request_spdm12_t),
     733              :         SPDM_MEASUREMENT_SPECIFICATION_DMTF,
     734              :         SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_1,
     735              :         SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_ECDSA_ECC_NIST_P256,
     736              :         SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA_256,
     737              :     },
     738              :     {
     739              :         {
     740              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE,
     741              :             0x20,
     742              :             SPDM_ALGORITHMS_DHE_NAMED_GROUP_SECP_256_R1
     743              :         },
     744              :         {
     745              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE,
     746              :             0x20,
     747              :             SPDM_ALGORITHMS_DHE_NAMED_GROUP_SECP_256_R1
     748              :         },
     749              :         {
     750              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG,
     751              :             0x20,
     752              :             SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_RSASSA_2048
     753              :         },
     754              :         {
     755              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE,
     756              :             0x20,
     757              :             SPDM_ALGORITHMS_KEY_SCHEDULE_SPDM
     758              :         }
     759              :     }
     760              : };
     761              : size_t m_libspdm_negotiate_algorithm_request25_size =
     762              :     sizeof(m_libspdm_negotiate_algorithm_request25);
     763              : 
     764              : libspdm_negotiate_algorithms_request_spdm12_t
     765              :     m_libspdm_negotiate_algorithm_request26 = {
     766              :     {
     767              :         {
     768              :             SPDM_MESSAGE_VERSION_12,
     769              :             SPDM_NEGOTIATE_ALGORITHMS,
     770              :             4,
     771              :             0
     772              :         },
     773              :         sizeof(libspdm_negotiate_algorithms_request_spdm12_t),
     774              :         SPDM_MEASUREMENT_SPECIFICATION_DMTF,
     775              :         SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_1,
     776              :         SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_ECDSA_ECC_NIST_P256,
     777              :         SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA_256,
     778              :     },
     779              :     {
     780              :         {
     781              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE,
     782              :             0x20,
     783              :             SPDM_ALGORITHMS_DHE_NAMED_GROUP_SECP_256_R1
     784              :         },
     785              :         {
     786              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG,
     787              :             0x20,
     788              :             SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_RSASSA_2048
     789              :         },
     790              :         {
     791              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE,
     792              :             0x20,
     793              :             SPDM_ALGORITHMS_KEY_SCHEDULE_SPDM
     794              :         },
     795              :         {
     796              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD,
     797              :             0x20,
     798              :             SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_AES_256_GCM
     799              :         }
     800              :     }
     801              : };
     802              : size_t m_libspdm_negotiate_algorithm_request26_size =
     803              :     sizeof(m_libspdm_negotiate_algorithm_request26);
     804              : 
     805              : libspdm_negotiate_algorithms_request_spdm12_more_algo_t
     806              :     m_libspdm_negotiate_algorithm_request27 = {
     807              :     {
     808              :         {
     809              :             SPDM_MESSAGE_VERSION_12,
     810              :             SPDM_NEGOTIATE_ALGORITHMS,
     811              :             5,
     812              :             0
     813              :         },
     814              :         sizeof(libspdm_negotiate_algorithms_request_spdm12_more_algo_t),
     815              :         SPDM_MEASUREMENT_SPECIFICATION_DMTF,
     816              :         SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_1,
     817              :         SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_ECDSA_ECC_NIST_P256,
     818              :         SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA_256,
     819              :     },
     820              :     {
     821              :         {
     822              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE - 1,
     823              :             0x20,
     824              :             SPDM_ALGORITHMS_DHE_NAMED_GROUP_SECP_256_R1
     825              :         },
     826              :         {
     827              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE,
     828              :             0x20,
     829              :             SPDM_ALGORITHMS_DHE_NAMED_GROUP_SECP_256_R1
     830              :         },
     831              :         {
     832              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD,
     833              :             0x20,
     834              :             SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_AES_256_GCM
     835              :         },
     836              :         {
     837              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG,
     838              :             0x20,
     839              :             SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_RSASSA_2048
     840              :         },
     841              :         {
     842              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE,
     843              :             0x20,
     844              :             SPDM_ALGORITHMS_KEY_SCHEDULE_SPDM
     845              :         },
     846              :     }
     847              : };
     848              : size_t m_libspdm_negotiate_algorithm_request27_size =
     849              :     sizeof(m_libspdm_negotiate_algorithm_request27);
     850              : 
     851              : libspdm_negotiate_algorithms_request_spdm12_more_algo_t
     852              :     m_libspdm_negotiate_algorithm_request28 = {
     853              :     {
     854              :         {
     855              :             SPDM_MESSAGE_VERSION_12,
     856              :             SPDM_NEGOTIATE_ALGORITHMS,
     857              :             5,
     858              :             0
     859              :         },
     860              :         sizeof(libspdm_negotiate_algorithms_request_spdm12_more_algo_t),
     861              :         SPDM_MEASUREMENT_SPECIFICATION_DMTF,
     862              :         SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_1,
     863              :         SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_ECDSA_ECC_NIST_P256,
     864              :         SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA_256,
     865              :     },
     866              :     {
     867              :         {
     868              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE,
     869              :             0x20,
     870              :             SPDM_ALGORITHMS_DHE_NAMED_GROUP_SECP_256_R1
     871              :         },
     872              :         {
     873              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD,
     874              :             0x20,
     875              :             SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_AES_256_GCM
     876              :         },
     877              :         {
     878              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG,
     879              :             0x20,
     880              :             SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_RSASSA_2048
     881              :         },
     882              :         {
     883              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE,
     884              :             0x20,
     885              :             SPDM_ALGORITHMS_KEY_SCHEDULE_SPDM
     886              :         },
     887              :         {
     888              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE + 1,
     889              :             0x20,
     890              :             SPDM_ALGORITHMS_KEY_SCHEDULE_SPDM
     891              :         }
     892              :     }
     893              : };
     894              : size_t m_libspdm_negotiate_algorithm_request28_size =
     895              :     sizeof(m_libspdm_negotiate_algorithm_request28);
     896              : 
     897              : libspdm_negotiate_algorithms_request_spdm12_t
     898              :     m_libspdm_negotiate_algorithm_request29 = {
     899              :     {
     900              :         {
     901              :             SPDM_MESSAGE_VERSION_12,
     902              :             SPDM_NEGOTIATE_ALGORITHMS,
     903              :             4,
     904              :             0
     905              :         },
     906              :         sizeof(libspdm_negotiate_algorithms_request_spdm12_t),
     907              :         SPDM_MEASUREMENT_SPECIFICATION_DMTF,
     908              :         SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_1,
     909              :         SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_ECDSA_ECC_NIST_P256,
     910              :         SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA_256,
     911              :     },
     912              :     {
     913              :         {
     914              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE,
     915              :             0x20,
     916              :             SPDM_ALGORITHMS_DHE_NAMED_GROUP_SECP_256_R1
     917              :         },
     918              :         {
     919              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD,
     920              :             0x20,
     921              :             /* No supported AlgTypes */
     922              :             0x00
     923              :         },
     924              :         {
     925              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG,
     926              :             0x20,
     927              :             SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_RSASSA_2048
     928              :         },
     929              :         {
     930              :             SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE,
     931              :             0x20,
     932              :             SPDM_ALGORITHMS_KEY_SCHEDULE_SPDM
     933              :         }
     934              :     }
     935              : };
     936              : size_t m_libspdm_negotiate_algorithm_request29_size =
     937              :     sizeof(m_libspdm_negotiate_algorithm_request29);
     938              : 
     939              : spdm_negotiate_algorithms_request_t m_libspdm_negotiate_algorithms_request30 = {
     940              :     { SPDM_MESSAGE_VERSION_13, SPDM_NEGOTIATE_ALGORITHMS, 0, 0 },
     941              :     sizeof(spdm_negotiate_algorithms_request_t),
     942              :     SPDM_MEASUREMENT_SPECIFICATION_DMTF,
     943              :     SPDM_ALGORITHMS_MULTI_KEY_CONN,
     944              : };
     945              : size_t m_libspdm_negotiate_algorithms_request30_size =
     946              :     sizeof(m_libspdm_negotiate_algorithms_request30);
     947              : 
     948            1 : static void rsp_algorithms_case1(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_algorithms_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 = 0x1;
     960            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_10 <<
     961              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
     962            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
     963            1 :     spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
     964            1 :     spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
     965              : 
     966            1 :     response_size = sizeof(response);
     967            1 :     status = libspdm_get_response_algorithms(
     968              :         spdm_context, m_libspdm_negotiate_algorithms_request1_size,
     969              :         &m_libspdm_negotiate_algorithms_request1, &response_size,
     970              :         response);
     971            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
     972            1 :     assert_int_equal(response_size, sizeof(spdm_algorithms_response_t));
     973            1 :     spdm_response = (void *)response;
     974            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_ALGORITHMS);
     975            1 : }
     976              : 
     977            1 : static void rsp_algorithms_case2(void **state)
     978              : {
     979              :     libspdm_return_t status;
     980              :     libspdm_test_context_t *spdm_test_context;
     981              :     libspdm_context_t *spdm_context;
     982              :     size_t response_size;
     983              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
     984              :     spdm_algorithms_response_t *spdm_response;
     985              : 
     986            1 :     spdm_test_context = *state;
     987            1 :     spdm_context = spdm_test_context->spdm_context;
     988            1 :     spdm_test_context->case_id = 0x2;
     989            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_10 <<
     990              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
     991            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
     992            1 :     spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
     993            1 :     spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
     994              : 
     995            1 :     response_size = sizeof(response);
     996            1 :     status = libspdm_get_response_algorithms(
     997              :         spdm_context, m_libspdm_negotiate_algorithms_request2_size,
     998              :         &m_libspdm_negotiate_algorithms_request2, &response_size,
     999              :         response);
    1000            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
    1001            1 :     assert_int_equal(response_size, sizeof(spdm_error_response_t));
    1002            1 :     spdm_response = (void *)response;
    1003            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_ERROR);
    1004            1 :     assert_int_equal(spdm_response->header.param1, SPDM_ERROR_CODE_INVALID_REQUEST);
    1005            1 :     assert_int_equal(spdm_response->header.param2, 0);
    1006            1 : }
    1007              : 
    1008            1 : static void rsp_algorithms_case3(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_algorithms_response_t *spdm_response;
    1016              : 
    1017            1 :     spdm_test_context = *state;
    1018            1 :     spdm_context = spdm_test_context->spdm_context;
    1019            1 :     spdm_test_context->case_id = 0x3;
    1020            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_10 <<
    1021              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1022            1 :     spdm_context->response_state = LIBSPDM_RESPONSE_STATE_BUSY;
    1023            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
    1024            1 :     spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    1025            1 :     spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
    1026              : 
    1027            1 :     response_size = sizeof(response);
    1028            1 :     status = libspdm_get_response_algorithms(
    1029              :         spdm_context, m_libspdm_negotiate_algorithms_request1_size,
    1030              :         &m_libspdm_negotiate_algorithms_request1, &response_size,
    1031              :         response);
    1032            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
    1033            1 :     assert_int_equal(response_size, sizeof(spdm_error_response_t));
    1034            1 :     spdm_response = (void *)response;
    1035            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_ERROR);
    1036            1 :     assert_int_equal(spdm_response->header.param1, SPDM_ERROR_CODE_BUSY);
    1037            1 :     assert_int_equal(spdm_response->header.param2, 0);
    1038            1 :     assert_int_equal(spdm_context->response_state, LIBSPDM_RESPONSE_STATE_BUSY);
    1039            1 : }
    1040              : 
    1041            1 : static void rsp_algorithms_case4(void **state)
    1042              : {
    1043              :     libspdm_return_t status;
    1044              :     libspdm_test_context_t *spdm_test_context;
    1045              :     libspdm_context_t *spdm_context;
    1046              :     size_t response_size;
    1047              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
    1048              :     spdm_algorithms_response_t *spdm_response;
    1049              : 
    1050            1 :     spdm_test_context = *state;
    1051            1 :     spdm_context = spdm_test_context->spdm_context;
    1052            1 :     spdm_test_context->case_id = 0x4;
    1053            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_10 <<
    1054              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1055            1 :     spdm_context->response_state = LIBSPDM_RESPONSE_STATE_NEED_RESYNC;
    1056            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
    1057            1 :     spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    1058            1 :     spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
    1059              : 
    1060            1 :     response_size = sizeof(response);
    1061            1 :     status = libspdm_get_response_algorithms(
    1062              :         spdm_context, m_libspdm_negotiate_algorithms_request1_size,
    1063              :         &m_libspdm_negotiate_algorithms_request1, &response_size,
    1064              :         response);
    1065            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
    1066            1 :     assert_int_equal(response_size, sizeof(spdm_error_response_t));
    1067            1 :     spdm_response = (void *)response;
    1068            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_ERROR);
    1069            1 :     assert_int_equal(spdm_response->header.param1, SPDM_ERROR_CODE_REQUEST_RESYNCH);
    1070            1 :     assert_int_equal(spdm_response->header.param2, 0);
    1071            1 :     assert_int_equal(spdm_context->response_state, LIBSPDM_RESPONSE_STATE_NEED_RESYNC);
    1072            1 : }
    1073              : 
    1074            1 : static void rsp_algorithms_case6(void **state)
    1075              : {
    1076              :     libspdm_return_t status;
    1077              :     libspdm_test_context_t *spdm_test_context;
    1078              :     libspdm_context_t *spdm_context;
    1079              :     size_t response_size;
    1080              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
    1081              :     spdm_algorithms_response_t *spdm_response;
    1082              : 
    1083            1 :     spdm_test_context = *state;
    1084            1 :     spdm_context = spdm_test_context->spdm_context;
    1085            1 :     spdm_test_context->case_id = 0x6;
    1086            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_10 <<
    1087              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1088            1 :     spdm_context->response_state = LIBSPDM_RESPONSE_STATE_NORMAL;
    1089            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_NOT_STARTED;
    1090            1 :     spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    1091            1 :     spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
    1092              : 
    1093            1 :     response_size = sizeof(response);
    1094            1 :     status = libspdm_get_response_algorithms(
    1095              :         spdm_context, m_libspdm_negotiate_algorithms_request1_size,
    1096              :         &m_libspdm_negotiate_algorithms_request1, &response_size,
    1097              :         response);
    1098            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
    1099            1 :     assert_int_equal(response_size, sizeof(spdm_error_response_t));
    1100            1 :     spdm_response = (void *)response;
    1101            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_ERROR);
    1102            1 :     assert_int_equal(spdm_response->header.param1, SPDM_ERROR_CODE_UNEXPECTED_REQUEST);
    1103            1 :     assert_int_equal(spdm_response->header.param2, 0);
    1104            1 : }
    1105              : 
    1106            1 : static void rsp_algorithms_case7(void **state) {
    1107              :     libspdm_return_t status;
    1108              :     libspdm_test_context_t    *spdm_test_context;
    1109              :     libspdm_context_t  *spdm_context;
    1110              :     size_t response_size;
    1111              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
    1112              :     libspdm_algorithms_response_mine_t *spdm_response;
    1113              : 
    1114            1 :     spdm_test_context = *state;
    1115            1 :     spdm_context = spdm_test_context->spdm_context;
    1116            1 :     spdm_test_context->case_id = 0x7;
    1117            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
    1118              : 
    1119            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_11 <<
    1120              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1121            1 :     spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    1122            1 :     spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
    1123            1 :     spdm_context->local_context.algorithm.dhe_named_group = m_libspdm_use_dhe_algo;
    1124            1 :     spdm_context->local_context.algorithm.aead_cipher_suite = m_libspdm_use_aead_algo;
    1125            1 :     spdm_context->local_context.algorithm.req_base_asym_alg = m_libspdm_use_req_asym_algo;
    1126            1 :     spdm_context->local_context.algorithm.key_schedule = m_libspdm_use_key_schedule_algo;
    1127              : 
    1128            1 :     libspdm_reset_message_a(spdm_context);
    1129              : 
    1130            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_EX_CAP;
    1131            1 :     spdm_context->connection_info.capability.flags |=
    1132              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP;
    1133              : 
    1134            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP;
    1135            1 :     spdm_context->connection_info.capability.flags |=
    1136              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP;
    1137              : 
    1138            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP;
    1139            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP;
    1140              : 
    1141            1 :     spdm_context->local_context.capability.flags |=
    1142              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
    1143            1 :     spdm_context->connection_info.capability.flags |=
    1144              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
    1145              : 
    1146            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP;
    1147            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP;
    1148              : 
    1149            1 :     response_size = sizeof(response);
    1150            1 :     status = libspdm_get_response_algorithms (spdm_context,
    1151              :                                               m_libspdm_negotiate_algorithm_request3_size,
    1152              :                                               &m_libspdm_negotiate_algorithm_request3,
    1153              :                                               &response_size,
    1154              :                                               response);
    1155            1 :     assert_int_equal (status, LIBSPDM_STATUS_SUCCESS);
    1156            1 :     assert_int_equal (response_size,
    1157              :                       sizeof(spdm_algorithms_response_t)+4*
    1158              :                       sizeof(spdm_negotiate_algorithms_common_struct_table_t));
    1159            1 :     spdm_response = (void *)response;
    1160            1 :     assert_int_equal (spdm_response->header.request_response_code, SPDM_ALGORITHMS);
    1161            1 :     assert_int_equal (spdm_response->header.spdm_version, SPDM_MESSAGE_VERSION_11);
    1162              : 
    1163            1 :     assert_int_equal (spdm_response->struct_table[0].alg_supported,
    1164              :                       spdm_context->local_context.algorithm.dhe_named_group);
    1165            1 :     assert_int_equal (spdm_response->struct_table[1].alg_supported,
    1166              :                       spdm_context->local_context.algorithm.aead_cipher_suite);
    1167            1 :     assert_int_equal (spdm_response->struct_table[2].alg_supported,
    1168              :                       spdm_context->local_context.algorithm.req_base_asym_alg);
    1169            1 :     assert_int_equal (spdm_response->struct_table[3].alg_supported,
    1170              :                       spdm_context->local_context.algorithm.key_schedule);
    1171            1 : }
    1172              : 
    1173            1 : static void rsp_algorithms_case8(void **state) {
    1174              :     libspdm_return_t status;
    1175              :     libspdm_test_context_t    *spdm_test_context;
    1176              :     libspdm_context_t  *spdm_context;
    1177              :     size_t response_size;
    1178              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
    1179              :     spdm_algorithms_response_t *spdm_response;
    1180              : 
    1181            1 :     spdm_test_context = *state;
    1182            1 :     spdm_context = spdm_test_context->spdm_context;
    1183            1 :     spdm_test_context->case_id = 0x8;
    1184            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
    1185              : 
    1186            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_11 <<
    1187              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1188            1 :     spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    1189            1 :     spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
    1190            1 :     spdm_context->local_context.algorithm.dhe_named_group = m_libspdm_use_dhe_algo;
    1191            1 :     spdm_context->local_context.algorithm.aead_cipher_suite = m_libspdm_use_aead_algo;
    1192            1 :     spdm_context->local_context.algorithm.req_base_asym_alg = m_libspdm_use_req_asym_algo;
    1193            1 :     spdm_context->local_context.algorithm.key_schedule = m_libspdm_use_key_schedule_algo;
    1194              : 
    1195            1 :     libspdm_reset_message_a(spdm_context);
    1196              : 
    1197            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CHAL_CAP;
    1198            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHAL_CAP;
    1199              : 
    1200            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_EX_CAP;
    1201            1 :     spdm_context->connection_info.capability.flags |=
    1202              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP;
    1203              : 
    1204            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP;
    1205            1 :     spdm_context->connection_info.capability.flags |=
    1206              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP;
    1207              : 
    1208            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP;
    1209            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP;
    1210              : 
    1211            1 :     spdm_context->local_context.capability.flags |=
    1212              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
    1213            1 :     spdm_context->connection_info.capability.flags |=
    1214              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
    1215              : 
    1216            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP;
    1217            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP;
    1218              : 
    1219            1 :     response_size = sizeof(response);
    1220            1 :     status = libspdm_get_response_algorithms (spdm_context,
    1221              :                                               m_libspdm_negotiate_algorithm_request4_size,
    1222              :                                               &m_libspdm_negotiate_algorithm_request4,
    1223              :                                               &response_size,
    1224              :                                               response);
    1225            1 :     assert_int_equal (status, LIBSPDM_STATUS_SUCCESS);
    1226            1 :     assert_int_equal (response_size, sizeof(spdm_error_response_t));
    1227            1 :     spdm_response = (void *)response;
    1228            1 :     assert_int_equal (spdm_response->header.request_response_code, SPDM_ERROR);
    1229            1 :     assert_int_equal (spdm_response->header.param1, SPDM_ERROR_CODE_INVALID_REQUEST);
    1230            1 :     assert_int_equal (spdm_response->header.param2, 0);
    1231            1 : }
    1232              : 
    1233            1 : static void rsp_algorithms_case9(void **state) {
    1234              :     libspdm_return_t status;
    1235              :     libspdm_test_context_t    *spdm_test_context;
    1236              :     libspdm_context_t  *spdm_context;
    1237              :     size_t response_size;
    1238              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
    1239              :     spdm_algorithms_response_t *spdm_response;
    1240              : 
    1241            1 :     spdm_test_context = *state;
    1242            1 :     spdm_context = spdm_test_context->spdm_context;
    1243            1 :     spdm_test_context->case_id = 0x9;
    1244            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
    1245              : 
    1246            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_11 <<
    1247              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1248            1 :     spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    1249            1 :     spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
    1250            1 :     spdm_context->local_context.algorithm.dhe_named_group = m_libspdm_use_dhe_algo;
    1251            1 :     spdm_context->local_context.algorithm.aead_cipher_suite = m_libspdm_use_aead_algo;
    1252            1 :     spdm_context->local_context.algorithm.req_base_asym_alg = m_libspdm_use_req_asym_algo;
    1253            1 :     spdm_context->local_context.algorithm.key_schedule = m_libspdm_use_key_schedule_algo;
    1254              : 
    1255            1 :     libspdm_reset_message_a(spdm_context);
    1256              : 
    1257            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CHAL_CAP;
    1258            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHAL_CAP;
    1259              : 
    1260            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_EX_CAP;
    1261            1 :     spdm_context->connection_info.capability.flags |=
    1262              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP;
    1263              : 
    1264            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP;
    1265            1 :     spdm_context->connection_info.capability.flags |=
    1266              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP;
    1267              : 
    1268            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP;
    1269            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP;
    1270              : 
    1271            1 :     spdm_context->local_context.capability.flags |=
    1272              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
    1273            1 :     spdm_context->connection_info.capability.flags |=
    1274              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
    1275              : 
    1276            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP;
    1277            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP;
    1278              : 
    1279            1 :     response_size = sizeof(response);
    1280            1 :     status = libspdm_get_response_algorithms (spdm_context,
    1281              :                                               m_libspdm_negotiate_algorithm_request5_size,
    1282              :                                               &m_libspdm_negotiate_algorithm_request5,
    1283              :                                               &response_size,
    1284              :                                               response);
    1285            1 :     assert_int_equal (status, LIBSPDM_STATUS_SUCCESS);
    1286            1 :     assert_int_equal (response_size, sizeof(spdm_error_response_t));
    1287            1 :     spdm_response = (void *)response;
    1288            1 :     assert_int_equal (spdm_response->header.request_response_code, SPDM_ERROR);
    1289            1 :     assert_int_equal (spdm_response->header.param1, SPDM_ERROR_CODE_INVALID_REQUEST);
    1290            1 :     assert_int_equal (spdm_response->header.param2, 0);
    1291            1 : }
    1292              : 
    1293            1 : static void rsp_algorithms_case10(void **state) {
    1294              :     libspdm_return_t status;
    1295              :     libspdm_test_context_t    *spdm_test_context;
    1296              :     libspdm_context_t  *spdm_context;
    1297              :     size_t response_size;
    1298              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
    1299              :     spdm_algorithms_response_t *spdm_response;
    1300              : 
    1301            1 :     spdm_test_context = *state;
    1302            1 :     spdm_context = spdm_test_context->spdm_context;
    1303            1 :     spdm_test_context->case_id = 0xA;
    1304            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
    1305              : 
    1306            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_11 <<
    1307              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1308            1 :     spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    1309            1 :     spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
    1310            1 :     spdm_context->local_context.algorithm.dhe_named_group = m_libspdm_use_dhe_algo;
    1311            1 :     spdm_context->local_context.algorithm.aead_cipher_suite = m_libspdm_use_aead_algo;
    1312            1 :     spdm_context->local_context.algorithm.req_base_asym_alg = m_libspdm_use_req_asym_algo;
    1313            1 :     spdm_context->local_context.algorithm.key_schedule = m_libspdm_use_key_schedule_algo;
    1314              : 
    1315            1 :     libspdm_reset_message_a(spdm_context);
    1316              : 
    1317            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CHAL_CAP;
    1318            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHAL_CAP;
    1319              : 
    1320            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_EX_CAP;
    1321            1 :     spdm_context->connection_info.capability.flags |=
    1322              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP;
    1323              : 
    1324            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP;
    1325            1 :     spdm_context->connection_info.capability.flags |=
    1326              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP;
    1327              : 
    1328            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP;
    1329            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP;
    1330              : 
    1331            1 :     spdm_context->local_context.capability.flags |=
    1332              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
    1333            1 :     spdm_context->connection_info.capability.flags |=
    1334              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
    1335              : 
    1336            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP;
    1337            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP;
    1338              : 
    1339            1 :     response_size = sizeof(response);
    1340            1 :     status = libspdm_get_response_algorithms (spdm_context,
    1341              :                                               m_libspdm_negotiate_algorithm_request6_size,
    1342              :                                               &m_libspdm_negotiate_algorithm_request6,
    1343              :                                               &response_size,
    1344              :                                               response);
    1345            1 :     assert_int_equal (status, LIBSPDM_STATUS_SUCCESS);
    1346            1 :     assert_int_equal (response_size, sizeof(spdm_error_response_t));
    1347            1 :     spdm_response = (void *)response;
    1348            1 :     assert_int_equal (spdm_response->header.request_response_code, SPDM_ERROR);
    1349            1 :     assert_int_equal (spdm_response->header.param1, SPDM_ERROR_CODE_INVALID_REQUEST);
    1350            1 :     assert_int_equal (spdm_response->header.param2, 0);
    1351            1 : }
    1352              : 
    1353            1 : static void rsp_algorithms_case11(void **state) {
    1354              :     libspdm_return_t status;
    1355              :     libspdm_test_context_t    *spdm_test_context;
    1356              :     libspdm_context_t  *spdm_context;
    1357              :     size_t response_size;
    1358              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
    1359              :     spdm_algorithms_response_t *spdm_response;
    1360              : 
    1361            1 :     spdm_test_context = *state;
    1362            1 :     spdm_context = spdm_test_context->spdm_context;
    1363            1 :     spdm_test_context->case_id = 0xB;
    1364            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
    1365              : 
    1366            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_11 <<
    1367              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1368            1 :     spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    1369            1 :     spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
    1370            1 :     spdm_context->local_context.algorithm.dhe_named_group = m_libspdm_use_dhe_algo;
    1371            1 :     spdm_context->local_context.algorithm.aead_cipher_suite = m_libspdm_use_aead_algo;
    1372            1 :     spdm_context->local_context.algorithm.req_base_asym_alg = m_libspdm_use_req_asym_algo;
    1373            1 :     spdm_context->local_context.algorithm.key_schedule = m_libspdm_use_key_schedule_algo;
    1374              : 
    1375            1 :     libspdm_reset_message_a(spdm_context);
    1376              : 
    1377            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CHAL_CAP;
    1378            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHAL_CAP;
    1379              : 
    1380            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_EX_CAP;
    1381            1 :     spdm_context->connection_info.capability.flags |=
    1382              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP;
    1383              : 
    1384            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP;
    1385            1 :     spdm_context->connection_info.capability.flags |=
    1386              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP;
    1387              : 
    1388            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP;
    1389            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP;
    1390              : 
    1391            1 :     spdm_context->local_context.capability.flags |=
    1392              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
    1393            1 :     spdm_context->connection_info.capability.flags |=
    1394              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
    1395              : 
    1396            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP;
    1397            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP;
    1398              : 
    1399            1 :     response_size = sizeof(response);
    1400            1 :     status = libspdm_get_response_algorithms (spdm_context,
    1401              :                                               m_libspdm_negotiate_algorithm_request7_size,
    1402              :                                               &m_libspdm_negotiate_algorithm_request7,
    1403              :                                               &response_size,
    1404              :                                               response);
    1405            1 :     assert_int_equal (status, LIBSPDM_STATUS_SUCCESS);
    1406            1 :     assert_int_equal (response_size, sizeof(spdm_error_response_t));
    1407            1 :     spdm_response = (void *)response;
    1408            1 :     assert_int_equal (spdm_response->header.request_response_code, SPDM_ERROR);
    1409            1 :     assert_int_equal (spdm_response->header.param1, SPDM_ERROR_CODE_INVALID_REQUEST);
    1410            1 :     assert_int_equal (spdm_response->header.param2, 0);
    1411            1 : }
    1412              : 
    1413            1 : static void rsp_algorithms_case12(void **state) {
    1414              :     libspdm_return_t status;
    1415              :     libspdm_test_context_t    *spdm_test_context;
    1416              :     libspdm_context_t  *spdm_context;
    1417              :     size_t response_size;
    1418              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
    1419              :     spdm_algorithms_response_t *spdm_response;
    1420              : 
    1421            1 :     spdm_test_context = *state;
    1422            1 :     spdm_context = spdm_test_context->spdm_context;
    1423            1 :     spdm_test_context->case_id = 0xC;
    1424            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
    1425              : 
    1426            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_11 <<
    1427              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1428            1 :     spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    1429            1 :     spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
    1430            1 :     spdm_context->local_context.algorithm.dhe_named_group = m_libspdm_use_dhe_algo;
    1431            1 :     spdm_context->local_context.algorithm.aead_cipher_suite = m_libspdm_use_aead_algo;
    1432            1 :     spdm_context->local_context.algorithm.req_base_asym_alg = m_libspdm_use_req_asym_algo;
    1433            1 :     spdm_context->local_context.algorithm.key_schedule = m_libspdm_use_key_schedule_algo;
    1434              : 
    1435            1 :     libspdm_reset_message_a(spdm_context);
    1436              : 
    1437            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CHAL_CAP;
    1438            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHAL_CAP;
    1439              : 
    1440            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_EX_CAP;
    1441            1 :     spdm_context->connection_info.capability.flags |=
    1442              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP;
    1443              : 
    1444            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP;
    1445            1 :     spdm_context->connection_info.capability.flags |=
    1446              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP;
    1447              : 
    1448            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP;
    1449            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP;
    1450              : 
    1451            1 :     spdm_context->local_context.capability.flags |=
    1452              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
    1453            1 :     spdm_context->connection_info.capability.flags |=
    1454              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
    1455              : 
    1456            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP;
    1457            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP;
    1458              : 
    1459            1 :     response_size = sizeof(response);
    1460            1 :     status = libspdm_get_response_algorithms (spdm_context,
    1461              :                                               m_libspdm_negotiate_algorithm_request8_size,
    1462              :                                               &m_libspdm_negotiate_algorithm_request8,
    1463              :                                               &response_size,
    1464              :                                               response);
    1465            1 :     assert_int_equal (status, LIBSPDM_STATUS_SUCCESS);
    1466            1 :     assert_int_equal (response_size, sizeof(spdm_error_response_t));
    1467            1 :     spdm_response = (void *)response;
    1468            1 :     assert_int_equal (spdm_response->header.request_response_code, SPDM_ERROR);
    1469            1 :     assert_int_equal (spdm_response->header.param1, SPDM_ERROR_CODE_INVALID_REQUEST);
    1470            1 :     assert_int_equal (spdm_response->header.param2, 0);
    1471            1 : }
    1472              : 
    1473            1 : static void rsp_algorithms_case13(void **state) {
    1474              :     libspdm_return_t status;
    1475              :     libspdm_test_context_t    *spdm_test_context;
    1476              :     libspdm_context_t  *spdm_context;
    1477              :     size_t response_size;
    1478              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
    1479              :     spdm_algorithms_response_t *spdm_response;
    1480              : 
    1481            1 :     spdm_test_context = *state;
    1482            1 :     spdm_context = spdm_test_context->spdm_context;
    1483            1 :     spdm_test_context->case_id = 0xD;
    1484            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
    1485              : 
    1486            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_11 <<
    1487              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1488            1 :     spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    1489            1 :     spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
    1490            1 :     spdm_context->local_context.algorithm.dhe_named_group = m_libspdm_use_dhe_algo;
    1491            1 :     spdm_context->local_context.algorithm.aead_cipher_suite = m_libspdm_use_aead_algo;
    1492            1 :     spdm_context->local_context.algorithm.req_base_asym_alg = m_libspdm_use_req_asym_algo;
    1493            1 :     spdm_context->local_context.algorithm.key_schedule = m_libspdm_use_key_schedule_algo;
    1494              : 
    1495            1 :     libspdm_reset_message_a(spdm_context);
    1496              : 
    1497            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CHAL_CAP;
    1498            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHAL_CAP;
    1499              : 
    1500            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_EX_CAP;
    1501            1 :     spdm_context->connection_info.capability.flags |=
    1502              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP;
    1503              : 
    1504            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP;
    1505            1 :     spdm_context->connection_info.capability.flags |=
    1506              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP;
    1507              : 
    1508            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP;
    1509            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP;
    1510              : 
    1511            1 :     spdm_context->local_context.capability.flags |=
    1512              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
    1513            1 :     spdm_context->connection_info.capability.flags |=
    1514              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
    1515              : 
    1516            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP;
    1517            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP;
    1518              : 
    1519            1 :     response_size = sizeof(response);
    1520            1 :     status = libspdm_get_response_algorithms (spdm_context,
    1521              :                                               m_libspdm_negotiate_algorithm_request9_size,
    1522              :                                               &m_libspdm_negotiate_algorithm_request9,
    1523              :                                               &response_size,
    1524              :                                               response);
    1525            1 :     assert_int_equal (status, LIBSPDM_STATUS_SUCCESS);
    1526            1 :     assert_int_equal (response_size, sizeof(spdm_error_response_t));
    1527            1 :     spdm_response = (void *)response;
    1528            1 :     assert_int_equal (spdm_response->header.request_response_code, SPDM_ERROR);
    1529            1 :     assert_int_equal (spdm_response->header.param1, SPDM_ERROR_CODE_INVALID_REQUEST);
    1530            1 :     assert_int_equal (spdm_response->header.param2, 0);
    1531            1 : }
    1532              : 
    1533            1 : static void rsp_algorithms_case14(void **state) {
    1534              :     libspdm_return_t status;
    1535              :     libspdm_test_context_t    *spdm_test_context;
    1536              :     libspdm_context_t  *spdm_context;
    1537              :     size_t response_size;
    1538              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
    1539              :     spdm_algorithms_response_t *spdm_response;
    1540              : 
    1541            1 :     spdm_test_context = *state;
    1542            1 :     spdm_context = spdm_test_context->spdm_context;
    1543            1 :     spdm_test_context->case_id = 0xE;
    1544            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
    1545              : 
    1546            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_10 <<
    1547              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1548            1 :     spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    1549            1 :     spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
    1550              : 
    1551            1 :     libspdm_reset_message_a(spdm_context);
    1552              : 
    1553            1 :     response_size = sizeof(response);
    1554            1 :     status = libspdm_get_response_algorithms (spdm_context,
    1555              :                                               m_libspdm_negotiate_algorithm_request10_size,
    1556              :                                               &m_libspdm_negotiate_algorithm_request10,
    1557              :                                               &response_size,
    1558              :                                               response);
    1559            1 :     assert_int_equal (status, LIBSPDM_STATUS_SUCCESS);
    1560            1 :     assert_int_equal (response_size, sizeof(spdm_error_response_t));
    1561            1 :     spdm_response = (void *)response;
    1562            1 :     assert_int_equal (spdm_response->header.request_response_code, SPDM_ERROR);
    1563            1 :     assert_int_equal (spdm_response->header.param1, SPDM_ERROR_CODE_INVALID_REQUEST);
    1564            1 :     assert_int_equal (spdm_response->header.param2, 0);
    1565            1 : }
    1566              : 
    1567            1 : static void rsp_algorithms_case15(void **state) {
    1568              :     libspdm_return_t status;
    1569              :     libspdm_test_context_t    *spdm_test_context;
    1570              :     libspdm_context_t  *spdm_context;
    1571              :     size_t response_size;
    1572              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
    1573              :     spdm_algorithms_response_t *spdm_response;
    1574              : 
    1575            1 :     spdm_test_context = *state;
    1576            1 :     spdm_context = spdm_test_context->spdm_context;
    1577            1 :     spdm_test_context->case_id = 0xF;
    1578            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
    1579              : 
    1580            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_11 <<
    1581              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1582            1 :     spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    1583            1 :     spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
    1584            1 :     spdm_context->local_context.algorithm.dhe_named_group = m_libspdm_use_dhe_algo;
    1585            1 :     spdm_context->local_context.algorithm.aead_cipher_suite = m_libspdm_use_aead_algo;
    1586            1 :     spdm_context->local_context.algorithm.req_base_asym_alg = m_libspdm_use_req_asym_algo;
    1587            1 :     spdm_context->local_context.algorithm.key_schedule = m_libspdm_use_key_schedule_algo;
    1588              : 
    1589            1 :     libspdm_reset_message_a(spdm_context);
    1590              : 
    1591            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_EX_CAP;
    1592            1 :     spdm_context->connection_info.capability.flags |=
    1593              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP;
    1594              : 
    1595            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP;
    1596            1 :     spdm_context->connection_info.capability.flags |=
    1597              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP;
    1598              : 
    1599            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP;
    1600            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP;
    1601              : 
    1602            1 :     spdm_context->local_context.capability.flags |=
    1603              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
    1604            1 :     spdm_context->connection_info.capability.flags |=
    1605              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
    1606              : 
    1607            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP;
    1608            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP;
    1609              : 
    1610            1 :     response_size = sizeof(response);
    1611            1 :     status = libspdm_get_response_algorithms (spdm_context,
    1612              :                                               m_libspdm_negotiate_algorithm_request11_size,
    1613              :                                               &m_libspdm_negotiate_algorithm_request11,
    1614              :                                               &response_size,
    1615              :                                               response);
    1616            1 :     assert_int_equal (status, LIBSPDM_STATUS_SUCCESS);
    1617            1 :     assert_int_equal (response_size, sizeof(spdm_error_response_t));
    1618            1 :     spdm_response = (void *)response;
    1619            1 :     assert_int_equal (spdm_response->header.request_response_code, SPDM_ERROR);
    1620            1 :     assert_int_equal (spdm_response->header.param1, SPDM_ERROR_CODE_INVALID_REQUEST);
    1621            1 :     assert_int_equal (spdm_response->header.param2, 0);
    1622            1 : }
    1623              : 
    1624            1 : static void rsp_algorithms_case16(void **state) {
    1625              :     libspdm_return_t status;
    1626              :     libspdm_test_context_t    *spdm_test_context;
    1627              :     libspdm_context_t  *spdm_context;
    1628              :     size_t response_size;
    1629              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
    1630              :     libspdm_algorithms_response_mine_t *spdm_response;
    1631              : 
    1632            1 :     spdm_test_context = *state;
    1633            1 :     spdm_context = spdm_test_context->spdm_context;
    1634            1 :     spdm_test_context->case_id = 0x10;
    1635            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
    1636              : 
    1637            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_11 <<
    1638              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1639            1 :     spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    1640            1 :     spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
    1641            1 :     spdm_context->local_context.algorithm.dhe_named_group = m_libspdm_use_dhe_algo;
    1642            1 :     spdm_context->local_context.algorithm.aead_cipher_suite = m_libspdm_use_aead_algo;
    1643            1 :     spdm_context->local_context.algorithm.req_base_asym_alg = m_libspdm_use_req_asym_algo;
    1644            1 :     spdm_context->local_context.algorithm.key_schedule = m_libspdm_use_key_schedule_algo;
    1645              : 
    1646            1 :     libspdm_reset_message_a(spdm_context);
    1647              : 
    1648            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_EX_CAP;
    1649            1 :     spdm_context->connection_info.capability.flags |=
    1650              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP;
    1651              : 
    1652            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP;
    1653            1 :     spdm_context->connection_info.capability.flags |=
    1654              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP;
    1655              : 
    1656            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP;
    1657            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP;
    1658              : 
    1659            1 :     spdm_context->local_context.capability.flags |=
    1660              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
    1661            1 :     spdm_context->connection_info.capability.flags |=
    1662              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
    1663              : 
    1664            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP;
    1665            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP;
    1666              : 
    1667            1 :     response_size = sizeof(response);
    1668            1 :     status = libspdm_get_response_algorithms (spdm_context,
    1669              :                                               m_libspdm_negotiate_algorithm_request12_size,
    1670              :                                               &m_libspdm_negotiate_algorithm_request12,
    1671              :                                               &response_size,
    1672              :                                               response);
    1673            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
    1674            1 :     assert_int_equal(response_size, sizeof(spdm_error_response_t));
    1675            1 :     spdm_response = (void*)response;
    1676            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_ERROR);
    1677            1 :     assert_int_equal(spdm_response->header.param1, SPDM_ERROR_CODE_INVALID_REQUEST);
    1678            1 :     assert_int_equal(spdm_response->header.param2, 0);
    1679            1 : }
    1680              : 
    1681            1 : static void rsp_algorithms_case17(void **state) {
    1682              :     libspdm_return_t status;
    1683              :     libspdm_test_context_t    *spdm_test_context;
    1684              :     libspdm_context_t  *spdm_context;
    1685              :     size_t response_size;
    1686              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
    1687              :     libspdm_algorithms_response_mine_t *spdm_response;
    1688              : 
    1689            1 :     spdm_test_context = *state;
    1690            1 :     spdm_context = spdm_test_context->spdm_context;
    1691            1 :     spdm_test_context->case_id = 0x11;
    1692            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
    1693              : 
    1694            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_11 <<
    1695              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1696            1 :     spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    1697            1 :     spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
    1698            1 :     spdm_context->local_context.algorithm.dhe_named_group = m_libspdm_use_dhe_algo;
    1699            1 :     spdm_context->local_context.algorithm.aead_cipher_suite = m_libspdm_use_aead_algo;
    1700            1 :     spdm_context->local_context.algorithm.req_base_asym_alg = m_libspdm_use_req_asym_algo;
    1701            1 :     spdm_context->local_context.algorithm.key_schedule = m_libspdm_use_key_schedule_algo;
    1702              : 
    1703            1 :     libspdm_reset_message_a(spdm_context);
    1704              : 
    1705            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_EX_CAP;
    1706            1 :     spdm_context->connection_info.capability.flags |=
    1707              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP;
    1708              : 
    1709            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP;
    1710            1 :     spdm_context->connection_info.capability.flags |=
    1711              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP;
    1712              : 
    1713            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP;
    1714            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP;
    1715              : 
    1716            1 :     spdm_context->local_context.capability.flags |=
    1717              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
    1718            1 :     spdm_context->connection_info.capability.flags |=
    1719              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
    1720              : 
    1721            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP;
    1722            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP;
    1723              : 
    1724            1 :     response_size = sizeof(response);
    1725            1 :     status = libspdm_get_response_algorithms (spdm_context,
    1726              :                                               m_libspdm_negotiate_algorithm_request13_size,
    1727              :                                               &m_libspdm_negotiate_algorithm_request13,
    1728              :                                               &response_size,
    1729              :                                               response);
    1730            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
    1731            1 :     assert_int_equal(response_size, sizeof(spdm_error_response_t));
    1732            1 :     spdm_response = (void*)response;
    1733            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_ERROR);
    1734            1 :     assert_int_equal(spdm_response->header.param1, SPDM_ERROR_CODE_INVALID_REQUEST);
    1735            1 :     assert_int_equal(spdm_response->header.param2, 0);
    1736            1 : }
    1737              : 
    1738            1 : static void rsp_algorithms_case18(void **state) {
    1739              :     libspdm_return_t status;
    1740              :     libspdm_test_context_t    *spdm_test_context;
    1741              :     libspdm_context_t  *spdm_context;
    1742              :     size_t response_size;
    1743              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
    1744              :     libspdm_algorithms_response_mine_t *spdm_response;
    1745              : 
    1746            1 :     spdm_test_context = *state;
    1747            1 :     spdm_context = spdm_test_context->spdm_context;
    1748            1 :     spdm_test_context->case_id = 0x12;
    1749            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
    1750              : 
    1751            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_11 <<
    1752              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1753            1 :     spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    1754            1 :     spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
    1755            1 :     spdm_context->local_context.algorithm.dhe_named_group = m_libspdm_use_dhe_algo;
    1756            1 :     spdm_context->local_context.algorithm.aead_cipher_suite = m_libspdm_use_aead_algo;
    1757            1 :     spdm_context->local_context.algorithm.req_base_asym_alg = m_libspdm_use_req_asym_algo;
    1758            1 :     spdm_context->local_context.algorithm.key_schedule = m_libspdm_use_key_schedule_algo;
    1759              : 
    1760            1 :     libspdm_reset_message_a(spdm_context);
    1761              : 
    1762            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_EX_CAP;
    1763            1 :     spdm_context->connection_info.capability.flags |=
    1764              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP;
    1765              : 
    1766            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP;
    1767            1 :     spdm_context->connection_info.capability.flags |=
    1768              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP;
    1769              : 
    1770            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP;
    1771            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP;
    1772              : 
    1773            1 :     spdm_context->local_context.capability.flags |=
    1774              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
    1775            1 :     spdm_context->connection_info.capability.flags |=
    1776              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
    1777              : 
    1778            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP;
    1779            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP;
    1780              : 
    1781            1 :     response_size = sizeof(response);
    1782            1 :     status = libspdm_get_response_algorithms (spdm_context,
    1783              :                                               m_libspdm_negotiate_algorithm_request14_size,
    1784              :                                               &m_libspdm_negotiate_algorithm_request14,
    1785              :                                               &response_size,
    1786              :                                               response);
    1787            1 :     assert_int_equal (status, LIBSPDM_STATUS_SUCCESS);
    1788            1 :     assert_int_equal (response_size, sizeof(spdm_error_response_t));
    1789            1 :     spdm_response = (void *)response;
    1790            1 :     assert_int_equal (spdm_response->header.request_response_code, SPDM_ERROR);
    1791            1 :     assert_int_equal (spdm_response->header.param1, SPDM_ERROR_CODE_INVALID_REQUEST);
    1792            1 :     assert_int_equal (spdm_response->header.param2, 0);
    1793            1 : }
    1794              : 
    1795            1 : static void rsp_algorithms_case19(void **state) {
    1796              :     libspdm_return_t status;
    1797              :     libspdm_test_context_t    *spdm_test_context;
    1798              :     libspdm_context_t  *spdm_context;
    1799              :     size_t response_size;
    1800              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
    1801              :     libspdm_algorithms_response_mine_t *spdm_response;
    1802              : 
    1803            1 :     spdm_test_context = *state;
    1804            1 :     spdm_context = spdm_test_context->spdm_context;
    1805            1 :     spdm_test_context->case_id = 0x13;
    1806            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
    1807              : 
    1808            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_11 <<
    1809              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1810            1 :     spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    1811            1 :     spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
    1812            1 :     spdm_context->local_context.algorithm.dhe_named_group = m_libspdm_use_dhe_algo;
    1813            1 :     spdm_context->local_context.algorithm.aead_cipher_suite = m_libspdm_use_aead_algo;
    1814            1 :     spdm_context->local_context.algorithm.req_base_asym_alg = m_libspdm_use_req_asym_algo;
    1815            1 :     spdm_context->local_context.algorithm.key_schedule = m_libspdm_use_key_schedule_algo;
    1816              : 
    1817            1 :     libspdm_reset_message_a(spdm_context);
    1818              : 
    1819            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_EX_CAP;
    1820            1 :     spdm_context->connection_info.capability.flags |=
    1821              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP;
    1822              : 
    1823            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP;
    1824            1 :     spdm_context->connection_info.capability.flags |=
    1825              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP;
    1826              : 
    1827            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP;
    1828            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP;
    1829              : 
    1830            1 :     spdm_context->local_context.capability.flags |=
    1831              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
    1832            1 :     spdm_context->connection_info.capability.flags |=
    1833              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
    1834              : 
    1835            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP;
    1836            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP;
    1837              : 
    1838            1 :     response_size = sizeof(response);
    1839            1 :     status = libspdm_get_response_algorithms (spdm_context,
    1840              :                                               m_libspdm_negotiate_algorithm_request15_size,
    1841              :                                               &m_libspdm_negotiate_algorithm_request15,
    1842              :                                               &response_size,
    1843              :                                               response);
    1844            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
    1845            1 :     assert_int_equal(response_size, sizeof(spdm_error_response_t));
    1846            1 :     spdm_response = (void*)response;
    1847            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_ERROR);
    1848            1 :     assert_int_equal(spdm_response->header.param1, SPDM_ERROR_CODE_INVALID_REQUEST);
    1849            1 :     assert_int_equal(spdm_response->header.param2, 0);
    1850            1 : }
    1851              : 
    1852              : /* When both of requester and responder support multiple algorithms, then defaults to choose the strongest available algorithm*/
    1853            1 : static void rsp_algorithms_case20(void **state) {
    1854              :     libspdm_return_t status;
    1855              :     libspdm_test_context_t    *spdm_test_context;
    1856              :     libspdm_context_t  *spdm_context;
    1857              :     size_t response_size;
    1858              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
    1859              :     libspdm_algorithms_response_mine_t *spdm_response;
    1860              : 
    1861            1 :     spdm_test_context = *state;
    1862            1 :     spdm_context = spdm_test_context->spdm_context;
    1863            1 :     spdm_test_context->case_id = 0x14;
    1864            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
    1865              : 
    1866            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_11 <<
    1867              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1868            1 :     spdm_context->local_context.algorithm.base_hash_algo =
    1869              :         SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA_512 |
    1870              :         SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA_256;
    1871            1 :     spdm_context->local_context.algorithm.base_asym_algo =
    1872              :         SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_ECDSA_ECC_NIST_P521 |
    1873              :         SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_ECDSA_ECC_NIST_P384 |
    1874              :         SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_RSASSA_2048;
    1875            1 :     spdm_context->local_context.algorithm.dhe_named_group =
    1876              :         SPDM_ALGORITHMS_DHE_NAMED_GROUP_SECP_521_R1 |
    1877              :         SPDM_ALGORITHMS_DHE_NAMED_GROUP_SECP_384_R1 |
    1878              :         SPDM_ALGORITHMS_DHE_NAMED_GROUP_SECP_256_R1;
    1879            1 :     spdm_context->local_context.algorithm.aead_cipher_suite = m_libspdm_use_aead_algo;
    1880            1 :     spdm_context->local_context.algorithm.req_base_asym_alg = m_libspdm_use_req_asym_algo;
    1881            1 :     spdm_context->local_context.algorithm.key_schedule = m_libspdm_use_key_schedule_algo;
    1882              : 
    1883            1 :     libspdm_reset_message_a(spdm_context);
    1884              : 
    1885            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_EX_CAP;
    1886            1 :     spdm_context->connection_info.capability.flags |=
    1887              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP;
    1888              : 
    1889            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP;
    1890            1 :     spdm_context->connection_info.capability.flags |=
    1891              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP;
    1892              : 
    1893            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP;
    1894            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP;
    1895              : 
    1896            1 :     spdm_context->local_context.capability.flags |=
    1897              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
    1898            1 :     spdm_context->connection_info.capability.flags |=
    1899              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
    1900              : 
    1901            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP;
    1902            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP;
    1903              : 
    1904            1 :     response_size = sizeof(response);
    1905            1 :     status = libspdm_get_response_algorithms (spdm_context,
    1906              :                                               m_libspdm_negotiate_algorithm_request16_size,
    1907              :                                               &m_libspdm_negotiate_algorithm_request16,
    1908              :                                               &response_size,
    1909              :                                               response);
    1910            1 :     assert_int_equal (status, LIBSPDM_STATUS_SUCCESS);
    1911            1 :     assert_int_equal (response_size,
    1912              :                       sizeof(spdm_algorithms_response_t)+4*
    1913              :                       sizeof(spdm_negotiate_algorithms_common_struct_table_t));
    1914            1 :     spdm_response = (void *)response;
    1915            1 :     assert_int_equal (spdm_response->header.request_response_code, SPDM_ALGORITHMS);
    1916            1 :     assert_int_equal (spdm_response->header.spdm_version, SPDM_MESSAGE_VERSION_11);
    1917              : 
    1918            1 :     assert_int_equal (spdm_response->base_hash_sel, SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA_512);
    1919            1 :     assert_int_equal (spdm_response->base_hash_sel,
    1920              :                       spdm_context->connection_info.algorithm.base_hash_algo);
    1921              : 
    1922            1 :     assert_int_equal (spdm_response->base_asym_sel,
    1923              :                       SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_ECDSA_ECC_NIST_P521);
    1924            1 :     assert_int_equal (spdm_response->base_asym_sel,
    1925              :                       spdm_context->connection_info.algorithm.base_asym_algo);
    1926              : 
    1927            1 :     assert_int_equal (spdm_response->struct_table[0].alg_supported,
    1928              :                       SPDM_ALGORITHMS_DHE_NAMED_GROUP_SECP_384_R1);
    1929            1 :     assert_int_equal (spdm_response->struct_table[0].alg_supported,
    1930              :                       spdm_context->connection_info.algorithm.dhe_named_group);
    1931              : 
    1932            1 :     assert_int_equal (spdm_response->struct_table[1].alg_supported,
    1933              :                       spdm_context->connection_info.algorithm.aead_cipher_suite);
    1934            1 :     assert_int_equal (spdm_response->struct_table[2].alg_supported,
    1935              :                       spdm_context->connection_info.algorithm.req_base_asym_alg);
    1936            1 :     assert_int_equal (spdm_response->struct_table[3].alg_supported,
    1937              :                       spdm_context->connection_info.algorithm.key_schedule);
    1938            1 : }
    1939              : 
    1940            1 : static void rsp_algorithms_case21(void **state) {
    1941              :     libspdm_return_t status;
    1942              :     libspdm_test_context_t *spdm_test_context;
    1943              :     libspdm_context_t *spdm_context;
    1944              :     size_t response_size;
    1945              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
    1946              :     libspdm_algorithms_response_mine_t *spdm_response;
    1947              :     size_t arbitrary_size;
    1948              : 
    1949            1 :     spdm_test_context = *state;
    1950            1 :     spdm_context = spdm_test_context->spdm_context;
    1951            1 :     spdm_test_context->case_id = 0x15;
    1952            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
    1953              : 
    1954            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_11 <<
    1955              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1956            1 :     spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    1957            1 :     spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
    1958            1 :     spdm_context->local_context.algorithm.dhe_named_group = m_libspdm_use_dhe_algo;
    1959            1 :     spdm_context->local_context.algorithm.aead_cipher_suite = m_libspdm_use_aead_algo;
    1960            1 :     spdm_context->local_context.algorithm.req_base_asym_alg = m_libspdm_use_req_asym_algo;
    1961            1 :     spdm_context->local_context.algorithm.key_schedule = m_libspdm_use_key_schedule_algo;
    1962              : 
    1963            1 :     libspdm_reset_message_a(spdm_context);
    1964              : 
    1965            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_EX_CAP;
    1966            1 :     spdm_context->connection_info.capability.flags |=
    1967              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP;
    1968              : 
    1969            1 :     spdm_context->local_context.capability.flags |=
    1970              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP;
    1971            1 :     spdm_context->connection_info.capability.flags |=
    1972              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP;
    1973              : 
    1974            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP;
    1975            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP;
    1976              : 
    1977            1 :     spdm_context->local_context.capability.flags |=
    1978              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
    1979            1 :     spdm_context->connection_info.capability.flags |=
    1980              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
    1981              : 
    1982            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP;
    1983            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP;
    1984              : 
    1985              :     /*filling A with arbitrary data*/
    1986            1 :     arbitrary_size = 10;
    1987            1 :     libspdm_set_mem(spdm_context->transcript.message_a.buffer, arbitrary_size, (uint8_t) 0xFF);
    1988            1 :     spdm_context->transcript.message_a.buffer_size = arbitrary_size;
    1989              : 
    1990            1 :     response_size = sizeof(response);
    1991            1 :     status = libspdm_get_response_algorithms(
    1992              :         spdm_context,
    1993              :         m_libspdm_negotiate_algorithm_request3_size, &m_libspdm_negotiate_algorithm_request3,
    1994              :         &response_size, response);
    1995            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
    1996            1 :     assert_int_equal(response_size,
    1997              :                      sizeof(spdm_algorithms_response_t) +
    1998              :                      4*sizeof(spdm_negotiate_algorithms_common_struct_table_t));
    1999            1 :     spdm_response = (void *)response;
    2000            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_ALGORITHMS);
    2001            1 :     assert_int_equal(spdm_response->header.spdm_version, SPDM_MESSAGE_VERSION_11);
    2002              : 
    2003            1 :     assert_int_equal(spdm_response->struct_table[0].alg_supported,
    2004              :                      spdm_context->local_context.algorithm.dhe_named_group);
    2005            1 :     assert_int_equal(spdm_response->struct_table[1].alg_supported,
    2006              :                      spdm_context->local_context.algorithm.aead_cipher_suite);
    2007            1 :     assert_int_equal(spdm_response->struct_table[2].alg_supported,
    2008              :                      spdm_context->local_context.algorithm.req_base_asym_alg);
    2009            1 :     assert_int_equal(spdm_response->struct_table[3].alg_supported,
    2010              :                      spdm_context->local_context.algorithm.key_schedule);
    2011              : 
    2012            1 :     assert_int_equal(spdm_context->transcript.message_a.buffer_size,
    2013              :                      arbitrary_size + m_libspdm_negotiate_algorithm_request3_size + response_size);
    2014            1 :     assert_memory_equal(spdm_context->transcript.message_a.buffer + arbitrary_size,
    2015              :                         &m_libspdm_negotiate_algorithm_request3,
    2016              :                         m_libspdm_negotiate_algorithm_request3_size);
    2017            1 :     assert_memory_equal(spdm_context->transcript.message_a.buffer + arbitrary_size +
    2018              :                         m_libspdm_negotiate_algorithm_request3_size, response, response_size);
    2019            1 : }
    2020              : 
    2021            1 : static void rsp_algorithms_case22(void **state)
    2022              : {
    2023              :     libspdm_return_t status;
    2024              :     libspdm_test_context_t    *spdm_test_context;
    2025              :     libspdm_context_t  *spdm_context;
    2026              :     size_t response_size;
    2027              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
    2028              :     libspdm_algorithms_response_mine_t *spdm_response;
    2029              : 
    2030            1 :     spdm_test_context = *state;
    2031            1 :     spdm_context = spdm_test_context->spdm_context;
    2032            1 :     spdm_test_context->case_id = 0x16;
    2033            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
    2034              : 
    2035            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_12 <<
    2036              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    2037            1 :     spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    2038            1 :     spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
    2039            1 :     spdm_context->local_context.algorithm.dhe_named_group = m_libspdm_use_dhe_algo;
    2040            1 :     spdm_context->local_context.algorithm.aead_cipher_suite = m_libspdm_use_aead_algo;
    2041            1 :     spdm_context->local_context.algorithm.req_base_asym_alg = m_libspdm_use_req_asym_algo;
    2042            1 :     spdm_context->local_context.algorithm.key_schedule = m_libspdm_use_key_schedule_algo;
    2043            1 :     spdm_context->local_context.algorithm.other_params_support =
    2044              :         SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_1;
    2045              :     /* spdm_context->connection_info.algorithm.other_params_support = SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_1; */
    2046            1 :     libspdm_reset_message_a(spdm_context);
    2047            1 :     spdm_context->local_context.capability.flags = 0;
    2048            1 :     spdm_context->connection_info.capability.flags = 0;
    2049            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_EX_CAP;
    2050            1 :     spdm_context->connection_info.capability.flags |=
    2051              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP;
    2052              : 
    2053            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP;
    2054            1 :     spdm_context->connection_info.capability.flags |=
    2055              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP;
    2056              : 
    2057            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP;
    2058            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP;
    2059              : 
    2060            1 :     spdm_context->local_context.capability.flags |=
    2061              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
    2062            1 :     spdm_context->connection_info.capability.flags |=
    2063              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
    2064              : 
    2065            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP;
    2066            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP;
    2067              : 
    2068            1 :     response_size = sizeof(response);
    2069            1 :     status = libspdm_get_response_algorithms (spdm_context,
    2070              :                                               m_libspdm_negotiate_algorithm_request17_size,
    2071              :                                               &m_libspdm_negotiate_algorithm_request17,
    2072              :                                               &response_size,
    2073              :                                               response);
    2074            1 :     assert_int_equal (status, LIBSPDM_STATUS_SUCCESS);
    2075            1 :     assert_int_equal (response_size,
    2076              :                       sizeof(spdm_algorithms_response_t)+4*
    2077              :                       sizeof(spdm_negotiate_algorithms_common_struct_table_t));
    2078            1 :     spdm_response = (void *)response;
    2079            1 :     assert_int_equal (spdm_response->header.spdm_version, SPDM_MESSAGE_VERSION_12);
    2080            1 :     assert_int_equal (spdm_response->header.request_response_code, SPDM_ALGORITHMS);
    2081            1 :     assert_int_equal(spdm_response->header.param1, 4);
    2082            1 :     assert_int_equal (spdm_response->struct_table[0].alg_supported,
    2083              :                       spdm_context->local_context.algorithm.dhe_named_group);
    2084            1 :     assert_int_equal (spdm_response->struct_table[1].alg_supported,
    2085              :                       spdm_context->local_context.algorithm.aead_cipher_suite);
    2086            1 :     assert_int_equal (spdm_response->struct_table[2].alg_supported,
    2087              :                       spdm_context->local_context.algorithm.req_base_asym_alg);
    2088            1 :     assert_int_equal (spdm_response->struct_table[3].alg_supported,
    2089              :                       spdm_context->local_context.algorithm.key_schedule);
    2090            1 : }
    2091              : 
    2092            1 : static void rsp_algorithms_case23(void **state)
    2093              : {
    2094              :     libspdm_return_t status;
    2095              :     libspdm_test_context_t    *spdm_test_context;
    2096              :     libspdm_context_t  *spdm_context;
    2097              :     size_t response_size;
    2098              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
    2099              :     spdm_algorithms_response_t *spdm_response;
    2100              : 
    2101            1 :     spdm_test_context = *state;
    2102            1 :     spdm_context = spdm_test_context->spdm_context;
    2103            1 :     spdm_test_context->case_id = 0x17;
    2104            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
    2105              : 
    2106            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_12 <<
    2107              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    2108            1 :     spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    2109            1 :     spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
    2110            1 :     spdm_context->local_context.algorithm.dhe_named_group = m_libspdm_use_dhe_algo;
    2111            1 :     spdm_context->local_context.algorithm.aead_cipher_suite = m_libspdm_use_aead_algo;
    2112            1 :     spdm_context->local_context.algorithm.req_base_asym_alg = m_libspdm_use_req_asym_algo;
    2113            1 :     spdm_context->local_context.algorithm.key_schedule = m_libspdm_use_key_schedule_algo;
    2114            1 :     libspdm_reset_message_a(spdm_context);
    2115            1 :     spdm_context->local_context.capability.flags = 0;
    2116            1 :     spdm_context->connection_info.capability.flags = 0;
    2117            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_EX_CAP;
    2118            1 :     spdm_context->connection_info.capability.flags |=
    2119              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP;
    2120              : 
    2121            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP;
    2122            1 :     spdm_context->connection_info.capability.flags |=
    2123              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP;
    2124              : 
    2125            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP;
    2126            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP;
    2127              : 
    2128            1 :     spdm_context->local_context.capability.flags |=
    2129              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
    2130            1 :     spdm_context->connection_info.capability.flags |=
    2131              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
    2132              : 
    2133            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP;
    2134            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP;
    2135              : 
    2136              :     /* Sub Case 1: other_params_support set OpaqueDataFmt1 */
    2137            1 :     m_libspdm_negotiate_algorithm_request18.spdm_request_version10.other_params_support =
    2138              :         SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_1;
    2139            1 :     spdm_context->local_context.algorithm.other_params_support =
    2140              :         SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_1;
    2141            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
    2142            1 :     libspdm_reset_message_a(spdm_context);
    2143              : 
    2144            1 :     response_size = sizeof(response);
    2145            1 :     status = libspdm_get_response_algorithms (spdm_context,
    2146              :                                               m_libspdm_negotiate_algorithm_request18_size,
    2147              :                                               &m_libspdm_negotiate_algorithm_request18,
    2148              :                                               &response_size,
    2149              :                                               response);
    2150            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
    2151            1 :     assert_int_equal(response_size,
    2152              :                      sizeof(spdm_algorithms_response_t) + 4*
    2153              :                      sizeof(spdm_negotiate_algorithms_common_struct_table_t));
    2154            1 :     spdm_response = (void *)response;
    2155            1 :     assert_int_equal(spdm_response->header.spdm_version, SPDM_MESSAGE_VERSION_12);
    2156            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_ALGORITHMS);
    2157            1 :     assert_int_equal(spdm_response->other_params_selection, SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_1);
    2158            1 :     assert_int_equal(spdm_context->connection_info.algorithm.other_params_support,
    2159              :                      SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_1);
    2160              : 
    2161              :     /* Sub Case 2: Populate reserved field for version 1.2.
    2162              :      * Field values marked as Reserved shall be written as zero (0). */
    2163            1 :     spdm_context->local_context.algorithm.other_params_support =
    2164              :         SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_1 |
    2165              :         SPDM_ALGORITHMS_MULTI_KEY_CONN;
    2166            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
    2167            1 :     libspdm_reset_message_a(spdm_context);
    2168            1 :     response_size = sizeof(response);
    2169            1 :     status = libspdm_get_response_algorithms (spdm_context,
    2170              :                                               m_libspdm_negotiate_algorithm_request18_size,
    2171              :                                               &m_libspdm_negotiate_algorithm_request18,
    2172              :                                               &response_size,
    2173              :                                               response);
    2174            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
    2175            1 :     assert_int_equal(response_size,
    2176              :                      sizeof(spdm_algorithms_response_t) + 4*
    2177              :                      sizeof(spdm_negotiate_algorithms_common_struct_table_t));
    2178            1 :     spdm_response = (void *)response;
    2179            1 :     assert_int_equal(spdm_response->header.spdm_version, SPDM_MESSAGE_VERSION_12);
    2180            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_ALGORITHMS);
    2181            1 :     assert_int_equal(spdm_response->other_params_selection, SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_1);
    2182            1 :     assert_int_equal(spdm_context->connection_info.algorithm.other_params_support,
    2183              :                      SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_1);
    2184              : 
    2185              :     /* Sub Case 3: OpaqueDataFmt. Supports both SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_0 and
    2186              :      * SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_1. */
    2187            1 :     m_libspdm_negotiate_algorithm_request18.spdm_request_version10.other_params_support =
    2188              :         SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_0 |
    2189              :         SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_1;
    2190            1 :     spdm_context->local_context.algorithm.other_params_support =
    2191              :         SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_0 |
    2192              :         SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_1;
    2193            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
    2194            1 :     libspdm_reset_message_a(spdm_context);
    2195            1 :     response_size = sizeof(response);
    2196            1 :     status = libspdm_get_response_algorithms (spdm_context,
    2197              :                                               m_libspdm_negotiate_algorithm_request18_size,
    2198              :                                               &m_libspdm_negotiate_algorithm_request18,
    2199              :                                               &response_size,
    2200              :                                               response);
    2201            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
    2202            1 :     assert_int_equal(response_size,
    2203              :                      sizeof(spdm_algorithms_response_t) + 4*
    2204              :                      sizeof(spdm_negotiate_algorithms_common_struct_table_t));
    2205            1 :     spdm_response = (void *)response;
    2206            1 :     assert_int_equal(spdm_response->header.spdm_version, SPDM_MESSAGE_VERSION_12);
    2207            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_ALGORITHMS);
    2208            1 :     assert_int_equal(spdm_response->other_params_selection, SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_1);
    2209            1 :     assert_int_equal(spdm_context->connection_info.algorithm.other_params_support,
    2210              :                      SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_1);
    2211            1 : }
    2212              : 
    2213            1 : static void rsp_algorithms_case24(void **state)
    2214              : {
    2215              :     libspdm_return_t status;
    2216              :     libspdm_test_context_t    *spdm_test_context;
    2217              :     libspdm_context_t  *spdm_context;
    2218              :     size_t response_size;
    2219              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
    2220              :     spdm_algorithms_response_t *spdm_response;
    2221              : 
    2222            1 :     spdm_test_context = *state;
    2223            1 :     spdm_context = spdm_test_context->spdm_context;
    2224            1 :     spdm_test_context->case_id = 0x18;
    2225            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
    2226              : 
    2227            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_12 <<
    2228              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    2229            1 :     spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    2230            1 :     spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
    2231            1 :     spdm_context->local_context.algorithm.dhe_named_group = m_libspdm_use_dhe_algo;
    2232            1 :     spdm_context->local_context.algorithm.aead_cipher_suite = m_libspdm_use_aead_algo;
    2233            1 :     spdm_context->local_context.algorithm.req_base_asym_alg = m_libspdm_use_req_asym_algo;
    2234            1 :     spdm_context->local_context.algorithm.key_schedule = m_libspdm_use_key_schedule_algo;
    2235            1 :     spdm_context->local_context.algorithm.measurement_spec = m_libspdm_use_measurement_spec;
    2236            1 :     spdm_context->local_context.algorithm.measurement_hash_algo =
    2237              :         m_libspdm_use_measurement_hash_algo;
    2238            1 :     libspdm_reset_message_a(spdm_context);
    2239            1 :     spdm_context->local_context.capability.flags =
    2240              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP_SIG;
    2241            1 :     spdm_context->connection_info.capability.flags = 0;
    2242              : 
    2243            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_EX_CAP;
    2244            1 :     spdm_context->connection_info.capability.flags |=
    2245              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP;
    2246              : 
    2247            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP;
    2248            1 :     spdm_context->connection_info.capability.flags |=
    2249              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP;
    2250              : 
    2251            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP;
    2252            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP;
    2253              : 
    2254            1 :     spdm_context->local_context.capability.flags |=
    2255              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
    2256            1 :     spdm_context->connection_info.capability.flags |=
    2257              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
    2258              : 
    2259            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP;
    2260            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP;
    2261              : 
    2262            1 :     response_size = sizeof(response);
    2263            1 :     status = libspdm_get_response_algorithms (spdm_context,
    2264              :                                               m_libspdm_negotiate_algorithm_request24_size,
    2265              :                                               &m_libspdm_negotiate_algorithm_request24,
    2266              :                                               &response_size,
    2267              :                                               response);
    2268            1 :     assert_int_equal (status, LIBSPDM_STATUS_SUCCESS);
    2269            1 :     assert_int_equal(response_size,
    2270              :                      sizeof(spdm_algorithms_response_t) +
    2271              :                      4*sizeof(spdm_negotiate_algorithms_common_struct_table_t));
    2272            1 :     spdm_response = (void *)response;
    2273            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_ALGORITHMS);
    2274            1 :     assert_int_equal(spdm_response->measurement_hash_algo, 0);
    2275            1 :     assert_int_equal(spdm_response->measurement_specification_sel, 0);
    2276            1 : }
    2277              : 
    2278            1 : static void rsp_algorithms_case25(void **state)
    2279              : {
    2280              :     libspdm_return_t status;
    2281              :     libspdm_test_context_t    *spdm_test_context;
    2282              :     libspdm_context_t  *spdm_context;
    2283              :     size_t response_size;
    2284              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
    2285              :     spdm_algorithms_response_t *spdm_response;
    2286              : 
    2287            1 :     spdm_test_context = *state;
    2288            1 :     spdm_context = spdm_test_context->spdm_context;
    2289            1 :     spdm_test_context->case_id = 0x19;
    2290            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
    2291              : 
    2292            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_12 <<
    2293              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    2294            1 :     spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    2295            1 :     spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
    2296            1 :     spdm_context->local_context.algorithm.dhe_named_group = m_libspdm_use_dhe_algo;
    2297            1 :     spdm_context->local_context.algorithm.aead_cipher_suite = m_libspdm_use_aead_algo;
    2298            1 :     spdm_context->local_context.algorithm.req_base_asym_alg = m_libspdm_use_req_asym_algo;
    2299            1 :     spdm_context->local_context.algorithm.key_schedule = m_libspdm_use_key_schedule_algo;
    2300            1 :     spdm_context->local_context.algorithm.measurement_spec = m_libspdm_use_measurement_spec;
    2301            1 :     spdm_context->local_context.algorithm.measurement_hash_algo =
    2302              :         m_libspdm_use_measurement_hash_algo;
    2303            1 :     libspdm_reset_message_a(spdm_context);
    2304            1 :     spdm_context->local_context.capability.flags =
    2305              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP_SIG;
    2306            1 :     spdm_context->connection_info.capability.flags = 0;
    2307              : 
    2308            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_EX_CAP;
    2309            1 :     spdm_context->connection_info.capability.flags |=
    2310              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP;
    2311              : 
    2312            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP;
    2313            1 :     spdm_context->connection_info.capability.flags |=
    2314              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP;
    2315              : 
    2316            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP;
    2317            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP;
    2318              : 
    2319            1 :     spdm_context->local_context.capability.flags |=
    2320              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
    2321            1 :     spdm_context->connection_info.capability.flags |=
    2322              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
    2323              : 
    2324            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP;
    2325            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP;
    2326              : 
    2327            1 :     response_size = sizeof(response);
    2328            1 :     status = libspdm_get_response_algorithms (spdm_context,
    2329              :                                               m_libspdm_negotiate_algorithm_request25_size,
    2330              :                                               &m_libspdm_negotiate_algorithm_request25,
    2331              :                                               &response_size,
    2332              :                                               response);
    2333            1 :     assert_int_equal (status, LIBSPDM_STATUS_SUCCESS);
    2334            1 :     assert_int_equal (response_size, sizeof(spdm_error_response_t));
    2335            1 :     spdm_response = (void *)response;
    2336            1 :     assert_int_equal (spdm_response->header.request_response_code, SPDM_ERROR);
    2337            1 :     assert_int_equal (spdm_response->header.param1, SPDM_ERROR_CODE_INVALID_REQUEST);
    2338            1 :     assert_int_equal (spdm_response->header.param2, 0);
    2339            1 : }
    2340              : 
    2341            1 : static void rsp_algorithms_case26(void **state)
    2342              : {
    2343              :     libspdm_return_t status;
    2344              :     libspdm_test_context_t    *spdm_test_context;
    2345              :     libspdm_context_t  *spdm_context;
    2346              :     size_t response_size;
    2347              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
    2348              :     spdm_algorithms_response_t *spdm_response;
    2349              : 
    2350            1 :     spdm_test_context = *state;
    2351            1 :     spdm_context = spdm_test_context->spdm_context;
    2352            1 :     spdm_test_context->case_id = 0x1A;
    2353            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
    2354              : 
    2355            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_12 <<
    2356              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    2357            1 :     spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    2358            1 :     spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
    2359            1 :     spdm_context->local_context.algorithm.dhe_named_group = m_libspdm_use_dhe_algo;
    2360            1 :     spdm_context->local_context.algorithm.aead_cipher_suite = m_libspdm_use_aead_algo;
    2361            1 :     spdm_context->local_context.algorithm.req_base_asym_alg = m_libspdm_use_req_asym_algo;
    2362            1 :     spdm_context->local_context.algorithm.key_schedule = m_libspdm_use_key_schedule_algo;
    2363            1 :     spdm_context->local_context.algorithm.measurement_spec = m_libspdm_use_measurement_spec;
    2364            1 :     spdm_context->local_context.algorithm.measurement_hash_algo =
    2365              :         m_libspdm_use_measurement_hash_algo;
    2366            1 :     libspdm_reset_message_a(spdm_context);
    2367            1 :     spdm_context->local_context.capability.flags =
    2368              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP_SIG;
    2369            1 :     spdm_context->connection_info.capability.flags = 0;
    2370              : 
    2371            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_EX_CAP;
    2372            1 :     spdm_context->connection_info.capability.flags |=
    2373              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP;
    2374              : 
    2375            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP;
    2376            1 :     spdm_context->connection_info.capability.flags |=
    2377              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP;
    2378              : 
    2379            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP;
    2380            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP;
    2381              : 
    2382            1 :     spdm_context->local_context.capability.flags |=
    2383              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
    2384            1 :     spdm_context->connection_info.capability.flags |=
    2385              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
    2386              : 
    2387            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP;
    2388            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP;
    2389              : 
    2390            1 :     response_size = sizeof(response);
    2391            1 :     status = libspdm_get_response_algorithms (spdm_context,
    2392              :                                               m_libspdm_negotiate_algorithm_request26_size,
    2393              :                                               &m_libspdm_negotiate_algorithm_request26,
    2394              :                                               &response_size,
    2395              :                                               response);
    2396            1 :     assert_int_equal (status, LIBSPDM_STATUS_SUCCESS);
    2397            1 :     assert_int_equal (response_size, sizeof(spdm_error_response_t));
    2398            1 :     spdm_response = (void *)response;
    2399            1 :     assert_int_equal (spdm_response->header.request_response_code, SPDM_ERROR);
    2400            1 :     assert_int_equal (spdm_response->header.param1, SPDM_ERROR_CODE_INVALID_REQUEST);
    2401            1 :     assert_int_equal (spdm_response->header.param2, 0);
    2402            1 : }
    2403              : 
    2404            1 : static void rsp_algorithms_case27(void **state)
    2405              : {
    2406              :     libspdm_return_t status;
    2407              :     libspdm_test_context_t    *spdm_test_context;
    2408              :     libspdm_context_t  *spdm_context;
    2409              :     size_t response_size;
    2410              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
    2411              :     spdm_algorithms_response_t *spdm_response;
    2412              : 
    2413            1 :     spdm_test_context = *state;
    2414            1 :     spdm_context = spdm_test_context->spdm_context;
    2415            1 :     spdm_test_context->case_id = 0x1B;
    2416            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
    2417              : 
    2418            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_12 <<
    2419              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    2420            1 :     spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    2421            1 :     spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
    2422            1 :     spdm_context->local_context.algorithm.dhe_named_group = m_libspdm_use_dhe_algo;
    2423            1 :     spdm_context->local_context.algorithm.aead_cipher_suite = m_libspdm_use_aead_algo;
    2424            1 :     spdm_context->local_context.algorithm.req_base_asym_alg = m_libspdm_use_req_asym_algo;
    2425            1 :     spdm_context->local_context.algorithm.key_schedule = m_libspdm_use_key_schedule_algo;
    2426            1 :     spdm_context->local_context.algorithm.measurement_spec = m_libspdm_use_measurement_spec;
    2427            1 :     spdm_context->local_context.algorithm.measurement_hash_algo =
    2428              :         m_libspdm_use_measurement_hash_algo;
    2429            1 :     libspdm_reset_message_a(spdm_context);
    2430            1 :     spdm_context->local_context.capability.flags =
    2431              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP_SIG;
    2432            1 :     spdm_context->connection_info.capability.flags = 0;
    2433              : 
    2434            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_EX_CAP;
    2435            1 :     spdm_context->connection_info.capability.flags |=
    2436              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP;
    2437              : 
    2438            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP;
    2439            1 :     spdm_context->connection_info.capability.flags |=
    2440              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP;
    2441              : 
    2442            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP;
    2443            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP;
    2444              : 
    2445            1 :     spdm_context->local_context.capability.flags |=
    2446              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
    2447            1 :     spdm_context->connection_info.capability.flags |=
    2448              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
    2449              : 
    2450            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP;
    2451            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP;
    2452              : 
    2453            1 :     response_size = sizeof(response);
    2454            1 :     status = libspdm_get_response_algorithms (spdm_context,
    2455              :                                               m_libspdm_negotiate_algorithm_request27_size,
    2456              :                                               &m_libspdm_negotiate_algorithm_request27,
    2457              :                                               &response_size,
    2458              :                                               response);
    2459            1 :     assert_int_equal (status, LIBSPDM_STATUS_SUCCESS);
    2460            1 :     assert_int_equal (response_size, sizeof(spdm_error_response_t));
    2461            1 :     spdm_response = (void *)response;
    2462            1 :     assert_int_equal (spdm_response->header.request_response_code, SPDM_ERROR);
    2463            1 :     assert_int_equal (spdm_response->header.param1, SPDM_ERROR_CODE_INVALID_REQUEST);
    2464            1 :     assert_int_equal (spdm_response->header.param2, 0);
    2465            1 : }
    2466              : 
    2467            1 : static void rsp_algorithms_case28(void **state)
    2468              : {
    2469              :     libspdm_return_t status;
    2470              :     libspdm_test_context_t    *spdm_test_context;
    2471              :     libspdm_context_t  *spdm_context;
    2472              :     size_t response_size;
    2473              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
    2474              :     spdm_algorithms_response_t *spdm_response;
    2475              : 
    2476            1 :     spdm_test_context = *state;
    2477            1 :     spdm_context = spdm_test_context->spdm_context;
    2478            1 :     spdm_test_context->case_id = 0x1C;
    2479            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
    2480              : 
    2481            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_12 <<
    2482              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    2483            1 :     spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    2484            1 :     spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
    2485            1 :     spdm_context->local_context.algorithm.dhe_named_group = m_libspdm_use_dhe_algo;
    2486            1 :     spdm_context->local_context.algorithm.aead_cipher_suite = m_libspdm_use_aead_algo;
    2487            1 :     spdm_context->local_context.algorithm.req_base_asym_alg = m_libspdm_use_req_asym_algo;
    2488            1 :     spdm_context->local_context.algorithm.key_schedule = m_libspdm_use_key_schedule_algo;
    2489            1 :     spdm_context->local_context.algorithm.measurement_spec = m_libspdm_use_measurement_spec;
    2490            1 :     spdm_context->local_context.algorithm.measurement_hash_algo =
    2491              :         m_libspdm_use_measurement_hash_algo;
    2492            1 :     libspdm_reset_message_a(spdm_context);
    2493            1 :     spdm_context->local_context.capability.flags =
    2494              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP_SIG;
    2495            1 :     spdm_context->connection_info.capability.flags = 0;
    2496              : 
    2497            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_EX_CAP;
    2498            1 :     spdm_context->connection_info.capability.flags |=
    2499              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP;
    2500              : 
    2501            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP;
    2502            1 :     spdm_context->connection_info.capability.flags |=
    2503              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP;
    2504              : 
    2505            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP;
    2506            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP;
    2507              : 
    2508            1 :     spdm_context->local_context.capability.flags |=
    2509              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
    2510            1 :     spdm_context->connection_info.capability.flags |=
    2511              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
    2512              : 
    2513            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP;
    2514            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP;
    2515              : 
    2516            1 :     response_size = sizeof(response);
    2517            1 :     status = libspdm_get_response_algorithms (spdm_context,
    2518              :                                               m_libspdm_negotiate_algorithm_request28_size,
    2519              :                                               &m_libspdm_negotiate_algorithm_request28,
    2520              :                                               &response_size,
    2521              :                                               response);
    2522            1 :     assert_int_equal (status, LIBSPDM_STATUS_SUCCESS);
    2523            1 :     assert_int_equal (response_size, sizeof(spdm_error_response_t));
    2524            1 :     spdm_response = (void *)response;
    2525            1 :     assert_int_equal (spdm_response->header.request_response_code, SPDM_ERROR);
    2526            1 :     assert_int_equal (spdm_response->header.param1, SPDM_ERROR_CODE_INVALID_REQUEST);
    2527            1 :     assert_int_equal (spdm_response->header.param2, 0);
    2528            1 : }
    2529              : 
    2530            1 : static void rsp_algorithms_case29(void **state)
    2531              : {
    2532              :     libspdm_return_t status;
    2533              :     libspdm_test_context_t    *spdm_test_context;
    2534              :     libspdm_context_t  *spdm_context;
    2535              :     size_t response_size;
    2536              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
    2537              :     spdm_algorithms_response_t *spdm_response;
    2538              : 
    2539            1 :     spdm_test_context = *state;
    2540            1 :     spdm_context = spdm_test_context->spdm_context;
    2541            1 :     spdm_test_context->case_id = 0x1C;
    2542            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
    2543              : 
    2544            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_12 <<
    2545              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    2546            1 :     spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    2547            1 :     spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
    2548            1 :     spdm_context->local_context.algorithm.dhe_named_group = m_libspdm_use_dhe_algo;
    2549            1 :     spdm_context->local_context.algorithm.aead_cipher_suite = m_libspdm_use_aead_algo;
    2550            1 :     spdm_context->local_context.algorithm.req_base_asym_alg = m_libspdm_use_req_asym_algo;
    2551            1 :     spdm_context->local_context.algorithm.key_schedule = m_libspdm_use_key_schedule_algo;
    2552            1 :     spdm_context->local_context.algorithm.measurement_spec = m_libspdm_use_measurement_spec;
    2553            1 :     spdm_context->local_context.algorithm.measurement_hash_algo =
    2554              :         m_libspdm_use_measurement_hash_algo;
    2555            1 :     libspdm_reset_message_a(spdm_context);
    2556              : 
    2557            1 :     response_size = sizeof(response);
    2558            1 :     status = libspdm_get_response_algorithms (spdm_context,
    2559              :                                               m_libspdm_negotiate_algorithm_request29_size,
    2560              :                                               &m_libspdm_negotiate_algorithm_request29,
    2561              :                                               &response_size,
    2562              :                                               response);
    2563            1 :     assert_int_equal (status, LIBSPDM_STATUS_SUCCESS);
    2564            1 :     assert_int_equal (response_size, sizeof(spdm_error_response_t));
    2565            1 :     spdm_response = (void *)response;
    2566            1 :     assert_int_equal (spdm_response->header.request_response_code, SPDM_ERROR);
    2567            1 :     assert_int_equal (spdm_response->header.param1, SPDM_ERROR_CODE_INVALID_REQUEST);
    2568            1 :     assert_int_equal (spdm_response->header.param2, 0);
    2569            1 : }
    2570              : 
    2571              : /**
    2572              :  * Test 30: MULTI_KEY_CONN_REQ and MULTI_KEY_CONN_RSP value calculation
    2573              :  * +---------------+--------------------------+--------------------+
    2574              :  * | MULTI_KEY_CAP | RequesterMultiKeyConnSel | MULTI_KEY_CONN_REQ |
    2575              :  * +---------------+--------------------------+--------------------+
    2576              :  * | 00b           | 0                        | false              |
    2577              :  *  ----------------------------------------------------------------
    2578              :  * | 00b           | 1                        | invalid            |
    2579              :  *  ----------------------------------------------------------------
    2580              :  * | 01b           | 0                        | invalid            |
    2581              :  *  ----------------------------------------------------------------
    2582              :  * | 01b           | 1                        | true               |
    2583              :  *  ----------------------------------------------------------------
    2584              :  * | 10b           | 0                        | false              |
    2585              :  *  ----------------------------------------------------------------
    2586              :  * | 10b           | 1                        | true               |
    2587              :  * +---------------+--------------------------+--------------------+
    2588              :  * | MULTI_KEY_CAP | ResponderMultiKeyConn    | MULTI_KEY_CONN_RSP |
    2589              :  * +---------------+--------------------------+--------------------+
    2590              :  * | 00b           | 0                        | false              |
    2591              :  *  ----------------------------------------------------------------
    2592              :  * | 00b           | 1                        | invalid            |
    2593              :  *  ----------------------------------------------------------------
    2594              :  * | 01b           | 0                        | invalid            |
    2595              :  *  ----------------------------------------------------------------
    2596              :  * | 01b           | 1                        | true               |
    2597              :  *  ----------------------------------------------------------------
    2598              :  * | 10b           | 0                        | false              |
    2599              :  *  ----------------------------------------------------------------
    2600              :  * | 10b           | 1                        | true               |
    2601              :  *  ----------------------------------------------------------------
    2602              :  **/
    2603            1 : static void rsp_algorithms_case30(void **state)
    2604              : {
    2605              :     libspdm_return_t status;
    2606              :     libspdm_test_context_t *spdm_test_context;
    2607              :     libspdm_context_t *spdm_context;
    2608              :     size_t response_size;
    2609              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
    2610              :     spdm_algorithms_response_t *spdm_response;
    2611              : 
    2612            1 :     spdm_test_context = *state;
    2613            1 :     spdm_context = spdm_test_context->spdm_context;
    2614            1 :     spdm_test_context->case_id = 0x1D;
    2615            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_13 <<
    2616              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    2617              : 
    2618            1 :     spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    2619            1 :     spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
    2620            1 :     spdm_context->local_context.algorithm.measurement_hash_algo = 0;
    2621            1 :     spdm_context->local_context.algorithm.measurement_spec = 0;
    2622            1 :     spdm_context->local_context.capability.flags = 0;
    2623              : 
    2624            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
    2625            1 :     libspdm_reset_message_a(spdm_context);
    2626              : 
    2627            1 :     spdm_context->local_context.capability.flags = 0;
    2628            1 :     spdm_context->local_context.algorithm.other_params_support = 0;
    2629            1 :     spdm_context->connection_info.capability.flags = 0;
    2630            1 :     m_libspdm_negotiate_algorithms_request30.other_params_support = 0;
    2631              : 
    2632            1 :     response_size = sizeof(response);
    2633            1 :     status = libspdm_get_response_algorithms(
    2634              :         spdm_context, m_libspdm_negotiate_algorithms_request30_size,
    2635              :         &m_libspdm_negotiate_algorithms_request30, &response_size,
    2636              :         response);
    2637              : 
    2638            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
    2639            1 :     assert_int_equal(response_size, sizeof(spdm_algorithms_response_t));
    2640            1 :     spdm_response = (void *)response;
    2641            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_ALGORITHMS);
    2642            1 :     assert_int_equal(spdm_context->connection_info.multi_key_conn_rsp, false);
    2643            1 :     assert_int_equal(spdm_context->connection_info.multi_key_conn_req, false);
    2644              : 
    2645            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
    2646            1 :     libspdm_reset_message_a(spdm_context);
    2647              : 
    2648            1 :     spdm_context->local_context.capability.flags = 0;
    2649            1 :     spdm_context->local_context.algorithm.other_params_support = SPDM_ALGORITHMS_MULTI_KEY_CONN;
    2650            1 :     spdm_context->connection_info.capability.flags = 0;
    2651            1 :     m_libspdm_negotiate_algorithms_request30.other_params_support = SPDM_ALGORITHMS_MULTI_KEY_CONN;
    2652              : 
    2653            1 :     response_size = sizeof(response);
    2654            1 :     status = libspdm_get_response_algorithms(
    2655              :         spdm_context, m_libspdm_negotiate_algorithms_request30_size,
    2656              :         &m_libspdm_negotiate_algorithms_request30, &response_size,
    2657              :         response);
    2658              :     /* MULTI_KEY_CONN_REQ and MULTI_KEY_CONN_RSP invalid */
    2659            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
    2660            1 :     assert_int_equal (response_size, sizeof(spdm_error_response_t));
    2661            1 :     spdm_response = (void *)response;
    2662            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_ERROR);
    2663              : 
    2664            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
    2665            1 :     libspdm_reset_message_a(spdm_context);
    2666              : 
    2667            1 :     spdm_context->local_context.capability.flags =
    2668              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MULTI_KEY_CAP_ONLY;
    2669            1 :     spdm_context->local_context.algorithm.other_params_support = 0;
    2670            1 :     spdm_context->connection_info.capability.flags =
    2671              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MULTI_KEY_CAP_ONLY;
    2672            1 :     m_libspdm_negotiate_algorithms_request30.other_params_support = 0;
    2673              : 
    2674            1 :     response_size = sizeof(response);
    2675            1 :     status = libspdm_get_response_algorithms(
    2676              :         spdm_context, m_libspdm_negotiate_algorithms_request30_size,
    2677              :         &m_libspdm_negotiate_algorithms_request30, &response_size,
    2678              :         response);
    2679              :     /* MULTI_KEY_CONN_REQ and MULTI_KEY_CONN_RSP invalid */
    2680            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
    2681            1 :     assert_int_equal (response_size, sizeof(spdm_error_response_t));
    2682            1 :     spdm_response = (void *)response;
    2683            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_ERROR);
    2684              : 
    2685            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
    2686            1 :     libspdm_reset_message_a(spdm_context);
    2687              : 
    2688            1 :     spdm_context->local_context.capability.flags =
    2689              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MULTI_KEY_CAP_ONLY;
    2690            1 :     spdm_context->local_context.algorithm.other_params_support = SPDM_ALGORITHMS_MULTI_KEY_CONN;
    2691            1 :     spdm_context->connection_info.capability.flags =
    2692              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MULTI_KEY_CAP_ONLY;
    2693            1 :     m_libspdm_negotiate_algorithms_request30.other_params_support = SPDM_ALGORITHMS_MULTI_KEY_CONN;
    2694              : 
    2695            1 :     response_size = sizeof(response);
    2696            1 :     status = libspdm_get_response_algorithms(
    2697              :         spdm_context, m_libspdm_negotiate_algorithms_request30_size,
    2698              :         &m_libspdm_negotiate_algorithms_request30, &response_size,
    2699              :         response);
    2700            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
    2701            1 :     assert_int_equal(response_size, sizeof(spdm_algorithms_response_t));
    2702            1 :     spdm_response = (void *)response;
    2703            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_ALGORITHMS);
    2704            1 :     assert_int_equal(spdm_context->connection_info.multi_key_conn_rsp, true);
    2705            1 :     assert_int_equal(spdm_context->connection_info.multi_key_conn_req, true);
    2706              : 
    2707            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
    2708            1 :     libspdm_reset_message_a(spdm_context);
    2709              : 
    2710            1 :     spdm_context->local_context.capability.flags =
    2711              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MULTI_KEY_CAP_NEG;
    2712            1 :     spdm_context->local_context.algorithm.other_params_support = 0;
    2713            1 :     spdm_context->connection_info.capability.flags =
    2714              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MULTI_KEY_CAP_NEG;
    2715            1 :     m_libspdm_negotiate_algorithms_request30.other_params_support = 0;
    2716              : 
    2717            1 :     response_size = sizeof(response);
    2718            1 :     status = libspdm_get_response_algorithms(
    2719              :         spdm_context, m_libspdm_negotiate_algorithms_request30_size,
    2720              :         &m_libspdm_negotiate_algorithms_request30, &response_size,
    2721              :         response);
    2722            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
    2723            1 :     assert_int_equal(response_size, sizeof(spdm_algorithms_response_t));
    2724            1 :     spdm_response = (void *)response;
    2725            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_ALGORITHMS);
    2726            1 :     assert_int_equal(spdm_context->connection_info.multi_key_conn_rsp, false);
    2727            1 :     assert_int_equal(spdm_context->connection_info.multi_key_conn_req, false);
    2728              : 
    2729            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
    2730            1 :     libspdm_reset_message_a(spdm_context);
    2731              : 
    2732            1 :     spdm_context->local_context.capability.flags =
    2733              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MULTI_KEY_CAP_NEG;
    2734            1 :     spdm_context->local_context.algorithm.other_params_support = SPDM_ALGORITHMS_MULTI_KEY_CONN;
    2735            1 :     spdm_context->connection_info.capability.flags =
    2736              :         SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MULTI_KEY_CAP_NEG;
    2737            1 :     m_libspdm_negotiate_algorithms_request30.other_params_support = SPDM_ALGORITHMS_MULTI_KEY_CONN;
    2738              : 
    2739            1 :     response_size = sizeof(response);
    2740            1 :     status = libspdm_get_response_algorithms(
    2741              :         spdm_context, m_libspdm_negotiate_algorithms_request30_size,
    2742              :         &m_libspdm_negotiate_algorithms_request30, &response_size,
    2743              :         response);
    2744            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
    2745            1 :     assert_int_equal(response_size, sizeof(spdm_algorithms_response_t));
    2746            1 :     spdm_response = (void *)response;
    2747            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_ALGORITHMS);
    2748            1 :     assert_int_equal(spdm_context->connection_info.multi_key_conn_rsp, true);
    2749            1 :     assert_int_equal(spdm_context->connection_info.multi_key_conn_req, true);
    2750            1 : }
    2751              : 
    2752              : 
    2753              : /**
    2754              :  * Test 31: NEGOTIATE_ALGORITHMS message received with MEL correct
    2755              :  * Expected Behavior: get a LIBSPDM_STATUS_SUCCESS return code
    2756              :  **/
    2757            1 : static void rsp_algorithms_case31(void **state)
    2758              : {
    2759              :     libspdm_return_t status;
    2760              :     libspdm_test_context_t *spdm_test_context;
    2761              :     libspdm_context_t *spdm_context;
    2762              :     size_t response_size;
    2763              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
    2764              :     spdm_algorithms_response_t *spdm_response;
    2765              : 
    2766            1 :     spdm_test_context = *state;
    2767            1 :     spdm_context = spdm_test_context->spdm_context;
    2768            1 :     spdm_test_context->case_id = 0x1E;
    2769            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_13 <<
    2770              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    2771            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
    2772            1 :     spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    2773            1 :     spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
    2774            1 :     spdm_context->local_context.algorithm.measurement_hash_algo = 0;
    2775            1 :     spdm_context->local_context.algorithm.measurement_spec = 0;
    2776            1 :     spdm_context->local_context.capability.flags = 0;
    2777            1 :     spdm_context->local_context.algorithm.other_params_support = 0;
    2778            1 :     spdm_context->local_context.algorithm.mel_spec = SPDM_MEL_SPECIFICATION_DMTF;
    2779            1 :     libspdm_reset_message_a(spdm_context);
    2780              : 
    2781              :     /* Sub Case 1: MEL_CAP set 1, mel_specification set SPDM_MEL_SPECIFICATION_DMTF*/
    2782            1 :     m_libspdm_negotiate_algorithms_request30.other_params_support = 0;
    2783            1 :     m_libspdm_negotiate_algorithms_request30.mel_specification = SPDM_MEL_SPECIFICATION_DMTF;
    2784            1 :     spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEL_CAP;
    2785              : 
    2786            1 :     response_size = sizeof(response);
    2787            1 :     status = libspdm_get_response_algorithms(
    2788              :         spdm_context, m_libspdm_negotiate_algorithms_request30_size,
    2789              :         &m_libspdm_negotiate_algorithms_request30, &response_size,
    2790              :         response);
    2791              : 
    2792            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
    2793            1 :     assert_int_equal(response_size, sizeof(spdm_algorithms_response_t));
    2794            1 :     spdm_response = (void *)response;
    2795            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_ALGORITHMS);
    2796            1 :     assert_int_equal(spdm_response->mel_specification_sel, SPDM_MEL_SPECIFICATION_DMTF);
    2797            1 :     assert_int_equal(spdm_context->connection_info.algorithm.mel_spec, SPDM_MEL_SPECIFICATION_DMTF);
    2798              : 
    2799              :     /* Sub Case 2: MEL_CAP set 0, mel_specification set SPDM_MEL_SPECIFICATION_DMTF*/
    2800            1 :     m_libspdm_negotiate_algorithms_request30.mel_specification = SPDM_MEL_SPECIFICATION_DMTF;
    2801            1 :     spdm_context->local_context.capability.flags = 0;
    2802            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
    2803            1 :     libspdm_reset_message_a(spdm_context);
    2804              : 
    2805            1 :     response_size = sizeof(response);
    2806            1 :     status = libspdm_get_response_algorithms(
    2807              :         spdm_context, m_libspdm_negotiate_algorithms_request30_size,
    2808              :         &m_libspdm_negotiate_algorithms_request30, &response_size,
    2809              :         response);
    2810              : 
    2811            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
    2812            1 :     assert_int_equal(response_size, sizeof(spdm_algorithms_response_t));
    2813            1 :     spdm_response = (void *)response;
    2814            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_ALGORITHMS);
    2815            1 :     assert_int_equal(spdm_response->mel_specification_sel, 0);
    2816            1 :     assert_int_equal(spdm_context->connection_info.algorithm.mel_spec, 0);
    2817            1 : }
    2818              : 
    2819              : /**
    2820              :  * Test 32: NEGOTIATE_ALGORITHMS message received with MEAS correct
    2821              :  * Expected Behavior: get a LIBSPDM_STATUS_SUCCESS return code
    2822              :  **/
    2823            1 : static void rsp_algorithms_case32(void **state)
    2824              : {
    2825              :     libspdm_return_t status;
    2826              :     libspdm_test_context_t *spdm_test_context;
    2827              :     libspdm_context_t *spdm_context;
    2828              :     size_t response_size;
    2829              :     uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
    2830              :     spdm_algorithms_response_t *spdm_response;
    2831              : 
    2832            1 :     spdm_test_context = *state;
    2833            1 :     spdm_context = spdm_test_context->spdm_context;
    2834            1 :     spdm_test_context->case_id = 0x1F;
    2835            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_10 <<
    2836              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    2837            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
    2838            1 :     spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    2839            1 :     spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
    2840            1 :     spdm_context->local_context.algorithm.measurement_spec = 0;
    2841            1 :     spdm_context->local_context.algorithm.measurement_spec |= SPDM_MEASUREMENT_SPECIFICATION_DMTF;
    2842            1 :     spdm_context->local_context.capability.flags = 0;
    2843            1 :     spdm_context->local_context.algorithm.other_params_support = 0;
    2844            1 :     libspdm_reset_message_a(spdm_context);
    2845              : 
    2846              :     /* Sub Case 1: MEL_CAP set 1, measurement_spec set SPDM_MEASUREMENT_SPECIFICATION_DMTF*/
    2847            1 :     spdm_context->local_context.capability.flags |=
    2848              :         SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP_SIG;
    2849            1 :     spdm_context->local_context.algorithm.measurement_spec |= SPDM_MEASUREMENT_SPECIFICATION_DMTF;
    2850            1 :     spdm_context->local_context.algorithm.measurement_hash_algo =
    2851              :         m_libspdm_use_measurement_hash_algo;
    2852              : 
    2853            1 :     response_size = sizeof(response);
    2854            1 :     status = libspdm_get_response_algorithms(
    2855              :         spdm_context, m_libspdm_negotiate_algorithms_request1_size,
    2856              :         &m_libspdm_negotiate_algorithms_request1, &response_size,
    2857              :         response);
    2858              : 
    2859            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
    2860            1 :     assert_int_equal(response_size, sizeof(spdm_algorithms_response_t));
    2861            1 :     spdm_response = (void *)response;
    2862            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_ALGORITHMS);
    2863            1 :     assert_int_equal(spdm_response->measurement_specification_sel,
    2864              :                      SPDM_MEASUREMENT_SPECIFICATION_DMTF);
    2865            1 :     assert_int_equal(spdm_context->connection_info.algorithm.measurement_spec,
    2866              :                      SPDM_MEASUREMENT_SPECIFICATION_DMTF);
    2867              : 
    2868              :     /* Sub Case 2: MEL_CAP set 0, measurement_spec set 0*/
    2869            1 :     spdm_context->local_context.capability.flags = 0;
    2870            1 :     spdm_context->local_context.algorithm.measurement_hash_algo = 0;
    2871            1 :     spdm_context->local_context.algorithm.measurement_spec = 0;
    2872            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
    2873            1 :     m_libspdm_negotiate_algorithms_request1.measurement_specification = 0;
    2874            1 :     libspdm_reset_message_a(spdm_context);
    2875              : 
    2876            1 :     response_size = sizeof(response);
    2877            1 :     status = libspdm_get_response_algorithms(
    2878              :         spdm_context, m_libspdm_negotiate_algorithms_request1_size,
    2879              :         &m_libspdm_negotiate_algorithms_request1, &response_size,
    2880              :         response);
    2881              : 
    2882            1 :     assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
    2883            1 :     assert_int_equal(response_size, sizeof(spdm_algorithms_response_t));
    2884            1 :     spdm_response = (void *)response;
    2885            1 :     assert_int_equal(spdm_response->header.request_response_code, SPDM_ALGORITHMS);
    2886            1 :     assert_int_equal(spdm_response->measurement_specification_sel, 0);
    2887            1 :     assert_int_equal(spdm_context->connection_info.algorithm.measurement_spec, 0);
    2888            1 : }
    2889              : 
    2890            1 : int libspdm_rsp_algorithms_test(void)
    2891              : {
    2892            1 :     const struct CMUnitTest test_cases[] = {
    2893              :         /* Success Case*/
    2894              :         cmocka_unit_test(rsp_algorithms_case1),
    2895              :         /* Bad request size*/
    2896              :         cmocka_unit_test(rsp_algorithms_case2),
    2897              :         /* response_state: LIBSPDM_RESPONSE_STATE_BUSY*/
    2898              :         cmocka_unit_test(rsp_algorithms_case3),
    2899              :         /* response_state: LIBSPDM_RESPONSE_STATE_NEED_RESYNC*/
    2900              :         cmocka_unit_test(rsp_algorithms_case4),
    2901              :         /* connection_state Check*/
    2902              :         cmocka_unit_test(rsp_algorithms_case6),
    2903              :         /* Success case V1.1*/
    2904              :         cmocka_unit_test(rsp_algorithms_case7),
    2905              :         /* No match for base_asym_algo*/
    2906              :         cmocka_unit_test(rsp_algorithms_case8),
    2907              :         /* No match for base_hash_algo*/
    2908              :         cmocka_unit_test(rsp_algorithms_case9),
    2909              :         /* No match for dhe_named_group*/
    2910              :         cmocka_unit_test(rsp_algorithms_case10),
    2911              :         /* No match for aead_cipher_suite*/
    2912              :         cmocka_unit_test(rsp_algorithms_case11),
    2913              :         /* No match for req_base_asym_alg*/
    2914              :         cmocka_unit_test(rsp_algorithms_case12),
    2915              :         /* No match for key_schedule*/
    2916              :         cmocka_unit_test(rsp_algorithms_case13),
    2917              :         /* Spdm length greater than 64 bytes for V1.0*/
    2918              :         cmocka_unit_test(rsp_algorithms_case14),
    2919              :         /* Spdm length greater than 128 bytes for V1.1*/
    2920              :         cmocka_unit_test(rsp_algorithms_case15),
    2921              :         /* Multiple repeated Alg structs for V1.1*/
    2922              :         cmocka_unit_test(rsp_algorithms_case16),
    2923              :         /* param1 is smaller than the number of Alg structs for V1.1*/
    2924              :         cmocka_unit_test(rsp_algorithms_case17),
    2925              :         /* param1 is bigger than the number of  Alg structs for V1.1*/
    2926              :         cmocka_unit_test(rsp_algorithms_case18),
    2927              :         /* Invalid  Alg structs + valid Alg Structs for V1.1*/
    2928              :         cmocka_unit_test(rsp_algorithms_case19),
    2929              :         /* When support multiple algorithms, then defaults to choose the strongest available algorithm*/
    2930              :         cmocka_unit_test(rsp_algorithms_case20),
    2931              :         /* Buffer verification*/
    2932              :         cmocka_unit_test(rsp_algorithms_case21),
    2933              :         /* Success case V1.2*/
    2934              :         cmocka_unit_test(rsp_algorithms_case22),
    2935              :         /* Version 1.2 Check other_params_support */
    2936              :         cmocka_unit_test(rsp_algorithms_case23),
    2937              :         /* No support for MEASUREMENT from requester*/
    2938              :         cmocka_unit_test(rsp_algorithms_case24),
    2939              :         /* Invalid (Redundant) alg_type value*/
    2940              :         cmocka_unit_test(rsp_algorithms_case25),
    2941              :         /* Invalid (Decreasing) alg_type value*/
    2942              :         cmocka_unit_test(rsp_algorithms_case26),
    2943              :         /* Invalid (smaller than DHE) alg_type value*/
    2944              :         cmocka_unit_test(rsp_algorithms_case27),
    2945              :         /* Invalid (bigger than KEY_SCHEDULE) alg_type value*/
    2946              :         cmocka_unit_test(rsp_algorithms_case28),
    2947              :         /* Invalid AlgStruct, contains an AlgSupported=0 (Non-supported)*/
    2948              :         cmocka_unit_test(rsp_algorithms_case29),
    2949              :         /* MULTI_KEY_CONN_REQ and MULTI_KEY_CONN_RSP value validation*/
    2950              :         cmocka_unit_test(rsp_algorithms_case30),
    2951              :         /* Success Case , set MELspecificationSel*/
    2952              :         cmocka_unit_test(rsp_algorithms_case31),
    2953              :         /* Success Case , set MeasurementSpecification*/
    2954              :         cmocka_unit_test(rsp_algorithms_case32),
    2955              :     };
    2956              : 
    2957            1 :     m_libspdm_negotiate_algorithms_request1.base_asym_algo = m_libspdm_use_asym_algo;
    2958            1 :     m_libspdm_negotiate_algorithms_request1.base_hash_algo = m_libspdm_use_hash_algo;
    2959            1 :     m_libspdm_negotiate_algorithms_request2.base_asym_algo = m_libspdm_use_asym_algo;
    2960            1 :     m_libspdm_negotiate_algorithms_request2.base_hash_algo = m_libspdm_use_hash_algo;
    2961            1 :     m_libspdm_negotiate_algorithm_request3.spdm_request_version10.base_asym_algo =
    2962              :         m_libspdm_use_asym_algo;
    2963            1 :     m_libspdm_negotiate_algorithm_request3.spdm_request_version10.base_hash_algo =
    2964              :         m_libspdm_use_hash_algo;
    2965            1 :     m_libspdm_negotiate_algorithm_request4.spdm_request_version10.base_asym_algo =
    2966            1 :         (m_libspdm_use_asym_algo >> 1);
    2967            1 :     m_libspdm_negotiate_algorithm_request4.spdm_request_version10.base_hash_algo =
    2968              :         m_libspdm_use_hash_algo;
    2969            1 :     m_libspdm_negotiate_algorithm_request5.spdm_request_version10.base_asym_algo =
    2970              :         m_libspdm_use_asym_algo;
    2971            1 :     m_libspdm_negotiate_algorithm_request5.spdm_request_version10.base_hash_algo =
    2972              :         SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA3_512;
    2973            1 :     m_libspdm_negotiate_algorithm_request6.spdm_request_version10.base_asym_algo =
    2974              :         m_libspdm_use_asym_algo;
    2975            1 :     m_libspdm_negotiate_algorithm_request6.spdm_request_version10.base_hash_algo =
    2976              :         m_libspdm_use_hash_algo;
    2977            1 :     m_libspdm_negotiate_algorithm_request7.spdm_request_version10.base_asym_algo =
    2978              :         m_libspdm_use_asym_algo;
    2979            1 :     m_libspdm_negotiate_algorithm_request7.spdm_request_version10.base_hash_algo =
    2980              :         m_libspdm_use_hash_algo;
    2981            1 :     m_libspdm_negotiate_algorithm_request8.spdm_request_version10.base_asym_algo =
    2982              :         m_libspdm_use_asym_algo;
    2983            1 :     m_libspdm_negotiate_algorithm_request8.spdm_request_version10.base_hash_algo =
    2984              :         m_libspdm_use_hash_algo;
    2985            1 :     m_libspdm_negotiate_algorithm_request9.spdm_request_version10.base_asym_algo =
    2986              :         m_libspdm_use_asym_algo;
    2987            1 :     m_libspdm_negotiate_algorithm_request9.spdm_request_version10.base_hash_algo =
    2988              :         m_libspdm_use_hash_algo;
    2989            1 :     m_libspdm_negotiate_algorithm_request10.base_asym_algo = m_libspdm_use_asym_algo;
    2990            1 :     m_libspdm_negotiate_algorithm_request10.base_hash_algo = m_libspdm_use_hash_algo;
    2991            1 :     m_libspdm_negotiate_algorithm_request10.ext_asym_count = 0x09;
    2992            1 :     m_libspdm_negotiate_algorithm_request11.spdm_request_version10.base_asym_algo =
    2993              :         m_libspdm_use_asym_algo;
    2994            1 :     m_libspdm_negotiate_algorithm_request11.spdm_request_version10.base_hash_algo =
    2995              :         m_libspdm_use_hash_algo;
    2996            1 :     m_libspdm_negotiate_algorithm_request11.spdm_request_version10.ext_asym_count = 0x15;
    2997            1 :     m_libspdm_negotiate_algorithm_request12.spdm_request_version10.base_asym_algo =
    2998              :         m_libspdm_use_asym_algo;
    2999            1 :     m_libspdm_negotiate_algorithm_request12.spdm_request_version10.base_hash_algo =
    3000              :         m_libspdm_use_hash_algo;
    3001            1 :     m_libspdm_negotiate_algorithm_request13.spdm_request_version10.base_asym_algo =
    3002              :         m_libspdm_use_asym_algo;
    3003            1 :     m_libspdm_negotiate_algorithm_request13.spdm_request_version10.base_hash_algo =
    3004              :         m_libspdm_use_hash_algo;
    3005            1 :     m_libspdm_negotiate_algorithm_request14.spdm_request_version10.base_asym_algo =
    3006              :         m_libspdm_use_asym_algo;
    3007            1 :     m_libspdm_negotiate_algorithm_request14.spdm_request_version10.base_hash_algo =
    3008              :         m_libspdm_use_hash_algo;
    3009            1 :     m_libspdm_negotiate_algorithm_request15.spdm_request_version10.base_asym_algo =
    3010              :         m_libspdm_use_asym_algo;
    3011            1 :     m_libspdm_negotiate_algorithm_request15.spdm_request_version10.base_hash_algo =
    3012              :         m_libspdm_use_hash_algo;
    3013            1 :     m_libspdm_negotiate_algorithm_request16.spdm_request_version10.base_asym_algo =
    3014              :         SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_ECDSA_ECC_NIST_P521 |
    3015              :         SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_ECDSA_ECC_NIST_P384 |
    3016              :         SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_ECDSA_ECC_NIST_P256 |
    3017              :         SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_RSAPSS_3072 |
    3018              :         SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_RSASSA_2048;
    3019            1 :     m_libspdm_negotiate_algorithm_request16.spdm_request_version10.base_hash_algo =
    3020              :         SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA_512 |
    3021              :         SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA_384 |
    3022              :         SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA_256;
    3023            1 :     m_libspdm_negotiate_algorithm_request17.spdm_request_version10.base_hash_algo =
    3024              :         m_libspdm_use_hash_algo;
    3025            1 :     m_libspdm_negotiate_algorithm_request17.spdm_request_version10.base_asym_algo =
    3026              :         m_libspdm_use_asym_algo;
    3027            1 :     m_libspdm_negotiate_algorithm_request18.spdm_request_version10.base_hash_algo =
    3028              :         m_libspdm_use_hash_algo;
    3029            1 :     m_libspdm_negotiate_algorithm_request18.spdm_request_version10.base_asym_algo =
    3030              :         m_libspdm_use_asym_algo;
    3031            1 :     m_libspdm_negotiate_algorithm_request24.spdm_request_version10.base_asym_algo =
    3032              :         m_libspdm_use_asym_algo;
    3033              : 
    3034            1 :     libspdm_test_context_t test_context = {
    3035              :         LIBSPDM_TEST_CONTEXT_VERSION,
    3036              :         false,
    3037              :     };
    3038              : 
    3039            1 :     libspdm_setup_test_context(&test_context);
    3040              : 
    3041            1 :     return cmocka_run_group_tests(test_cases,
    3042              :                                   libspdm_unit_test_group_setup,
    3043              :                                   libspdm_unit_test_group_teardown);
    3044              : }
        

Generated by: LCOV version 2.0-1