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 /ClockSet.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 'ClockSet.c')
-rw-r--r-- | ClockSet.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/ClockSet.c b/ClockSet.c new file mode 100644 index 0000000..06a8f70 --- /dev/null +++ b/ClockSet.c @@ -0,0 +1,49 @@ +// 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" +#include "ClockSet_fp.h" +// +// Read the current TPMS_TIMER_INFO structure settings +// +// Error Returns Meaning +// +// TPM_RC_VALUE invalid new clock +// +TPM_RC +TPM2_ClockSet( + ClockSet_In *in // IN: input parameter list + ) +{ +#define CLOCK_UPDATE_MASK ((1ULL << NV_CLOCK_UPDATE_INTERVAL)- 1) + UINT64 clockNow; + +// Input Validation + + // new time can not be bigger than 0xFFFF000000000000 or smaller than + // current clock + if(in->newTime > 0xFFFF000000000000ULL + || in->newTime < go.clock) + return TPM_RC_VALUE + RC_ClockSet_newTime; + +// Internal Data Update + + // Internal Data Update + clockNow = go.clock; // grab the old value + go.clock = in->newTime; // set the new value + // Check to see if the update has caused a need for an nvClock update + if((in->newTime & CLOCK_UPDATE_MASK) > (clockNow & CLOCK_UPDATE_MASK)) + { + CryptDrbgGetPutState(GET_STATE); + NvWriteReserved(NV_ORDERLY_DATA, &go); + + // Now the time state is safe + go.clockSafe = YES; + } + + return TPM_RC_SUCCESS; +} |