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.5 % 695 441
Test Date: 2026-02-22 08:11:49 Functions: 100.0 % 25 25

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

Generated by: LCOV version 2.0-1