|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectsun.security.pkcs.PKCS8Key
public class PKCS8Key
Holds a PKCS#8 key, for example a private key
| Field Summary | |
|---|---|
protected AlgorithmId |
algid
|
protected byte[] |
encodedKey
|
protected byte[] |
key
|
static BigInteger |
version
|
| Constructor Summary | |
|---|---|
PKCS8Key()
Default constructor. |
|
| Method Summary | |
|---|---|
void |
decode(byte[] encodedKey)
|
void |
decode(InputStream in)
Initialize an PKCS8Key object from an input stream. |
byte[] |
encode()
Returns the DER-encoded form of the key as a byte array. |
void |
encode(DerOutputStream out)
PKCS#8 sequence on the DER output stream. |
boolean |
equals(Object object)
Compares two private keys. |
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. |
String |
getFormat()
Returns the format for this key: "PKCS#8" |
int |
hashCode()
Calculates a hash code value for this object. |
static PKCS8Key |
parse(DerValue in)
|
static PrivateKey |
parseKey(DerValue in)
Construct PKCS#8 subject public key from a DER value. |
protected void |
parseKeyBits()
Parse the key bits. |
String |
toString()
Returns a string representation of the object. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected AlgorithmId algid
protected byte[] key
protected byte[] encodedKey
public static final BigInteger version
| Constructor Detail |
|---|
public PKCS8Key()
decode.
| Method Detail |
|---|
public static PKCS8Key parse(DerValue in)
throws IOException
IOException
public static PrivateKey parseKey(DerValue in)
throws IOException
This mechanism gurantees 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 accomodated.
in - the DER-encoded SubjectPublicKeyInfo value
IOException - on data format errors
protected void parseKeyBits()
throws IOException,
InvalidKeyException
key bits; Diffie-Hellman and
DSS/DSA keys encapsulate a single unsigned integer.
This function is called when creating PKCS#8 SubjectPublicKeyInfo
values using the PKCS8Key member functions, such as parse
and decode.
IOException - if a parsing error occurs.
InvalidKeyException - if the key encoding is invalid.public String getAlgorithm()
getAlgorithm in interface Keypublic AlgorithmId getAlgorithmId()
public final void encode(DerOutputStream out)
throws IOException
IOExceptionpublic byte[] getEncoded()
getEncoded in interface Keypublic String getFormat()
getFormat in interface Key
public byte[] encode()
throws InvalidKeyException
InvalidKeyException - if an encoding error occurs.public String toString()
ObjecttoString method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
toString in class Object
public void decode(InputStream in)
throws InvalidKeyException
Subclasses should not normally redefine this method; they should
instead provide a parseKeyBits method to parse any
fields inside the key member.
in - an input stream with a DER-encoded PKCS#8
SubjectPublicKeyInfo value
InvalidKeyException - if a parsing error occurs.
public void decode(byte[] encodedKey)
throws InvalidKeyException
InvalidKeyExceptionpublic boolean equals(Object object)
Key.
Otherwise, the encoding of this key object is compared with the
encoding of the given key object.
equals in class Objectobject - the object with which to compare
true if this key has the same encoding as the
object argument; false otherwise.Object.hashCode(),
Hashtablepublic int hashCode()
hashCode in class ObjectObject.equals(java.lang.Object),
Hashtable
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||