aboutsummaryrefslogtreecommitdiff
path: root/PCR_Reset.c
blob: a9bb16908f981497a594512d6793448e751d1c9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// 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 "PCR_Reset_fp.h"
//
//
//     Error Returns                     Meaning
//
//     TPM_RC_LOCALITY                   current command locality is not allowed to reset the PCR referenced
//                                       by pcrHandle
//
TPM_RC
TPM2_PCR_Reset(
   PCR_Reset_In      *in                 // IN: input parameter list
   )
{
   TPM_RC        result;

// Input Validation

   // Check if the reset operation is allowed by the current command locality
   if(!PCRIsResetAllowed(in->pcrHandle))
       return TPM_RC_LOCALITY;

   // If PCR is state saved and we need to update orderlyState, check NV
   // availability
   if(PCRIsStateSaved(in->pcrHandle) && gp.orderlyState != SHUTDOWN_NONE)
   {
       result = NvIsAvailable();
       if(result != TPM_RC_SUCCESS)
           return result;
       g_clearOrderly = TRUE;
   }

// Internal Data Update

   // Reset selected PCR in all banks to 0
   PCRSetValue(in->pcrHandle, 0);

   // Indicate that the PCR changed so that pcrCounter will be incremented if
   // necessary.
   PCRChanged(in->pcrHandle);

   return TPM_RC_SUCCESS;
}