UnitTest/TestSpdmRequester/TestSpdmRequesterGetDigest.c
/**
  Test 4: a request message is successfully sent and an ERROR response message with error code = InvalidRequest is received
  Expected Behavior: requester returns the status RETURN_DEVICE_ERROR, with no DIGESTS message received
**/
Test 4: a request message is successfully sent and an ERROR response message with error code = InvalidRequest is received
Expected Behavior: requester returns the status RETURN_DEVICE_ERROR, with no DIGESTS message received
Test 4 : a request message is successfully sent and an ERROR response message with error code = InvalidRequest is received Expected Behavior : requester returns the status RETURN_DEVICE_ERROR with no DIGESTS message received
void TestSpdmRequesterGetDigestCase4(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 = 0x4;
  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, 0);
}
void TestSpdmRequesterGetDigestCase4 ( 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 = 0x4 ; 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 , 0 ) ; }
Test 4: a request message is successfully sent and an ERROR response message with error code = InvalidRequest is received
Expected Behavior: requester returns the status RETURN_DEVICE_ERROR, with no DIGESTS message received
Test 4 : a request message is successfully sent and an ERROR response message with error code = InvalidRequest is received Expected Behavior : requester returns the status RETURN_DEVICE_ERROR with no DIGESTS message received