C# Class Tpm2Lib.Tbs

Instances of the class TPM are created on top of TPM devices (either a physical TPM, or another Tbs) via new Tbs(theTpmDevice). TPM device contexts are then typically created through GetTpm(int locality).
Inheritance: IDisposable
Show file Open project: Microsoft/TSS.MSR Class Usage Examples

Public Methods

Method Description
DebugAssertTpmIsEmpty ( ) : void
DestroyContext ( Tpm2Lib.Tpm2Device tpmDevice ) : void
Dispose ( ) : void
DisposeContext ( TbsContext c ) : void

Removes all TPM objects referenced by this context and then removes the context from the TBS database.

GetFreeSessionCount ( ) : int
GetSessionCount ( int &savedSessionCount ) : int
GetUnderlyingTpm ( ) : Tpm2
NumActiveContexts ( ) : int
NumEntitiesInTpm ( ) : int
SetS3Probability ( double probability ) : void

If probability is not 0.0, the SlotManager will randomly cycle the TPM through a simulated S3 transition at the start of DispatchCommand (before the requested command is invoked).

Tbs ( Tpm2Lib.Tpm2Device theUnderlyingTpm, bool tpmHasRm ) : System

Private Methods

Method Description
CheckConsistency ( string message = "" ) : void
CleanTpm ( ) : void
ContextSaveEverything ( ) : void
CreateTbsContext ( ) : TbsContext
DebugStateSave ( ) : void
DispatchCommand ( TbsContext caller, Tpm2Lib.CommandModifier active, byte inBuf, byte &outBuf ) : void

Dispatch a command to the underlying TPM. This method implements all significant functionality. DispatchCommand examines the command stream and performs (approximately) the following functions 1) If the command references a handle (session or transient object) then TBS makes sure that the entity is loaded. If it is, then the handle is "translated" to the underlying TPM handle. If it is not, then TBS checks to see if it has a saved context for the entity, and if so loads it. 2) If the command will fill a slot, then TBS ensures that a slot is available. It does this by ContextSaving the LRU entity of the proper type (that is not used in this command).

FormatError ( TpmRc errorCode ) : byte[]

Create a 10 byte error response that matches TPM error responses.

GetAllLoadedEntities ( Tpm2 tpm ) : Tpm2Lib.TpmHandle[]
GetLoadedEntities ( Tpm2 tpm, Ht rangeToQuery ) : Tpm2Lib.TpmHandle[]
GetReferencedObjects ( TbsContext caller, TpmHandle inHandles ) : Tpm2Lib.ObjectContext[]

Look up TBS ObjectContext records given the handles in the inHandles input parms.

GetResultCode ( byte responseBuf ) : TpmRc
GetSessions ( TbsContext caller, SessionIn inSessions ) : Tpm2Lib.ObjectContext[]

Get the TBS ObjectContext given SessionIn objects collected from the inputs stream.

LoadEntities ( ObjectContext neededContexts ) : bool

Ensure that all referenced objects are loaded.

LoadObject ( ObjectContext contextToLoad, ObjectContext doNotEvict ) : bool

Load an object making a space if needed. If we need to make a space then we are mindful not to evict anything in the doNotEvict array.

MakeSpace ( SlotType neededSlot, ObjectContext doNotEvict ) : bool

Make a space in the TPM for an entity of type neededSlot (while not evicting another needed entity)

ProcessUpdatedTpmState ( TbsContext caller, Tpm2Lib.CommandInfo command, TpmHandle responseHandles, ObjectContext inputObjects ) : void

Updates TBS context database for commands that either fill or empty slots.

ReplaceHandlesIn ( TpmHandle handles, SessionIn sessions, ObjectContext theObjects, ObjectContext theSessions ) : void

Modifies the handles and sessions arrays so that they contain the translated handles.

ReplaceHandlesOut ( IEnumerable outHandles ) : void
SlotTypeFromHandle ( TpmHandle h ) : SlotType
StateSaveAndReload ( bool startupState, bool doPowerCycle ) : void

TPM Debug support. Cycle the TPM through (a) SaveContext all loaded contexts, (b) StateSave(), (c) powerOff, (d) powerOn (e) Startup(SU_State) or Startup(S_CLEAR). Then needed objects and sessions will be paged back in as needed. This command is NOT thread safe. This command has side-effects on the startup counter and will likely result in clock discontinuities.

UpdateLastUseCount ( IEnumerable entities ) : void

Method Details

DebugAssertTpmIsEmpty() public method

public DebugAssertTpmIsEmpty ( ) : void
return void

DestroyContext() public method

public DestroyContext ( Tpm2Lib.Tpm2Device tpmDevice ) : void
tpmDevice Tpm2Lib.Tpm2Device
return void

Dispose() public method

public Dispose ( ) : void
return void

DisposeContext() public method

Removes all TPM objects referenced by this context and then removes the context from the TBS database.
public DisposeContext ( TbsContext c ) : void
c TbsContext
return void

GetFreeSessionCount() public method

public GetFreeSessionCount ( ) : int
return int

GetSessionCount() public method

public GetSessionCount ( int &savedSessionCount ) : int
savedSessionCount int
return int

GetUnderlyingTpm() public method

public GetUnderlyingTpm ( ) : Tpm2
return Tpm2

NumActiveContexts() public method

public NumActiveContexts ( ) : int
return int

NumEntitiesInTpm() public method

public NumEntitiesInTpm ( ) : int
return int

SetS3Probability() public method

If probability is not 0.0, the SlotManager will randomly cycle the TPM through a simulated S3 transition at the start of DispatchCommand (before the requested command is invoked).
public SetS3Probability ( double probability ) : void
probability double
return void

Tbs() public method

public Tbs ( Tpm2Lib.Tpm2Device theUnderlyingTpm, bool tpmHasRm ) : System
theUnderlyingTpm Tpm2Lib.Tpm2Device
tpmHasRm bool
return System