Coverage Report

Created: 2023-06-07 06:46

/src/tpm2/PCR_Reset.c
Line
Count
Source (jump to first uncovered line)
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_Reset_fp.h"
10
//
11
//
12
//     Error Returns                     Meaning
13
//
14
//     TPM_RC_LOCALITY                   current command locality is not allowed to reset the PCR referenced
15
//                                       by pcrHandle
16
//
17
TPM_RC
18
TPM2_PCR_Reset(
19
   PCR_Reset_In      *in                 // IN: input parameter list
20
   )
21
5
{
22
5
   TPM_RC        result;
23
24
// Input Validation
25
26
   // Check if the reset operation is allowed by the current command locality
27
5
   if(!PCRIsResetAllowed(in->pcrHandle))
28
3
       return TPM_RC_LOCALITY;
29
30
   // If PCR is state saved and we need to update orderlyState, check NV
31
   // availability
32
2
   if(PCRIsStateSaved(in->pcrHandle) && gp.orderlyState != SHUTDOWN_NONE)
33
0
   {
34
0
       result = NvIsAvailable();
35
0
       if(result != TPM_RC_SUCCESS)
36
0
           return result;
37
0
       g_clearOrderly = TRUE;
38
0
   }
39
40
// Internal Data Update
41
42
   // Reset selected PCR in all banks to 0
43
2
   PCRSetValue(in->pcrHandle, 0);
44
45
   // Indicate that the PCR changed so that pcrCounter will be incremented if
46
   // necessary.
47
2
   PCRChanged(in->pcrHandle);
48
49
2
   return TPM_RC_SUCCESS;
50
2
}