com.upek.android.ptapi.rsa
Class RSAPublicKey

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

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

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

The native TFM representation is returned by getEncoded().

See Also:
Serialized Form

Constructor Summary
RSAPublicKey(byte[] ptApiData)
          Creates a new key from TFM internal format (returned by e.g.
RSAPublicKey(java.security.interfaces.RSAPrivateCrtKey key)
          Creates a new key from another class implementing RSAPrivateCrtKey (it is full RSA key specification which contains all private and public parts).
RSAPublicKey(java.security.spec.RSAPrivateCrtKeySpec keySpec)
          Creates a new key from RSAPrivateCrtKey key specifiction (it is full RSA key specification which contains all private and public parts).
RSAPublicKey(java.security.interfaces.RSAPublicKey key)
          Creates a new key from another class implementing RSAPublicKey.
RSAPublicKey(java.security.spec.RSAPublicKeySpec keySpec)
          Creates a new key from RSAPublicKeySpec 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.RSAPublicKeySpec getKeySpec()
          Exports this key in a new RSAPublicKeySpec object.
 java.math.BigInteger getModulus()
           
 java.math.BigInteger getPublicExponent()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RSAPublicKey

public RSAPublicKey(byte[] ptApiData)
             throws PtException
Creates a new key from TFM internal format (returned by e.g. generateDeviceKeyPair()). There must be present a public key or full key in the buffer.

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

RSAPublicKey

public RSAPublicKey(java.security.interfaces.RSAPrivateCrtKey key)
Creates a new key from another class implementing RSAPrivateCrtKey (it is full RSA key specification which contains all private and public parts).

Parameters:
key - is the source key to copy

RSAPublicKey

public RSAPublicKey(java.security.spec.RSAPrivateCrtKeySpec keySpec)
Creates a new key from RSAPrivateCrtKey key specifiction (it is full RSA key specification which contains all private and public parts).

Parameters:
keySpec - is the source key specification

RSAPublicKey

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

Parameters:
key - is the source key to copy

RSAPublicKey

public RSAPublicKey(java.security.spec.RSAPublicKeySpec keySpec)
Creates a new key from RSAPublicKeySpec 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.RSAPublicKeySpec getKeySpec()
Exports this key in a new RSAPublicKeySpec object.

Returns:
new key specification

getModulus

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

getPublicExponent

public java.math.BigInteger getPublicExponent()
Specified by:
getPublicExponent in interface java.security.interfaces.RSAPublicKey