iaik.tc.tss.impl.java.tcs.sessmgr
Class TcTcsSessManager

java.lang.Object
  extended by iaik.tc.tss.impl.java.tcs.sessmgr.TcTcsSessManager

public class TcTcsSessManager
extends java.lang.Object

The functionality provided by this class is only usable by TPMs conforming to the version 1.2 of the TPM specification! This class implements the management of saved TPM sessions as specified in the 1.2 TPM specification. Sessions can be exported from the TPM via the TPM_SaveContext command and re-loaded into the TPM using the TPM_LoadContext command. The number of sessions that can be saved is limited by the size of contextList[]. This is a list kept inside the TPM that holds contextCound values. All sessions exported from the TPM are assigned such a contextCount value which is not allowed to wrap. Note: The following resource types are handled in contextList: TPM_RT_AUTH, TPM_RT_TRANS, TPM_RT_DAA_TPM. Keys (TPM_RT_KEY) are NOT handled in this list. That means that the size limitation of contextList does NOT apply to keys exported (via SaveContext) from the TPM.


Constructor Summary
TcTcsSessManager()
           
 
Method Summary
 void addSavedSession(TcTpmContextBlob blob)
          This method adds a session to the list of saved sessions.
 void evictAllSavedSessions()
          This method evicts all saved context sessions from the TPM.
 void evictAllSavedSessions(TcTddl tddl)
          This method evicts all saved context sessions from the TPM.
 boolean evictOldestSavedSess(long[] notHandles)
          According to the TPM 1.2 spec, a TPM can only hold a limited amount of saved sessions (this is limited by the size of contextList inside the TPM).
 boolean evictOldestSavedSess(long resType, long[] notHandles)
          According to the TPM 1.2 spec, a TPM can only hold a limited amount of saved sessions (this is limited by the size of contextList inside the TPM).
static TcTcsSessManager getInstance()
          This class can only be instantiated once (Singleton).
 long getNumFreeSavedSessSlots()
          This method returns the number of free (available) slots for saved contexts inside the TPM.
 boolean handleIsInCache(long resType, long handle)
          This method checks if an entity with the given resource type and handle is in the cache.
 long loadSession(long resType, long handle)
          This method loads a saved session into the TPM.
 java.lang.String savedSessionsToString()
          This method is designed for debug purposes.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TcTcsSessManager

public TcTcsSessManager()
Method Detail

getInstance

public static TcTcsSessManager getInstance()
This class can only be instantiated once (Singleton).


evictAllSavedSessions

public void evictAllSavedSessions()
                           throws TcTddlException,
                                  TcTpmException
This method evicts all saved context sessions from the TPM. The TSS is supposed to have full control of the TPM. No other entity than the TSS is responsible for managing sessions. Consequently, the TSS flushes all old saved context sessions before taking control of the saved context slots.

Throws:
TcTddlException
TcTpmException

evictAllSavedSessions

public void evictAllSavedSessions(TcTddl tddl)
                           throws TcTddlException,
                                  TcTpmException
This method evicts all saved context sessions from the TPM. The TSS is supposed to have full control of the TPM. No other entity than the TSS is responsible for managing sessions. Consequently, the TSS flushes all old saved context sessions before taking control of the saved context slots.

Throws:
TcTddlException
TcTpmException

addSavedSession

public void addSavedSession(TcTpmContextBlob blob)
This method adds a session to the list of saved sessions. This method is called whenever a session had to be swapped out of the TPM due to space limitations.

Parameters:
blob - The saved context blob that was exported from the TPM.

getNumFreeSavedSessSlots

public long getNumFreeSavedSessSlots()
                              throws TcTddlException,
                                     TcTpmException
This method returns the number of free (available) slots for saved contexts inside the TPM. The TPM keeps track of saved context sessions in an internal list called contextList which is is finite.

Returns:
The number of free slots for saved sessions.
Throws:
TcTddlException
TcTpmException

evictOldestSavedSess

public boolean evictOldestSavedSess(long resType,
                                    long[] notHandles)
                             throws TcTddlException,
                                    TcTpmException
According to the TPM 1.2 spec, a TPM can only hold a limited amount of saved sessions (this is limited by the size of contextList inside the TPM). If the list of saved context sessions can not hold any further sessions (i.e. numFreeContextSlots return 0) no more sessions can be swapped out of the TPM. In such a case, this method allows to evict the oldest saved session to free up space in the list of saved sessions. This method deletes a sessions bases on a given resource type. The session is removed from the internal list as well as from the TPM.

Parameters:
resType - The resource type of the session to be removed.
notHandles - With this parameter, the caller can specify a handle that MUST not be removed even if it is the oldest handle of the given resource type. If passing -1 (invalid handle) as notHandle, this parameter has no effect.
Returns:
If a handle matching the given resource type that does not match notHande could be found and successfully remove, true is returned. If no such handle could be found, false is returned.
Throws:
TcTddlException
TcTpmException

evictOldestSavedSess

public boolean evictOldestSavedSess(long[] notHandles)
                             throws TcTddlException,
                                    TcTpmException
According to the TPM 1.2 spec, a TPM can only hold a limited amount of saved sessions (this is limited by the size of contextList inside the TPM). If the list of saved context sessions can not hold any further sessions (i.e. numFreeContextSlots return 0) no more sessions can be swapped out of the TPM. In such a case, this method allows to evict the oldest saved session to free up space in the list of saved sessions. The session is removed from the internal list as well as from the TPM.

Parameters:
notHandles - With this parameter, the caller can specify handles that MUST not be removed even if they are the oldest handles of the given resource type. If passing an empty array as notHandles, this parameter has no effect.
Returns:
If a handle that does not match notHande could be found and successfully remove, true is returned. If no such handle could be found, false is returned.
Throws:
TcTddlException
TcTpmException

loadSession

public long loadSession(long resType,
                        long handle)
                 throws TcTddlException,
                        TcTpmException,
                        TcTcsException
This method loads a saved session into the TPM. It is assumed that there is enough space to load the session. This method will not attempt to free space inside the TPM if the session can not be loaded. If not enough space is available, this is indicated by a TcTpmException.

Parameters:
resType - The resource type of the session to be loaded.
handle - The handle of the session to be reloaded.
Returns:
When reloading sessions, the TPM may assign a new handle to the reloaded session. The session handle assigned by the TPM is returned by this method.
Throws:
TcTddlException
TcTpmException
TcTcsException - This exception is thrown if the given resource type/handle combination could not be found in the cache.

handleIsInCache

public boolean handleIsInCache(long resType,
                               long handle)
This method checks if an entity with the given resource type and handle is in the cache.


savedSessionsToString

public java.lang.String savedSessionsToString()
                                       throws TcTddlException,
                                              TcTpmException
This method is designed for debug purposes. It returns a String holding the saved sessions as reported by the TPM and as stored in the session cache.

Throws:
TcTddlException
TcTpmException