|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--java.util.AbstractCollection
|
+--java.util.AbstractList
|
+--java.util.ArrayList
|
+--codec.asn1.ASN1AbstractCollection
|
+--codec.asn1.ASN1Sequence
|
+--codec.pkcs8.PrivateKeyInfo
This class represents a PrivateKeyInfo as defined in PKCS#8.
The ASN.1 definition of this structure is
PrivateKeyInfo ::= SEQUENCE ( version Version, -- 0 for version 1.2 Nov 93 privateKeyAlgorithm PrivateKeyAlgorithmIdentifier, privateKey PrivateKey, attributes [0] IMPLICIT Attributes OPTIONAL } Version ::= INTEGER PrivateKeyAlgorithmIdentifier ::= AlgorithmIdentifier PrivateKey ::= OCTET STRING Attributes ::= SET OF AttributeThe following definitions are taken from the X501 standard:Attribute ::= SEQUENCE { type AttributeType values SET OF AttributeValue -- at least one value is required -- } AttributeType ::= OBJECT IDENTIFIER AttributeValue ::= ANY
| Field Summary | |
protected AlgorithmIdentifier |
algorithm_
The OID of the private key algorithm used in
this structure. |
protected ASN1Set |
attributes_
Attributes are the extended information that is encrypted along with the private-key information. |
static int |
VERSION
The default version. |
protected ASN1Integer |
version_
Version is the syntax version number, for compatibility with future revisions of the . |
static int |
VERSION_1_2
Version 1.2 November 1993 identifier. |
| Fields inherited from class java.util.AbstractList |
modCount |
| Constructor Summary | |
PrivateKeyInfo()
This constructor builds the data structure. |
|
PrivateKeyInfo(AlgorithmIdentifier aid,
ASN1Type key)
Creates an instance with the given ASN.1 raw key. |
|
PrivateKeyInfo(AlgorithmIdentifier aid,
byte[] key)
Creates an instance with the given pre encoded raw key. |
|
PrivateKeyInfo(PrivateKey key)
Creates an instance with the given private key. |
|
| Method Summary | |
AlgorithmIdentifier |
getAlgorithmIdentifier()
Returns the AlgorithmIdentifier of the
embedded key. |
List |
getAttributes()
Returns an unmodifiable list view on the attributes. |
ASN1Type |
getDecodedRawKey()
Returns an ASN.1 type that represents the decoded raw key. |
PrivateKey |
getPrivateKey()
Returns the private key embedded in this structure. |
byte[] |
getRawKey()
Returns the raw key material. |
int |
getVersion()
Returns the version number of this instance. |
void |
setAlgorithm(AlgorithmIdentifier aid)
Sets the AlgorithmIdentifier of this
instance. |
void |
setAttributes(Collection attributes)
Sets the given attributes. |
void |
setPrivateKey(PrivateKey key)
Initializes this instance with the given private key. |
protected void |
setRawKey(ASN1Type key)
Encodes and sets the given ASN.1 key structure as the raw key. |
void |
setVersion(int version)
Sets the version number of this instance. |
| Methods inherited from class codec.asn1.ASN1Sequence |
getTag |
| Methods inherited from class codec.asn1.ASN1AbstractCollection |
checkConstraints, decode, encode, getCollection, getConstraint, getTagClass, getValue, isExplicit, isOptional, isType, readExternal, setConstraint, setExplicit, setOptional, toString, writeExternal |
| Methods inherited from class java.util.ArrayList |
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, removeRange, set, size, toArray, toArray, trimToSize |
| Methods inherited from class java.util.AbstractList |
equals, hashCode, iterator, listIterator, listIterator, subList |
| Methods inherited from class java.util.AbstractCollection |
containsAll, remove, removeAll, retainAll |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Collection |
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
| Methods inherited from interface java.util.List |
containsAll, equals, hashCode, iterator, listIterator, listIterator, remove, removeAll, retainAll, subList |
| Field Detail |
public static final int VERSION
public static final int VERSION_1_2
protected ASN1Integer version_
protected AlgorithmIdentifier algorithm_
OID of the private key algorithm used in
this structure.protected ASN1Set attributes_
| Constructor Detail |
public PrivateKeyInfo()
public PrivateKeyInfo(AlgorithmIdentifier aid,
byte[] key)
getEncoded()
method of the Key interface must not be passed to this
constructor because the bytes returned by this method do not contain a
raw key but a complete PrivateKeyInfo structure (as this one).aid - The AlgorithmIdentifier with the OID and parameters for
the raw algorithm that belongs to the given key.key - The raw key that shall be wrapped in this instance.
public PrivateKeyInfo(AlgorithmIdentifier aid,
ASN1Type key)
aid - The AlgorithmIdentifier with the OID and parameters for
the raw algorithm that belongs to the given key.key - The raw key that shall be wrapped in this instance.InconsistentStateException - if an exception is thrown while encoding the given key.
No such exception should ever happen.
public PrivateKeyInfo(PrivateKey key)
throws InvalidKeyException
key - the actual private key as a java objectNullPointerException - if the given key is null.| Method Detail |
public AlgorithmIdentifier getAlgorithmIdentifier()
AlgorithmIdentifier of the
embedded key.
public PrivateKey getPrivateKey()
throws NoSuchAlgorithmException
This method creates an PKCS8EncodedKeySpec of this instance and feeds it into a key factory. In order to locate a suitable key factory, the installed providers must define appropriate OID mappings.
InconsistentStateException - if the key spec generated by this method is rejected by
the key factory that is used to generate the key.NoSuchAlgorithmException - if there is no key factory registered for the algorithm
of the embedded key or no appropriate OID mapping is
defined by the installed providers.
public void setPrivateKey(PrivateKey key)
throws InvalidKeyException
key - The private key from which this instance is initialized.InvalidKeyException - if the given key cannot be decoded properly.NullPointerException - if the given key is null.public int getVersion()
public void setVersion(int version)
version - The version number.public void setAlgorithm(AlgorithmIdentifier aid)
AlgorithmIdentifier of this
instance. This algorithm identifier must match the raw key of this
instance.
The given instance is set up in this structure. Side effects will occur if it is modified subsequently.
aid - The AlgorithmIdentifier.protected void setRawKey(ASN1Type key)
InconsistentStateException - if an internal error occurs while the key is encoded.
This should never happen.public List getAttributes()
public void setAttributes(Collection attributes)
attributes - The attributes.public byte[] getRawKey()
If the key encoding is ASN.1/DER then the raw key can be retrieved as an
ASN.1 type by means of the getDecodedRawKey()
method.
The returned value is a copy. No side effects are caused by modifying it.
public ASN1Type getDecodedRawKey()
throws CorruptedCodeException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||