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 /SequenceUpdate.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 'SequenceUpdate.c')
-rw-r--r-- | SequenceUpdate.c | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/SequenceUpdate.c b/SequenceUpdate.c new file mode 100644 index 0000000..19ee845 --- /dev/null +++ b/SequenceUpdate.c @@ -0,0 +1,79 @@ +// 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 "SequenceUpdate_fp.h" +// +// +// Error Returns Meaning +// +// TPM_RC_MODE sequenceHandle does not reference a hash or HMAC sequence +// object +// +TPM_RC +TPM2_SequenceUpdate( + SequenceUpdate_In *in // IN: input parameter list + ) +{ + OBJECT *object; + +// Input Validation + + // Get sequence object pointer + object = ObjectGet(in->sequenceHandle); + + // Check that referenced object is a sequence object. + if(!ObjectIsSequence(object)) + return TPM_RC_MODE + RC_SequenceUpdate_sequenceHandle; + +// Internal Data Update + + if(object->attributes.eventSeq == SET) + { + // Update event sequence object + UINT32 i; + HASH_OBJECT *hashObject = (HASH_OBJECT *)object; + for(i = 0; i < HASH_COUNT; i++) + { + // Update sequence object + CryptUpdateDigest2B(&hashObject->state.hashState[i], &in->buffer.b); + } + } + else + { + HASH_OBJECT *hashObject = (HASH_OBJECT *)object; + + // Update hash/HMAC sequence object + if(hashObject->attributes.hashSeq == SET) + { + // Is this the first block of the sequence + if(hashObject->attributes.firstBlock == CLEAR) + { + // If so, indicate that first block was received + hashObject->attributes.firstBlock = SET; + + // Check the first block to see if the first block can contain + // the TPM_GENERATED_VALUE. If it does, it is not safe for + // a ticket. + if(TicketIsSafe(&in->buffer.b)) + hashObject->attributes.ticketSafe = SET; + } + // Update sequence object hash/HMAC stack + CryptUpdateDigest2B(&hashObject->state.hashState[0], &in->buffer.b); + + } + else if(object->attributes.hmacSeq == SET) + { + HASH_OBJECT *hashObject = (HASH_OBJECT *)object; + + // Update sequence object hash/HMAC stack + CryptUpdateDigest2B(&hashObject->state.hmacState, &in->buffer.b); + } + } + + return TPM_RC_SUCCESS; +} |