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_UndefineSpace_fp.h" 10 // 11 // 12 // Error Returns Meaning 13 // 14 // TPM_RC_ATTRIBUTES TPMA_NV_POLICY_DELETE is SET in the Index referenced by 15 // nvIndex so this command may not be used to delete this Index (see 16 // TPM2_NV_UndefineSpaceSpecial()) 17 // TPM_RC_NV_AUTHORIZATION attempt to use ownerAuth to delete an index created by the platform 18 // 19 TPM_RC TPM2_NV_UndefineSpace(NV_UndefineSpace_In * in)20TPM2_NV_UndefineSpace( 21 NV_UndefineSpace_In *in // IN: input parameter list 22 ) 23 { 24 TPM_RC result; 25 NV_INDEX nvIndex; 26 27 // The command needs NV update. Check if NV is available. 28 // A TPM_RC_NV_UNAVAILABLE or TPM_RC_NV_RATE error may be returned at 29 // this point 30 result = NvIsAvailable(); 31 if(result != TPM_RC_SUCCESS) return result; 32 33 // Input Validation 34 35 // Get NV index info 36 NvGetIndexInfo(in->nvIndex, &nvIndex); 37 38 // This command can't be used to delete an index with TPMA_NV_POLICY_DELETE SET 39 if(SET == nvIndex.publicArea.attributes.TPMA_NV_POLICY_DELETE) 40 return TPM_RC_ATTRIBUTES + RC_NV_UndefineSpace_nvIndex; 41 42 // The owner may only delete an index that was defined with ownerAuth. The 43 // platform may delete an index that was created with either auth. 44 if( in->authHandle == TPM_RH_OWNER 45 && nvIndex.publicArea.attributes.TPMA_NV_PLATFORMCREATE == SET) 46 return TPM_RC_NV_AUTHORIZATION; 47 48 // Internal Data Update 49 50 // Call implementation dependent internal routine to delete NV index 51 NvDeleteEntity(in->nvIndex); 52 53 return TPM_RC_SUCCESS; 54 } 55