UnitTest/TestSpdmRequester/TestSpdmRequesterGetDigest.c
/**
  Test 12: a request message is successfully sent but the size of the response message is smaller than the size of the SPDM message header, 
  meaning it is an invalid response message
  Expected Behavior: requester returns the status RETURN_DEVICE_ERROR, with no successful DIGESTS message received (managed buffer not shrinked)
**/
Test 12: a request message is successfully sent but the size of the response message is smaller than the size of the SPDM message header,
meaning it is an invalid response message
Expected Behavior: requester returns the status RETURN_DEVICE_ERROR, with no successful DIGESTS message received (managed buffer not shrinked)
Test 12 : a request message is successfully sent but the size of the response message is smaller than the size of the SPDM message header meaning it is an invalid response message Expected Behavior : requester returns the status RETURN_DEVICE_ERROR with no successful DIGESTS message received ( managed buffer not shrinked )
void TestSpdmRequesterGetDigestCase12(void **state) {
  RETURN_STATUS        Status;
  SPDM_TEST_CONTEXT    *SpdmTestContext;
  SPDM_DEVICE_CONTEXT  *SpdmContext;
  UINT8                 SlotMask;
  UINT8                 TotalDigestBuffer[MAX_HASH_SIZE * MAX_SPDM_SLOT_COUNT];
  SpdmTestContext = *state;
  SpdmContext = SpdmTestContext->SpdmContext;
  SpdmTestContext->CaseId = 0xC;
  SpdmContext->ConnectionInfo.ConnectionState = SpdmConnectionStateNegotiated;
  SpdmContext->ConnectionInfo.Capability.Flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_CAP;
  SpdmContext->ConnectionInfo.Algorithm.BaseHashAlgo = mUseHashAlgo;
  SpdmContext->LocalContext.PeerCertChainProvision = LocalCertificateChain;
  SpdmContext->LocalContext.PeerCertChainProvisionSize = MAX_SPDM_MESSAGE_BUFFER_SIZE;
  SetMem (LocalCertificateChain, MAX_SPDM_MESSAGE_BUFFER_SIZE, (UINT8)(0xFF));
  SpdmContext->Transcript.MessageB.BufferSize = 0;
  ZeroMem (TotalDigestBuffer, sizeof(TotalDigestBuffer));
  Status = SpdmGetDigest (SpdmContext, &SlotMask, &TotalDigestBuffer);
  assert_int_equal (Status, RETURN_DEVICE_ERROR);
  assert_int_equal (SpdmContext->Transcript.MessageB.BufferSize, sizeof(SPDM_GET_DIGESTS_REQUEST));
}
void TestSpdmRequesterGetDigestCase12 ( void * * state ) { RETURN_STATUS Status ; SPDM_TEST_CONTEXT * SpdmTestContext ; SPDM_DEVICE_CONTEXT * SpdmContext ; UINT8 SlotMask ; UINT8 TotalDigestBuffer [ MAX_HASH_SIZE * MAX_SPDM_SLOT_COUNT ] ; SpdmTestContext = * state ; SpdmContext = SpdmTestContext -> SpdmContext ; SpdmTestContext -> CaseId = 0xC ; SpdmContext -> ConnectionInfo . ConnectionState = SpdmConnectionStateNegotiated ; SpdmContext -> ConnectionInfo . Capability . Flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_CAP ; SpdmContext -> ConnectionInfo . Algorithm . BaseHashAlgo = mUseHashAlgo ; SpdmContext -> LocalContext . PeerCertChainProvision = LocalCertificateChain ; SpdmContext -> LocalContext . PeerCertChainProvisionSize = MAX_SPDM_MESSAGE_BUFFER_SIZE ; SetMem ( LocalCertificateChain , MAX_SPDM_MESSAGE_BUFFER_SIZE , ( UINT8 ) ( 0xFF ) ) ; SpdmContext -> Transcript . MessageB . BufferSize = 0 ; ZeroMem ( TotalDigestBuffer , sizeof ( TotalDigestBuffer ) ) ; Status = SpdmGetDigest ( SpdmContext , & SlotMask , & TotalDigestBuffer ) ; assert_int_equal ( Status , RETURN_DEVICE_ERROR ) ; assert_int_equal ( SpdmContext -> Transcript . MessageB . BufferSize , sizeof ( SPDM_GET_DIGESTS_REQUEST ) ) ; }
Test 12: a request message is successfully sent but the size of the response message is smaller than the size of the SPDM message header,
meaning it is an invalid response message
Expected Behavior: requester returns the status RETURN_DEVICE_ERROR, with no successful DIGESTS message received (managed buffer not shrinked)
Test 12 : a request message is successfully sent but the size of the response message is smaller than the size of the SPDM message header meaning it is an invalid response message Expected Behavior : requester returns the status RETURN_DEVICE_ERROR with no successful DIGESTS message received ( managed buffer not shrinked )