Line | Count | Source |
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 "PCR_Extend_fp.h" |
10 | | // |
11 | | // |
12 | | // Error Returns Meaning |
13 | | // |
14 | | // TPM_RC_LOCALITY current command locality is not allowed to extend the PCR |
15 | | // referenced by pcrHandle |
16 | | // |
17 | | TPM_RC |
18 | | TPM2_PCR_Extend( |
19 | | PCR_Extend_In *in // IN: input parameter list |
20 | | ) |
21 | 23 | { |
22 | 23 | TPM_RC result; |
23 | 23 | UINT32 i; |
24 | | |
25 | | // Input Validation |
26 | | |
27 | | // NOTE: This function assumes that the unmarshaling function for 'digests' will |
28 | | // have validated that all of the indicated hash algorithms are valid. If the |
29 | | // hash algorithms are correct, the unmarshaling code will unmarshal a digest |
30 | | // of the size indicated by the hash algorithm. If the overall size is not |
31 | | // consistent, the unmarshaling code will run out of input data or have input |
32 | | // data left over. In either case, it will cause an unmarshaling error and this |
33 | | // function will not be called. |
34 | | |
35 | | // For NULL handle, do nothing and return success |
36 | 23 | if(in->pcrHandle == TPM_RH_NULL) |
37 | 0 | return TPM_RC_SUCCESS; |
38 | | |
39 | | // Check if the extend operation is allowed by the current command locality |
40 | 23 | if(!PCRIsExtendAllowed(in->pcrHandle)) |
41 | 0 | return TPM_RC_LOCALITY; |
42 | | |
43 | | // If PCR is state saved and we need to update orderlyState, check NV |
44 | | // availability |
45 | 23 | if(PCRIsStateSaved(in->pcrHandle) && gp.orderlyState != SHUTDOWN_NONE) |
46 | 0 | { |
47 | 0 | result = NvIsAvailable(); |
48 | 0 | if(result != TPM_RC_SUCCESS) return result; |
49 | 0 | g_clearOrderly = TRUE; |
50 | 0 | } |
51 | | |
52 | | // Internal Data Update |
53 | | |
54 | | // Iterate input digest list to extend |
55 | 88 | for(i = 0; i < in->digests.count; i++) |
56 | 65 | { |
57 | 65 | PCRExtend(in->pcrHandle, in->digests.digests[i].hashAlg, |
58 | 65 | CryptGetHashDigestSize(in->digests.digests[i].hashAlg), |
59 | 65 | (BYTE *) &in->digests.digests[i].digest); |
60 | 65 | } |
61 | | |
62 | 23 | return TPM_RC_SUCCESS; |
63 | 23 | } |