iaik.tc.tss.impl.csp
Class TcCrypto

java.lang.Object
  extended by iaik.tc.tss.impl.csp.TcBasicCrypto
      extended by iaik.tc.tss.impl.csp.TcCrypto

public class TcCrypto
extends TcBasicCrypto

This class is the CSP (crypto service provider) of the TSS. That means that all cryptographic functionality required by the TSS is centralized in this class. The intention is to make porting to different crypto libraries as simple as possible. * To allow compilation of the API definition (without implementation) (i.e. for Wrapper translation with GCJ), the TcCrypto class has been split in a basic part, and a full implementation that extends it. TcCrypto is not compatible with GCJ (without additional crypto libs).


Constructor Summary
TcCrypto()
           
 
Method Summary
static TcBlobData create3DESkey()
          This method calls the JCE to create a new 3DES key.
static TcBlobData createAESkey(int keysize)
          This method calls the JCE to create a new AES key.
static TcTpmNonce createTcgNonce()
          This method returns TPM_SHA1BASED_NONCE_LEN bytes of random data.
static TcBlobData decryptRsaEcbPkcs1Padding(TcTpmPubkey pubKey, TcBlobData inputData)
           
static TcBlobData decryptSymmetricCbcPkcs5Pad(java.lang.String algo, TcBlobData symKey, TcBlobData iv, TcBlobData encData)
          This method decrypts the given data blob using the given symKey and the IV.
static TcBlobData encryptSymmetricCbcPkcs5Pad(java.lang.String algo, TcBlobData symKey, TcBlobData iv, TcBlobData plainData)
          This method encrypts the given data blob using the given symKey and the IV.
static TcBlobData getRandom(int numBytes)
          This method returns numBytes bytes of random data.
static byte[] privJavaPrimePToByte(java.security.interfaces.RSAPrivateCrtKey privateKey)
          This method takes a Java RSA private key object and extracts the prime factor P as a byte array.
static TcBlobData pubEncryptRsaEcbPkcs1Padding(TcTpmPubkey pubKey, TcBlobData plainData)
           
static TcBlobData pubEncryptRsaOaepSha1Mgf1(TcTpmPubkey pubKey, TcBlobData plainData)
           
static TcTpmPubkey pubJavaToTpmKey(java.security.interfaces.RSAPublicKey publickey)
          This method takes a Java RSA public key object and converts it into a TPM public key structure.
static java.security.interfaces.RSAPublicKey pubTpmKeyToJava(TcTpmPubkey pubKey)
          This method takes a TPM public key structure and converts it into a Java RSA public key object.
 
Methods inherited from class iaik.tc.tss.impl.csp.TcBasicCrypto
checkCryptoAvailability, hmacSha1, sha1, xor
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TcCrypto

public TcCrypto()
Method Detail

pubEncryptRsaOaepSha1Mgf1

public static TcBlobData pubEncryptRsaOaepSha1Mgf1(TcTpmPubkey pubKey,
                                                   TcBlobData plainData)
                                            throws TcTcsException
Throws:
TcTcsException

pubEncryptRsaEcbPkcs1Padding

public static TcBlobData pubEncryptRsaEcbPkcs1Padding(TcTpmPubkey pubKey,
                                                      TcBlobData plainData)
                                               throws TcTcsException
Throws:
TcTcsException

decryptRsaEcbPkcs1Padding

public static TcBlobData decryptRsaEcbPkcs1Padding(TcTpmPubkey pubKey,
                                                   TcBlobData inputData)
                                            throws TcTcsException
Throws:
TcTcsException

encryptSymmetricCbcPkcs5Pad

public static TcBlobData encryptSymmetricCbcPkcs5Pad(java.lang.String algo,
                                                     TcBlobData symKey,
                                                     TcBlobData iv,
                                                     TcBlobData plainData)
                                              throws TcTcsException
This method encrypts the given data blob using the given symKey and the IV. The mode of operation is fixed to CBC and the padding is set to PKCS5.

Throws:
TcTcsException

decryptSymmetricCbcPkcs5Pad

public static TcBlobData decryptSymmetricCbcPkcs5Pad(java.lang.String algo,
                                                     TcBlobData symKey,
                                                     TcBlobData iv,
                                                     TcBlobData encData)
                                              throws TcTcsException
This method decrypts the given data blob using the given symKey and the IV. The mode of operation is fixed to CBC and the padding is set to PKCS5.

Throws:
TcTcsException

create3DESkey

public static TcBlobData create3DESkey()
This method calls the JCE to create a new 3DES key. The key is returned as a blob object.


createAESkey

public static TcBlobData createAESkey(int keysize)
                               throws TcTssException
This method calls the JCE to create a new AES key. The key is returned as a blob object.

Parameters:
keysize - Key size in bits.
Throws:
TcTssException

getRandom

public static TcBlobData getRandom(int numBytes)
This method returns numBytes bytes of random data.

Returns:
numBytes bytes of random data.

createTcgNonce

public static TcTpmNonce createTcgNonce()
This method returns TPM_SHA1BASED_NONCE_LEN bytes of random data.

Returns:
numBytes bytes of random data.

pubJavaToTpmKey

public static TcTpmPubkey pubJavaToTpmKey(java.security.interfaces.RSAPublicKey publickey)
This method takes a Java RSA public key object and converts it into a TPM public key structure.


pubTpmKeyToJava

public static java.security.interfaces.RSAPublicKey pubTpmKeyToJava(TcTpmPubkey pubKey)
This method takes a TPM public key structure and converts it into a Java RSA public key object.


privJavaPrimePToByte

public static byte[] privJavaPrimePToByte(java.security.interfaces.RSAPrivateCrtKey privateKey)
This method takes a Java RSA private key object and extracts the prime factor P as a byte array.