de.datenzone.tpm4java
Class TPMKeyWrapper

java.lang.Object
  extended by de.datenzone.tpm4java.TPMKeyWrapper
All Implemented Interfaces:
java.io.Serializable

public class TPMKeyWrapper
extends java.lang.Object
implements java.io.Serializable

A wrapper for a key which was generated by the tpm. Besides the readable public part of the key, the encrypted private key is also included.

Author:
Martin Hermanowski.
See Also:
Serialized Form

Field Summary
static short KEYFLAG_MIGRATABLE
           
static short TPM_KEY_AUTHCHANGE
           
static short TPM_KEY_BIND
           
static short TPM_KEY_IDENTITY
           
static short TPM_KEY_LEGACY
           
static short TPM_KEY_SIGNING
           
static short TPM_KEY_STORAGE
           
 
Constructor Summary
TPMKeyWrapper()
          Create an empty key wrapper
TPMKeyWrapper(byte[] raw)
          parse a TPM structure and create a new key wrapper
TPMKeyWrapper(java.nio.ByteBuffer raw)
          parse a TPM structure and create a new key wrapper
 
Method Summary
 byte[] buildBuffer(boolean pcr_present)
          Create a native TPM key structure
 byte[] buildBuffer12(boolean pcr_present)
          like buildBuffer, but create a TPM_KEY12 structure instead.
 byte[] getEncprivkey()
           
 int getKeyflags()
           
 short getKeyusage()
           
 TPMPubKeyWrapper getPub()
           
 byte[] getRaw()
           
 int getVersion()
           
 boolean isAuthdatausage()
           
 void setAuthdatausage(boolean authdatausage)
           
 void setEncprivkey(byte[] encprivkey)
           
 void setKeyflag(short flag)
          Set a key flag
 void setKeyflags(int keyflags)
           
 void setKeyusage(short keyusage)
           
 void setPub(TPMPubKeyWrapper pub)
           
 void setVersion(int version)
           
static TPMKeyWrapper templateAIK()
          Create a template for a attestation identity key
static TPMKeyWrapper templateBind()
          Create a template for a binding (aka encryption) key
static TPMKeyWrapper templateLegacy()
          Create a template for a legacy (ie. encryption and signing) key
static TPMKeyWrapper templateSigning()
          Create a template for a signing key
static TPMKeyWrapper templateStorage()
          Create a template for a storage key
 java.lang.String toString()
           
 void unsetKeyflag(short flag)
          unset a key flag
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

KEYFLAG_MIGRATABLE

public static final short KEYFLAG_MIGRATABLE
See Also:
Constant Field Values

TPM_KEY_SIGNING

public static final short TPM_KEY_SIGNING
See Also:
Constant Field Values

TPM_KEY_STORAGE

public static final short TPM_KEY_STORAGE
See Also:
Constant Field Values

TPM_KEY_IDENTITY

public static final short TPM_KEY_IDENTITY
See Also:
Constant Field Values

TPM_KEY_AUTHCHANGE

public static final short TPM_KEY_AUTHCHANGE
See Also:
Constant Field Values

TPM_KEY_BIND

public static final short TPM_KEY_BIND
See Also:
Constant Field Values

TPM_KEY_LEGACY

public static final short TPM_KEY_LEGACY
See Also:
Constant Field Values
Constructor Detail

TPMKeyWrapper

public TPMKeyWrapper()
Create an empty key wrapper


TPMKeyWrapper

public TPMKeyWrapper(byte[] raw)
parse a TPM structure and create a new key wrapper

Parameters:
raw -

TPMKeyWrapper

public TPMKeyWrapper(java.nio.ByteBuffer raw)
parse a TPM structure and create a new key wrapper

Parameters:
raw -
Method Detail

setKeyflag

public void setKeyflag(short flag)
Set a key flag

Parameters:
flag -

unsetKeyflag

public void unsetKeyflag(short flag)
unset a key flag

Parameters:
flag -

setAuthdatausage

public void setAuthdatausage(boolean authdatausage)

buildBuffer

public byte[] buildBuffer(boolean pcr_present)
Create a native TPM key structure

Parameters:
pcr_present - whether a PCRInfo field should be present
Returns:
the blob

buildBuffer12

public byte[] buildBuffer12(boolean pcr_present)
like buildBuffer, but create a TPM_KEY12 structure instead. The only difference is, that, instead of the version, TPM_TAG_KEY12 and two 0 bytes make up the first 4 bytes.

Parameters:
pcr_present -
Returns:

getEncprivkey

public byte[] getEncprivkey()

setEncprivkey

public void setEncprivkey(byte[] encprivkey)

getKeyflags

public int getKeyflags()

setKeyflags

public void setKeyflags(int keyflags)

getKeyusage

public short getKeyusage()

setKeyusage

public void setKeyusage(short keyusage)

getVersion

public int getVersion()

setVersion

public void setVersion(int version)

isAuthdatausage

public boolean isAuthdatausage()

getPub

public TPMPubKeyWrapper getPub()

setPub

public void setPub(TPMPubKeyWrapper pub)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

templateStorage

public static TPMKeyWrapper templateStorage()
Create a template for a storage key

Returns:
the newly created template

templateSigning

public static TPMKeyWrapper templateSigning()
Create a template for a signing key

Returns:
the newly created template

templateBind

public static TPMKeyWrapper templateBind()
Create a template for a binding (aka encryption) key

Returns:
the newly created template

templateLegacy

public static TPMKeyWrapper templateLegacy()
Create a template for a legacy (ie. encryption and signing) key

Returns:
the newly created template

templateAIK

public static TPMKeyWrapper templateAIK()
Create a template for a attestation identity key

Returns:
the newly created template

getRaw

public byte[] getRaw()


http://tpm4java.datenzone.de/