Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions TPMCmd/tpm/include/private/prototypes/Object_fp.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,16 @@ ObjectCreateEventSequence(TPM2B_AUTH* auth, // IN: authValue
TPMI_DH_OBJECT* newHandle // OUT: sequence object handle
);

//*** ObjectCreateEventSequenceHcrtmDrtm()
// This function creates an event sequence object for Hcrtm/Drtm case,
// it is called in _TPM_Hash_Start().
// Return Type: TPM_RC
// TPM_RC_OBJECT_MEMORY if there is no free slot for an object
TPM_RC
ObjectCreateEventSequenceHcrtmDrtm(TPM2B_AUTH* auth, // IN: authValue
TPMI_DH_OBJECT* newHandle // OUT: sequence object handle
);

//*** ObjectTerminateEvent()
// This function is called to close out the event sequence and clean up the hash
// context states.
Expand Down
6 changes: 3 additions & 3 deletions TPMCmd/tpm/src/events/_TPM_Hash_Start.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ LIB_EXPORT BOOL _TPM_Hash_Start(void)
VERIFY(FlushObject(oldHandle), FATAL_ERROR_INTERNAL, FALSE);
}

// Create an event sequence object and store the handle in global
// Create an event sequence object for Hcrtm/Drtm and store the handle in global
// g_DRTMHandle. A TPM_RC_OBJECT_MEMORY error may be returned at this point
// The NULL value for the first parameter will cause the sequence structure to
// be allocated without being set as present. This keeps the sequence from
// being left behind if the sequence is terminated early.
result = ObjectCreateEventSequence(NULL, &g_DRTMHandle);
result = ObjectCreateEventSequenceHcrtmDrtm(NULL, &g_DRTMHandle);

// If a free slot was not available, then free up a slot.
if(result != TPM_RC_SUCCESS)
Expand Down Expand Up @@ -51,7 +51,7 @@ LIB_EXPORT BOOL _TPM_Hash_Start(void)

// Try to create an event sequence object again. This time, we must
// succeed.
result = ObjectCreateEventSequence(NULL, &g_DRTMHandle);
result = ObjectCreateEventSequenceHcrtmDrtm(NULL, &g_DRTMHandle);
if(result != TPM_RC_SUCCESS)
FAIL_BOOL(FATAL_ERROR_INTERNAL);
}
Expand Down
32 changes: 32 additions & 0 deletions TPMCmd/tpm/src/subsystem/Object.c
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,38 @@ ObjectCreateEventSequence(TPM2B_AUTH* auth, // IN: authValue
return TPM_RC_SUCCESS;
}

//*** ObjectCreateEventSequenceHcrtmDrtm()
// This function creates an event sequence object for HCRTM/DRTM use case.
// Return Type: TPM_RC
// TPM_RC_OBJECT_MEMORY if there is no free slot for an object
TPM_RC
ObjectCreateEventSequenceHcrtmDrtm(
TPM2B_AUTH *auth, // IN: authValue
TPMI_DH_OBJECT *newHandle // OUT: sequence object handle
)
{
HASH_OBJECT* hashObject = AllocateSequenceSlot(newHandle, auth);
TPMI_DH_PCR pcrHandle = TPMIsStarted()? PCR_FIRST + DRTM_PCR : PCR_FIRST + HCRTM_PCR;
UINT32 i;
TPM_ALG_ID hash;
//
// See if slot allocated
if(hashObject == NULL)
return TPM_RC_OBJECT_MEMORY;
// Set the event sequence attribute
hashObject->attributes.eventSeq = SET;

// Initialize hash states for each implemented PCR algorithms
for(i = 0; i < HASH_COUNT; i++)
{
hash = CryptHashGetAlgByIndex(i);
// make sure that the PCR is implemented for this algorithm
if(PcrIsAllocated(pcrHandle, hash))
CryptHashStart(&hashObject->state.hashState[i], hash);
}
return TPM_RC_SUCCESS;
}

//*** ObjectTerminateEvent()
// This function is called to close out the event sequence and clean up the hash
// context states.
Expand Down