All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class iaik.security.rsa.RSAPublicKey

java.lang.Object
   |
   +----iaik.security.rsa.RSAKey
           |
           +----iaik.security.rsa.RSAPublicKey

public class RSAPublicKey
extends RSAKey
implements RSAPublicKey, Serializable
This class implements RSA public keys.

See Also:
Key, PublicKey, PrivateKey, RSAPrivateKey

Constructor Index

 o RSAPublicKey(ASN1Object)
Creates a new public key from an ASN1Object.
 o RSAPublicKey(BigInteger, BigInteger)
Creates a new public key with given values for the modulus and the public exponent.
 o RSAPublicKey(byte[])
Creates a new public key from an array.
 o RSAPublicKey(String)
Creates a new public key from a DER or PEM file.

Method Index

 o crypt(BigInteger)
Uses the public key to encrypt or decrypt a message.
 o getAlgorithm()
Returns the name of the algorithm: RSA.
 o getEncoded()
Returns the public key encoded as SubjectPublicKeyInfo.
 o getExponent()
Returns the publicexponent of the public key.
 o getFingerprint()
Returns the fingerprint of this public key.
 o getFormat()
Returns the name of the encoding format: X.509.
 o getModulus()
Returns the modulus of the public key.
 o getSaveFormat()
Returns the file format (ASN1.DER, ASN1.PEM) of the public key.
 o saveToFile(String)
Saves this public key into a file.
 o setSaveFormat(int)
Sets the file format when saving the public key.
 o toASN1Object()
Returns the public key encoded as SubjectPublicKeyInfo.
 o toString()
Returns a string that represents the contents of this public key.

Constructors

 o RSAPublicKey
 public RSAPublicKey(BigInteger publicExponent,
                     BigInteger modulus)
Creates a new public key with given values for the modulus and the public exponent.

Parameters:
publicExponent - the public exponent of the key
modulus - the modulus of the key
 o RSAPublicKey
 public RSAPublicKey(byte pk[]) throws InvalidKeyException
Creates a new public key from an array. The coding format of the array can be DER or PEM and the ASN.1 type can be:

Parameters:
pk - the encoded public key
Throws: InvalidKeyException
if something is wrong with the key encoding
 o RSAPublicKey
 public RSAPublicKey(ASN1Object obj) throws InvalidKeyException
Creates a new public key from an ASN1Object. The ASN1Object can be of the following type:

Parameters:
obj - ASN1Object of the following type:
Throws: InvalidKeyException
if something is wrong with the key encoding
 o RSAPublicKey
 public RSAPublicKey(String fileName) throws IOException, InvalidKeyException
Creates a new public key from a DER or PEM file.

Parameters:
fileName - the key file name
Throws: InvalidKeyException
if something is wrong with the key encoding
Throws: IOException
if something is wrong with the file

Methods

 o getEncoded
 public byte[] getEncoded()
Returns the public key encoded as SubjectPublicKeyInfo.

Returns:
the public key as a DER encoded ASN.1 datastructure
 o toASN1Object
 public ASN1Object toASN1Object()
Returns the public key encoded as SubjectPublicKeyInfo.

Returns:
the public key as an ASN1Object
 o crypt
 public BigInteger crypt(BigInteger message)
Uses the public key to encrypt or decrypt a message. Simply performs a modula exponentiation.

Parameters:
message - the message to en/decrypt as BigInteger
Returns:
the encrypted or decrypted message
Overrides:
crypt in class RSAKey
 o getAlgorithm
 public String getAlgorithm()
Returns the name of the algorithm: RSA.

Returns:
the name of the algorithm
 o getFormat
 public String getFormat()
Returns the name of the encoding format: X.509.

Returns:
the name of the encoding format
 o saveToFile
 public void saveToFile(String fileName) throws IOException
Saves this public key into a file.

Parameters:
fileName - the name of the file
Throws: IOException
if an error occurs during saving the file
 o setSaveFormat
 public void setSaveFormat(int format)
Sets the file format when saving the public key.

Parameters:
format - ASN1.PEM or ASN1.DER
 o getSaveFormat
 public int getSaveFormat()
Returns the file format (ASN1.DER, ASN1.PEM) of the public key.

Returns:
the safe format
 o getExponent
 public BigInteger getExponent()
Returns the publicexponent of the public key.

Returns:
the public exponent
Overrides:
getExponent in class RSAKey
 o getModulus
 public BigInteger getModulus()
Returns the modulus of the public key.

Returns:
the modulus
Overrides:
getModulus in class RSAKey
 o getFingerprint
 public byte[] getFingerprint()
Returns the fingerprint of this public key. This is a MD5 hash of the DER encoded SubjectPublicKey.

Returns:
the fingerprint of the public key
 o toString
 public String toString()
Returns a string that represents the contents of this public key.

Returns:
the string representation
Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index