LCOV - code coverage report
Current view: top level - unit_test/test_spdm_requester/error_test - get_digests_err.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 63.4 % 696 441
Test Date: 2025-10-12 08:10:56 Functions: 100.0 % 25 25

            Line data    Source code
       1              : /**
       2              :  *  Copyright Notice:
       3              :  *  Copyright 2021-2025 DMTF. All rights reserved.
       4              :  *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
       5              :  **/
       6              : 
       7              : #include "spdm_unit_test.h"
       8              : #include "internal/libspdm_requester_lib.h"
       9              : #include "internal/libspdm_secured_message_lib.h"
      10              : 
      11              : #if LIBSPDM_SEND_GET_CERTIFICATE_SUPPORT
      12              : 
      13              : static uint8_t m_libspdm_local_certificate_chain[LIBSPDM_MAX_CERT_CHAIN_SIZE];
      14              : 
      15              : static void *m_libspdm_local_certificate_chain_test_cert;
      16              : static size_t m_libspdm_local_certificate_chain_size;
      17              : 
      18              : static bool m_get_digest;
      19              : 
      20           31 : static libspdm_return_t send_message(
      21              :     void *spdm_context, size_t request_size, const void *request, uint64_t timeout)
      22              : {
      23              :     libspdm_test_context_t *spdm_test_context;
      24              : 
      25           31 :     spdm_test_context = libspdm_get_test_context();
      26           31 :     switch (spdm_test_context->case_id) {
      27            1 :     case 0x1:
      28            1 :         return LIBSPDM_STATUS_SEND_FAIL;
      29            1 :     case 0x2:
      30            1 :         return LIBSPDM_STATUS_SUCCESS;
      31            0 :     case 0x3:
      32            0 :         return LIBSPDM_STATUS_SUCCESS;
      33            1 :     case 0x4:
      34            1 :         return LIBSPDM_STATUS_SUCCESS;
      35            1 :     case 0x5:
      36            1 :         return LIBSPDM_STATUS_SUCCESS;
      37            0 :     case 0x6:
      38            0 :         return LIBSPDM_STATUS_SUCCESS;
      39            1 :     case 0x7:
      40            1 :         return LIBSPDM_STATUS_SUCCESS;
      41            2 :     case 0x8:
      42            2 :         return LIBSPDM_STATUS_SUCCESS;
      43            1 :     case 0x9:
      44            1 :         return LIBSPDM_STATUS_SUCCESS;
      45            0 :     case 0xA:
      46            0 :         return LIBSPDM_STATUS_SUCCESS;
      47            1 :     case 0xB:
      48            1 :         return LIBSPDM_STATUS_SUCCESS;
      49            0 :     case 0xC:
      50            0 :         return LIBSPDM_STATUS_SUCCESS;
      51            1 :     case 0xD:
      52            1 :         return LIBSPDM_STATUS_SUCCESS;
      53            1 :     case 0xE:
      54            1 :         return LIBSPDM_STATUS_SUCCESS;
      55            0 :     case 0xF:
      56            0 :         return LIBSPDM_STATUS_SUCCESS;
      57            0 :     case 0x10:
      58            0 :         return LIBSPDM_STATUS_SUCCESS;
      59            0 :     case 0x11:
      60            0 :         return LIBSPDM_STATUS_SUCCESS;
      61            1 :     case 0x12:
      62            1 :         return LIBSPDM_STATUS_SUCCESS;
      63            0 :     case 0x13:
      64            0 :         return LIBSPDM_STATUS_SUCCESS;
      65            0 :     case 0x14:
      66            0 :         return LIBSPDM_STATUS_SUCCESS;
      67            0 :     case 0x15:
      68            0 :         return LIBSPDM_STATUS_SUCCESS;
      69           18 :     case 0x16:
      70           18 :         return LIBSPDM_STATUS_SUCCESS;
      71            1 :     case 0x17:
      72            1 :         return LIBSPDM_STATUS_SUCCESS;
      73            0 :     case 0x18:
      74            0 :         return LIBSPDM_STATUS_SUCCESS;
      75            0 :     case 0x19:
      76            0 :         return LIBSPDM_STATUS_SUCCESS;
      77            0 :     default:
      78            0 :         return LIBSPDM_STATUS_SEND_FAIL;
      79              :     }
      80              : }
      81              : 
      82           29 : static libspdm_return_t receive_message(
      83              :     void *spdm_context, size_t *response_size, void **response, uint64_t timeout)
      84              : {
      85              :     libspdm_test_context_t *spdm_test_context;
      86              : 
      87           29 :     spdm_test_context = libspdm_get_test_context();
      88           29 :     switch (spdm_test_context->case_id) {
      89            0 :     case 0x1:
      90            0 :         return LIBSPDM_STATUS_RECEIVE_FAIL;
      91              : 
      92            0 :     case 0x2: {
      93              :         spdm_digest_response_t *spdm_response;
      94              :         uint8_t *digest;
      95              :         size_t spdm_response_size;
      96              :         size_t transport_header_size;
      97              : 
      98              :         ((libspdm_context_t *)spdm_context)
      99            0 :         ->connection_info.algorithm.base_hash_algo =
     100              :             m_libspdm_use_hash_algo;
     101            0 :         spdm_response_size = sizeof(spdm_digest_response_t) +
     102            0 :                              libspdm_get_hash_size(m_libspdm_use_hash_algo);
     103            0 :         transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
     104            0 :         spdm_response = (void *)((uint8_t *)*response + transport_header_size);
     105              : 
     106            0 :         spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
     107            0 :         spdm_response->header.param1 = 0;
     108            0 :         spdm_response->header.request_response_code = SPDM_DIGESTS;
     109            0 :         spdm_response->header.param2 = 0;
     110            0 :         libspdm_set_mem(m_libspdm_local_certificate_chain,
     111              :                         sizeof(m_libspdm_local_certificate_chain),
     112              :                         (uint8_t)(0xFF));
     113              : 
     114            0 :         digest = (void *)(spdm_response + 1);
     115            0 :         libspdm_zero_mem (digest,
     116            0 :                           libspdm_get_hash_size(m_libspdm_use_hash_algo) *
     117              :                           (SPDM_MAX_SLOT_COUNT - 1));
     118            0 :         libspdm_hash_all(m_libspdm_use_hash_algo, m_libspdm_local_certificate_chain,
     119              :                          sizeof(m_libspdm_local_certificate_chain), &digest[0]);
     120            0 :         spdm_response->header.param2 |= (0x01 << 0);
     121              : 
     122            0 :         libspdm_transport_test_encode_message(spdm_context, NULL, false,
     123              :                                               false, spdm_response_size,
     124              :                                               spdm_response, response_size,
     125              :                                               response);
     126              :     }
     127            0 :         return LIBSPDM_STATUS_SUCCESS;
     128              : 
     129            0 :     case 0x3: {
     130              :         spdm_digest_response_t *spdm_response;
     131              :         uint8_t *digest;
     132              :         size_t spdm_response_size;
     133              :         size_t transport_header_size;
     134              : 
     135              :         ((libspdm_context_t *)spdm_context)
     136            0 :         ->connection_info.algorithm.base_hash_algo =
     137              :             m_libspdm_use_hash_algo;
     138            0 :         spdm_response_size = sizeof(spdm_digest_response_t) +
     139            0 :                              libspdm_get_hash_size(m_libspdm_use_hash_algo);
     140            0 :         transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
     141            0 :         spdm_response = (void *)((uint8_t *)*response + transport_header_size);
     142              : 
     143            0 :         spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
     144            0 :         spdm_response->header.param1 = 0;
     145            0 :         spdm_response->header.request_response_code = SPDM_DIGESTS;
     146            0 :         spdm_response->header.param2 = 0;
     147            0 :         libspdm_set_mem(m_libspdm_local_certificate_chain,
     148              :                         sizeof(m_libspdm_local_certificate_chain),
     149              :                         (uint8_t)(0xFF));
     150              : 
     151            0 :         digest = (void *)(spdm_response + 1);
     152            0 :         libspdm_hash_all(m_libspdm_use_hash_algo, m_libspdm_local_certificate_chain,
     153              :                          sizeof(m_libspdm_local_certificate_chain), &digest[0]);
     154            0 :         spdm_response->header.param2 |= (1 << 0);
     155              : 
     156            0 :         libspdm_transport_test_encode_message(spdm_context, NULL, false,
     157              :                                               false, spdm_response_size,
     158              :                                               spdm_response, response_size,
     159              :                                               response);
     160              :     }
     161            0 :         return LIBSPDM_STATUS_SUCCESS;
     162              : 
     163            1 :     case 0x4: {
     164              :         spdm_error_response_t *spdm_response;
     165              :         size_t spdm_response_size;
     166              :         size_t transport_header_size;
     167              : 
     168            1 :         spdm_response_size = sizeof(spdm_error_response_t);
     169            1 :         transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
     170            1 :         spdm_response = (void *)((uint8_t *)*response + transport_header_size);
     171              : 
     172            1 :         spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
     173            1 :         spdm_response->header.request_response_code = SPDM_ERROR;
     174            1 :         spdm_response->header.param1 = SPDM_ERROR_CODE_INVALID_REQUEST;
     175            1 :         spdm_response->header.param2 = 0;
     176              : 
     177            1 :         libspdm_transport_test_encode_message(spdm_context, NULL, false,
     178              :                                               false, spdm_response_size,
     179              :                                               spdm_response,
     180              :                                               response_size, response);
     181              :     }
     182            1 :         return LIBSPDM_STATUS_SUCCESS;
     183              : 
     184            1 :     case 0x5: {
     185              :         spdm_error_response_t *spdm_response;
     186              :         size_t spdm_response_size;
     187              :         size_t transport_header_size;
     188              : 
     189            1 :         spdm_response_size = sizeof(spdm_error_response_t);
     190            1 :         transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
     191            1 :         spdm_response = (void *)((uint8_t *)*response + transport_header_size);
     192              : 
     193            1 :         spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
     194            1 :         spdm_response->header.request_response_code = SPDM_ERROR;
     195            1 :         spdm_response->header.param1 = SPDM_ERROR_CODE_BUSY;
     196            1 :         spdm_response->header.param2 = 0;
     197              : 
     198            1 :         libspdm_transport_test_encode_message(spdm_context, NULL, false,
     199              :                                               false, spdm_response_size,
     200              :                                               spdm_response,
     201              :                                               response_size, response);
     202              :     }
     203            1 :         return LIBSPDM_STATUS_SUCCESS;
     204              : 
     205            0 :     case 0x6: {
     206              :         static size_t sub_index1 = 0;
     207            0 :         if (sub_index1 == 0) {
     208              :             spdm_error_response_t *spdm_response;
     209              :             size_t spdm_response_size;
     210              :             size_t transport_header_size;
     211              : 
     212            0 :             spdm_response_size = sizeof(spdm_error_response_t);
     213            0 :             transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
     214            0 :             spdm_response = (void *)((uint8_t *)*response + transport_header_size);
     215              : 
     216            0 :             spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
     217            0 :             spdm_response->header.request_response_code = SPDM_ERROR;
     218            0 :             spdm_response->header.param1 = SPDM_ERROR_CODE_BUSY;
     219            0 :             spdm_response->header.param2 = 0;
     220              : 
     221            0 :             libspdm_transport_test_encode_message(
     222              :                 spdm_context, NULL, false, false,
     223              :                 spdm_response_size, spdm_response,
     224              :                 response_size, response);
     225            0 :         } else if (sub_index1 == 1) {
     226              :             spdm_digest_response_t *spdm_response;
     227              :             uint8_t *digest;
     228              :             size_t spdm_response_size;
     229              :             size_t transport_header_size;
     230              : 
     231              :             ((libspdm_context_t *)spdm_context)
     232            0 :             ->connection_info.algorithm.base_hash_algo =
     233              :                 m_libspdm_use_hash_algo;
     234            0 :             spdm_response_size = sizeof(spdm_digest_response_t) +
     235            0 :                                  libspdm_get_hash_size(m_libspdm_use_hash_algo);
     236            0 :             transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
     237            0 :             spdm_response = (void *)((uint8_t *)*response + transport_header_size);
     238              : 
     239            0 :             spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
     240            0 :             spdm_response->header.param1 = 0;
     241            0 :             spdm_response->header.request_response_code = SPDM_DIGESTS;
     242            0 :             spdm_response->header.param2 = 0;
     243            0 :             libspdm_set_mem(m_libspdm_local_certificate_chain,
     244              :                             sizeof(m_libspdm_local_certificate_chain), (uint8_t)(0xFF));
     245              : 
     246            0 :             digest = (void *)(spdm_response + 1);
     247            0 :             libspdm_hash_all(m_libspdm_use_hash_algo,
     248              :                              m_libspdm_local_certificate_chain,
     249              :                              sizeof(m_libspdm_local_certificate_chain), &digest[0]);
     250            0 :             spdm_response->header.param2 |= (1 << 0);
     251              : 
     252            0 :             libspdm_transport_test_encode_message(
     253              :                 spdm_context, NULL, false, false, spdm_response_size,
     254              :                 spdm_response, response_size, response);
     255              :         }
     256            0 :         sub_index1++;
     257              :     }
     258            0 :         return LIBSPDM_STATUS_SUCCESS;
     259              : 
     260            1 :     case 0x7: {
     261              :         spdm_error_response_t *spdm_response;
     262              :         size_t spdm_response_size;
     263              :         size_t transport_header_size;
     264              : 
     265            1 :         spdm_response_size = sizeof(spdm_error_response_t);
     266            1 :         transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
     267            1 :         spdm_response = (void *)((uint8_t *)*response + transport_header_size);
     268              : 
     269            1 :         spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
     270            1 :         spdm_response->header.request_response_code = SPDM_ERROR;
     271            1 :         spdm_response->header.param1 = SPDM_ERROR_CODE_REQUEST_RESYNCH;
     272            1 :         spdm_response->header.param2 = 0;
     273              : 
     274            1 :         libspdm_transport_test_encode_message(spdm_context, NULL, false,
     275              :                                               false, spdm_response_size,
     276              :                                               spdm_response,
     277              :                                               response_size, response);
     278              :     }
     279            1 :         return LIBSPDM_STATUS_SUCCESS;
     280              : 
     281            2 :     case 0x8: {
     282              :         spdm_error_response_data_response_not_ready_t *spdm_response;
     283              :         size_t spdm_response_size;
     284              :         size_t transport_header_size;
     285              : 
     286            2 :         spdm_response_size = sizeof(spdm_error_response_data_response_not_ready_t);
     287            2 :         transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
     288            2 :         spdm_response = (void *)((uint8_t *)*response + transport_header_size);
     289              : 
     290            2 :         spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
     291            2 :         spdm_response->header.request_response_code = SPDM_ERROR;
     292            2 :         spdm_response->header.param1 = SPDM_ERROR_CODE_RESPONSE_NOT_READY;
     293            2 :         spdm_response->header.param2 = 0;
     294            2 :         spdm_response->extend_error_data.rd_exponent = 1;
     295            2 :         spdm_response->extend_error_data.rd_tm = 2;
     296            2 :         spdm_response->extend_error_data.request_code = SPDM_GET_DIGESTS;
     297            2 :         spdm_response->extend_error_data.token = 0;
     298              : 
     299            2 :         libspdm_transport_test_encode_message(spdm_context, NULL, false,
     300              :                                               false, spdm_response_size,
     301              :                                               spdm_response,
     302              :                                               response_size, response);
     303              :     }
     304            2 :         return LIBSPDM_STATUS_SUCCESS;
     305              : 
     306            1 :     case 0x9: {
     307              :         spdm_digest_response_t *spdm_response;
     308              :         uint8_t *digest;
     309              :         size_t spdm_response_size;
     310              :         size_t transport_header_size;
     311              : 
     312            1 :         ((libspdm_context_t *)spdm_context)->connection_info.algorithm.base_hash_algo =
     313              :             m_libspdm_use_hash_algo;
     314            1 :         spdm_response_size = sizeof(spdm_digest_response_t) +
     315            1 :                              libspdm_get_hash_size(m_libspdm_use_hash_algo);
     316            1 :         transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
     317            1 :         spdm_response = (void *)((uint8_t *)*response + transport_header_size);
     318              : 
     319            1 :         spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_11;
     320            1 :         spdm_response->header.param1 = 0;
     321            1 :         spdm_response->header.request_response_code = SPDM_DIGESTS;
     322            1 :         spdm_response->header.param2 = 0;
     323            1 :         libspdm_set_mem(m_libspdm_local_certificate_chain,
     324              :                         sizeof(m_libspdm_local_certificate_chain),
     325              :                         (uint8_t)(0xFF));
     326              : 
     327            1 :         digest = (void *)(spdm_response + 1);
     328            1 :         libspdm_zero_mem (digest,
     329            1 :                           libspdm_get_hash_size(m_libspdm_use_hash_algo) * SPDM_MAX_SLOT_COUNT);
     330            1 :         libspdm_hash_all(m_libspdm_use_hash_algo, m_libspdm_local_certificate_chain,
     331              :                          sizeof(m_libspdm_local_certificate_chain), &digest[0]);
     332            1 :         spdm_response->header.param2 |= (0x01 << 0);
     333              : 
     334            1 :         libspdm_transport_test_encode_message(spdm_context, NULL, false,
     335              :                                               false, spdm_response_size,
     336              :                                               spdm_response, response_size,
     337              :                                               response);
     338              :     }
     339            1 :         return LIBSPDM_STATUS_SUCCESS;
     340              : 
     341            0 :     case 0xA:
     342            0 :         return LIBSPDM_STATUS_SUCCESS;
     343              : 
     344            1 :     case 0xB:
     345            1 :         return LIBSPDM_STATUS_RECEIVE_FAIL;
     346              : 
     347            0 :     case 0xC: {
     348              :         spdm_digest_response_t *spdm_response;
     349              :         size_t spdm_response_size;
     350              :         size_t transport_header_size;
     351              : 
     352              :         ((libspdm_context_t *)spdm_context)
     353            0 :         ->connection_info.algorithm.base_hash_algo =
     354              :             m_libspdm_use_hash_algo;
     355            0 :         spdm_response_size = 2;
     356            0 :         transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
     357            0 :         spdm_response = (void *)((uint8_t *)*response + transport_header_size);
     358              : 
     359            0 :         spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
     360            0 :         spdm_response->header.param1 = 0;
     361            0 :         spdm_response->header.request_response_code = SPDM_DIGESTS;
     362            0 :         spdm_response->header.param2 = 0;
     363              : 
     364            0 :         libspdm_transport_test_encode_message(spdm_context, NULL, false,
     365              :                                               false, spdm_response_size,
     366              :                                               spdm_response, response_size,
     367              :                                               response);
     368              :     }
     369            0 :         return LIBSPDM_STATUS_SUCCESS;
     370              : 
     371            1 :     case 0xD: {
     372              :         spdm_digest_response_t *spdm_response;
     373              :         uint8_t *digest;
     374              :         size_t spdm_response_size;
     375              :         size_t transport_header_size;
     376              : 
     377              :         ((libspdm_context_t *)spdm_context)
     378            1 :         ->connection_info.algorithm.base_hash_algo =
     379              :             m_libspdm_use_hash_algo;
     380            1 :         spdm_response_size = sizeof(spdm_digest_response_t) +
     381            1 :                              libspdm_get_hash_size(m_libspdm_use_hash_algo);
     382            1 :         transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
     383            1 :         spdm_response = (void *)((uint8_t *)*response + transport_header_size);
     384              : 
     385            1 :         spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
     386            1 :         spdm_response->header.param1 = 0;
     387            1 :         spdm_response->header.request_response_code = SPDM_CERTIFICATE;
     388            1 :         spdm_response->header.param2 = 0;
     389            1 :         libspdm_set_mem(m_libspdm_local_certificate_chain,
     390              :                         sizeof(m_libspdm_local_certificate_chain),
     391              :                         (uint8_t)(0xFF));
     392              : 
     393            1 :         digest = (void *)(spdm_response + 1);
     394            1 :         libspdm_hash_all(m_libspdm_use_hash_algo, m_libspdm_local_certificate_chain,
     395              :                          sizeof(m_libspdm_local_certificate_chain), &digest[0]);
     396            1 :         spdm_response->header.param2 |= (1 << 0);
     397              : 
     398            1 :         libspdm_transport_test_encode_message(spdm_context, NULL, false,
     399              :                                               false, spdm_response_size,
     400              :                                               spdm_response, response_size,
     401              :                                               response);
     402              :     }
     403            1 :         return LIBSPDM_STATUS_SUCCESS;
     404              : 
     405            1 :     case 0xE: {
     406              :         spdm_digest_response_t *spdm_response;
     407              :         size_t spdm_response_size;
     408              :         size_t transport_header_size;
     409              : 
     410            1 :         spdm_response_size = sizeof(spdm_digest_response_t);
     411            1 :         transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
     412            1 :         spdm_response = (void *)((uint8_t *)*response + transport_header_size);
     413              : 
     414            1 :         spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
     415            1 :         spdm_response->header.param1 = 0;
     416            1 :         spdm_response->header.request_response_code = SPDM_DIGESTS;
     417            1 :         spdm_response->header.param2 = 0;
     418              : 
     419            1 :         libspdm_transport_test_encode_message(spdm_context, NULL, false,
     420              :                                               false, spdm_response_size,
     421              :                                               spdm_response,
     422              :                                               response_size, response);
     423              :     }
     424            1 :         return LIBSPDM_STATUS_SUCCESS;
     425              : 
     426            0 :     case 0xF:
     427            0 :         return LIBSPDM_STATUS_SUCCESS;
     428              : 
     429            0 :     case 0x10: {
     430              :         spdm_digest_response_t *spdm_response;
     431              :         uint8_t *digest;
     432              :         size_t spdm_response_size;
     433              :         size_t transport_header_size;
     434              : 
     435              : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
     436              :         ((libspdm_context_t *)spdm_context)->transcript.message_b.buffer_size =
     437              :             ((libspdm_context_t *)spdm_context)->transcript.message_b.max_buffer_size -
     438              :             (sizeof(spdm_digest_response_t));
     439              : #endif
     440              : 
     441              :         ((libspdm_context_t *)spdm_context)
     442            0 :         ->connection_info.algorithm.base_hash_algo =
     443              :             m_libspdm_use_hash_algo;
     444            0 :         spdm_response_size = sizeof(spdm_digest_response_t) +
     445            0 :                              libspdm_get_hash_size(m_libspdm_use_hash_algo);
     446            0 :         transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
     447            0 :         spdm_response = (void *)((uint8_t *)*response + transport_header_size);
     448              : 
     449            0 :         spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
     450            0 :         spdm_response->header.param1 = 0;
     451            0 :         spdm_response->header.request_response_code = SPDM_DIGESTS;
     452            0 :         spdm_response->header.param2 = 0;
     453            0 :         libspdm_set_mem(m_libspdm_local_certificate_chain,
     454              :                         sizeof(m_libspdm_local_certificate_chain),
     455              :                         (uint8_t)(0xFF));
     456              : 
     457            0 :         digest = (void *)(spdm_response + 1);
     458            0 :         libspdm_hash_all(m_libspdm_use_hash_algo, m_libspdm_local_certificate_chain,
     459              :                          sizeof(m_libspdm_local_certificate_chain), &digest[0]);
     460            0 :         spdm_response->header.param2 |= (1 << 0);
     461              : 
     462            0 :         libspdm_transport_test_encode_message(spdm_context, NULL, false,
     463              :                                               false, spdm_response_size,
     464              :                                               spdm_response, response_size,
     465              :                                               response);
     466              :     }
     467            0 :         return LIBSPDM_STATUS_SUCCESS;
     468              : 
     469            0 :     case 0x11:
     470            0 :         return LIBSPDM_STATUS_SUCCESS;
     471              : 
     472            1 :     case 0x12: {
     473              :         spdm_digest_response_t *spdm_response;
     474              :         uint8_t *digest;
     475              :         size_t digest_count;
     476              :         size_t spdm_response_size;
     477              :         size_t transport_header_size;
     478              :         size_t index;
     479              : 
     480              :         ((libspdm_context_t *)spdm_context)
     481            1 :         ->connection_info.algorithm.base_hash_algo =
     482              :             m_libspdm_use_hash_algo;
     483            1 :         digest_count = 4;
     484            1 :         spdm_response_size = sizeof(spdm_digest_response_t) +
     485            1 :                              libspdm_get_hash_size(m_libspdm_use_hash_algo);
     486            1 :         transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
     487            1 :         spdm_response = (void *)((uint8_t *)*response + transport_header_size);
     488              : 
     489            1 :         spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
     490            1 :         spdm_response->header.param1 = 0;
     491            1 :         spdm_response->header.request_response_code = SPDM_DIGESTS;
     492            1 :         spdm_response->header.param2 = 0;
     493            1 :         libspdm_set_mem(m_libspdm_local_certificate_chain,
     494              :                         sizeof(m_libspdm_local_certificate_chain),
     495              :                         (uint8_t)(0xFF));
     496              : 
     497            1 :         digest = (void *)(spdm_response + 1);
     498              : 
     499            1 :         libspdm_hash_all(m_libspdm_use_hash_algo, m_libspdm_local_certificate_chain,
     500              :                          sizeof(m_libspdm_local_certificate_chain), &digest[0]);
     501            5 :         for (index = 0; index < digest_count; index++) {
     502            4 :             spdm_response->header.param2 |= (1 << index);
     503              :         }
     504              : 
     505            1 :         libspdm_transport_test_encode_message(spdm_context, NULL, false,
     506              :                                               false, spdm_response_size,
     507              :                                               spdm_response, response_size,
     508              :                                               response);
     509              :     }
     510            1 :         return LIBSPDM_STATUS_SUCCESS;
     511              : 
     512            0 :     case 0x13: {
     513              :         spdm_digest_response_t *spdm_response;
     514              :         uint8_t *digest;
     515              :         size_t digest_count;
     516              :         size_t spdm_response_size;
     517              :         size_t transport_header_size;
     518              :         size_t index;
     519              : 
     520              :         ((libspdm_context_t *)spdm_context)
     521            0 :         ->connection_info.algorithm.base_hash_algo =
     522              :             m_libspdm_use_hash_algo;
     523            0 :         digest_count = 4;
     524            0 :         spdm_response_size =
     525              :             sizeof(spdm_digest_response_t) +
     526            0 :             digest_count * libspdm_get_hash_size(m_libspdm_use_hash_algo);
     527            0 :         transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
     528            0 :         spdm_response = (void *)((uint8_t *)*response + transport_header_size);
     529              : 
     530            0 :         spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
     531            0 :         spdm_response->header.param1 = 0;
     532            0 :         spdm_response->header.request_response_code = SPDM_DIGESTS;
     533            0 :         spdm_response->header.param2 = 0;
     534            0 :         libspdm_set_mem(m_libspdm_local_certificate_chain,
     535              :                         sizeof(m_libspdm_local_certificate_chain),
     536              :                         (uint8_t)(0xFF));
     537              : 
     538            0 :         digest = (void *)(spdm_response + 1);
     539              : 
     540            0 :         for (index = 0; index < digest_count; index++) {
     541            0 :             libspdm_hash_all(
     542              :                 m_libspdm_use_hash_algo, m_libspdm_local_certificate_chain,
     543              :                 sizeof(m_libspdm_local_certificate_chain),
     544            0 :                 &digest[index *
     545            0 :                         libspdm_get_hash_size(m_libspdm_use_hash_algo)]);
     546            0 :             spdm_response->header.param2 |= (1 << index);
     547            0 :             if (index == 0) {
     548            0 :                 continue;
     549              :             }
     550            0 :             digest[(index + 1) * libspdm_get_hash_size(m_libspdm_use_hash_algo) -
     551            0 :                    1] = 0;
     552              :         }
     553              : 
     554            0 :         libspdm_transport_test_encode_message(spdm_context, NULL, false,
     555              :                                               false, spdm_response_size,
     556              :                                               spdm_response, response_size,
     557              :                                               response);
     558              :     }
     559            0 :         return LIBSPDM_STATUS_SUCCESS;
     560              : 
     561            0 :     case 0x14: {
     562              :         spdm_digest_response_t *spdm_response;
     563              :         size_t spdm_response_size;
     564              :         size_t transport_header_size;
     565              : 
     566            0 :         ((libspdm_context_t *)spdm_context)->connection_info.algorithm.base_hash_algo =
     567              :             m_libspdm_use_hash_algo;
     568            0 :         spdm_response_size = 5;
     569            0 :         transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
     570            0 :         spdm_response = (void *)((uint8_t *)*response + transport_header_size);
     571              : 
     572            0 :         spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
     573            0 :         spdm_response->header.param1 = 0;
     574            0 :         spdm_response->header.request_response_code = SPDM_DIGESTS;
     575            0 :         spdm_response->header.param2 = 0;
     576              : 
     577            0 :         libspdm_transport_test_encode_message(spdm_context, NULL, false,
     578              :                                               false, spdm_response_size,
     579              :                                               spdm_response, response_size,
     580              :                                               response);
     581              :     }
     582            0 :         return LIBSPDM_STATUS_SUCCESS;
     583              : 
     584            0 :     case 0x15: {
     585              :         spdm_digest_response_t *spdm_response;
     586              :         uint8_t *digest;
     587              :         size_t spdm_response_size;
     588              :         size_t transport_header_size;
     589              : 
     590              :         ((libspdm_context_t *)spdm_context)
     591            0 :         ->connection_info.algorithm.base_hash_algo =
     592              :             m_libspdm_use_hash_algo;
     593            0 :         spdm_response_size = sizeof(spdm_message_header_t) +
     594              :                              LIBSPDM_MAX_HASH_SIZE * SPDM_MAX_SLOT_COUNT + 1;
     595            0 :         transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
     596            0 :         spdm_response = (void *)((uint8_t *)*response + transport_header_size);
     597              : 
     598            0 :         spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
     599            0 :         spdm_response->header.param1 = 0;
     600            0 :         spdm_response->header.request_response_code = SPDM_DIGESTS;
     601            0 :         spdm_response->header.param2 = 0;
     602            0 :         libspdm_set_mem(m_libspdm_local_certificate_chain,
     603              :                         sizeof(m_libspdm_local_certificate_chain),
     604              :                         (uint8_t)(0xFF));
     605              : 
     606            0 :         digest = (void *)(spdm_response + 1);
     607            0 :         libspdm_hash_all(m_libspdm_use_hash_algo, m_libspdm_local_certificate_chain,
     608              :                          sizeof(m_libspdm_local_certificate_chain), &digest[0]);
     609            0 :         spdm_response->header.param2 |= (1 << 0);
     610              : 
     611            0 :         libspdm_transport_test_encode_message(spdm_context, NULL, false,
     612              :                                               false, spdm_response_size,
     613              :                                               spdm_response, response_size,
     614              :                                               response);
     615              :     }
     616            0 :         return LIBSPDM_STATUS_SUCCESS;
     617              : 
     618           18 :     case 0x16:
     619              :     {
     620              :         static uint16_t error_code = LIBSPDM_ERROR_CODE_RESERVED_00;
     621              : 
     622              :         spdm_error_response_t *spdm_response;
     623              :         size_t spdm_response_size;
     624              :         size_t transport_header_size;
     625              : 
     626           18 :         spdm_response_size = sizeof(spdm_error_response_t);
     627           18 :         transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
     628           18 :         spdm_response = (void *)((uint8_t *)*response + transport_header_size);
     629              : 
     630           18 :         if(error_code <= 0xff) {
     631           18 :             libspdm_zero_mem (spdm_response, spdm_response_size);
     632           18 :             spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_11;
     633           18 :             spdm_response->header.request_response_code = SPDM_ERROR;
     634           18 :             spdm_response->header.param1 = (uint8_t) error_code;
     635           18 :             spdm_response->header.param2 = 0;
     636              : 
     637           18 :             libspdm_transport_test_encode_message (spdm_context, NULL, false, false,
     638              :                                                    spdm_response_size, spdm_response,
     639              :                                                    response_size, response);
     640              :         }
     641              : 
     642           18 :         error_code++;
     643           18 :         if(error_code == SPDM_ERROR_CODE_BUSY) { /*busy is treated in cases 5 and 6*/
     644            1 :             error_code = SPDM_ERROR_CODE_UNEXPECTED_REQUEST;
     645              :         }
     646           18 :         if(error_code == LIBSPDM_ERROR_CODE_RESERVED_0D) { /*skip some reserved error codes (0d to 3e)*/
     647            1 :             error_code = LIBSPDM_ERROR_CODE_RESERVED_3F;
     648              :         }
     649           18 :         if(error_code == SPDM_ERROR_CODE_RESPONSE_NOT_READY) { /*skip response not ready, request resync, and some reserved codes (44 to fc)*/
     650            1 :             error_code = LIBSPDM_ERROR_CODE_RESERVED_FD;
     651              :         }
     652              :     }
     653           18 :         return LIBSPDM_STATUS_SUCCESS;
     654              : 
     655            1 :     case 0x17: {
     656              :         spdm_digest_response_t *spdm_response;
     657              :         uint8_t *digest;
     658              :         size_t spdm_response_size;
     659              :         size_t transport_header_size;
     660              :         uint32_t hash_size;
     661              :         uint8_t slot_count;
     662              : 
     663            1 :         slot_count = 2;
     664              : 
     665            1 :         hash_size = libspdm_get_hash_size(m_libspdm_use_hash_algo);
     666              : 
     667            1 :         spdm_response_size = sizeof(spdm_digest_response_t) + (hash_size * slot_count);
     668            1 :         transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
     669            1 :         spdm_response = (void *)((uint8_t *)*response + transport_header_size);
     670              : 
     671            1 :         spdm_response->header.request_response_code = SPDM_DIGESTS;
     672            1 :         spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_13;
     673            1 :         spdm_response->header.param1 = 0x01;
     674              :         /* Illegal value. Bit cannot be set unless also set in param1. */
     675            1 :         spdm_response->header.param2 = 0x03;
     676              : 
     677            1 :         libspdm_set_mem(m_libspdm_local_certificate_chain,
     678              :                         sizeof(m_libspdm_local_certificate_chain),
     679              :                         (uint8_t)(0xFF));
     680              : 
     681            1 :         digest = (void *)(spdm_response + 1);
     682            1 :         libspdm_zero_mem (digest, hash_size * slot_count);
     683              : 
     684            1 :         libspdm_hash_all(m_libspdm_use_hash_algo, m_libspdm_local_certificate_chain,
     685              :                          sizeof(m_libspdm_local_certificate_chain), &digest[hash_size * 0]);
     686            1 :         libspdm_hash_all(m_libspdm_use_hash_algo, m_libspdm_local_certificate_chain,
     687            1 :                          sizeof(m_libspdm_local_certificate_chain), &digest[hash_size * 1]);
     688              : 
     689            1 :         libspdm_transport_test_encode_message(spdm_context, NULL, false,
     690              :                                               false, spdm_response_size,
     691              :                                               spdm_response, response_size,
     692              :                                               response);
     693              :     }
     694            1 :         return LIBSPDM_STATUS_SUCCESS;
     695              : 
     696            0 :     case 0x18: {
     697            0 :         if (m_get_digest) {
     698              :             spdm_digest_response_t *spdm_response;
     699              :             uint8_t *digest;
     700              :             size_t spdm_response_size;
     701              :             size_t transport_header_size;
     702              : 
     703              :             ((libspdm_context_t *)spdm_context)
     704            0 :             ->connection_info.algorithm.base_hash_algo =
     705              :                 m_libspdm_use_hash_algo;
     706            0 :             spdm_response_size = sizeof(spdm_digest_response_t) +
     707            0 :                                  libspdm_get_hash_size(m_libspdm_use_hash_algo);
     708            0 :             transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
     709            0 :             spdm_response = (void *)((uint8_t *)*response + transport_header_size);
     710              : 
     711            0 :             spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
     712            0 :             spdm_response->header.param1 = 0;
     713            0 :             spdm_response->header.request_response_code = SPDM_DIGESTS;
     714            0 :             spdm_response->header.param2 = 0;
     715            0 :             libspdm_set_mem(m_libspdm_local_certificate_chain,
     716              :                             sizeof(m_libspdm_local_certificate_chain),
     717              :                             (uint8_t)(0xFF));
     718              : 
     719            0 :             digest = (void *)(spdm_response + 1);
     720            0 :             libspdm_zero_mem (digest,
     721            0 :                               libspdm_get_hash_size(m_libspdm_use_hash_algo) * SPDM_MAX_SLOT_COUNT);
     722            0 :             libspdm_hash_all(m_libspdm_use_hash_algo, m_libspdm_local_certificate_chain,
     723              :                              sizeof(m_libspdm_local_certificate_chain), &digest[0]);
     724            0 :             spdm_response->header.param2 |= (0x01 << 0);
     725              : 
     726            0 :             libspdm_transport_test_encode_message(spdm_context, NULL, false,
     727              :                                                   false, spdm_response_size,
     728              :                                                   spdm_response, response_size,
     729              :                                                   response);
     730              :         } else {
     731              :             spdm_certificate_response_t *spdm_response;
     732              :             size_t spdm_response_size;
     733              :             size_t transport_header_size;
     734              :             uint16_t portion_length;
     735              :             uint16_t remainder_length;
     736              :             size_t count;
     737              :             static size_t calling_index = 0;
     738              : 
     739            0 :             if (m_libspdm_local_certificate_chain_test_cert == NULL) {
     740            0 :                 libspdm_read_responder_public_certificate_chain(
     741              :                     m_libspdm_use_hash_algo, m_libspdm_use_asym_algo,
     742              :                     &m_libspdm_local_certificate_chain_test_cert,
     743              :                     &m_libspdm_local_certificate_chain_size, NULL, NULL);
     744              :             }
     745            0 :             if (m_libspdm_local_certificate_chain_test_cert == NULL) {
     746            0 :                 return LIBSPDM_STATUS_RECEIVE_FAIL;
     747              :             }
     748            0 :             count = (m_libspdm_local_certificate_chain_size +
     749            0 :                      LIBSPDM_MAX_CERT_CHAIN_BLOCK_LEN - 1) /
     750              :                     LIBSPDM_MAX_CERT_CHAIN_BLOCK_LEN;
     751            0 :             if (calling_index != count - 1) {
     752            0 :                 portion_length = LIBSPDM_MAX_CERT_CHAIN_BLOCK_LEN;
     753            0 :                 remainder_length =
     754            0 :                     (uint16_t)(m_libspdm_local_certificate_chain_size -
     755              :                                LIBSPDM_MAX_CERT_CHAIN_BLOCK_LEN *
     756            0 :                                (calling_index + 1));
     757              :             } else {
     758            0 :                 portion_length = (uint16_t)(
     759              :                     m_libspdm_local_certificate_chain_size -
     760            0 :                     LIBSPDM_MAX_CERT_CHAIN_BLOCK_LEN * (count - 1));
     761            0 :                 remainder_length = 0;
     762              :             }
     763              : 
     764            0 :             spdm_response_size =
     765            0 :                 sizeof(spdm_certificate_response_t) + portion_length;
     766            0 :             transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
     767            0 :             spdm_response = (void *)((uint8_t *)*response + transport_header_size);
     768              : 
     769            0 :             spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
     770            0 :             spdm_response->header.request_response_code = SPDM_CERTIFICATE;
     771            0 :             spdm_response->header.param1 = 0;
     772            0 :             spdm_response->header.param2 = 0;
     773            0 :             spdm_response->portion_length = portion_length;
     774            0 :             spdm_response->remainder_length = remainder_length;
     775            0 :             libspdm_copy_mem(spdm_response + 1,
     776            0 :                              (size_t)(*response) + *response_size - (size_t)(spdm_response + 1),
     777            0 :                              (uint8_t *)m_libspdm_local_certificate_chain_test_cert +
     778            0 :                              LIBSPDM_MAX_CERT_CHAIN_BLOCK_LEN * calling_index,
     779              :                              portion_length);
     780              : 
     781            0 :             libspdm_transport_test_encode_message(spdm_context, NULL, false,
     782              :                                                   false, spdm_response_size,
     783              :                                                   spdm_response, response_size,
     784              :                                                   response);
     785              : 
     786            0 :             calling_index++;
     787            0 :             if (calling_index == count) {
     788            0 :                 calling_index = 0;
     789            0 :                 free(m_libspdm_local_certificate_chain_test_cert);
     790            0 :                 m_libspdm_local_certificate_chain_test_cert = NULL;
     791            0 :                 m_libspdm_local_certificate_chain_size = 0;
     792              :             }
     793              :         }
     794              :     }
     795            0 :         return LIBSPDM_STATUS_SUCCESS;
     796              : 
     797            0 :     case 0x19: {
     798              :         spdm_digest_response_t *spdm_response;
     799              :         uint8_t *digest;
     800              :         size_t spdm_response_size;
     801              :         size_t transport_header_size;
     802              :         uint32_t session_id;
     803              :         libspdm_session_info_t *session_info;
     804              :         uint8_t *scratch_buffer;
     805              :         size_t scratch_buffer_size;
     806              : 
     807            0 :         session_id = 0xFFFFFFFF;
     808              : 
     809              :         ((libspdm_context_t *)spdm_context)
     810            0 :         ->connection_info.algorithm.base_hash_algo =
     811              :             m_libspdm_use_hash_algo;
     812            0 :         spdm_response_size = sizeof(spdm_digest_response_t) +
     813            0 :                              libspdm_get_hash_size(m_libspdm_use_hash_algo);
     814            0 :         transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
     815            0 :         spdm_response = (void *)((uint8_t *)*response + transport_header_size);
     816              : 
     817            0 :         spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
     818            0 :         spdm_response->header.param1 = 0;
     819            0 :         spdm_response->header.request_response_code = SPDM_DIGESTS;
     820            0 :         spdm_response->header.param2 = 0;
     821              : 
     822              :         /* For secure message, message is in sender buffer, we need copy it to scratch buffer.
     823              :          * transport_message is always in sender buffer. */
     824            0 :         libspdm_get_scratch_buffer (spdm_context, (void **)&scratch_buffer, &scratch_buffer_size);
     825              : 
     826            0 :         libspdm_set_mem(m_libspdm_local_certificate_chain,
     827              :                         sizeof(m_libspdm_local_certificate_chain),
     828              :                         (uint8_t)(0xFF));
     829              : 
     830            0 :         digest = (void *)(spdm_response + 1);
     831            0 :         libspdm_zero_mem (digest,
     832            0 :                           libspdm_get_hash_size(m_libspdm_use_hash_algo) * SPDM_MAX_SLOT_COUNT);
     833            0 :         libspdm_hash_all(m_libspdm_use_hash_algo, m_libspdm_local_certificate_chain,
     834              :                          sizeof(m_libspdm_local_certificate_chain), &digest[0]);
     835            0 :         spdm_response->header.param2 |= (0x01 << 0);
     836              : 
     837            0 :         libspdm_copy_mem (scratch_buffer + transport_header_size,
     838              :                           scratch_buffer_size - transport_header_size,
     839              :                           spdm_response, spdm_response_size);
     840            0 :         spdm_response = (void *)(scratch_buffer + transport_header_size);
     841            0 :         libspdm_transport_test_encode_message(spdm_context, &session_id, false,
     842              :                                               false, spdm_response_size,
     843              :                                               spdm_response, response_size,
     844              :                                               response);
     845              : 
     846            0 :         session_info = libspdm_get_session_info_via_session_id(
     847              :             spdm_context, session_id);
     848            0 :         if (session_info == NULL) {
     849            0 :             return LIBSPDM_STATUS_RECEIVE_FAIL;
     850              :         }
     851              :         /* WALKAROUND: If just use single context to encode message and then decode message */
     852              :         ((libspdm_secured_message_context_t
     853            0 :           *)(session_info->secured_message_context))
     854            0 :         ->application_secret.response_data_sequence_number--;
     855              : 
     856              :     }
     857            0 :         return LIBSPDM_STATUS_SUCCESS;
     858              : 
     859            0 :     default:
     860            0 :         return LIBSPDM_STATUS_RECEIVE_FAIL;
     861              :     }
     862              : }
     863              : 
     864              : /**
     865              :  * Test 1: a failure occurs during the sending of the request message
     866              :  * Expected Behavior: requester returns the status LIBSPDM_STATUS_SEND_FAIL, with no DIGESTS message received
     867              :  **/
     868            1 : static void libspdm_test_requester_get_digests_err_case1(void **state)
     869              : {
     870              :     libspdm_return_t status;
     871              :     libspdm_test_context_t *spdm_test_context;
     872              :     libspdm_context_t *spdm_context;
     873              :     uint8_t slot_mask;
     874              :     uint8_t total_digest_buffer[LIBSPDM_MAX_HASH_SIZE * SPDM_MAX_SLOT_COUNT];
     875              : 
     876            1 :     spdm_test_context = *state;
     877            1 :     spdm_context = spdm_test_context->spdm_context;
     878            1 :     spdm_test_context->case_id = 0x1;
     879            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_10 <<
     880              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
     881            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_NEGOTIATED;
     882            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_CAP;
     883            1 :     spdm_context->connection_info.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
     884            1 :     libspdm_set_mem(m_libspdm_local_certificate_chain,
     885              :                     sizeof(m_libspdm_local_certificate_chain),
     886              :                     (uint8_t)(0xFF));
     887            1 :     libspdm_reset_message_b(spdm_context);
     888              : 
     889            1 :     libspdm_zero_mem(total_digest_buffer, sizeof(total_digest_buffer));
     890            1 :     status = libspdm_get_digest(spdm_context, NULL, &slot_mask, &total_digest_buffer);
     891            1 :     assert_int_equal(status, LIBSPDM_STATUS_SEND_FAIL);
     892              : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
     893              :     assert_int_equal(spdm_context->transcript.message_b.buffer_size, 0);
     894              : #endif
     895            1 : }
     896              : 
     897              : /**
     898              :  * Test 2: Requester is unable to acquire the sender buffer.
     899              :  * Expected Behavior: returns with error LIBSPDM_STATUS_ACQUIRE_FAIL.
     900              :  **/
     901            1 : static void libspdm_test_requester_get_digests_err_case2(void **state)
     902              : {
     903              :     libspdm_return_t status;
     904              :     libspdm_test_context_t *spdm_test_context;
     905              :     libspdm_context_t *spdm_context;
     906              :     uint8_t slot_mask;
     907              :     uint8_t total_digest_buffer[LIBSPDM_MAX_HASH_SIZE * SPDM_MAX_SLOT_COUNT];
     908              : 
     909            1 :     spdm_test_context = *state;
     910            1 :     spdm_context = spdm_test_context->spdm_context;
     911            1 :     spdm_test_context->case_id = 0x2;
     912            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_10 <<
     913              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
     914            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_NEGOTIATED;
     915            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_CAP;
     916            1 :     spdm_context->connection_info.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
     917            1 :     libspdm_set_mem(m_libspdm_local_certificate_chain,
     918              :                     sizeof(m_libspdm_local_certificate_chain),
     919              :                     (uint8_t)(0xFF));
     920            1 :     libspdm_reset_message_b(spdm_context);
     921              : 
     922            1 :     libspdm_zero_mem(total_digest_buffer, sizeof(total_digest_buffer));
     923              : 
     924            1 :     libspdm_force_error(LIBSPDM_ERR_ACQUIRE_SENDER_BUFFER);
     925            1 :     status = libspdm_get_digest(spdm_context, NULL, &slot_mask, &total_digest_buffer);
     926            1 :     libspdm_release_error(LIBSPDM_ERR_ACQUIRE_SENDER_BUFFER);
     927              : 
     928            1 :     assert_int_equal(status, LIBSPDM_STATUS_ACQUIRE_FAIL);
     929            1 : }
     930              : 
     931              : /**
     932              :  * Test 3: connection_state equals to zero and makes the check fail, meaning that steps
     933              :  * GET_CAPABILITIES-CAPABILITIES and NEGOTIATE_ALGORITHMS-ALGORITHMS of the protocol were not previously completed
     934              :  * Expected Behavior: requester returns the status LIBSPDM_STATUS_INVALID_STATE_LOCAL, with no DIGESTS message received
     935              :  **/
     936            1 : static void libspdm_test_requester_get_digests_err_case3(void **state)
     937              : {
     938              :     libspdm_return_t status;
     939              :     libspdm_test_context_t *spdm_test_context;
     940              :     libspdm_context_t *spdm_context;
     941              :     uint8_t slot_mask;
     942              :     uint8_t total_digest_buffer[LIBSPDM_MAX_HASH_SIZE * SPDM_MAX_SLOT_COUNT];
     943              : 
     944            1 :     spdm_test_context = *state;
     945            1 :     spdm_context = spdm_test_context->spdm_context;
     946            1 :     spdm_test_context->case_id = 0x3;
     947            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_10 <<
     948              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
     949            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_NOT_STARTED;
     950            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_CAP;
     951            1 :     spdm_context->connection_info.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
     952            1 :     libspdm_set_mem(m_libspdm_local_certificate_chain,
     953              :                     sizeof(m_libspdm_local_certificate_chain),
     954              :                     (uint8_t)(0xFF));
     955            1 :     libspdm_reset_message_b(spdm_context);
     956              : 
     957            1 :     libspdm_zero_mem(total_digest_buffer, sizeof(total_digest_buffer));
     958            1 :     status = libspdm_get_digest(spdm_context, NULL, &slot_mask, &total_digest_buffer);
     959            1 :     assert_int_equal(status, LIBSPDM_STATUS_INVALID_STATE_LOCAL);
     960              : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
     961              :     assert_int_equal(spdm_context->transcript.message_b.buffer_size, 0);
     962              : #endif
     963            1 : }
     964              : 
     965              : /**
     966              :  * Test 4: a request message is successfully sent and an ERROR response message with error code = InvalidRequest is received
     967              :  * Expected Behavior: requester returns the status LIBSPDM_STATUS_ERROR_PEER, with no DIGESTS message received
     968              :  **/
     969            1 : static void libspdm_test_requester_get_digests_err_case4(void **state)
     970              : {
     971              :     libspdm_return_t status;
     972              :     libspdm_test_context_t *spdm_test_context;
     973              :     libspdm_context_t *spdm_context;
     974              :     uint8_t slot_mask;
     975              :     uint8_t total_digest_buffer[LIBSPDM_MAX_HASH_SIZE * SPDM_MAX_SLOT_COUNT];
     976              : 
     977            1 :     spdm_test_context = *state;
     978            1 :     spdm_context = spdm_test_context->spdm_context;
     979            1 :     spdm_test_context->case_id = 0x4;
     980            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_10 <<
     981              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
     982            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_NEGOTIATED;
     983            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_CAP;
     984            1 :     spdm_context->connection_info.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
     985            1 :     libspdm_set_mem(m_libspdm_local_certificate_chain,
     986              :                     sizeof(m_libspdm_local_certificate_chain),
     987              :                     (uint8_t)(0xFF));
     988            1 :     libspdm_reset_message_b(spdm_context);
     989              : 
     990            1 :     libspdm_zero_mem(total_digest_buffer, sizeof(total_digest_buffer));
     991            1 :     status = libspdm_get_digest(spdm_context, NULL, &slot_mask, &total_digest_buffer);
     992            1 :     assert_int_equal(status, LIBSPDM_STATUS_ERROR_PEER);
     993              : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
     994              :     assert_int_equal(spdm_context->transcript.message_b.buffer_size, 0);
     995              : #endif
     996            1 : }
     997              : 
     998              : /**
     999              :  * Test 5: request messages are successfully sent and ERROR response messages with error code = Busy are received in all attempts
    1000              :  * Expected Behavior: requester returns the status LIBSPDM_STATUS_BUSY_PEER, with no DIGESTS message received
    1001              :  **/
    1002            1 : static void libspdm_test_requester_get_digests_err_case5(void **state)
    1003              : {
    1004              :     libspdm_return_t status;
    1005              :     libspdm_test_context_t *spdm_test_context;
    1006              :     libspdm_context_t *spdm_context;
    1007              :     uint8_t slot_mask;
    1008              :     uint8_t total_digest_buffer[LIBSPDM_MAX_HASH_SIZE * SPDM_MAX_SLOT_COUNT];
    1009              : 
    1010            1 :     spdm_test_context = *state;
    1011            1 :     spdm_context = spdm_test_context->spdm_context;
    1012            1 :     spdm_test_context->case_id = 0x5;
    1013            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_10 <<
    1014              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1015            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_NEGOTIATED;
    1016            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_CAP;
    1017            1 :     spdm_context->connection_info.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    1018            1 :     libspdm_set_mem(m_libspdm_local_certificate_chain,
    1019              :                     sizeof(m_libspdm_local_certificate_chain),
    1020              :                     (uint8_t)(0xFF));
    1021            1 :     libspdm_reset_message_b(spdm_context);
    1022              : 
    1023            1 :     libspdm_zero_mem(total_digest_buffer, sizeof(total_digest_buffer));
    1024            1 :     status = libspdm_get_digest(spdm_context, NULL, &slot_mask, &total_digest_buffer);
    1025            1 :     assert_int_equal(status, LIBSPDM_STATUS_BUSY_PEER);
    1026              : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
    1027              :     assert_int_equal(spdm_context->transcript.message_b.buffer_size, 0);
    1028              : #endif
    1029            1 : }
    1030              : 
    1031              : /**
    1032              :  * Test 6: Requester is unable to acquire the receiver buffer.
    1033              :  * Expected Behavior: returns with error LIBSPDM_STATUS_ACQUIRE_FAIL.
    1034              :  **/
    1035            1 : static void libspdm_test_requester_get_digests_err_case6(void **state)
    1036              : {
    1037              :     libspdm_return_t status;
    1038              :     libspdm_test_context_t *spdm_test_context;
    1039              :     libspdm_context_t *spdm_context;
    1040              :     uint8_t slot_mask;
    1041              :     uint8_t total_digest_buffer[LIBSPDM_MAX_HASH_SIZE * SPDM_MAX_SLOT_COUNT];
    1042              : 
    1043            1 :     spdm_test_context = *state;
    1044            1 :     spdm_context = spdm_test_context->spdm_context;
    1045            1 :     spdm_test_context->case_id = 0x2;
    1046            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_10 <<
    1047              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1048            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_NEGOTIATED;
    1049            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_CAP;
    1050            1 :     spdm_context->connection_info.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    1051            1 :     libspdm_set_mem(m_libspdm_local_certificate_chain,
    1052              :                     sizeof(m_libspdm_local_certificate_chain),
    1053              :                     (uint8_t)(0xFF));
    1054            1 :     libspdm_reset_message_b(spdm_context);
    1055              : 
    1056            1 :     libspdm_zero_mem(total_digest_buffer, sizeof(total_digest_buffer));
    1057              : 
    1058            1 :     libspdm_force_error(LIBSPDM_ERR_ACQUIRE_RECEIVER_BUFFER);
    1059            1 :     status = libspdm_get_digest(spdm_context, NULL, &slot_mask, &total_digest_buffer);
    1060            1 :     libspdm_release_error(LIBSPDM_ERR_ACQUIRE_RECEIVER_BUFFER);
    1061              : 
    1062            1 :     assert_int_equal(status, LIBSPDM_STATUS_ACQUIRE_FAIL);
    1063            1 : }
    1064              : 
    1065              : /**
    1066              :  * Test 7: a request message is successfully sent and an ERROR response message with error code = RequestResynch
    1067              :  * (Meaning Responder is requesting Requester to reissue GET_VERSION to resynchronize) is received
    1068              :  * Expected Behavior: requester returns the status RETURN_DEVICE_ERROR, with no DIGESTS message received
    1069              :  **/
    1070            1 : static void libspdm_test_requester_get_digests_err_case7(void **state)
    1071              : {
    1072              :     libspdm_return_t status;
    1073              :     libspdm_test_context_t *spdm_test_context;
    1074              :     libspdm_context_t *spdm_context;
    1075              :     uint8_t slot_mask;
    1076              :     uint8_t total_digest_buffer[LIBSPDM_MAX_HASH_SIZE * SPDM_MAX_SLOT_COUNT];
    1077              : 
    1078            1 :     spdm_test_context = *state;
    1079            1 :     spdm_context = spdm_test_context->spdm_context;
    1080            1 :     spdm_test_context->case_id = 0x7;
    1081            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_10 <<
    1082              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1083            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_NEGOTIATED;
    1084            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_CAP;
    1085            1 :     spdm_context->connection_info.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    1086            1 :     libspdm_set_mem(m_libspdm_local_certificate_chain,
    1087              :                     sizeof(m_libspdm_local_certificate_chain),
    1088              :                     (uint8_t)(0xFF));
    1089            1 :     libspdm_reset_message_b(spdm_context);
    1090              : 
    1091            1 :     libspdm_zero_mem(total_digest_buffer, sizeof(total_digest_buffer));
    1092            1 :     status = libspdm_get_digest(spdm_context, NULL, &slot_mask, &total_digest_buffer);
    1093            1 :     assert_int_equal(status, LIBSPDM_STATUS_RESYNCH_PEER);
    1094            1 :     assert_int_equal(spdm_context->connection_info.connection_state,
    1095              :                      LIBSPDM_CONNECTION_STATE_NOT_STARTED);
    1096              : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
    1097              :     assert_int_equal(spdm_context->transcript.message_b.buffer_size, 0);
    1098              : #endif
    1099            1 : }
    1100              : 
    1101              : /**
    1102              :  * Test 8: request messages are successfully sent and ERROR response messages with error code = ResponseNotReady
    1103              :  * are received in all attempts
    1104              :  * Expected Behavior: requester returns the status LIBSPDM_STATUS_ERROR_PEER
    1105              :  **/
    1106            1 : static void libspdm_test_requester_get_digests_err_case8(void **state)
    1107              : {
    1108              :     libspdm_return_t status;
    1109              :     libspdm_test_context_t *spdm_test_context;
    1110              :     libspdm_context_t *spdm_context;
    1111              :     uint8_t slot_mask;
    1112              :     uint8_t total_digest_buffer[LIBSPDM_MAX_HASH_SIZE * SPDM_MAX_SLOT_COUNT];
    1113              : 
    1114            1 :     spdm_test_context = *state;
    1115            1 :     spdm_context = spdm_test_context->spdm_context;
    1116            1 :     spdm_test_context->case_id = 0x8;
    1117            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_10 <<
    1118              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1119            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_NEGOTIATED;
    1120            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_CAP;
    1121            1 :     spdm_context->connection_info.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    1122            1 :     libspdm_set_mem(m_libspdm_local_certificate_chain,
    1123              :                     sizeof(m_libspdm_local_certificate_chain),
    1124              :                     (uint8_t)(0xFF));
    1125            1 :     libspdm_reset_message_b(spdm_context);
    1126              : 
    1127            1 :     libspdm_zero_mem(total_digest_buffer, sizeof(total_digest_buffer));
    1128            1 :     status = libspdm_get_digest(spdm_context, NULL, &slot_mask, &total_digest_buffer);
    1129            1 :     assert_int_equal(status, LIBSPDM_STATUS_NOT_READY_PEER);
    1130            1 : }
    1131              : 
    1132              : /**
    1133              :  * Test 9: Invalid SPDM version in the DIGESTS response.
    1134              :  * Expected Behavior: returns with LIBSPDM_STATUS_INVALID_MSG_FIELD.
    1135              :  **/
    1136            1 : static void libspdm_test_requester_get_digests_err_case9(void **state)
    1137              : {
    1138              :     libspdm_return_t status;
    1139              :     libspdm_test_context_t *spdm_test_context;
    1140              :     libspdm_context_t *spdm_context;
    1141              :     uint8_t slot_mask;
    1142              :     uint8_t total_digest_buffer[LIBSPDM_MAX_HASH_SIZE * SPDM_MAX_SLOT_COUNT];
    1143              : 
    1144            1 :     spdm_test_context = *state;
    1145            1 :     spdm_context = spdm_test_context->spdm_context;
    1146            1 :     spdm_test_context->case_id = 0x9;
    1147            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_10 <<
    1148              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1149            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_NEGOTIATED;
    1150            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_CAP;
    1151            1 :     spdm_context->connection_info.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    1152            1 :     libspdm_set_mem(m_libspdm_local_certificate_chain,
    1153              :                     sizeof(m_libspdm_local_certificate_chain),
    1154              :                     (uint8_t)(0xFF));
    1155            1 :     libspdm_reset_message_b(spdm_context);
    1156              : 
    1157            1 :     libspdm_zero_mem(total_digest_buffer, sizeof(total_digest_buffer));
    1158            1 :     status = libspdm_get_digest(spdm_context, NULL, &slot_mask, &total_digest_buffer);
    1159              : 
    1160            1 :     assert_int_equal(status, LIBSPDM_STATUS_INVALID_MSG_FIELD);
    1161            1 : }
    1162              : 
    1163              : /**
    1164              :  * Test 10: flag cert_cap from CAPABILITIES is not set meaning the Requester does not support DIGESTS and
    1165              :  * CERTIFICATE response messages
    1166              :  * Expected Behavior: requester returns the status LIBSPDM_STATUS_UNSUPPORTED_CAP, with no DIGESTS message received
    1167              :  **/
    1168            1 : static void libspdm_test_requester_get_digests_err_case10(void **state)
    1169              : {
    1170              :     libspdm_return_t status;
    1171              :     libspdm_test_context_t *spdm_test_context;
    1172              :     libspdm_context_t *spdm_context;
    1173              :     uint8_t slot_mask;
    1174              :     uint8_t total_digest_buffer[LIBSPDM_MAX_HASH_SIZE * SPDM_MAX_SLOT_COUNT];
    1175              : 
    1176            1 :     spdm_test_context = *state;
    1177            1 :     spdm_context = spdm_test_context->spdm_context;
    1178            1 :     spdm_test_context->case_id = 0xA;
    1179            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_10 <<
    1180              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1181            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_NEGOTIATED;
    1182            1 :     spdm_context->connection_info.capability.flags = 0;
    1183            1 :     spdm_context->connection_info.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    1184            1 :     libspdm_set_mem(m_libspdm_local_certificate_chain,
    1185              :                     sizeof(m_libspdm_local_certificate_chain),
    1186              :                     (uint8_t)(0xFF));
    1187            1 :     libspdm_reset_message_b(spdm_context);
    1188              : 
    1189            1 :     libspdm_zero_mem(total_digest_buffer, sizeof(total_digest_buffer));
    1190            1 :     status = libspdm_get_digest(spdm_context, NULL, &slot_mask, &total_digest_buffer);
    1191            1 :     assert_int_equal(status, LIBSPDM_STATUS_UNSUPPORTED_CAP);
    1192              : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
    1193              :     assert_int_equal(spdm_context->transcript.message_b.buffer_size, 0);
    1194              : #endif
    1195            1 : }
    1196              : 
    1197              : /**
    1198              :  * Test 11: a request message is successfully sent but a failure occurs during the receiving of the response message
    1199              :  * Expected Behavior: requester returns the status LIBSPDM_STATUS_RECEIVE_FAIL, with no DIGESTS message received
    1200              :  **/
    1201            1 : static void libspdm_test_requester_get_digests_err_case11(void **state)
    1202              : {
    1203              :     libspdm_return_t status;
    1204              :     libspdm_test_context_t *spdm_test_context;
    1205              :     libspdm_context_t *spdm_context;
    1206              :     uint8_t slot_mask;
    1207              :     uint8_t total_digest_buffer[LIBSPDM_MAX_HASH_SIZE * SPDM_MAX_SLOT_COUNT];
    1208              : 
    1209            1 :     spdm_test_context = *state;
    1210            1 :     spdm_context = spdm_test_context->spdm_context;
    1211            1 :     spdm_test_context->case_id = 0xB;
    1212            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_10 <<
    1213              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1214            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_NEGOTIATED;
    1215            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_CAP;
    1216            1 :     spdm_context->connection_info.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    1217            1 :     libspdm_set_mem(m_libspdm_local_certificate_chain,
    1218              :                     sizeof(m_libspdm_local_certificate_chain),
    1219              :                     (uint8_t)(0xFF));
    1220            1 :     libspdm_reset_message_b(spdm_context);
    1221              : 
    1222            1 :     libspdm_zero_mem(total_digest_buffer, sizeof(total_digest_buffer));
    1223            1 :     status = libspdm_get_digest(spdm_context, NULL, &slot_mask, &total_digest_buffer);
    1224            1 :     assert_int_equal(status, LIBSPDM_STATUS_RECEIVE_FAIL);
    1225              : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
    1226              :     assert_int_equal(spdm_context->transcript.message_b.buffer_size,
    1227              :                      0);
    1228              : #endif
    1229            1 : }
    1230              : 
    1231              : /**
    1232              :  * Test 12:
    1233              :  * Expected Behavior:
    1234              :  **/
    1235            1 : static void libspdm_test_requester_get_digests_err_case12(void **state)
    1236              : {
    1237            1 : }
    1238              : 
    1239              : /**
    1240              :  * Test 13: a request message is successfully sent but the request_response_code from the response message is different than the code of SPDM_DIGESTS
    1241              :  * Expected Behavior: requester returns the status LIBSPDM_STATUS_INVALID_MSG_FIELD, with no DIGESTS message received
    1242              :  **/
    1243            1 : static void libspdm_test_requester_get_digests_err_case13(void **state)
    1244              : {
    1245              :     libspdm_return_t status;
    1246              :     libspdm_test_context_t *spdm_test_context;
    1247              :     libspdm_context_t *spdm_context;
    1248              :     uint8_t slot_mask;
    1249              :     uint8_t total_digest_buffer[LIBSPDM_MAX_HASH_SIZE * SPDM_MAX_SLOT_COUNT];
    1250              : 
    1251            1 :     spdm_test_context = *state;
    1252            1 :     spdm_context = spdm_test_context->spdm_context;
    1253            1 :     spdm_test_context->case_id = 0xD;
    1254            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_10 <<
    1255              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1256            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_NEGOTIATED;
    1257            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_CAP;
    1258            1 :     spdm_context->connection_info.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    1259            1 :     libspdm_set_mem(m_libspdm_local_certificate_chain,
    1260              :                     sizeof(m_libspdm_local_certificate_chain),
    1261              :                     (uint8_t)(0xFF));
    1262            1 :     libspdm_reset_message_b(spdm_context);
    1263              : 
    1264            1 :     libspdm_zero_mem(total_digest_buffer, sizeof(total_digest_buffer));
    1265            1 :     status = libspdm_get_digest(spdm_context, NULL, &slot_mask, &total_digest_buffer);
    1266            1 :     assert_int_equal(status, LIBSPDM_STATUS_INVALID_MSG_FIELD);
    1267              : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
    1268              :     assert_int_equal(spdm_context->transcript.message_b.buffer_size, 0);
    1269              : #endif
    1270            1 : }
    1271              : 
    1272              : /**
    1273              :  * Test 14: a request message is successfully sent but the number of digests in the response message is equal to zero
    1274              :  * Expected Behavior: requester returns the status LIBSPDM_STATUS_INVALID_MSG_FIELD, with no successful DIGESTS message received
    1275              :  **/
    1276            1 : static void libspdm_test_requester_get_digests_err_case14(void **state)
    1277              : {
    1278              :     libspdm_return_t status;
    1279              :     libspdm_test_context_t *spdm_test_context;
    1280              :     libspdm_context_t *spdm_context;
    1281              :     uint8_t slot_mask;
    1282              :     uint8_t total_digest_buffer[LIBSPDM_MAX_HASH_SIZE * SPDM_MAX_SLOT_COUNT];
    1283              : 
    1284            1 :     spdm_test_context = *state;
    1285            1 :     spdm_context = spdm_test_context->spdm_context;
    1286            1 :     spdm_test_context->case_id = 0xE;
    1287            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_10 <<
    1288              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1289            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_NEGOTIATED;
    1290            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_CAP;
    1291            1 :     spdm_context->connection_info.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    1292            1 :     libspdm_set_mem(m_libspdm_local_certificate_chain,
    1293              :                     sizeof(m_libspdm_local_certificate_chain),
    1294              :                     (uint8_t)(0xFF));
    1295            1 :     libspdm_reset_message_b(spdm_context);
    1296              : 
    1297            1 :     libspdm_zero_mem(total_digest_buffer, sizeof(total_digest_buffer));
    1298            1 :     status = libspdm_get_digest(spdm_context, NULL, &slot_mask, &total_digest_buffer);
    1299            1 :     assert_int_equal(status, LIBSPDM_STATUS_INVALID_MSG_FIELD);
    1300              : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
    1301              :     assert_int_equal(spdm_context->transcript.message_b.buffer_size,
    1302              :                      0);
    1303              : #endif
    1304            1 : }
    1305              : 
    1306              : /**
    1307              :  * Test 15:
    1308              :  * Expected Behavior:
    1309              :  **/
    1310            1 : static void libspdm_test_requester_get_digests_err_case15(void **state)
    1311              : {
    1312            1 : }
    1313              : 
    1314              : /**
    1315              :  * Test 16: a request message is successfully sent but the response message cannot be appended to the internal cache since the internal cache is full
    1316              :  * Expected Behavior: requester returns the status RETURN_SECURITY_VIOLATION
    1317              :  **/
    1318            1 : static void libspdm_test_requester_get_digests_err_case16(void **state)
    1319              : {
    1320              : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
    1321              :     libspdm_return_t status;
    1322              :     uint8_t slot_mask;
    1323              : #endif
    1324              :     libspdm_test_context_t *spdm_test_context;
    1325              :     libspdm_context_t *spdm_context;
    1326              :     uint8_t total_digest_buffer[LIBSPDM_MAX_HASH_SIZE * SPDM_MAX_SLOT_COUNT];
    1327              : 
    1328            1 :     spdm_test_context = *state;
    1329            1 :     spdm_context = spdm_test_context->spdm_context;
    1330            1 :     spdm_test_context->case_id = 0x10;
    1331            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_10 <<
    1332              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1333            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_NEGOTIATED;
    1334            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_CAP;
    1335            1 :     spdm_context->connection_info.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    1336            1 :     libspdm_set_mem(m_libspdm_local_certificate_chain,
    1337              :                     sizeof(m_libspdm_local_certificate_chain),
    1338              :                     (uint8_t)(0xFF));
    1339              : 
    1340            1 :     libspdm_zero_mem(total_digest_buffer, sizeof(total_digest_buffer));
    1341              : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
    1342              :     status = libspdm_get_digest(spdm_context, NULL, &slot_mask, &total_digest_buffer);
    1343              :     assert_int_equal(status, LIBSPDM_STATUS_BUFFER_FULL);
    1344              : #endif
    1345            1 : }
    1346              : 
    1347              : /**
    1348              :  * Test 17:
    1349              :  * Expected Behavior:
    1350              :  **/
    1351            1 : static void libspdm_test_requester_get_digests_err_case17(void **state)
    1352              : {
    1353            1 : }
    1354              : 
    1355              : /**
    1356              :  * Test 18: a request message is successfully sent but the number of digests received in the response message is different than
    1357              :  * the number of bits set in param2 - Slot mask
    1358              :  * Expected Behavior: requester returns the status RETURN_DEVICE_ERROR, with no successful DIGESTS message received (managed buffer is not shrunk)
    1359              :  **/
    1360            1 : static void libspdm_test_requester_get_digests_err_case18(void **state)
    1361              : {
    1362              :     libspdm_return_t status;
    1363              :     libspdm_test_context_t *spdm_test_context;
    1364              :     libspdm_context_t *spdm_context;
    1365              :     uint8_t slot_mask;
    1366              :     uint8_t total_digest_buffer[LIBSPDM_MAX_HASH_SIZE * SPDM_MAX_SLOT_COUNT];
    1367              : 
    1368            1 :     spdm_test_context = *state;
    1369            1 :     spdm_context = spdm_test_context->spdm_context;
    1370            1 :     spdm_test_context->case_id = 0x12;
    1371            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_10 <<
    1372              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1373            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_NEGOTIATED;
    1374            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_CAP;
    1375            1 :     spdm_context->connection_info.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    1376            1 :     libspdm_set_mem(m_libspdm_local_certificate_chain,
    1377              :                     sizeof(m_libspdm_local_certificate_chain),
    1378              :                     (uint8_t)(0xFF));
    1379            1 :     libspdm_reset_message_b(spdm_context);
    1380              : 
    1381            1 :     libspdm_zero_mem(total_digest_buffer, sizeof(total_digest_buffer));
    1382            1 :     status = libspdm_get_digest(spdm_context, NULL, &slot_mask, &total_digest_buffer);
    1383            1 :     assert_int_equal(status, LIBSPDM_STATUS_INVALID_MSG_SIZE);
    1384              : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
    1385              :     assert_int_equal(spdm_context->transcript.message_b.buffer_size,
    1386              :                      0);
    1387              : #endif
    1388            1 : }
    1389              : 
    1390              : #if 0
    1391              : /**
    1392              :  * Test 19: a request message is successfully sent but several digests (except the first) received in the response message are invalid
    1393              :  * Expected Behavior: requester returns the status RETURN_SECURITY_VIOLATION, with error state LIBSPDM_STATUS_ERROR_CERTIFICATE_FAILURE
    1394              :  **/
    1395              : static void libspdm_test_requester_get_digests_err_case19(void **state)
    1396              : {
    1397              :     libspdm_return_t status;
    1398              :     libspdm_test_context_t *spdm_test_context;
    1399              :     libspdm_context_t *spdm_context;
    1400              :     uint8_t slot_mask;
    1401              :     uint8_t total_digest_buffer[LIBSPDM_MAX_HASH_SIZE * SPDM_MAX_SLOT_COUNT];
    1402              : 
    1403              :     spdm_test_context = *state;
    1404              :     spdm_context = spdm_test_context->spdm_context;
    1405              :     spdm_test_context->case_id = 0x13;
    1406              :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_10 <<
    1407              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1408              :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_NEGOTIATED;
    1409              :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_CAP;
    1410              :     spdm_context->connection_info.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    1411              :     libspdm_set_mem(m_libspdm_local_certificate_chain,
    1412              :                     sizeof(m_libspdm_local_certificate_chain),
    1413              :                     (uint8_t)(0xFF));
    1414              :     libspdm_reset_message_b(spdm_context);
    1415              : 
    1416              :     libspdm_zero_mem(total_digest_buffer, sizeof(total_digest_buffer));
    1417              :     status = libspdm_get_digest(spdm_context, NULL, &slot_mask, &total_digest_buffer);
    1418              :     assert_int_equal(status, LIBSPDM_STATUS_VERIF_FAIL);
    1419              : }
    1420              : 
    1421              : /**
    1422              :  * Test 20: a request message is successfully sent but the size of the response message is smaller than the minimum size of a SPDM DIGESTS response,
    1423              :  * meaning it is an invalid response message.
    1424              :  * Expected Behavior: requester returns the status RETURN_DEVICE_ERROR, with no successful DIGESTS message received (managed buffer is not shrunk)
    1425              :  **/
    1426              : static void libspdm_test_requester_get_digests_err_case20(void **state)
    1427              : {
    1428              :     libspdm_return_t status;
    1429              :     libspdm_test_context_t *spdm_test_context;
    1430              :     libspdm_context_t *spdm_context;
    1431              :     uint8_t slot_mask;
    1432              :     uint8_t total_digest_buffer[LIBSPDM_MAX_HASH_SIZE * SPDM_MAX_SLOT_COUNT];
    1433              : 
    1434              :     spdm_test_context = *state;
    1435              :     spdm_context = spdm_test_context->spdm_context;
    1436              :     spdm_test_context->case_id = 0x14;
    1437              :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_10 <<
    1438              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1439              :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_NEGOTIATED;
    1440              :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_CAP;
    1441              :     spdm_context->connection_info.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    1442              :     libspdm_set_mem(m_libspdm_local_certificate_chain,
    1443              :                     sizeof(m_libspdm_local_certificate_chain),
    1444              :                     (uint8_t)(0xFF));
    1445              :     libspdm_reset_message_b(spdm_context);
    1446              : 
    1447              :     libspdm_zero_mem(total_digest_buffer, sizeof(total_digest_buffer));
    1448              :     status = libspdm_get_digest(spdm_context, NULL, &slot_mask, &total_digest_buffer);
    1449              :     assert_int_equal(status, LIBSPDM_STATUS_INVALID_MSG_SIZE);
    1450              : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
    1451              :     assert_int_equal(spdm_context->transcript.message_b.buffer_size,
    1452              :                      sizeof(spdm_get_digest_request_t));
    1453              : #endif
    1454              : }
    1455              : 
    1456              : /**
    1457              :  * Test 21: a request message is successfully sent but the size of the response message is bigger than the maximum size of a SPDM DIGESTS response,
    1458              :  * meaning it is an invalid response message.
    1459              :  * Expected Behavior: requester returns the status RETURN_DEVICE_ERROR, with no successful DIGESTS message received (managed buffer is not shrunk)
    1460              :  **/
    1461              : static void libspdm_test_requester_get_digests_err_case21(void **state)
    1462              : {
    1463              :     libspdm_return_t status;
    1464              :     libspdm_test_context_t *spdm_test_context;
    1465              :     libspdm_context_t *spdm_context;
    1466              :     uint8_t slot_mask;
    1467              :     uint8_t total_digest_buffer[LIBSPDM_MAX_HASH_SIZE * SPDM_MAX_SLOT_COUNT];
    1468              : 
    1469              :     spdm_test_context = *state;
    1470              :     spdm_context = spdm_test_context->spdm_context;
    1471              :     spdm_test_context->case_id = 0x15;
    1472              :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_10 <<
    1473              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1474              :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_NEGOTIATED;
    1475              :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_CAP;
    1476              :     spdm_context->connection_info.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    1477              :     libspdm_set_mem(m_libspdm_local_certificate_chain,
    1478              :                     sizeof(m_libspdm_local_certificate_chain),
    1479              :                     (uint8_t)(0xFF));
    1480              :     libspdm_reset_message_b(spdm_context);
    1481              : 
    1482              :     libspdm_zero_mem(total_digest_buffer, sizeof(total_digest_buffer));
    1483              :     status = libspdm_get_digest(spdm_context, NULL, &slot_mask, &total_digest_buffer);
    1484              :     assert_int_equal(status, LIBSPDM_STATUS_INVALID_MSG_SIZE);
    1485              : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
    1486              :     assert_int_equal(spdm_context->transcript.message_b.buffer_size,
    1487              :                      sizeof(spdm_get_digest_request_t));
    1488              : #endif
    1489              : }
    1490              : #endif
    1491              : 
    1492              : /**
    1493              :  * Test 22: receiving an unexpected ERROR message from the responder.
    1494              :  * There are tests for all named codes, including some reserved ones
    1495              :  * (namely, 0x00, 0x0b, 0x0c, 0x3f, 0xfd, 0xfe).
    1496              :  * However, for having specific test cases, it is excluded from this case:
    1497              :  * Busy (0x03), ResponseNotReady (0x42), and RequestResync (0x43).
    1498              :  * Expected behavior: client returns a status of RETURN_DEVICE_ERROR.
    1499              :  **/
    1500            1 : static void libspdm_test_requester_get_digests_err_case22(void **state) {
    1501              :     libspdm_return_t status;
    1502              :     libspdm_test_context_t    *spdm_test_context;
    1503              :     libspdm_context_t  *spdm_context;
    1504              :     uint8_t slot_mask;
    1505              :     uint8_t total_digest_buffer[LIBSPDM_MAX_HASH_SIZE * SPDM_MAX_SLOT_COUNT];
    1506              :     uint16_t error_code;
    1507              : 
    1508            1 :     spdm_test_context = *state;
    1509            1 :     spdm_context = spdm_test_context->spdm_context;
    1510            1 :     spdm_test_context->case_id = 0x16;
    1511            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_11 <<
    1512              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1513            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_CAP;
    1514            1 :     spdm_context->connection_info.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    1515            1 :     libspdm_set_mem (m_libspdm_local_certificate_chain,
    1516              :                      sizeof(m_libspdm_local_certificate_chain),
    1517              :                      (uint8_t)(0xFF));
    1518              : 
    1519            1 :     error_code = LIBSPDM_ERROR_CODE_RESERVED_00;
    1520           19 :     while(error_code <= 0xff) {
    1521           18 :         spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_NEGOTIATED;
    1522           18 :         libspdm_reset_message_b(spdm_context);
    1523              : 
    1524           18 :         libspdm_zero_mem (total_digest_buffer, sizeof(total_digest_buffer));
    1525           18 :         status = libspdm_get_digest (spdm_context, NULL, &slot_mask, &total_digest_buffer);
    1526           18 :         LIBSPDM_ASSERT_INT_EQUAL_CASE (status, LIBSPDM_STATUS_ERROR_PEER, error_code);
    1527              : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
    1528              :         LIBSPDM_ASSERT_INT_EQUAL_CASE (spdm_context->transcript.message_b.buffer_size, 0,
    1529              :                                        error_code);
    1530              : #endif
    1531              : 
    1532           18 :         error_code++;
    1533           18 :         if(error_code == SPDM_ERROR_CODE_BUSY) { /*busy is treated in cases 5 and 6*/
    1534            1 :             error_code = SPDM_ERROR_CODE_UNEXPECTED_REQUEST;
    1535              :         }
    1536           18 :         if(error_code == LIBSPDM_ERROR_CODE_RESERVED_0D) { /*skip some reserved error codes (0d to 3e)*/
    1537            1 :             error_code = LIBSPDM_ERROR_CODE_RESERVED_3F;
    1538              :         }
    1539           18 :         if(error_code == SPDM_ERROR_CODE_RESPONSE_NOT_READY) { /*skip response not ready, request resync, and some reserved codes (44 to fc)*/
    1540            1 :             error_code = LIBSPDM_ERROR_CODE_RESERVED_FD;
    1541              :         }
    1542              :     }
    1543            1 : }
    1544              : 
    1545              : /**
    1546              :  * Test 23: Responder returns invalid combination of SupportedSlotMask and ProvisionedSlotMask.
    1547              :  * Expected Behavior: returns LIBSPDM_STATUS_INVALID_MSG_FIELD.
    1548              :  **/
    1549            1 : static void libspdm_test_requester_get_digests_err_case23(void **state)
    1550              : {
    1551              :     libspdm_return_t status;
    1552              :     libspdm_test_context_t *spdm_test_context;
    1553              :     libspdm_context_t *spdm_context;
    1554              :     uint8_t slot_mask;
    1555              :     uint8_t total_digest_buffer[LIBSPDM_MAX_HASH_SIZE * SPDM_MAX_SLOT_COUNT];
    1556              : 
    1557            1 :     spdm_test_context = *state;
    1558            1 :     spdm_context = spdm_test_context->spdm_context;
    1559            1 :     spdm_test_context->case_id = 0x17;
    1560            1 :     spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_13 <<
    1561              :                                             SPDM_VERSION_NUMBER_SHIFT_BIT;
    1562            1 :     spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_NEGOTIATED;
    1563            1 :     spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_CAP;
    1564            1 :     spdm_context->connection_info.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
    1565            1 :     libspdm_set_mem(m_libspdm_local_certificate_chain,
    1566              :                     sizeof(m_libspdm_local_certificate_chain),
    1567              :                     (uint8_t)(0xFF));
    1568            1 :     libspdm_reset_message_b(spdm_context);
    1569              : 
    1570            1 :     libspdm_zero_mem(total_digest_buffer, sizeof(total_digest_buffer));
    1571            1 :     status = libspdm_get_digest(spdm_context, NULL, &slot_mask, &total_digest_buffer);
    1572            1 :     assert_int_equal(status, LIBSPDM_STATUS_INVALID_MSG_FIELD);
    1573              : 
    1574              : #if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
    1575              :     assert_int_equal(spdm_context->transcript.message_b.buffer_size, 0);
    1576              : #endif
    1577            1 : }
    1578              : 
    1579              : /**
    1580              :  * Test 24:
    1581              :  * Expected Behavior:
    1582              :  **/
    1583            1 : static void libspdm_test_requester_get_digests_err_case24(void **state)
    1584              : {
    1585            1 : }
    1586              : 
    1587              : /**
    1588              :  * Test 25:
    1589              :  * Expected Behavior:
    1590              :  **/
    1591            1 : static void libspdm_test_requester_get_digests_err_case25(void **state)
    1592              : {
    1593            1 : }
    1594              : 
    1595            1 : int libspdm_req_get_digests_error_test(void)
    1596              : {
    1597            1 :     const struct CMUnitTest test_cases[] = {
    1598              :         cmocka_unit_test(libspdm_test_requester_get_digests_err_case1),
    1599              :         cmocka_unit_test(libspdm_test_requester_get_digests_err_case2),
    1600              :         cmocka_unit_test(libspdm_test_requester_get_digests_err_case3),
    1601              :         cmocka_unit_test(libspdm_test_requester_get_digests_err_case4),
    1602              :         cmocka_unit_test(libspdm_test_requester_get_digests_err_case5),
    1603              :         cmocka_unit_test(libspdm_test_requester_get_digests_err_case6),
    1604              :         cmocka_unit_test(libspdm_test_requester_get_digests_err_case7),
    1605              :         cmocka_unit_test(libspdm_test_requester_get_digests_err_case8),
    1606              :         cmocka_unit_test(libspdm_test_requester_get_digests_err_case9),
    1607              :         cmocka_unit_test(libspdm_test_requester_get_digests_err_case10),
    1608              :         cmocka_unit_test(libspdm_test_requester_get_digests_err_case11),
    1609              :         cmocka_unit_test(libspdm_test_requester_get_digests_err_case12),
    1610              :         cmocka_unit_test(libspdm_test_requester_get_digests_err_case13),
    1611              :         cmocka_unit_test(libspdm_test_requester_get_digests_err_case14),
    1612              :         cmocka_unit_test(libspdm_test_requester_get_digests_err_case15),
    1613              :         cmocka_unit_test(libspdm_test_requester_get_digests_err_case16),
    1614              :         cmocka_unit_test(libspdm_test_requester_get_digests_err_case17),
    1615              :         cmocka_unit_test(libspdm_test_requester_get_digests_err_case18),
    1616              :         /* cmocka_unit_test(libspdm_test_requester_get_digests_err_case19),
    1617              :          * cmocka_unit_test(libspdm_test_requester_get_digests_err_case20),
    1618              :          * cmocka_unit_test(libspdm_test_requester_get_digests_err_case21), */
    1619              :         cmocka_unit_test(libspdm_test_requester_get_digests_err_case22),
    1620              :         cmocka_unit_test(libspdm_test_requester_get_digests_err_case23),
    1621              :         cmocka_unit_test(libspdm_test_requester_get_digests_err_case24),
    1622              :         cmocka_unit_test(libspdm_test_requester_get_digests_err_case25),
    1623              :     };
    1624              : 
    1625            1 :     libspdm_test_context_t test_context = {
    1626              :         LIBSPDM_TEST_CONTEXT_VERSION,
    1627              :         true,
    1628              :         send_message,
    1629              :         receive_message,
    1630              :     };
    1631              : 
    1632            1 :     libspdm_setup_test_context(&test_context);
    1633              : 
    1634            1 :     return cmocka_run_group_tests(test_cases,
    1635              :                                   libspdm_unit_test_group_setup,
    1636              :                                   libspdm_unit_test_group_teardown);
    1637              : }
    1638              : 
    1639              : #endif /* LIBSPDM_SEND_GET_CERTIFICATE_SUPPORT */
        

Generated by: LCOV version 2.0-1