public class RSAPublicKey extends RSAKey implements PublicKey, java.security.interfaces.RSAPublicKey
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.
| Constructor and Description |
|---|
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.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
assertAllowExport, getAlgorithm, getBitLength, getExponent, getModulus, modulusLength, readExternal, setBytes, setModulusExponent, writeExternalequals, getClass, hashCode, notify, notifyAll, wait, wait, waitgetAlgorithm, getBitLengthpublic RSAPublicKey()
public RSAPublicKey(byte[] key)
throws java.io.IOException
key - DER-encoding of an RSA public keyjava.io.IOException
public RSAPublicKey(java.io.InputStream is)
throws java.io.IOException
java.io.IOException
public RSAPublicKey(java.math.BigInteger mod,
java.math.BigInteger exp)
mod - The modulus.exp - The exponent.public java.math.BigInteger getPublicExponent()
getPublicExponent in interface java.security.interfaces.RSAPublicKeypublic byte[] getEncoded()
KeygetEncoded in interface java.security.Keypublic boolean getAllowExport()
true.FIPS_140_2.getAllowKeyExport()public java.lang.String getFormat()
getFormat in interface java.security.Keypublic void erase()
Keys can be erased multiple times with no consequence.
public void finalize()
Note: There is no guarantee of when, if ever, finalize will be invoked by the Java runtime.
finalize in class java.lang.Objectpublic java.lang.Object clone()
RSAPublicKey instance.public void initialize(AlgorithmIdentifier algID, ASN1Object contents) throws AlgorithmIdentifierException, InvalidInputException
PublicKeypublic AlgorithmIdentifier getAlgID()
PublicKeypublic ASN1Object getContents()
PublicKeypublic boolean isPublic()
public java.lang.String toString()
toString in class java.lang.Object
public void input(java.io.InputStream is)
throws java.io.IOException
input in interface Streamablejava.io.IOException
public void output(java.io.OutputStream os)
throws java.io.IOException
Streamableoutput in interface Streamablejava.io.IOExceptionpublic int length()
Streamablelength in interface Streamable