/// <summary> /// This sample demonstrates how the caller can control simulated power, locality /// and physical-presence against the simulated TPM /// </summary> /// <param name="tpm">Reference to the TPM object.</param> static void PowerAndLocality(Tpm2 tpm) { // // Do a complete simulated clean power-down // tpm.Shutdown(Su.Clear); tpm._GetUnderlyingDevice().PowerCycle(); tpm.Startup(Su.Clear); Console.WriteLine("Power cycle with TPM2_Startup(CLEAR) completed."); // // Now do a simulated hibernate // tpm.Shutdown(Su.State); tpm._GetUnderlyingDevice().PowerCycle(); tpm.Startup(Su.State); Console.WriteLine("Power cycle with TPM2_Startup(STATE) completed."); // // Execute a command at locality 2 // tpm._SetLocality(LocalityAttr.TpmLocTwo); tpm[_nullAuth].PcrReset(TpmHandle.Pcr(21)); tpm._SetLocality(LocalityAttr.TpmLocZero); Console.WriteLine("PCR[21] for locality 2 reset."); // // Execute a command that needs physical-presence // tpm._AssertPhysicalPresence(true); tpm[_nullAuth].PpCommands(TpmHandle.RhPlatform, new TpmCc[0], new TpmCc[0]); tpm._AssertPhysicalPresence(false); Console.WriteLine("Physical presence commands tested."); }