/src/tpm2/NV_UndefineSpaceSpecial.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 "NV_UndefineSpaceSpecial_fp.h" |
10 | | // |
11 | | // |
12 | | // Error Returns Meaning |
13 | | // |
14 | | // TPM_RC_ATTRIBUTES TPMA_NV_POLICY_DELETE is not SET in the Index referenced by |
15 | | // nvIndex |
16 | | // |
17 | | TPM_RC |
18 | | TPM2_NV_UndefineSpaceSpecial( |
19 | | NV_UndefineSpaceSpecial_In *in // IN: input parameter list |
20 | | ) |
21 | 0 | { |
22 | 0 | TPM_RC result; |
23 | 0 | NV_INDEX nvIndex; |
24 | | |
25 | | // The command needs NV update. Check if NV is available. |
26 | | // A TPM_RC_NV_UNAVAILABLE or TPM_RC_NV_RATE error may be returned at |
27 | | // this point |
28 | 0 | result = NvIsAvailable(); |
29 | 0 | if(result != TPM_RC_SUCCESS) |
30 | 0 | return result; |
31 | | |
32 | | // Indexes in the virtual range cannot be undefined. |
33 | 0 | if (_plat__NvGetHandleVirtualOffset(in->nvIndex)) |
34 | 0 | return TPM_RC_NV_AUTHORIZATION; |
35 | | |
36 | | // Check if there are platform-specific reasons to prohibit updating this |
37 | | // index. |
38 | 0 | if (!_plat__NvUpdateAllowed(in->nvIndex)) |
39 | 0 | return TPM_RC_NV_AUTHORIZATION; |
40 | | |
41 | | // Input Validation |
42 | | |
43 | | // Get NV index info |
44 | 0 | NvGetIndexInfo(in->nvIndex, &nvIndex); |
45 | | |
46 | | // This operation only applies when the TPMA_NV_POLICY_DELETE attribute is SET |
47 | 0 | if(CLEAR == nvIndex.publicArea.attributes.TPMA_NV_POLICY_DELETE) |
48 | 0 | return TPM_RC_ATTRIBUTES + RC_NV_UndefineSpaceSpecial_nvIndex; |
49 | | |
50 | | // Internal Data Update |
51 | | |
52 | | // Call implementation dependent internal routine to delete NV index |
53 | 0 | NvDeleteEntity(in->nvIndex); |
54 | |
|
55 | 0 | return TPM_RC_SUCCESS; |
56 | 0 | } |