UnitTest/TestSpdmRequester/TestSpdmRequesterGetMeasurement.c
/**
  Test 11: Successful response to get a measurement block, without signature
  Expected Behavior: get a RETURN_SUCCESS return code, correct Transcript.MessageM.BufferSize
**/
Test 11: Successful response to get a measurement block, without signature
Expected Behavior: get a RETURN_SUCCESS return code, correct Transcript.MessageM.BufferSize
Test 11 : Successful response to get a measurement block without signature Expected Behavior : get a RETURN_SUCCESS return code correct Transcript . MessageM . BufferSize
void TestSpdmRequesterGetMeasurementCase11(void **state) {
  RETURN_STATUS        Status;
  SPDM_TEST_CONTEXT    *SpdmTestContext;
  SPDM_DEVICE_CONTEXT  *SpdmContext;
  UINT8                NumberOfBlock;
  UINT32               MeasurementRecordLength;
  UINT8                MeasurementRecord[MAX_SPDM_MEASUREMENT_RECORD_SIZE];
  UINT8                RequestAttribute;
  VOID                 *Data;
  UINTN                DataSize;
  VOID                 *Hash;
  UINTN                HashSize;
  SpdmTestContext = *state;
  SpdmContext = SpdmTestContext->SpdmContext;
  SpdmTestContext->CaseId = 0xB;
  SpdmContext->ConnectionInfo.ConnectionState = SpdmConnectionStateAuthenticated;
  SpdmContext->ConnectionInfo.Capability.Flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP_SIG;
  ReadResponderPublicCertificateChain (mUseHashAlgo, mUseAsymAlgo, &Data, &DataSize, &Hash, &HashSize);
  SpdmContext->Transcript.MessageM.BufferSize = 0;
  SpdmContext->ConnectionInfo.Algorithm.MeasurementSpec = mUseMeasurementSpec;
  SpdmContext->ConnectionInfo.Algorithm.MeasurementHashAlgo = mUseMeasurementHashAlgo;
  SpdmContext->ConnectionInfo.Algorithm.BaseHashAlgo = mUseHashAlgo;
  SpdmContext->ConnectionInfo.Algorithm.BaseAsymAlgo = mUseAsymAlgo;
  SpdmContext->ConnectionInfo.PeerUsedCertChainBufferSize = DataSize;
  CopyMem (SpdmContext->ConnectionInfo.PeerUsedCertChainBuffer, Data, DataSize);
  RequestAttribute = 0;
  MeasurementRecordLength = sizeof(MeasurementRecord);
  Status = SpdmGetMeasurement (SpdmContext, NULL, RequestAttribute, 1, 0, &NumberOfBlock, &MeasurementRecordLength, MeasurementRecord);
  assert_int_equal (Status, RETURN_SUCCESS);
  assert_int_equal (SpdmContext->Transcript.MessageM.BufferSize, sizeof(SPDM_MESSAGE_HEADER) + sizeof(SPDM_MEASUREMENTS_RESPONSE) + sizeof(SPDM_MEASUREMENT_BLOCK_DMTF) + GetSpdmMeasurementHashSize (mUseMeasurementHashAlgo) + sizeof(UINT16));
  free(Data);
}
void TestSpdmRequesterGetMeasurementCase11 ( void * * state ) { RETURN_STATUS Status ; SPDM_TEST_CONTEXT * SpdmTestContext ; SPDM_DEVICE_CONTEXT * SpdmContext ; UINT8 NumberOfBlock ; UINT32 MeasurementRecordLength ; UINT8 MeasurementRecord [ MAX_SPDM_MEASUREMENT_RECORD_SIZE ] ; UINT8 RequestAttribute ; VOID * Data ; UINTN DataSize ; VOID * Hash ; UINTN HashSize ; SpdmTestContext = * state ; SpdmContext = SpdmTestContext -> SpdmContext ; SpdmTestContext -> CaseId = 0xB ; SpdmContext -> ConnectionInfo . ConnectionState = SpdmConnectionStateAuthenticated ; SpdmContext -> ConnectionInfo . Capability . Flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP_SIG ; ReadResponderPublicCertificateChain ( mUseHashAlgo , mUseAsymAlgo , & Data , & DataSize , & Hash , & HashSize ) ; SpdmContext -> Transcript . MessageM . BufferSize = 0 ; SpdmContext -> ConnectionInfo . Algorithm . MeasurementSpec = mUseMeasurementSpec ; SpdmContext -> ConnectionInfo . Algorithm . MeasurementHashAlgo = mUseMeasurementHashAlgo ; SpdmContext -> ConnectionInfo . Algorithm . BaseHashAlgo = mUseHashAlgo ; SpdmContext -> ConnectionInfo . Algorithm . BaseAsymAlgo = mUseAsymAlgo ; SpdmContext -> ConnectionInfo . PeerUsedCertChainBufferSize = DataSize ; CopyMem ( SpdmContext -> ConnectionInfo . PeerUsedCertChainBuffer , Data , DataSize ) ; RequestAttribute = 0 ; MeasurementRecordLength = sizeof ( MeasurementRecord ) ; Status = SpdmGetMeasurement ( SpdmContext , NULL , RequestAttribute , 1 , 0 , & NumberOfBlock , & MeasurementRecordLength , MeasurementRecord ) ; assert_int_equal ( Status , RETURN_SUCCESS ) ; assert_int_equal ( SpdmContext -> Transcript . MessageM . BufferSize , sizeof ( SPDM_MESSAGE_HEADER ) + sizeof ( SPDM_MEASUREMENTS_RESPONSE ) + sizeof ( SPDM_MEASUREMENT_BLOCK_DMTF ) + GetSpdmMeasurementHashSize ( mUseMeasurementHashAlgo ) + sizeof ( UINT16 ) ) ; free ( Data ) ; }
Test 11: Successful response to get a measurement block, without signature
Expected Behavior: get a RETURN_SUCCESS return code, correct Transcript.MessageM.BufferSize
Test 11 : Successful response to get a measurement block without signature Expected Behavior : get a RETURN_SUCCESS return code correct Transcript . MessageM . BufferSize