com.upek.android.ptapi.rsa
Class RSAPrivateKey

java.lang.Object
  extended by com.upek.android.ptapi.rsa.RSAPrivateKey
All Implemented Interfaces:
java.io.Serializable, java.security.interfaces.RSAKey, java.security.interfaces.RSAPrivateKey, java.security.Key, java.security.PrivateKey

public class RSAPrivateKey
extends java.lang.Object
implements java.security.interfaces.RSAPrivateKey, java.io.Serializable

This class represents a private RSA key, which can be imported and exported to TFM native representation. It implements java.security.interfaces.RSAPrivateKey interface, so it can be used directly with RSA implementation from Java Cryptography Extension. Export and import from java.security.spec.RSAPrivateKeySpec is supported too.

The native TFM representation is returned by getEncoded().

See Also:
Serialized Form

Constructor Summary
RSAPrivateKey(byte[] ptApiData)
          Creates a new key from TFM internal format.
RSAPrivateKey(java.security.interfaces.RSAPrivateKey key)
          Creates a new key from another class implementing RSAPrivateKey.
RSAPrivateKey(java.security.spec.RSAPrivateKeySpec keySpec)
          Creates a new key from RSAPrivateCrtKeySpec key specifiction.
 
Method Summary
 java.lang.String getAlgorithm()
           
 int getBitLegth()
          Returns a bit length of this key.
 byte[] getEncoded()
           
 java.lang.String getFormat()
           
 java.security.spec.RSAPrivateKeySpec getKeySpec()
          Exports this key in a new RSAPrivateKeySpec object.
 java.math.BigInteger getModulus()
           
 java.math.BigInteger getPrivateExponent()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RSAPrivateKey

public RSAPrivateKey(byte[] ptApiData)
              throws PtException
Creates a new key from TFM internal format. There must be present a private key in the buffer.

Parameters:
ptApiData - contains key in native TFM RSA key representation
Throws:
PtException - whether buffer has invalid structure

RSAPrivateKey

public RSAPrivateKey(java.security.interfaces.RSAPrivateKey key)
Creates a new key from another class implementing RSAPrivateKey.

Parameters:
key - is the source key to copy

RSAPrivateKey

public RSAPrivateKey(java.security.spec.RSAPrivateKeySpec keySpec)
Creates a new key from RSAPrivateCrtKeySpec key specifiction.

Parameters:
keySpec - is the source key specification
Method Detail

getAlgorithm

public java.lang.String getAlgorithm()
Specified by:
getAlgorithm in interface java.security.Key

getBitLegth

public int getBitLegth()
Returns a bit length of this key.

Returns:
a key bit length

getEncoded

public byte[] getEncoded()
Specified by:
getEncoded in interface java.security.Key

getFormat

public java.lang.String getFormat()
Specified by:
getFormat in interface java.security.Key

getKeySpec

public java.security.spec.RSAPrivateKeySpec getKeySpec()
Exports this key in a new RSAPrivateKeySpec object.

Returns:
new key specification

getModulus

public java.math.BigInteger getModulus()
Specified by:
getModulus in interface java.security.interfaces.RSAKey

getPrivateExponent

public java.math.BigInteger getPrivateExponent()
Specified by:
getPrivateExponent in interface java.security.interfaces.RSAPrivateKey