/// <summary>
/// Copies parameters associated with the session handle encapsulated in the
/// sess argument into the sess object. These parameters are the ones passed
/// to the StartAuthSession command. They are remembered by this Tpm2 object,
/// until this method is called.
///
/// Note that _InitializeSession() can be used only once for the given session
/// handle, as the associated parameters are erased from Tpm2 Object after
/// they were copied into AuthSession object for the first time.
/// </summary>
/// <param name="sess"></param>
internal bool _InitializeSession(AuthSession sess)
{
if (!sess.Initialized())
{
if (!SessionParams.ContainsKey(sess))
{
// There are no session parameters associated with the session
// handle (e.g., when the session was created by other Tpm2 object).
return false;
}
sess.Init(SessionParams[sess]);
sess.CalcSessionKey();
SessionParams.Remove(sess);
}
return true;
}