|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.security.pkcsutil.PKCSDerObject | +--com.ibm.security.pkcs8.PrivateKeyInfo
Implements the PrivateKeyInfo data type as defined in PKCS #8.
This class may be subclassed by specific private key classes wishing to adhere to the PKCS #8 standard.
Field Summary | |
protected AlgorithmId |
algid
The algorithm information (name, parameters, etc). |
protected PKCSAttributes |
attributes
The attributes associated with the key. |
protected byte[] |
key
The key bytes, without the algorithm information |
static BigInteger |
version
The version for this key |
Fields inherited from class com.ibm.security.pkcsutil.PKCSDerObject |
provider |
Fields inherited from interface java.security.PrivateKey |
serialVersionUID |
Fields inherited from interface java.security.Key |
serialVersionUID |
Constructor Summary | |
PrivateKeyInfo()
Create an uninitialized PrivateKeyInfo object. |
|
PrivateKeyInfo(AlgorithmId algid,
byte[] key,
PKCSAttributes attrs)
Creates a PrivateKeyInfo object with the specified values. |
|
PrivateKeyInfo(AlgorithmId algid,
byte[] key,
PKCSAttributes attrs,
String provider)
Creates a PrivateKeyInfo object with the specified values. |
|
PrivateKeyInfo(byte[] der)
Create a PKCS #8 PrivateKeyInfo object with a DER byte array. |
|
PrivateKeyInfo(byte[] der,
String provider)
Create a PKCS #8 PrivateKeyInfo object with a DER byte array. |
|
PrivateKeyInfo(String provider)
Create an uninitialized PrivateKeyInfo object. |
|
PrivateKeyInfo(String filename,
boolean base64)
Create a PrivateKeyInfo with the filename of the DER-encoded or BASE64-encoded object. |
|
PrivateKeyInfo(String filename,
boolean base64,
String provider)
Create a PrivateKeyInfo with the filename of the DER-encoded or BASE64-encoded object. |
Method Summary | |
PrivateKeyInfo |
addAttribute(PKCSAttribute attrib)
Add a PKCS attribute into the set of attributes for this PrivateKeyInfo object. |
PrivateKeyInfo |
addAttributes(PKCSAttributes attribs)
Add a PKCSAttributes set of attributes into the set of attributes for this PrivateKeyInfo object. |
Object |
clone()
Creates a clone of this PrivateKeyInfo object. |
protected void |
decode(com.ibm.security.pkcs8.DerValue encoding)
Initialize an PrivateKeyInfo object from an input stream. |
void |
encode(OutputStream os)
Encodes this object to an OutputStream. |
boolean |
equals(Object other)
Determines if this PrivateKeyInfo object is equivalent to the input object. |
protected void |
finalize()
Ensures that the key bytes are nulled out when there are no more references to this object. |
String |
getAlgorithm()
Returns the algorithm to be used with this key. |
AlgorithmId |
getAlgorithmId()
Returns the algorithm identifier. |
PKCSAttribute |
getAttribute(ObjectIdentifier oid)
Returns an attribute from the attribute set based on an ObjectIdentifier. |
PKCSAttributes |
getAttributes()
Returns the PKCS attributes associated 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" |
byte[] |
getKeyBytes()
Return a copy of the private key byte array. |
boolean |
hasAttribute(ObjectIdentifier oid)
Determines if this PrivateKeyInfo has the attribute specified by the ObjectIdentifier. |
boolean |
hasAttributes()
Determines if this PrivateKeyInfo has any attributes. |
int |
hashCode()
Calculates a hash code value for this object. |
static PrivateKey |
parseKey(com.ibm.security.pkcs8.DerValue in)
Constructs a PKCS #8 subject private key from a DER value. |
static PrivateKey |
parseKey(com.ibm.security.pkcs8.DerValue in,
String provider)
Constructs a PKCS #8 subject private key from a DER value. |
protected void |
parseKeyBits()
Parses the key bits. |
String |
toString()
Returns a string representation of this PrivateKeyInfo object. |
Methods inherited from class com.ibm.security.pkcsutil.PKCSDerObject |
decode,
decode,
encode,
getObjectIdentifier,
read,
readBASE64,
write,
write,
writeBASE64 |
Methods inherited from class java.lang.Object |
getClass,
notify,
notifyAll,
wait,
wait,
wait |
Field Detail |
public static final BigInteger version
protected AlgorithmId algid
protected byte[] key
protected PKCSAttributes attributes
Constructor Detail |
public PrivateKeyInfo()
public PrivateKeyInfo(String provider)
public PrivateKeyInfo(byte[] der) throws IOException
der
- a DER byte array of a PrivateKeyInfo object.public PrivateKeyInfo(byte[] der, String provider) throws IOException
der
- a DER byte array of a PrivateKeyInfo object.provider
- the provider to be used.public PrivateKeyInfo(AlgorithmId algid, byte[] key, PKCSAttributes attrs) throws IOException
algid
- the private key algorithm and any associated parameters.key
- the encoded private key.attrs
- optional PKCSAttributes for this key. May be null.public PrivateKeyInfo(AlgorithmId algid, byte[] key, PKCSAttributes attrs, String provider) throws IOException
algid
- the private key algorithm and any associated parameters.key
- the encoded private key.attrs
- optional PKCSAttributes for this key. May be null.provider
- the provider to be used.public PrivateKeyInfo(String filename, boolean base64) throws IOException
filename
- name of the DER-encoded or base64-encoded objectbase64
- true if BASE64-encoded, false if DER-encodedpublic PrivateKeyInfo(String filename, boolean base64, String provider) throws IOException
filename
- name of the DER-encoded or base64-encoded objectbase64
- true if BASE64-encoded, false if DER-encodedprovider
- the provider to be usedMethod Detail |
public void encode(OutputStream os) throws IOException
os
- the OutputStream on which to write the DER encoding.public static PrivateKey parseKey(com.ibm.security.pkcs8.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 PrivateKeyInfo value.public static PrivateKey parseKey(com.ibm.security.pkcs8.DerValue in, String provider) 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 PrivateKeyInfo value.provider
- the provider to be used.public PrivateKeyInfo addAttributes(PKCSAttributes attribs)
attribs
- the PKCSAttributes to add.public PrivateKeyInfo addAttribute(PKCSAttribute attrib)
attrib
- the PKCS attribute to add.public String getAlgorithm()
public AlgorithmId getAlgorithmId()
public byte[] getEncoded()
public String getFormat()
public PKCSAttribute getAttribute(ObjectIdentifier oid)
oid
- ObjectIdentifier to matchpublic PKCSAttributes getAttributes()
public boolean hasAttribute(ObjectIdentifier oid)
oid
- ObjectIdentifier to matchpublic boolean hasAttributes()
public boolean equals(Object other)
other
- the object to compare this one to.public String toString()
public int hashCode()
public Object clone()
protected void decode(com.ibm.security.pkcs8.DerValue encoding) throws IOException
Subclasses should not normally redefine this method; they should
instead provide a parseKeyBits
method to parse any
fields inside the key
member.
encoding
- a DER-encoded PrivateKeyInfo object.protected void parseKeyBits() throws IOException
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 PrivateKeyInfo member functions, such as
parse
and decode
.
public byte[] getKeyBytes()
protected void finalize()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |