java.lang.Object | |
↳ | sun.security.pkcs.PKCS8Key |
![]() |
Holds a PKCS#8 key, for example a private key
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
algid | |||||||||||
encodedKey | |||||||||||
key | |||||||||||
version |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Default constructor.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Initialize an PKCS8Key object from an input stream.
| |||||||||||
Returns the DER-encoded form of the key as a byte array.
| |||||||||||
PKCS#8 sequence on the DER output stream.
| |||||||||||
Compares two private keys.
| |||||||||||
Returns the algorithm to be used with this key.
| |||||||||||
Returns the algorithm ID to be used with this key.
| |||||||||||
Returns the DER-encoded form of the key as a byte array.
| |||||||||||
Returns the format for this key: "PKCS#8"
| |||||||||||
Calculates a hash code value for this object.
| |||||||||||
Construct PKCS#8 subject public key from a DER value.
| |||||||||||
Returns a string representation of the object.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Parse the key bits.
| |||||||||||
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
Default constructor. The key constructed must have its key
and algorithm initialized before it may be used, for example
by using decode
.
Initialize an PKCS8Key object from an input stream. The data on that input stream must be encoded using DER, obeying the PKCS#8 format: a sequence consisting of a version, an algorithm ID and a bit string which holds the key. (That bit string is often used to encapsulate another DER encoded sequence.)
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. |
---|
Returns the DER-encoded form of the key as a byte array.
InvalidKeyException | if an encoding error occurs. |
---|
PKCS#8 sequence on the DER output stream.
IOException |
---|
Compares two private keys. This returns false if the object with which
to compare is not of type Key
.
Otherwise, the encoding of this key object is compared with the
encoding of the given key object.
object | the object with which to compare |
---|
true
if this key has the same encoding as the
object argument; false
otherwise.
Returns the algorithm to be used with this key.
Returns the DER-encoded form of the key as a byte array.
Returns the format for this key: "PKCS#8"
Calculates a hash code value for this object. Objects which are equal will also have the same hashcode.
Construct PKCS#8 subject public key from a DER value. If the runtime environment is configured with a specific class for this kind of key, a subclass is returned. Otherwise, a generic PKCS8Key object is returned.
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 |
---|
Returns a string representation of the object. In general, the
toString
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())
Parse the key bits. This may be redefined by subclasses to take
advantage of structure within the key. For example, RSA public
keys encapsulate two unsigned integers (modulus and exponent) as
DER values within the 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. |