C# Class Tpm2Lib.AuthSession

AuthSession encapsulates HMAC, policy, encryption/decryption, and audit sessions, i.e. all session types that are represented by a TPM handle created by means of TPM2_StartAuthSession command.
Inheritance: SessionBase
Show file Open project: Microsoft/TSS.MSR Class Usage Examples

Public Properties

Property Type Description
Attrs SessionAttr
AuthHash TpmAlgId
BindObject TpmHandle
NonceCaller byte[]
NonceTpm byte[]
Salt byte[]
SessionKey byte[]
SessionType TpmSe
Symmetric SymDef

Public Methods

Method Description
AuthSession ( ParametrizedHandle ph ) : System
AuthSession ( TpmHandle h ) : System

Constructs an object encapsulating a session opened in TPM. The Tpm2 object that was used to create the session tracks other information associated with it and uses it to compute session key and command/response HMAC.

NewNonceCaller ( ) : void
RunPolicy ( Tpm2 tpm, PolicyTree policyTree, string branchToEvaluate = null, bool allowErrors = false ) : TpmRc

Run a path on the policy tree. The path is identified by the leaf identifier string. A session is created and returned. If allowErrors is true then errors returned do not cause an exception (but are returned in the response code).

SetNonceTpm ( byte nonceTpm ) : void

Protected Methods

Method Description
AuthSession ( ) : System

Private Methods

Method Description
AuthSession ( TpmSe sessionType, TpmHandle tpmKey, TpmHandle bindObject, byte nonceCaller, byte nonceTpm, SymDef symmetric, TpmAlgId authHash ) : System

Constructs a temporary object to hold parameters of a session. Intended only for internal use by the Tpm2 class.

CalcSessionKey ( ) : void

Calculate the session-key from the nonces and salt/bound values (if present)

CanEncrypt ( ) : bool

Checks whether the given session can be used for parameter encryption.

GetAuthHmac ( byte parmHash, Direction direction, byte nonceDec = null, byte nonceEnc = null ) : byte[]

Calculate and return the auth-hmac (or plaintext auth if it is a policy session with PlaintextAuth set) based on the current session parms.

Init ( AuthSession Params ) : void

Sets parameters associated with the session.

Initialized ( ) : bool

Returns true if the parameters associated with the session context in TPM have been set in this object.

ParmEncrypt ( byte parm, Direction inOrOut ) : byte[]

Method Details

AuthSession() protected method

protected AuthSession ( ) : System
return System

AuthSession() public method

public AuthSession ( ParametrizedHandle ph ) : System
ph ParametrizedHandle
return System

AuthSession() public method

Constructs an object encapsulating a session opened in TPM. The Tpm2 object that was used to create the session tracks other information associated with it and uses it to compute session key and command/response HMAC.
public AuthSession ( TpmHandle h ) : System
h TpmHandle
return System

NewNonceCaller() public method

public NewNonceCaller ( ) : void
return void

RunPolicy() public method

Run a path on the policy tree. The path is identified by the leaf identifier string. A session is created and returned. If allowErrors is true then errors returned do not cause an exception (but are returned in the response code).
public RunPolicy ( Tpm2 tpm, PolicyTree policyTree, string branchToEvaluate = null, bool allowErrors = false ) : TpmRc
tpm Tpm2
policyTree PolicyTree
branchToEvaluate string
allowErrors bool
return TpmRc

SetNonceTpm() public method

public SetNonceTpm ( byte nonceTpm ) : void
nonceTpm byte
return void

Property Details

Attrs public property

public SessionAttr Attrs
return SessionAttr

AuthHash public property

Hash algorithm used by this session.
public TpmAlgId AuthHash
return TpmAlgId

BindObject public property

public TpmHandle,Tpm2Lib BindObject
return TpmHandle

NonceCaller public property

public byte[] NonceCaller
return byte[]

NonceTpm public property

public byte[] NonceTpm
return byte[]

Salt public property

public byte[] Salt
return byte[]

SessionKey public property

public byte[] SessionKey
return byte[]

SessionType public property

public TpmSe SessionType
return TpmSe

Symmetric public property

Symmetric cipher to be used for encrypting and decrypting sessions.
public SymDef,Tpm2Lib Symmetric
return SymDef