blob: a3737238d166fe99a287f859bfb05ba2e1acd5e4 [file] [log] [blame]
Vadim Bendebury56797522015-05-20 10:32:25 -07001// This file was extracted from the TCG Published
2// Trusted Platform Module Library
3// Part 3: Commands
4// Family "2.0"
5// Level 00 Revision 01.16
6// October 30, 2014
7
8#include "InternalRoutines.h"
9#include "Platform.h"
10#include "PCR_fp.h"
11//
12// This function is called to process a _TPM_Hash_Data() indication.
13//
14void
15_TPM_Hash_Data(
16 UINT32 dataSize, // IN: size of data to be extend
17 BYTE *data // IN: data buffer
18 )
19{
20 UINT32 i;
21 HASH_OBJECT *hashObject;
22 TPMI_DH_PCR pcrHandle = TPMIsStarted()
23 ? PCR_FIRST + DRTM_PCR : PCR_FIRST + HCRTM_PCR;
24
25 // If there is no DRTM sequence object, then _TPM_Hash_Start
26 // was not called so this function returns without doing
27 // anything.
28 if(g_DRTMHandle == TPM_RH_UNASSIGNED)
29 return;
30
31 hashObject = (HASH_OBJECT *)ObjectGet(g_DRTMHandle);
32 pAssert(hashObject->attributes.eventSeq);
33
34 // For each of the implemented hash algorithms, update the digest with the
35 // data provided.
36 for(i = 0; i < HASH_COUNT; i++)
37 {
38 // make sure that the PCR is implemented for this algorithm
39 if(PcrIsAllocated(pcrHandle,
40 hashObject->state.hashState[i].state.hashAlg))
41 // Update sequence object
42 CryptUpdateDigest(&hashObject->state.hashState[i], dataSize, data);
43 }
44
45 return;
46}