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
-
RSAPublicKey(ASN1Object)
- Creates a new public key from an ASN1Object.
-
RSAPublicKey(BigInteger, BigInteger)
- Creates a new public key with given values for the modulus and the
public exponent.
-
RSAPublicKey(byte[])
- Creates a new public key from an array.
-
RSAPublicKey(String)
- Creates a new public key from a DER or PEM file.
-
crypt(BigInteger)
- Uses the public key to encrypt or decrypt a message.
-
getAlgorithm()
- Returns the name of the algorithm: RSA.
-
getEncoded()
- Returns the public key encoded as SubjectPublicKeyInfo.
-
getExponent()
- Returns the publicexponent of the public key.
-
getFingerprint()
- Returns the fingerprint of this public key.
-
getFormat()
- Returns the name of the encoding format: X.509.
-
getModulus()
- Returns the modulus of the public key.
-
getSaveFormat()
- Returns the file format (ASN1.DER, ASN1.PEM) of the public key.
-
saveToFile(String)
- Saves this public key into a file.
-
setSaveFormat(int)
- Sets the file format when saving the public key.
-
toASN1Object()
- Returns the public key encoded as SubjectPublicKeyInfo.
-
toString()
- Returns a string that represents the contents of this public key.
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
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:
- SubjectPublicKey
- SubjectPublicKeyInfo
- Parameters:
- pk - the encoded public key
- Throws: InvalidKeyException
- if something is wrong with the key encoding
RSAPublicKey
public RSAPublicKey(ASN1Object obj) throws InvalidKeyException
- Creates a new public key from an ASN1Object.
The ASN1Object can be of the following type:
- SubjectPublicKey
- SubjectPublicKeyInfo
- Parameters:
- obj - ASN1Object of the following type:
- Throws: InvalidKeyException
- if something is wrong with the key encoding
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
getEncoded
public byte[] getEncoded()
- Returns the public key encoded as SubjectPublicKeyInfo.
- Returns:
- the public key as a DER encoded ASN.1 datastructure
toASN1Object
public ASN1Object toASN1Object()
- Returns the public key encoded as SubjectPublicKeyInfo.
- Returns:
- the public key as an ASN1Object
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
getAlgorithm
public String getAlgorithm()
- Returns the name of the algorithm: RSA.
- Returns:
- the name of the algorithm
getFormat
public String getFormat()
- Returns the name of the encoding format: X.509.
- Returns:
- the name of the encoding format
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
setSaveFormat
public void setSaveFormat(int format)
- Sets the file format when saving the public key.
- Parameters:
- format - ASN1.PEM or ASN1.DER
getSaveFormat
public int getSaveFormat()
- Returns the file format (ASN1.DER, ASN1.PEM) of the public key.
- Returns:
- the safe format
getExponent
public BigInteger getExponent()
- Returns the publicexponent of the public key.
- Returns:
- the public exponent
- Overrides:
- getExponent in class RSAKey
getModulus
public BigInteger getModulus()
- Returns the modulus of the public key.
- Returns:
- the modulus
- Overrides:
- getModulus in class RSAKey
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
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