public abstract class RSAKey extends java.lang.Object implements Key, ASN1Object, java.security.interfaces.RSAKey
RSAPrivateKey, RSAPublicKey, Serialized Form| Modifier | Constructor and Description |
|---|---|
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.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetAllowExport, getEncoded, getFormatinput, length, outputprotected RSAKey()
protected RSAKey(byte[] key)
throws java.io.IOException
key - The encoded representation of the key.java.io.IOException
protected RSAKey(java.io.InputStream is)
throws java.io.IOException
java.io.IOExceptionprotected RSAKey(ASN1Sequence s) throws java.io.IOException
java.io.IOException
protected RSAKey(java.math.BigInteger mod,
java.math.BigInteger exp)
mod - The modulus.exp - The public exponent in the case of a public key, the private exponent in case of a private key.public java.lang.String getAlgorithm()
KeygetAlgorithm in interface java.security.Keypublic int getBitLength()
0 will be returned if the key has not been initialized.
public void erase()
protected void assertAllowExport()
false, this method throws a KeyExportException.FIPS_140_2.getAllowKeyExport()public abstract java.lang.Object clone()
RSAKey object.clone in class java.lang.Object
public void setBytes(byte[] key)
throws java.io.IOException
java.io.IOExceptionpublic int modulusLength()
public java.math.BigInteger getModulus()
getModulus in interface java.security.interfaces.RSAKeypublic java.math.BigInteger getExponent()
public void setModulusExponent(java.math.BigInteger mod,
java.math.BigInteger exp)
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.public abstract boolean isPublic()
true if this is a public key, false if it's a private key.
public void writeExternal(java.io.ObjectOutput os)
throws java.io.IOException
writeExternal in interface java.io.Externalizableos - The output stream to write the encoding to.java.io.IOException
public void readExternal(java.io.ObjectInput is)
throws java.io.IOException,
java.lang.ClassNotFoundException
readExternal in interface java.io.Externalizableis - The stream to read from.java.io.IOExceptionjava.lang.ClassNotFoundException