Skip navigation links

Oracle Fusion Middleware Crypto FIPS Java API Reference for Oracle Security Developer Tools
11g Release 1 (11.1.1)

E10696-04


oracle.security.crypto.core
Class RSAPublicKey

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

All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, java.lang.Cloneable, java.security.interfaces.RSAKey, java.security.interfaces.RSAPublicKey, java.security.Key, java.security.PublicKey, ASN1Object, Streamable

public class RSAPublicKey
extends RSAKey
implements PublicKey, java.security.interfaces.RSAPublicKey

An RSA public key.

RSA public keys are output in X.509 SubjectPublicKeyInfo format, and this is also the preferred format for input. However, for backwards compatibility reasons, the PKCS #1 RSAPublicKey format is recognized for input as well.

See Also:
Serialized Form

Field Summary

 

Fields inherited from interface java.security.interfaces.RSAPublicKey
serialVersionUID

 

Constructor Summary
RSAPublicKey()
          Empty constructor.
RSAPublicKey(java.math.BigInteger mod, java.math.BigInteger exp)
          Constructs a new RSA public key with the given parameters.
RSAPublicKey(byte[] key)
          Constructs a new RSA public key from the given encoding.
RSAPublicKey(java.io.InputStream is)
          Creates a new RSAPublicKey from the specified input stream.

 

Method Summary
 java.lang.Object clone()
          Creates a deep copy of this RSAPublicKey instance.
 void erase()
          Erases the key material making the key un-usable.
 void finalize()
          Erases this object prior to being reclaimed by the garbage collector.
 AlgorithmIdentifier getAlgID()
          Returns the algorithm identifier for this key.
 boolean getAllowExport()
          Always returns true.
 ASN1Object getContents()
          Returns the contents of this key.
 byte[] getEncoded()
          Returns the encoded form of this key.
 java.lang.String getFormat()
          Returns a string which indicates the format of this object's encoding.
 java.math.BigInteger getPublicExponent()
           
 void initialize(AlgorithmIdentifier algID, ASN1Object contents)
          Initializes this instance from the given algorithm paramters and key contents.
 void input(java.io.InputStream is)
          Reads an RSA private key from the specified input stream.
 boolean isPublic()
          Indicates whether this is a public key.
 int length()
          Length of this object's encoding.
 void output(java.io.OutputStream os)
          Outputs this object to the specified output stream.
 java.lang.String toString()
          Returns a string representation of this object.

 

Methods inherited from class oracle.security.crypto.core.RSAKey
assertAllowExport, getAlgorithm, getBitLength, getExponent, getModulus, modulusLength, readExternal, setBytes, setModulusExponent, writeExternal

 

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

 

Methods inherited from interface oracle.security.crypto.core.Key
getAlgorithm, getBitLength

 

Methods inherited from interface java.io.Externalizable
readExternal, writeExternal

 

Methods inherited from interface java.security.interfaces.RSAKey
getModulus

 

Constructor Detail

RSAPublicKey

public RSAPublicKey()
Empty constructor.

RSAPublicKey

public RSAPublicKey(byte[] key)
             throws java.io.IOException
Constructs a new RSA public key from the given encoding.
Parameters:
key - DER-encoding of an RSA public key
Throws:
java.io.IOException

RSAPublicKey

public RSAPublicKey(java.io.InputStream is)
             throws java.io.IOException
Creates a new RSAPublicKey from the specified input stream.
Throws:
java.io.IOException

RSAPublicKey

public RSAPublicKey(java.math.BigInteger mod,
                    java.math.BigInteger exp)
Constructs a new RSA public key with the given parameters.
Parameters:
mod - The modulus.
exp - The exponent.

Method Detail

getPublicExponent

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

getEncoded

public byte[] getEncoded()
Description copied from interface: Key
Returns the encoded form of this key.
Specified by:
getEncoded in interface java.security.Key

getAllowExport

public boolean getAllowExport()
Always returns true.
Returns:
Whether or not this key's material may be exported in plaintext.
Since:
3.0
See Also:
FIPS_140_2.getAllowKeyExport()

getFormat

public java.lang.String getFormat()
Returns a string which indicates the format of this object's encoding.
Specified by:
getFormat in interface java.security.Key
Returns:
"X.509"

erase

public void erase()
Erases the key material making the key un-usable.

Keys can be erased multiple times with no consequence.

Overrides:
erase in class RSAKey

finalize

public void finalize()
Erases this object prior to being reclaimed by the garbage collector.

Note: There is no guarantee of when, if ever, finalize will be invoked by the Java runtime.

Overrides:
finalize in class java.lang.Object

clone

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

initialize

public void initialize(AlgorithmIdentifier algID,
                       ASN1Object contents)
                throws AlgorithmIdentifierException,
                       InvalidInputException
Description copied from interface: PublicKey
Initializes this instance from the given algorithm paramters and key contents.
Throws:
AlgorithmIdentifierException
InvalidInputException

getAlgID

public AlgorithmIdentifier getAlgID()
Description copied from interface: PublicKey
Returns the algorithm identifier for this key.

getContents

public ASN1Object getContents()
Description copied from interface: PublicKey
Returns the contents of this key.

isPublic

public boolean isPublic()
Indicates whether this is a public key.
Specified by:
isPublic in class RSAKey
Returns:
Always returns true.

toString

public java.lang.String toString()
Returns a string representation of this object.
Overrides:
toString in class java.lang.Object

input

public void input(java.io.InputStream is)
           throws java.io.IOException
Reads an RSA private key from the specified input stream.
Specified by:
input in interface Streamable
Throws:
java.io.IOException

output

public void output(java.io.OutputStream os)
            throws java.io.IOException
Description copied from interface: Streamable
Outputs this object to the specified output stream.
Specified by:
output in interface Streamable
Throws:
java.io.IOException

length

public int length()
Description copied from interface: Streamable
Length of this object's encoding.
Specified by:
length in interface Streamable

Skip navigation links

Oracle Fusion Middleware Crypto FIPS Java API Reference for Oracle Security Developer Tools
11g Release 1 (11.1.1)

E10696-04


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