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_SetAuthValue_fp.h"
10 //
11 //
12 //     Error Returns                 Meaning
13 //
14 //     TPM_RC_VALUE                  PCR referenced by pcrHandle is not a member of a PCR
15 //                                   authorization group
16 //
17 TPM_RC
TPM2_PCR_SetAuthValue(PCR_SetAuthValue_In * in)18 TPM2_PCR_SetAuthValue(
19    PCR_SetAuthValue_In       *in              // IN: input parameter list
20    )
21 {
22    UINT32      groupIndex;
23    TPM_RC      result;
24 
25 // Input Validation:
26 
27    // If PCR does not belong to an auth group, return TPM_RC_VALUE
28    if(!PCRBelongsAuthGroup(in->pcrHandle, &groupIndex))
29        return TPM_RC_VALUE;
30 
31    // The command may cause the orderlyState to be cleared due to the update of
32    // state clear data. If this is the case, Check if NV is available.
33    // A TPM_RC_NV_UNAVAILABLE or TPM_RC_NV_RATE error may be returned at
34    // this point
35    if(gp.orderlyState != SHUTDOWN_NONE)
36    {
37        result = NvIsAvailable();
38        if(result != TPM_RC_SUCCESS) return result;
39        g_clearOrderly = TRUE;
40    }
41 
42 // Internal Data Update
43 
44    // Set PCR authValue
45    gc.pcrAuthValues.auth[groupIndex] = in->auth;
46 
47    return TPM_RC_SUCCESS;
48 }
49