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 "ChangePPS_fp.h" 10 TPM_RC TPM2_ChangePPS(ChangePPS_In * in)11TPM2_ChangePPS( 12 ChangePPS_In *in // IN: input parameter list 13 ) 14 { 15 UINT32 i; 16 TPM_RC result; 17 18 // Check if NV is available. A TPM_RC_NV_UNAVAILABLE or TPM_RC_NV_RATE 19 // error may be returned at this point 20 result = NvIsAvailable(); 21 if(result != TPM_RC_SUCCESS) return result; 22 23 // Input parameter is not reference in command action 24 in = NULL; 25 26 // Internal Data Update 27 28 // Reset platform hierarchy seed from RNG 29 CryptGenerateRandom(PRIMARY_SEED_SIZE, gp.PPSeed.t.buffer); 30 31 // Create a new phProof value from RNG to prevent the saved platform 32 // hierarchy contexts being loaded 33 CryptGenerateRandom(PROOF_SIZE, gp.phProof.t.buffer); 34 35 // Set platform authPolicy to null 36 gc.platformAlg = TPM_ALG_NULL; 37 gc.platformPolicy.t.size = 0; 38 39 // Flush loaded object in platform hierarchy 40 ObjectFlushHierarchy(TPM_RH_PLATFORM); 41 42 // Flush platform evict object and index in NV 43 NvFlushHierarchy(TPM_RH_PLATFORM); 44 45 // Save hierarchy changes to NV 46 NvWriteReserved(NV_PP_SEED, &gp.PPSeed); 47 NvWriteReserved(NV_PH_PROOF, &gp.phProof); 48 49 // Re-initialize PCR policies 50 for(i = 0; i < NUM_POLICY_PCR_GROUP; i++) 51 { 52 gp.pcrPolicies.hashAlg[i] = TPM_ALG_NULL; 53 gp.pcrPolicies.policy[i].t.size = 0; 54 } 55 NvWriteReserved(NV_PCR_POLICIES, &gp.pcrPolicies); 56 57 // orderly state should be cleared because of the update to state clear data 58 g_clearOrderly = TRUE; 59 60 return TPM_RC_SUCCESS; 61 } 62