|
Oracle Fusion Middleware Crypto Java API Reference for Oracle Security Developer Tools 11g Release 1 (11.1.1) E10668-05 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
oracle.security.crypto.core.RSAKey
oracle.security.crypto.core.RSAPrivateKey
public class RSAPrivateKey
An RSA private key.
RSA private keys are output in PKCS #8 PrivateKeyInfo format, and this is also the preferred format for input. However, for backwards compatibility reasons, the PKCS #1 RSAPrivateKey format is recognized for input as well.
| Field Summary |
|---|
| Fields inherited from interface java.security.interfaces.RSAPrivateCrtKey |
|---|
serialVersionUID |
| Constructor Summary | |
|---|---|
RSAPrivateKey()Creates a new, uninitialized RSA private key. |
|
RSAPrivateKey(java.math.BigInteger mod, java.math.BigInteger exp)Construct a new RSAPrivateKey object with the given parameters. |
|
RSAPrivateKey(java.math.BigInteger mod, java.math.BigInteger exp, java.math.BigInteger e, java.math.BigInteger p, java.math.BigInteger q, java.math.BigInteger e1, java.math.BigInteger e2, java.math.BigInteger c)Construct a new RSAPrivateKey object with the given parameters. |
|
RSAPrivateKey(byte[] encoded)Makes a new RSA private key from a specified encoding. |
|
RSAPrivateKey(java.io.File f)Construct a new RSAPrivateKey object from a file. |
|
RSAPrivateKey(java.io.InputStream is)Initializes this RSA private key by reading its encoding from the given stream. |
|
| Method Summary | |
|---|---|
java.lang.Object |
clone()Creates a deep copy of this RSAPrivateKey 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()Returns false if plaintext export of this key's key material is not allowed; returns true if plaintext export is allowed. |
ASN1Object |
getContents()Returns this RSAPrivateKey's contents in PKCS #1 privateKey format (as opposed to PKCS #8 privateKeyInfo format). |
java.math.BigInteger |
getCrtCoefficient()Returns the CRT coefficient. |
byte[] |
getEncoded()Returns ASN.1 DER bytes containing the PKCS#8 PrivateKeyInfo encoding of this private key. |
java.lang.String |
getFormat()Returns a string which indicates the format of this object's encoding. |
java.math.BigInteger |
getPrimeExponentP()Returns the prime exponent p. |
java.math.BigInteger |
getPrimeExponentQ()Returns the prime exponent q. |
java.math.BigInteger |
getPrimeP()Returns the prime p. |
java.math.BigInteger |
getPrimeQ()Returns the prime q. |
java.math.BigInteger |
getPrivateExponent() |
java.math.BigInteger |
getPublicExponent()Returns the public exponent. |
RSAPublicKey |
getPublicKey()Get the public key from this private key. |
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)Writes the DER encoding of this key in PKCS #8 privateKeyInfo format (as opposed to PKCS #1 privateKey format) to the given output stream. |
void |
setAllowExport(boolean value)Set to false to disallow plaintext export of this key's key material; set to true to allow plaintext export if the global value in FIPS_140_2 is also set to true. |
java.lang.String |
toString()Returns a description of this RSAPrivateKey. |
| 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 |
|---|
public RSAPrivateKey()
public RSAPrivateKey(java.math.BigInteger mod,
java.math.BigInteger exp)
RSAPrivateKey object with the given parameters.
Note: A RSAPrivateKey constructed using only the modulus and private exponent cannot be used to derive the corresponding public key, nor can it be output to a DER-encoded ASN.1 representation.
mod - The modulus.exp - The private exponent.
public RSAPrivateKey(java.math.BigInteger mod,
java.math.BigInteger exp,
java.math.BigInteger e,
java.math.BigInteger p,
java.math.BigInteger q,
java.math.BigInteger e1,
java.math.BigInteger e2,
java.math.BigInteger c)
RSAPrivateKey object with the given parameters.
mod - The modulus.exp - The private exponent.e - The public exponent.p - A big prime p.q - A big prime q.e1 - Prime exponent p.e2 - Prime exponent q.c - The CRT coefficient.
public RSAPrivateKey(java.io.File f)
throws java.io.FileNotFoundException,
java.io.IOException
RSAPrivateKey object from a file.
f - The file that stores the RSAPrivateKey.java.io.FileNotFoundException - If the file does not exist.java.io.IOException - If an input exception occured.
public RSAPrivateKey(byte[] encoded)
throws java.io.IOException
encoded - A BER encoding of an RSA private key.java.io.IOException
public RSAPrivateKey(java.io.InputStream is)
throws java.io.IOException
java.io.IOException| Method Detail |
|---|
public byte[] getEncoded()
getEncoded in interface java.security.Keypublic boolean getAllowExport()
false if plaintext export of this key's key material is not allowed; returns true if plaintext export is allowed.
If either this value or the global value is false, the output(java.io.OutputStream), getContents() and getEncoded() methods will throw a KeyExportException.
false if plaintext key material export is not allowed, true if allowed.FIPS_140_2.getAllowKeyExport(), Cipher.wrapKey(PrivateKey key)public void setAllowExport(boolean value)
false to disallow plaintext export of this key's key material; set to true to allow plaintext export if the global value in FIPS_140_2 is also set to true.
If either this value or the global value is false, the output(java.io.OutputStream), getContents() and getEncoded() methods will throw a KeyExportException.
value - false to disallow plaintext key material export, true to allow.FIPS_140_2.setAllowKeyExport(boolean), Cipher.wrapKey(PrivateKey key)public void erase()
Keys can be erased multiple times with no consequence.
erase in class RSAKeypublic 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.String getFormat()
getFormat in interface java.security.Keypublic java.lang.Object clone()
RSAPrivateKey instance.clone in class RSAKey
public void initialize(AlgorithmIdentifier algID,
ASN1Object contents)
throws AlgorithmIdentifierException,
InvalidInputException
PrivateKeyAlgorithmIdentifierExceptionInvalidInputExceptionpublic ASN1Object getContents()
RSAPrivateKey's contents in PKCS #1 privateKey format (as opposed to PKCS #8 privateKeyInfo format).
To output the key in this format in DER encoding, use code like the following:
RSAPrivateKey key = ... ;
OutputStream os = ... ;
key.getContents().output(os);
for PKCS #8 privateKeyInfo format.public AlgorithmIdentifier getAlgID()
PrivateKeypublic boolean isPublic()
isPublic in class RSAKeyfalse.public RSAPublicKey getPublicKey()
public java.math.BigInteger getPublicExponent()
getPublicExponent in interface java.security.interfaces.RSAPrivateCrtKeypublic java.math.BigInteger getPrivateExponent()
getPrivateExponent in interface java.security.interfaces.RSAPrivateKeypublic java.math.BigInteger getPrimeP()
getPrimeP in interface java.security.interfaces.RSAPrivateCrtKeypublic java.math.BigInteger getPrimeQ()
getPrimeQ in interface java.security.interfaces.RSAPrivateCrtKeypublic java.math.BigInteger getPrimeExponentP()
getPrimeExponentP in interface java.security.interfaces.RSAPrivateCrtKeypublic java.math.BigInteger getPrimeExponentQ()
getPrimeExponentQ in interface java.security.interfaces.RSAPrivateCrtKeypublic java.math.BigInteger getCrtCoefficient()
getCrtCoefficient in interface java.security.interfaces.RSAPrivateCrtKey
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
output in interface Streamablejava.io.IOExceptionfor PKCS #1 privateKey format.public int length()
Streamablelength in interface Streamablepublic java.lang.String toString()
toString in class java.lang.Object
|
Oracle Fusion Middleware Crypto Java API Reference for Oracle Security Developer Tools 11g Release 1 (11.1.1) E10668-05 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||