iaik.tc.tss.impl.java.tsp
Class TcContext

java.lang.Object
  extended by iaik.tc.tss.impl.java.tsp.TcAttributes
      extended by iaik.tc.tss.impl.java.tsp.TcWorkingObject
          extended by iaik.tc.tss.impl.java.tsp.TcContext
All Implemented Interfaces:
TcIAttributes, TcIContext, TcIWorkingObject

public class TcContext
extends TcWorkingObject
implements TcIContext


Method Summary
 void closeContext()
          This method destroys the object associated with the object handle.
 void closeObject(TcIWorkingObject obj)
          This method is used to close a given object.
 void connect()
          This method tries to connect the context to the default host (localhost).
 void connect(java.lang.String hostname)
          This method tries to connect the context to a host running a TCS service.
 TcIEncData createEncDataObject(long initFlags)
          This method returns a new encdata object.
 TcIHash createHashObject(long initFlags)
          This method returns a new hash object.
 TcIMigData createMigDataObject(long initFlags)
          This method returns a new migdata object.
 TcIPcrComposite createPcrCompositeObject(long initFlags)
          This method returns a new PCR object.
 TcIPolicy createPolicyObject(long initFlags)
          This method returns a new policy object.
 TcIRsaKey createRsaKeyObject(long initFlags)
          For general details on this method please refer to TcIContext.createRsaKeyObject(long).
 void freeMemory(long cPtr)
          Deprecated.  
 long getAttribConnectionVersion(long subFlag)
          This method returns the connection version.
 long getAttribHashMode(long subFlag)
          This method returns if secrets obtained via popups are hashed with or without null termination.
 TcBlobData getAttribMachineName(long subFlag)
          This method returns the machines host name.
 long getAttribSilentMode(long subFlag)
          This method returns the silent mode setting of the context.
 long getAttribVersionMode(long subFlag)
          This method returns the version mode setting of the context.
 TcBlobData getCapability(long capArea, TcBlobData subCap)
          This method provides the capabilities of the TSS Core Service or TSS Service Provider.
 boolean getCapabilityBoolean(long capArea, TcBlobData subCap)
          This method provides the capabilities of the TSS Core Service or TSS Service Provider.
 TcTssVersion getCapabilityVersion(long capArea, TcBlobData subCap)
          This method provides the capabilities of the TSS Core Service or TSS Service Provider.
 TcIPolicy getDefaultPolicy()
          Note: The default policy object is returned by reference.
 TcIRsaKey getKeyByPublicInfo(long stypeKey, long algId, TcBlobData publicInfo)
          This method searches the persistent storage for a registered key using the provided public key information and creates a key object initialized according to the found data.
 TcIRsaKey getKeyByUuid(long stypeKey, TcTssUuid uuidKey)
          This method searches the persistent storage for a registered key using the provided UUID and creates a key object initialized according to the found data.
 TcIMonotonicCtr getMonotonicCounters(long handle)
          This method is used to obtain a Monotonic Counter object that allows interaction with the TPM's counters.
 TcINvRam getNvRamObject(long nvIndex)
          This method is used to obtain a NV RAM object that allows interaction with the TPM's NV RAM.
 TcTssKmKeyinfo[] getRegisteredKeysByUuid(TcTssUuid uuid, long storage)
          This method gets an array of key info objects.
 TcTssKmKeyinfo[] getRegisteredKeysByUuidSystem(TcTssUuid uuid)
          This method is a wrapper for the getRegisteredKeysByUuid method.
 TcTssKmKeyinfo[] getRegisteredKeysByUuidUser(TcTssUuid uuid)
          This method is a wrapper for the getRegisteredKeysByUuid method.
 TcITcsBinding getTcsBinding()
          This method returns the underlying TCS binding.
 long getTcsContextHandle()
          This method returns the handle of the corresponding TCS context.
 TcITpm getTpmObject()
          This method is used to obtain a TPM object that allows interaction with the system's TPM.
 boolean isConnected()
          This method returns the status of the context: True is returned if the context is connected, otherwise false.
 TcIRsaKey loadKeyByBlob(TcIRsaKey unwrappingKey, TcBlobData blob)
          This method creates a key object based on the information got by the key blob and loads the key into the TPM which unwraps the key blob utilizing the key addressed by unwrappingKey.
 TcIRsaKey loadKeyByUuidFromSystem(TcTssUuid uuid)
          This method creates a key object based on the information contained in the key manager using the UUID and loads the key into the TPM.
 TcIRsaKey loadKeyByUuidFromUser(TcTssUuid uuid)
          This method creates a key object based on the information contained in the key manager using the UUID and loads the key into the TPM.
 void registerKey(TcIRsaKey key, long stypeKey, TcTssUuid uuidKey, long stypeParentKey, TcTssUuid uuidParent)
          This method registers a key in the TSS Persistent Storage database.
 void setAttribHashMode(long subflag, long attrib)
          This method is used to specify if passwords obtained via popups should be hashed with or without null termination.
 void setAttribSilentMode(long subflag, long attrib)
          This method is used to specify if GUI popups for entering passwords should be displayed or not.
 void setAttribVersionMode(long subflag, long attrib)
          This method is used to specify if 1.1 or 1.2.
 TcIRsaKey unregisterKey(long stypeKey, TcTssUuid uuidKey)
          This method unregisters a key from the persistent storage database.
 
Methods inherited from class iaik.tc.tss.impl.java.tsp.TcAttributes
getAttribData, getAttribUint32, setAttribData, setAttribUint32
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface iaik.tc.tss.api.tspi.TcIAttributes
getAttribData, getAttribUint32, setAttribData, setAttribUint32
 

Method Detail

connect

public void connect(java.lang.String hostname)
             throws TcTssException
Description copied from interface: TcIContext
This method tries to connect the context to a host running a TCS service.

Specified by:
connect in interface TcIContext
Parameters:
hostname - The name of the cost to connect to. For example "http://127.0.0.1:30004/axis/services/TSSCoreServiceBindingImpl"
Throws:
TcTssException

connect

public void connect()
             throws TcTssException
Description copied from interface: TcIContext
This method tries to connect the context to the default host (localhost).

Specified by:
connect in interface TcIContext
Throws:
TcTssException

closeContext

public void closeContext()
                  throws TcTssException
Description copied from interface: TcIContext
This method destroys the object associated with the object handle. All allocated resources (e.g. objects) associated within the object are also released.

Specified by:
closeContext in interface TcIContext
Throws:
TcTssException

closeObject

public void closeObject(TcIWorkingObject obj)
                 throws TcTssException
Description copied from interface: TcIContext
This method is used to close a given object.

Specified by:
closeObject in interface TcIContext
Parameters:
obj - The object to be closed.
Throws:
TcTssException

getTcsBinding

public TcITcsBinding getTcsBinding()
This method returns the underlying TCS binding. This method is used by internal methods only to get access to the TCS.


getTcsContextHandle

public long getTcsContextHandle()
                         throws TcTssException
This method returns the handle of the corresponding TCS context.

Throws:
TcTssException

isConnected

public boolean isConnected()
Description copied from interface: TcIContext
This method returns the status of the context: True is returned if the context is connected, otherwise false.

Specified by:
isConnected in interface TcIContext
Returns:
boolean indication connections status

freeMemory

public void freeMemory(long cPtr)
                throws TcTssException
Deprecated. 

This method is not required in a pure Java TSS implementation and therefore not supported.

Specified by:
freeMemory in interface TcIContext
Parameters:
cPtr - The memory block to be freed.
Throws:
TcTssException

getCapability

public TcBlobData getCapability(long capArea,
                                TcBlobData subCap)
                         throws TcTssException
Description copied from interface: TcIContext
This method provides the capabilities of the TSS Core Service or TSS Service Provider. This method returns the capability data as a binary blob.

Specified by:
getCapability in interface TcIContext
Parameters:
capArea - Flag indicating the attribute to query.
Valid capAreas are:
subCap - Data indicating the attribute to query.
Valid subCaps are:
Returns:
capability blob
Throws:
TcTssException

getCapabilityBoolean

public boolean getCapabilityBoolean(long capArea,
                                    TcBlobData subCap)
                             throws TcTssException
Description copied from interface: TcIContext
This method provides the capabilities of the TSS Core Service or TSS Service Provider. This method is to be used to read boolean flags.

Specified by:
getCapabilityBoolean in interface TcIContext
Parameters:
capArea - Flag indicating the attribute to query.
Valid capAreas are:
subCap - Data indicating the attribute to query.
Valid subCaps are:
Returns:
boolean value
Throws:
TcTssException

getCapabilityVersion

public TcTssVersion getCapabilityVersion(long capArea,
                                         TcBlobData subCap)
                                  throws TcTssException
Description copied from interface: TcIContext
This method provides the capabilities of the TSS Core Service or TSS Service Provider. This method is to be used to read version flags.

Specified by:
getCapabilityVersion in interface TcIContext
Parameters:
capArea - Flag indicating the attribute to query.
Valid capAreas are:
subCap - Data indicating the attribute to query
Returns:
version object
Throws:
TcTssException

createEncDataObject

public TcIEncData createEncDataObject(long initFlags)
                               throws TcTssException
Description copied from interface: TcIContext
This method returns a new encdata object. It is based on the createObject method of the TSS with TSS_OBJECT_TYPE_ENCDATA as parameter.

Specified by:
createEncDataObject in interface TcIContext
Parameters:
initFlags - is used to specify further options for the new object as defined by the TSS specification. EncData related initialization values are prefixed with TSS_ENCDATA_ and are defined in TcTssConstants.
Valid initFlags are:
Returns:
the new encdata object.
Throws:
TcTssException

createHashObject

public TcIHash createHashObject(long initFlags)
                         throws TcTssException
Description copied from interface: TcIContext
This method returns a new hash object. It is based on the createObject method of the TSS with TSS_OBJECT_TYPE_HASH as parameter.

Specified by:
createHashObject in interface TcIContext
Parameters:
initFlags - is used to specify further options for the new object as defined by the TSS specification. Hash related initialization values are prefixed with TSS_HASH_ and are defined in TcTssConstants.
Valid initFlags are:
Returns:
the new hash object.
Throws:
TcTssException

createMigDataObject

public TcIMigData createMigDataObject(long initFlags)
                               throws TcTssException
Description copied from interface: TcIContext
This method returns a new migdata object. It is based on the createObject method of the TSS with TSS_OBJECT_TYPE_MIGDATA as parameter.

Specified by:
createMigDataObject in interface TcIContext
Parameters:
initFlags - is used to specify further options for the new object as defined by the TSS specification. Note: For TSS version 1.2 there is no migdata related init flag defined. Consequently, 0 should be used as initFlags parameter.
Returns:
the new migdata object.
Throws:
TcTssException

createPcrCompositeObject

public TcIPcrComposite createPcrCompositeObject(long initFlags)
                                         throws TcTssException
Description copied from interface: TcIContext
This method returns a new PCR object. It is based on the createObject method of the TSS with TSS_OBJECT_TYPE_PCRS as parameter.

Specified by:
createPcrCompositeObject in interface TcIContext
Parameters:
initFlags - is used to specify further options for the new object as defined by the TSS specification. Note: For TSS version 1.1 there is no PCR related init flag defined. Consequently, 0 should be used as initFlags parameter.
Returns:
the new pcr object
Throws:
TcTssException

createPolicyObject

public TcIPolicy createPolicyObject(long initFlags)
                             throws TcTssException
Description copied from interface: TcIContext
This method returns a new policy object. It is based on the createObject method of the TSS with TSS_OBJECT_TYPE_POLICY as parameter.

Specified by:
createPolicyObject in interface TcIContext
Parameters:
initFlags - is used to specify further options for the new object as defined by the TSS specification. Policy related initialization values are prefixed with TSS_POLICY_ and are defined in TcTssConstants.
Valid initFlags are:
Returns:
the new policy object.
Throws:
TcTssException

createRsaKeyObject

public TcIRsaKey createRsaKeyObject(long initFlags)
                             throws TcTssException
For general details on this method please refer to TcIContext.createRsaKeyObject(long).
Implementation specific note: The TSS specification states that upon creation of new working objects, these objects are assigned to the default policy of the TSS. The specification however leaves room for interpretation if new working objects get a copy of the default policy of the context or if all working objects share the same policy object. For this implementation it has been opted to go with the first variant, namely that working objects are assigned a real copy of the current default policy of the context.

Specified by:
createRsaKeyObject in interface TcIContext
Parameters:
initFlags - is used to specify further options for the new object as defined by the TSS specification. Key related initialization values are prefixed with TSS_KEY_ and are defined in TcTssConstants.
Valid initFlags are:
Returns:
The new key object.
Throws:
TcTssException

getDefaultPolicy

public TcIPolicy getDefaultPolicy()
                           throws TcTssException
Note: The default policy object is returned by reference. For general documentation of this method refer to TcIContext.getDefaultPolicy().

Specified by:
getDefaultPolicy in interface TcIContext
Returns:
The default policy object bound to the context.
Throws:
TcTssException

getKeyByPublicInfo

public TcIRsaKey getKeyByPublicInfo(long stypeKey,
                                    long algId,
                                    TcBlobData publicInfo)
                             throws TcTssException
Description copied from interface: TcIContext
This method searches the persistent storage for a registered key using the provided public key information and creates a key object initialized according to the found data. On successful completion of the method a handle to the created new key object is returned. NOTE: The returned key structure does not carry a UUID.

Specified by:
getKeyByPublicInfo in interface TcIContext
Parameters:
stypeKey - Flag indicating the persistent storage.
algId - Parameter indicates the algorithm of the requested key.
publicInfo - Public key info provided to identify the key to be looked for.
Returns:
Object representing the key.
Throws:
TcTssException

getKeyByUuid

public TcIRsaKey getKeyByUuid(long stypeKey,
                              TcTssUuid uuidKey)
                       throws TcTssException
Description copied from interface: TcIContext
This method searches the persistent storage for a registered key using the provided UUID and creates a key object initialized according to the found data. On successful completion of the method a handle to the created new key object is returned.

Specified by:
getKeyByUuid in interface TcIContext
Parameters:
stypeKey - Flag indicating the persistent storage
uuidKey - UUID of the key by which the key was registered in the persistent storage
Returns:
key object representing the key
Throws:
TcTssException

getRegisteredKeysByUuid

public TcTssKmKeyinfo[] getRegisteredKeysByUuid(TcTssUuid uuid,
                                                long storage)
                                         throws TcTssException
Description copied from interface: TcIContext
This method gets an array of key info objects. This information reflects the registered key hierarchy. The keys stored in the persistent storage are totally independent from either the context of the function call or the context, which was provided while processing the key registration.

Specified by:
getRegisteredKeysByUuid in interface TcIContext
Parameters:
uuid - The UUID the key was registered in the persistent storage. If no key UUID is provided (null), the returned key info array contains data reflecting the whole key hierarchy starting with the root key. If a certain key UUID is provided, the returned array only contains data reflecting the path of the key hierarchy regarding that key. The first array entry is the key addressed by the given UUID followed by its parent key up to the root key.
storage - Flag indicating the persistent storage the key is registered in (TcTssConstatnts.TSS_PS_TYPE_*).
Returns:
Array containing the actual key hierarchy data
Throws:
TcTssException

getRegisteredKeysByUuidSystem

public TcTssKmKeyinfo[] getRegisteredKeysByUuidSystem(TcTssUuid uuid)
                                               throws TcTssException
Description copied from interface: TcIContext
This method is a wrapper for the getRegisteredKeysByUuid method. The storage type is set to TSS_PS_TYPE_SYSTEM.

Specified by:
getRegisteredKeysByUuidSystem in interface TcIContext
Parameters:
uuid - (see getRegisteredKeysByUuid)
Returns:
(see getRegisteredKeysByUuid)
Throws:
TcTssException

getRegisteredKeysByUuidUser

public TcTssKmKeyinfo[] getRegisteredKeysByUuidUser(TcTssUuid uuid)
                                             throws TcTssException
Description copied from interface: TcIContext
This method is a wrapper for the getRegisteredKeysByUuid method. The storage type is set to TSS_PS_TYPE_USER.

Specified by:
getRegisteredKeysByUuidUser in interface TcIContext
Parameters:
uuid - (see getRegisteredKeysByUuid)
Returns:
(see getRegisteredKeysByUuid)
Throws:
TcTssException

getTpmObject

public TcITpm getTpmObject()
                    throws TcTssException
Description copied from interface: TcIContext
This method is used to obtain a TPM object that allows interaction with the system's TPM.

Specified by:
getTpmObject in interface TcIContext
Returns:
TPM object representing the system's TPM
Throws:
TcTssException

loadKeyByBlob

public TcIRsaKey loadKeyByBlob(TcIRsaKey unwrappingKey,
                               TcBlobData blob)
                        throws TcTssException
Description copied from interface: TcIContext
This method creates a key object based on the information got by the key blob and loads the key into the TPM which unwraps the key blob utilizing the key addressed by unwrappingKey. The key addressed by unwrappingKey must have been loaded previously into the TPM.

Specified by:
loadKeyByBlob in interface TcIContext
Parameters:
unwrappingKey - Key to unwrap the blob.
blob - Wrapped key blob to load.
Returns:
The created key object.
Throws:
TcTssException

loadKeyByUuidFromSystem

public TcIRsaKey loadKeyByUuidFromSystem(TcTssUuid uuid)
                                  throws TcTssException
Description copied from interface: TcIContext
This method creates a key object based on the information contained in the key manager using the UUID and loads the key into the TPM. The persistent storage provides all information to load the parent keys required to load the key associated with the given UUID. This method tries to load the requested key from the system storage.

Specified by:
loadKeyByUuidFromSystem in interface TcIContext
Parameters:
uuid - UUID of the key to be loaded.
Returns:
key object representing the loaded key
Throws:
TcTssException

loadKeyByUuidFromUser

public TcIRsaKey loadKeyByUuidFromUser(TcTssUuid uuid)
                                throws TcTssException
Description copied from interface: TcIContext
This method creates a key object based on the information contained in the key manager using the UUID and loads the key into the TPM. The persistent storage provides all information to load the parent keys required to load the key associated with the given UUID. This method tries to load the requested key from the user storage.

Specified by:
loadKeyByUuidFromUser in interface TcIContext
Parameters:
uuid - UUID of the key to be loaded.
Returns:
key object representing the loaded key
Throws:
TcTssException

registerKey

public void registerKey(TcIRsaKey key,
                        long stypeKey,
                        TcTssUuid uuidKey,
                        long stypeParentKey,
                        TcTssUuid uuidParent)
                 throws TcTssException
Description copied from interface: TcIContext
This method registers a key in the TSS Persistent Storage database.

Specified by:
registerKey in interface TcIContext
Parameters:
key - Handle of the key object addressing the key to be registered.
stypeKey - Flag indicating the persistent storage
uuidKey - UUID by which the key is registered in the persistent storage
stypeParentKey - Flag indicating the persistent storage
uuidParent - UUID by which the parent key was registered in the persistent storage
Throws:
TcTssException

unregisterKey

public TcIRsaKey unregisterKey(long stypeKey,
                               TcTssUuid uuidKey)
                        throws TcTssException
Description copied from interface: TcIContext
This method unregisters a key from the persistent storage database.

Specified by:
unregisterKey in interface TcIContext
Parameters:
stypeKey - Flag indicating the persistent storage
uuidKey - UUID of the key to be removed from the persistent storage
Returns:
key object containing the info from the archive
Throws:
TcTssException

setAttribSilentMode

public void setAttribSilentMode(long subflag,
                                long attrib)
                         throws TcTssException
This method is used to specify if GUI popups for entering passwords should be displayed or not. By default, popups will be displayed. This method is an alternative to using TcIAttributes.setAttribUint32(long, long, long). Note that this method is not standardized as part of the TSP Interface (TSPI).

Parameters:
subflag - Ignored (set to 0).
attrib - Either TcTssConstants.TSS_TSPATTRIB_CONTEXT_SILENT or TcTssConstants.TSS_TSPATTRIB_CONTEXT_NOT_SILENT.
Throws:
TcTssException

getAttribSilentMode

public long getAttribSilentMode(long subFlag)
                         throws TcTssException
This method returns the silent mode setting of the context. This method is an alternative to using TcIAttributes.getAttribUint32(long, long).

Parameters:
subFlag - Ignored (set to 0).
Returns:
Either TcTssConstants.TSS_TSPATTRIB_CONTEXT_SILENT or TcTssConstants.TSS_TSPATTRIB_CONTEXT_NOT_SILENT.
Throws:
TcTssException

setAttribVersionMode

public void setAttribVersionMode(long subflag,
                                 long attrib)
                          throws TcTssException
This method is used to specify if 1.1 or 1.2. data structures should be created. The default setting are 1.1 data structures. This method is an alternative to using TcIAttributes.setAttribUint32(long, long, long).

Parameters:
subflag - Ignored (set to 0).
attrib - Either TcTssConstants.TSS_TSPATTRIB_CONTEXT_VERSION_V1_1 or TcTssConstants.TSS_TSPATTRIB_CONTEXT_VERSION_V1_2 or TcTssConstants.TSS_TSPATTRIB_CONTEXT_VERSION_AUTO.
Throws:
TcTssException

getAttribVersionMode

public long getAttribVersionMode(long subFlag)
                          throws TcTssException
This method returns the version mode setting of the context. The version mode determines if 1.1 or 1.2 data structures are created. This method is an alternative to using TcIAttributes.getAttribUint32(long, long).

Parameters:
subFlag - Ignored (set to 0).
Returns:
Either TcTssConstants.TSS_TSPATTRIB_CONTEXT_VERSION_V1_1 or TcTssConstants.TSS_TSPATTRIB_CONTEXT_VERSION_V1_2 or TcTssConstants.TSS_TSPATTRIB_CONTEXT_VERSION_AUTO.
Throws:
TcTssException

setAttribHashMode

public void setAttribHashMode(long subflag,
                              long attrib)
                       throws TcTssException
This method is used to specify if passwords obtained via popups should be hashed with or without null termination. This method is an alternative to using TcIAttributes.setAttribUint32(long, long, long).

Parameters:
subflag - TcTssConstants.TSS_TSPATTRIB_SECRET_HASH_MODE_POPUP
attrib - Either TcTssConstants.TSS_TSPATTRIB_HASH_MODE_NOT_NULL or TcTssConstants.TSS_TSPATTRIB_HASH_MODE_NULL.
Throws:
TcTssException

getAttribHashMode

public long getAttribHashMode(long subFlag)
                       throws TcTssException
This method returns if secrets obtained via popups are hashed with or without null termination. This method is an alternative to using TcIAttributes.getAttribUint32(long, long).

Parameters:
subFlag - TcTssConstants.TSS_TSPATTRIB_SECRET_HASH_MODE_POPUP
Returns:
Either TcTssConstants.TSS_TSPATTRIB_HASH_MODE_NOT_NULL or TcTssConstants.TSS_TSPATTRIB_HASH_MODE_NULL.
Throws:
TcTssException

getAttribConnectionVersion

public long getAttribConnectionVersion(long subFlag)
                                throws TcTssException
This method returns the connection version. The version indicates if 1.1 or 1.2 features are supported by the underlying TCS and TPM. This method is an alternative to using TcIAttributes.getAttribUint32(long, long).

Parameters:
subFlag - Ignored (set to 0).
Returns:
Either TcTssConstants.TSS_CONNECTION_VERSION_1_1 or TcTssConstants.TSS_CONNECTION_VERSION_1_2.
Throws:
{@link - TcTssException}
TcTssException

getAttribMachineName

public TcBlobData getAttribMachineName(long subFlag)
                                throws TcTssException
This method returns the machines host name. This method is an alternative to using TcIAttributes.getAttribUint32(long, long).

Parameters:
subFlag - Ignored (set to 0).
Returns:
The host name of the machine.
Throws:
{@link - TcTssException}
TcTssException

getMonotonicCounters

public TcIMonotonicCtr getMonotonicCounters(long handle)
                                     throws TcTssException
Description copied from interface: TcIContext
This method is used to obtain a Monotonic Counter object that allows interaction with the TPM's counters.

Specified by:
getMonotonicCounters in interface TcIContext
Returns:
Ctr object representing the system's montonic counters
Throws:
TcTssException

getNvRamObject

public TcINvRam getNvRamObject(long nvIndex)
                        throws TcTssException
Description copied from interface: TcIContext
This method is used to obtain a NV RAM object that allows interaction with the TPM's NV RAM.

Specified by:
getNvRamObject in interface TcIContext
Returns:
an object representing the system's NV-RAM
Throws:
TcTssException