public class PKCS8Key
extends java.lang.Object
implements java.security.PrivateKey
| Modifier and Type | Field and Description |
|---|---|
protected AlgorithmId |
algid |
protected byte[] |
encodedKey |
protected byte[] |
key |
| Modifier | Constructor and Description |
|---|---|
protected |
PKCS8Key()
Default constructor.
|
protected |
PKCS8Key(byte[] input)
Another constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
boolean |
equals(java.lang.Object object)
Compares two private keys.
|
java.lang.String |
getAlgorithm()
Returns the algorithm to be used with this key.
|
AlgorithmId |
getAlgorithmId()
Returns the algorithm ID to be used with this key.
|
byte[] |
getEncoded()
Returns the DER-encoded form of the key as a byte array,
or
null if an encoding error occurs. |
java.lang.String |
getFormat()
Returns the format for this key: "PKCS#8"
|
int |
hashCode()
Calculates a hash code value for this object.
|
static java.security.PrivateKey |
parseKey(byte[] encoded)
Construct PKCS#8 subject public key from a DER encoding.
|
protected java.lang.Object |
writeReplace() |
protected AlgorithmId algid
protected byte[] key
protected byte[] encodedKey
protected PKCS8Key()
protected PKCS8Key(byte[] input)
throws java.security.InvalidKeyException
encodedKey directly.
This method is also used by parseKey(byte[]) to create a raw key.java.security.InvalidKeyExceptionpublic static java.security.PrivateKey parseKey(byte[] encoded)
throws java.io.IOException
This mechanism guarantees that keys (and algorithms) may be freely manipulated and transferred, without risk of losing information. Also, when a key (or algorithm) needs some special handling, that specific need can be accommodated.
encoded - the DER-encoded SubjectPublicKeyInfo valuejava.io.IOException - on data format errorspublic java.lang.String getAlgorithm()
getAlgorithm in interface java.security.Keypublic AlgorithmId getAlgorithmId()
public byte[] getEncoded()
null if an encoding error occurs.getEncoded in interface java.security.Keypublic java.lang.String getFormat()
getFormat in interface java.security.Keyprotected java.lang.Object writeReplace()
throws java.io.ObjectStreamException
java.io.ObjectStreamExceptionpublic boolean equals(java.lang.Object object)
Key.
Otherwise, the encoding of this key object is compared with the
encoding of the given key object.equals in class java.lang.Objectobject - the object with which to comparetrue if this key has the same encoding as the
object argument; false otherwise.public int hashCode()
hashCode in class java.lang.Objectpublic void clear()