blob: 50b862a4c2fc5007f2de552aca8d1e6f299613d0 [file] [log] [blame]
Vadim Bendebury56797522015-05-20 10:32:25 -07001// 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 "ClearControl_fp.h"
10//
11//
12// Error Returns Meaning
13//
14// TPM_RC_AUTH_FAIL authorization is not properly given
15//
16TPM_RC
17TPM2_ClearControl(
18 ClearControl_In *in // IN: input parameter list
19 )
20{
21 TPM_RC result;
22
23 // The command needs NV update. Check if NV is available.
24 // A TPM_RC_NV_UNAVAILABLE or TPM_RC_NV_RATE error may be returned at
25 // this point
26 result = NvIsAvailable();
27 if(result != TPM_RC_SUCCESS) return result;
28
29// Input Validation
30
31 // LockoutAuth may be used to set disableLockoutClear to TRUE but not to FALSE
32 if(in->auth == TPM_RH_LOCKOUT && in->disable == NO)
33 return TPM_RC_AUTH_FAIL;
34
35// Internal Data Update
36
37 if(in->disable == YES)
38 gp.disableClear = TRUE;
39 else
40 gp.disableClear = FALSE;
41
42 // Record the change to NV
43 NvWriteReserved(NV_DISABLE_CLEAR, &gp.disableClear);
44
45 return TPM_RC_SUCCESS;
46}