Skip navigation links

Oracle Security Developer Tools Crypto Java API Reference
11g (11.1.1)

E10668-02


oracle.security.crypto.core
Class RSAKey

java.lang.Object
  extended by oracle.security.crypto.core.RSAKey

All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, java.lang.Cloneable, ASN1Object, Key, Streamable
Direct Known Subclasses:
RSAPrivateKey, RSAPublicKey

public abstract class RSAKey
extends java.lang.Object
implements Key, ASN1Object

An abstract class for RSA keys. Input and output is done using ASN.1 DER format.

See Also:
RSAPrivateKey, RSAPublicKey, Serialized Form

Constructor Summary
protected RSAKey()
          Empty constructor.
protected RSAKey(ASN1Sequence s)
          Creates an RSAKey from the specified ASN1Sequence.
protected RSAKey(java.math.BigInteger mod, java.math.BigInteger exp)
          Creates an RSAKey from the specified BigInteger objects.
protected RSAKey(byte[] key)
          Creates an RSAKey from the encoded representation.
protected RSAKey(java.io.InputStream is)
          Creates an RSAKey from the specified stream.

 

Method Summary
protected  void assertAllowExport()
          If either this key's export flag or the global export flag is set to false, this method throws a KeyExportException.
abstract  java.lang.Object clone()
          Creates a deep clone of this RSAKey object.
 void erase()
          Erases the data stored in the key.
 java.lang.String getAlgorithm()
          Returns the algorithm for which this key is primarily used.
 int getBitLength()
          Returns the number of bits needed to represent the RSAKey's modulus.
 java.math.BigInteger getExponent()
          Returns the public exponent in this key is an RSAPublicKey, or the private exponent if this key is an RSAPrivateKey.
 java.math.BigInteger getModulus()
          Returns the modulus of this RSAKey.
abstract  boolean isPublic()
          Returns true if this is a public key, false if it's a private key.
 int modulusLength()
          The length of the modulus in bytes.
 void readExternal(java.io.ObjectInput is)
          Reads the input stream and initializes the RSA key.
 void setBytes(byte[] key)
          Set bytes of the key.
 void setModulusExponent(java.math.BigInteger mod, java.math.BigInteger exp)
          Sets the modulus and the exponent.
 void writeExternal(java.io.ObjectOutput os)
          Writes to the output stream the DER encoding of this object.

 

Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Methods inherited from interface oracle.security.crypto.core.Key
getAllowExport, getEncoded, getFormat

 

Methods inherited from interface oracle.security.crypto.util.Streamable
input, length, output

 

Constructor Detail

RSAKey

protected RSAKey()
Empty constructor.

RSAKey

protected RSAKey(byte[] key)
          throws java.io.IOException
Creates an RSAKey from the encoded representation.
Parameters:
key - The encoded representation of the key.
Throws:
java.io.IOException

RSAKey

protected RSAKey(java.io.InputStream is)
          throws java.io.IOException
Creates an RSAKey from the specified stream.
Throws:
java.io.IOException

RSAKey

protected RSAKey(ASN1Sequence s)
          throws java.io.IOException
Creates an RSAKey from the specified ASN1Sequence.
Throws:
java.io.IOException

RSAKey

protected RSAKey(java.math.BigInteger mod,
                 java.math.BigInteger exp)
Creates an RSAKey from the specified BigInteger objects.
Parameters:
mod - The modulus.
exp - The public exponent in the case of a public key, the private exponent in case of a private key.

Method Detail

getAlgorithm

public java.lang.String getAlgorithm()
Description copied from interface: Key
Returns the algorithm for which this key is primarily used.
Specified by:
getAlgorithm in interface Key

getBitLength

public int getBitLength()
Returns the number of bits needed to represent the RSAKey's modulus.

0 will be returned if the key has not been initialized.

Specified by:
getBitLength in interface Key

erase

public void erase()
Erases the data stored in the key.
Specified by:
erase in interface Key

assertAllowExport

protected void assertAllowExport()
If either this key's export flag or the global export flag is set to false, this method throws a KeyExportException.
Since:
3.0
See Also:
FIPS_140_2.getAllowKeyExport()

clone

public abstract java.lang.Object clone()
Creates a deep clone of this RSAKey object.
Specified by:
clone in interface Key
Overrides:
clone in class java.lang.Object
Returns:
A deep clone of the Key instance.

setBytes

public void setBytes(byte[] key)
              throws java.io.IOException
Set bytes of the key.
Throws:
java.io.IOException

modulusLength

public int modulusLength()
The length of the modulus in bytes.

getModulus

public java.math.BigInteger getModulus()
Returns the modulus of this RSAKey.

getExponent

public java.math.BigInteger getExponent()
Returns the public exponent in this key is an RSAPublicKey, or the private exponent if this key is an RSAPrivateKey.

setModulusExponent

public void setModulusExponent(java.math.BigInteger mod,
                               java.math.BigInteger exp)
Sets the modulus and the exponent.
Parameters:
mod - The modulus.
exp - The public exponent if this key is a public key, or the private exponent if this key is a private key.

isPublic

public abstract boolean isPublic()
Returns true if this is a public key, false if it's a private key.

writeExternal

public void writeExternal(java.io.ObjectOutput os)
                   throws java.io.IOException
Writes to the output stream the DER encoding of this object.
Specified by:
writeExternal in interface java.io.Externalizable
Parameters:
os - The output stream to write the encoding to.
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput is)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Reads the input stream and initializes the RSA key.
Specified by:
readExternal in interface java.io.Externalizable
Parameters:
is - The stream to read from.
Throws:
java.io.IOException
java.lang.ClassNotFoundException

Skip navigation links

Oracle Security Developer Tools Crypto Java API Reference
11g (11.1.1)

E10668-02


Copyright © 2005, 2009, Oracle. All rights reserved.