• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // 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 "SequenceUpdate_fp.h"
10 //
11 //
12 //     Error Returns                   Meaning
13 //
14 //     TPM_RC_MODE                     sequenceHandle does not reference a hash or HMAC sequence
15 //                                     object
16 //
17 TPM_RC
TPM2_SequenceUpdate(SequenceUpdate_In * in)18 TPM2_SequenceUpdate(
19    SequenceUpdate_In     *in               // IN: input parameter list
20    )
21 {
22    OBJECT                      *object;
23 
24 // Input Validation
25 
26    // Get sequence object pointer
27    object = ObjectGet(in->sequenceHandle);
28 
29    // Check that referenced object is a sequence object.
30    if(!ObjectIsSequence(object))
31        return TPM_RC_MODE + RC_SequenceUpdate_sequenceHandle;
32 
33 // Internal Data Update
34 
35    if(object->attributes.eventSeq == SET)
36    {
37        // Update event sequence object
38        UINT32           i;
39        HASH_OBJECT     *hashObject = (HASH_OBJECT *)object;
40        for(i = 0; i < HASH_COUNT; i++)
41        {
42            // Update sequence object
43            CryptUpdateDigest2B(&hashObject->state.hashState[i], &in->buffer.b);
44        }
45    }
46    else
47    {
48        HASH_OBJECT     *hashObject = (HASH_OBJECT *)object;
49 
50        // Update hash/HMAC sequence object
51        if(hashObject->attributes.hashSeq == SET)
52        {
53            // Is this the first block of the sequence
54            if(hashObject->attributes.firstBlock == CLEAR)
55            {
56                // If so, indicate that first block was received
57                hashObject->attributes.firstBlock = SET;
58 
59                 // Check the first block to see if the first block can contain
60                 // the TPM_GENERATED_VALUE. If it does, it is not safe for
61                 // a ticket.
62                 if(TicketIsSafe(&in->buffer.b))
63                     hashObject->attributes.ticketSafe = SET;
64             }
65             // Update sequence object hash/HMAC stack
66             CryptUpdateDigest2B(&hashObject->state.hashState[0], &in->buffer.b);
67 
68        }
69        else if(object->attributes.hmacSeq == SET)
70        {
71            HASH_OBJECT     *hashObject = (HASH_OBJECT *)object;
72 
73             // Update sequence object hash/HMAC stack
74             CryptUpdateDigest2B(&hashObject->state.hmacState, &in->buffer.b);
75        }
76    }
77 
78    return TPM_RC_SUCCESS;
79 }
80