|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--iaik.pkcs.pkcs8.PrivateKeyInfo
This class implements the PKCS#8 Private-Key Information Syntax Standard for storing private keys.
A Private-key information according to PKCS#8 combines a private key (of a
public-key algorithm) and some attributes, which are used for developing trust
in information like public keys from top-level certification authorities (see
http://www.rsasecurity.com/rsalabs/pkcs/pkcs-8/).
PKCS#8 defines PrivateKeyInfo as an ASN.1 SEQUENCE containing the
following components:
PrivateKeyInfo ::= SEQUENCE {
version Version,
privateKeyAlgorithm PrivateKeyAlgorithmIdentifier,
privateKey PrivateKey
attributes [0] IMPLICIT Attributes OPTIONAL }
where:
This class may be extended for every particular private key implemetation wishing to suppoert PKCS#8 PrivateKeyInfo.Version ::= INTEGER -- Syntax Version Number PrivateKeyAlgorithmIdentifier ::= AlgorithmIdentifier -- private key algorithm, e.g. rsaEncryption from PKCS#1 PrivateKey ::= OCTET STRING -- the value of the private key, e.g. a BER encoded RSAPrivateKey value Attributes ::= SET OF Attribute -- additional information, encrypted together with the private-key information
This class provides a variety of methods for creating, parsing, de- and encoding private key informations.
DHPrivateKey,
DSAPrivateKey,
RSAPrivateKey, Serialized Form| Field Summary | |
protected AlgorithmID |
private_key_algorithm
Identifies the appertaining private-key algorithm. |
| Fields inherited from interface java.security.PrivateKey |
serialVersionUID |
| Constructor Summary | |
protected |
PrivateKeyInfo()
Default Constructor for derived classes. |
|
PrivateKeyInfo(ASN1Object obj)
Creates a new PrivateKeyInfo from an ASN1Object. |
|
PrivateKeyInfo(byte[] arr)
Creates a new PrivateKeyInfo from a byte array. |
|
PrivateKeyInfo(InputStream is)
Creates a new PrivateKeyInfo from an InputStream. |
| Method Summary | |
Object |
clone()
Return a clone of this private key object. |
protected void |
createPrivateKeyInfo()
Creates a PrivateKeyInfo ASN.1 data structure (PKCS#8). |
void |
decode(ASN1Object obj)
Decodes the given ASN.1 PrivateKeyInfo object
for parsing the internal structure.
|
protected abstract void |
decode(byte[] privateKey)
Abstract method to be implemented for decoding a DER encoded private key. |
protected abstract byte[] |
encode()
Abstract method to be implemented for encoding this private key according to DER. |
boolean |
equals(Object obj)
Compares this private key to another private key. |
abstract String |
getAlgorithm()
Returns the name of the algorithm. |
byte[] |
getEncoded()
Returns this PrivateKeyInfo as a DER encoded ASN.1 data structure. |
String |
getFormat()
Returns the name of the encoding format.. |
static PrivateKey |
getPrivateKey(ASN1Object privateKeyInfo)
Creates a PrivateKeyInfo from an ASN1Object. |
static PrivateKey |
getPrivateKey(byte[] privateKeyInfo)
Creates a PrivateKey from a DER encoded byte array in PKCS#8 PrivateKeyInfo format. |
int |
hashCode()
Returns a hash code for this object. |
ASN1Object |
toASN1Object()
Returns this PrivateKeyInfo as ASN1Object. |
String |
toString()
Returns a string that represents the contents of this private key. |
void |
writeTo(OutputStream os)
Writes this private key to an output stream. |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected AlgorithmID private_key_algorithm
| Constructor Detail |
protected PrivateKeyInfo()
public PrivateKeyInfo(ASN1Object obj)
throws InvalidKeyException
This constructor may be used for parsing an
already exisiting PrivateKeyInfo object, supplied as
ASN1Object that may have been created by calling
toASN1Object.
obj - the PrivateKeyInfo as ASN1ObjectInvalidKeyException - if the data can not be parsed
public PrivateKeyInfo(InputStream is)
throws InvalidKeyException,
IOException
This constructor reads a PrivateKeyInfo previously written with
method writeTo.
This constructor cannot be used to read a serialized object.
is - the input stream from where the PrivateKeyInfo shall be readInvalidKeyException - if the data can not be parsedIOException - if an I/O error occurs
public PrivateKeyInfo(byte[] arr)
throws InvalidKeyException
This constructor may be used for parsing an
already exisiting PrivateKeyInfo object, supplied
as DER encoded ASN.1 structure, which may have been created
by calling the getEncoded
method of this class.
arr - the array containing the encoded PrivateKeyInfoInvalidKeyException - if the data can not be parsed| Method Detail |
protected abstract void decode(byte[] privateKey)
throws InvalidKeyException
privateKey - the private key as DER encoded byte arrayInvalidKeyException - if the does not match to the implemented
public-key algorithmprotected abstract byte[] encode()
public abstract String getAlgorithm()
getAlgorithm in interface Keypublic Object clone()
clone in class Object
public void decode(ASN1Object obj)
throws CodingException
PrivateKeyInfo object
for parsing the internal structure.
This method implements the ASN1Type interface and internally is called when
creating a PKCS#8 PrivateKeyInfo object from an
already existing PrivateKeyInfo object, supplied
as ASN1Object or DER encoded ASN1Object.
decode in interface ASN1Typeobj - the PrivateKeyInfo as ASN1ObjectCodingException - if the ASN1Object could not be parsedprotected void createPrivateKeyInfo()
This method is called by extending classes for creating a PrivateKeyInfo. This method creates a PrivateKeyInfo as an ASN.1 SEQUENCE object with components as specified in the PKCS#8 Private-Key Information Syntax Standard:
public static PrivateKey getPrivateKey(ASN1Object privateKeyInfo)
throws InvalidKeyException
This is a static method and therefore may be called for creating a PrivateKeyInfo from the given ASN1Object without explicitly instantiating this class, e.g:
PrivateKeyInfo priv_ki = PrivateKeyInfo.getPrivateKeyInfo(asn1_obj);
The given ASN1Object represents an already exisiting
PrivateKeyInfo object, and may have been created by calling
toASN1Object.
This method uses a KeyFactory for the registered algorithm to create the PrivateKeyInfo from the DER encoding of the supplied ASN1Object.
privateKeyInfo - the PrivateKeyInfo as ASN1ObjectInvalidKeyException - if the ASN1Object cannot be parsed or the inherent AlgorithmID does
not match to any implemented private-key algorithm
public static PrivateKey getPrivateKey(byte[] privateKeyInfo)
throws InvalidKeyException
PrivateKey priv_ki = PrivateKeyInfo.getPrivateKey(key_array);
This method uses a KeyFactory for the registered algorithm to create the PrivateKey from the supplied DER encoded byte array.
privateKey - the PrivateKey as DER encoded byte arrayInvalidKeyException - if the privateKey cannot be parsedpublic ASN1Object toASN1Object()
toASN1Object in interface ASN1Typepublic boolean equals(Object obj)
equals in class Objectpublic int hashCode()
hashCode in class Objectpublic byte[] getEncoded()
getEncoded in interface Keypublic String getFormat()
getFormat in interface Key
public void writeTo(OutputStream os)
throws IOException
os - the output streamIOException - if an I/O error occurspublic String toString()
toString in class Object
|
This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note). | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
IAIK-JCE 3.1 with IAIK-JCE CC Core 3.1, (c) 1997-2004 IAIK