Oracle Security Developer Tools Crypto Java API Reference
10g Release 2 (10.1.2.0.2)

B15565-01


oracle.security.crypto.core
Class RSAPublicKey

java.lang.Object
  extended byoracle.security.crypto.core.RSAKey
      extended byoracle.security.crypto.core.RSAPublicKey

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

public class RSAPublicKey
extends RSAKey
implements PublicKey, java.io.Externalizable

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

Constructor Summary
RSAPublicKey()
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)

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()
ASN1Object getContents()
java.lang.String getFormat()
Returns a string which indicates the format of this object's encoding.
void initialize(AlgorithmIdentifier algID, ASN1Object 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.
void readExternal(java.io.ObjectInput is)
java.lang.String toString()
Returns a string representation of this object.
void writeExternal(java.io.ObjectOutput os)

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

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, getEncoded

Constructor Detail

RSAPublicKey

public RSAPublicKey()

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

RSAPublicKey

public RSAPublicKey(java.io.InputStream is)
             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

initialize

public void initialize(AlgorithmIdentifier algID,
                       ASN1Object contents)
                throws AlgorithmIdentifierException,
                       InvalidInputException
Specified by:
initialize in interface PublicKey
Throws:
AlgorithmIdentifierException
InvalidInputException

getAlgID

public AlgorithmIdentifier getAlgID()
Specified by:
getAlgID in interface PublicKey

getFormat

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

getContents

public ASN1Object getContents()
Specified by:
getContents in interface PublicKey

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.
Returns:
a string representation of this object

erase

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

Keys can be erased multiple times with no consequence.

Specified by:
erase in interface Key
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.


clone

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

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

writeExternal

public void writeExternal(java.io.ObjectOutput os)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput is)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException

Oracle Security Developer Tools Crypto Java API Reference
10g Release 2 (10.1.2.0.2)

B15565-01


Copyright © 2005 , Oracle. All rights reserved.