|
Oracle Security Developer Tools Crypto Java API Reference 10g Release 2 (10.1.2.0.2) B15565-01 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
oracle.security.crypto.core.PrivateKeyPKCS8
A class for PKCS #5 and PKCS #12 password-encrypted RSA/DSA private keys in PKCS #8 format.
When a PrivateKeyPKCS8 is constructed from components, the private key is encrypted when any of the methods
getContents()
, getEncoded()
, output(java.io.OutputStream)
or length()
are called.
When a PrivateKeyPKCS8 is instantiated by inputting its encoding from a stream or file, the private key is decrypted immediately if the password has been set or made available to the constructor. If the password has not been provided, the private key will not be decrypted until the
getKey()
method is called. Note that the getKey()
method is invoked by the methods getAlgID()
, getAlgorithm()
, getFormat()
and getBitLength()
. This class may not be backward compatible for Serialization: PKCS5 serialized objects created with PSE 2.2.2 and later until PSE 2.2.3 Build G may not be read.
PKCS5
, Serialized FormConstructor Summary | |
PrivateKeyPKCS8() Creates a new instance with the default encryption mode for the PKCS5 class and the default random bits source. |
|
PrivateKeyPKCS8(ASN1Sequence s) |
|
PrivateKeyPKCS8(java.io.InputStream is) Read encrypted private key from a stream. |
|
PrivateKeyPKCS8(int mode) Creates a new instance with the given PKCS#5 encryption mode and the default random bits source. |
|
PrivateKeyPKCS8(int mode, RandomBitsSource rbs) Creates a new instance with the given PKCS#5 encryption mode and random bits source. |
|
PrivateKeyPKCS8(PrivateKey key) Creates a new instance with the given private key and the default random bits source and mode SHA_3DES. |
|
PrivateKeyPKCS8(PrivateKey key, int mode) |
|
PrivateKeyPKCS8(PrivateKey key, int mode, RandomBitsSource rbs) |
|
PrivateKeyPKCS8(PrivateKey key, RandomBitsSource rbs) Creates a new instance with the given private key and random bits source, using the default mode SHA_3DES. |
|
PrivateKeyPKCS8(PrivateKey key, java.lang.String passwd, int mode) Creates a new instance with the given private key, password, and PKCS#5 encryption mode, and the default random bits source. |
|
PrivateKeyPKCS8(PrivateKey key, java.lang.String passwd, int mode, RandomBitsSource rbs) Creates a new instance with the given private key, password, PKCS#5 encryption mode and random bits source. |
|
PrivateKeyPKCS8(java.lang.String password, ASN1Sequence s) Read encrypted private key from an ASN1 encoding. |
|
PrivateKeyPKCS8(java.lang.String password, java.io.File f) Read encrypted private key from a file. |
|
PrivateKeyPKCS8(java.lang.String password, java.io.InputStream is) Read encrypted private key from a stream. |
|
PrivateKeyPKCS8(java.lang.String passwd, PrivateKey key) Uses the default mode SHA_3DES and the default RandomBitsSource. |
|
PrivateKeyPKCS8(java.lang.String passwd, PrivateKey key, RandomBitsSource rbs) Uses the default mode SHA_3DES. |
Method Summary | |
java.lang.Object |
clone() Creates a clone of the instance. |
void |
erase() Erases the key material, making the key un-usable. |
AlgorithmIdentifier |
getAlgID() Returns the AlgorithmIdentifier of the underlying PrivateKey, or null if the key has not been input or set, or the key cannot be decrypted. |
java.lang.String |
getAlgorithm() Returns the algorithm of the underlying PrivateKey, or null if the underlying key hasn't been input or set, or if the key cannot be decrypted. |
int |
getBitLength() Returns the bit length of the underlying PrivateKey or 0 if the underlying key hasn't been input or set or if the key cannot be decrypted. |
ASN1Object |
getContents() Returns the ASN1Object that is output to the output(OutputStream os) method. |
byte[] |
getEncoded() Returns the bytes that are output from the output(OutputStream os) method. |
java.lang.String |
getFormat() Returns the format of the underlying PrivateKey or null if the underlying key hasn't been input or set, or if the key cannot be decrypted. |
PrivateKey |
getKey() Get the private key. |
int |
getMode() Returns the mode for PKCS5/12. |
void |
initialize(AlgorithmIdentifier algID, ASN1Object contents) Initializes the underlying PrivateKey, creating a new instance if one does not already exist. |
void |
input(ASN1Sequence s) |
void |
input(java.io.InputStream is) Inputs this object from the specified input stream. |
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) |
void |
setCount(int c) Set the count for PKCS5/12. |
void |
setKey(PrivateKey key) Set the private key. |
void |
setMode(int m) Set the mode for PKCS5/12. |
void |
setPassword(java.lang.String pw) Set the password for PKCS5/12. |
void |
setSalt(byte[] salt) Set the salt for PKCS5/12. |
java.lang.String |
toString() Returns a string representation of this object. |
void |
writeExternal(java.io.ObjectOutput os) |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public PrivateKeyPKCS8()
PKCS5
class and the default random bits source.public PrivateKeyPKCS8(int mode, RandomBitsSource rbs)
public PrivateKeyPKCS8(int mode)
public PrivateKeyPKCS8(PrivateKey key, RandomBitsSource rbs)
public PrivateKeyPKCS8(PrivateKey key)
public PrivateKeyPKCS8(PrivateKey key, int mode, RandomBitsSource rbs)
public PrivateKeyPKCS8(PrivateKey key, int mode)
public PrivateKeyPKCS8(java.lang.String passwd, PrivateKey key, RandomBitsSource rbs)
public PrivateKeyPKCS8(java.lang.String passwd, PrivateKey key)
public PrivateKeyPKCS8(PrivateKey key, java.lang.String passwd, int mode, RandomBitsSource rbs)
public PrivateKeyPKCS8(PrivateKey key, java.lang.String passwd, int mode)
public PrivateKeyPKCS8(java.lang.String password, java.io.InputStream is) throws java.io.IOException
public PrivateKeyPKCS8(java.io.InputStream is) throws java.io.IOException
setPassword(java.lang.String)
public PrivateKeyPKCS8(ASN1Sequence s) throws java.io.IOException
public PrivateKeyPKCS8(java.lang.String password, java.io.File f) throws java.io.IOException, java.io.FileNotFoundException
public PrivateKeyPKCS8(java.lang.String password, ASN1Sequence s) throws java.io.IOException
Method Detail |
public void input(java.io.InputStream is) throws java.io.IOException
Streamable
input
in interface Streamable
java.io.IOException
public void input(ASN1Sequence s) throws java.io.IOException
java.io.IOException
public void output(java.io.OutputStream os) throws java.io.IOException
Streamable
output
in interface Streamable
java.io.IOException
public int length()
Streamable
length
in interface Streamable
public void setPassword(java.lang.String pw)
public void setMode(int m)
public int getMode()
public void setCount(int c)
public void setSalt(byte[] salt)
public PrivateKey getKey()
java.lang.IllegalStateException
- If an error occurs while decrypting the private key.public void setKey(PrivateKey key)
public java.lang.String toString()
public AlgorithmIdentifier getAlgID()
null
if the key has not been input or set, or the key cannot be decrypted.getAlgID
in interface PrivateKey
public ASN1Object getContents()
output(OutputStream os)
method.getContents
in interface PrivateKey
StreamableOutputException
- If an error occurs generating the output (e.g., key encryption fails).public void initialize(AlgorithmIdentifier algID, ASN1Object contents) throws InvalidInputException, AlgorithmIdentifierException
initialize
in interface PrivateKey
algID
- The algorithm identifier of the enclosed private key.contents
- The ASN.1 DER-encoded bytes of the private key.InvalidInputException
AlgorithmIdentifierException
public java.lang.Object clone()
clone
in interface Key
public void erase()
Key
Keys can be erased multiple times with no consequence.
erase
in interface Key
public java.lang.String getAlgorithm()
null
if the underlying key hasn't been input or set, or if the key cannot be decrypted.getAlgorithm
in interface Key
public int getBitLength()
0
if the underlying key hasn't been input or set or if the key cannot be decrypted.getBitLength
in interface Key
public byte[] getEncoded()
output(OutputStream os)
method.getEncoded
in interface Key
StreamableOutputException
- If an error occurs generating the output bytes (e.g., key encryption fails).public java.lang.String getFormat()
null
if the underlying key hasn't been input or set, or if the key cannot be decrypted.getFormat
in interface Key
public void writeExternal(java.io.ObjectOutput os) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
java.io.IOException
public void readExternal(java.io.ObjectInput is) throws java.io.IOException, java.lang.ClassNotFoundException
readExternal
in interface java.io.Externalizable
java.io.IOException
java.lang.ClassNotFoundException
|
Oracle Security Developer Tools Crypto Java API Reference 10g Release 2 (10.1.2.0.2) B15565-01 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |