diff options
author | Vadim Bendebury <vbendeb@chromium.org> | 2015-05-20 10:32:25 -0700 |
---|---|---|
committer | Vadim Bendebury <vbendeb@chromium.org> | 2015-05-20 22:32:05 -0700 |
commit | 5679752bf24c21135884e987c4077e2f71848971 (patch) | |
tree | 3e680dd91a7af84c45ea1170ee88225bd4ad32c8 /_TPM_Hash_End.c | |
download | tpm2-5679752bf24c21135884e987c4077e2f71848971.tar.gz |
Initial commit to seed TPM2.0 source code directory
LICENSE file text copied from TCG library specification. README
describes the procedure used to extract source code from parts 3 and 4
of the specification.
The python scripts and part{34}.txt files will be removed in the
following commits.
Change-Id: Ie281e6e988481831f33483053455e8aff8f3f75f
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Diffstat (limited to '_TPM_Hash_End.c')
-rw-r--r-- | _TPM_Hash_End.c | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/_TPM_Hash_End.c b/_TPM_Hash_End.c new file mode 100644 index 0000000..eb21a63 --- /dev/null +++ b/_TPM_Hash_End.c @@ -0,0 +1,78 @@ +// This file was extracted from the TCG Published +// Trusted Platform Module Library +// Part 3: Commands +// Family "2.0" +// Level 00 Revision 01.16 +// October 30, 2014 + +#include "InternalRoutines.h" +// +// This function is called to process a _TPM_Hash_End() indication. +// +void +_TPM_Hash_End( + void + ) +{ + + UINT32 i; + TPM2B_DIGEST digest; + HASH_OBJECT *hashObject; + TPMI_DH_PCR pcrHandle; + + // If the DRTM handle is not being used, then either _TPM_Hash_Start has not + // been called, _TPM_Hash_End was previously called, or some other command + // was executed and the sequence was aborted. + if(g_DRTMHandle == TPM_RH_UNASSIGNED) + return; + + // Get DRTM sequence object + hashObject = (HASH_OBJECT *)ObjectGet(g_DRTMHandle); + + // Is this _TPM_Hash_End after Startup or before + if(TPMIsStarted()) + { + // After + + // Reset the DRTM PCR + PCRResetDynamics(); + + // Extend the DRTM_PCR. + pcrHandle = PCR_FIRST + DRTM_PCR; + + // DRTM sequence increments restartCount + gr.restartCount++; + } + else + { + pcrHandle = PCR_FIRST + HCRTM_PCR; + } + + // Complete hash and extend PCR, or if this is an HCRTM, complete + // the hash, reset the H-CRTM register (PCR[0]) to 0...04, and then + // extend the H-CRTM data + for(i = 0; i < HASH_COUNT; i++) + { + TPMI_ALG_HASH hash = CryptGetHashAlgByIndex(i); + // make sure that the PCR is implemented for this algorithm + if(PcrIsAllocated(pcrHandle, + hashObject->state.hashState[i].state.hashAlg)) + { + // Complete hash + digest.t.size = CryptGetHashDigestSize(hash); + CryptCompleteHash2B(&hashObject->state.hashState[i], &digest.b); + + PcrDrtm(pcrHandle, hash, &digest); + } + } + + // Flush sequence object. +// + ObjectFlush(g_DRTMHandle); + + g_DRTMHandle = TPM_RH_UNASSIGNED; + + g_DrtmPreStartup = TRUE; + + return; +} |