public class RawPrivateKey extends PrivateKeyInfo implements java.io.Serializable, java.lang.Cloneable
When calling PrivateKeyInfo.getPrivateKey
to parse a private key a KeyFactory for the key algorithm is instantiated. If no KeyFactory
is available for the key algorithm a generic raw private key is created allowing to get some
information about the key (algorithm, encoding).
private_key_algorithm
Constructor and Description |
---|
RawPrivateKey(ASN1Object obj)
Creates a raw PrivateKey from the given ASN.1 object.
|
RawPrivateKey(byte[] pk)
Creates a raw PrivateKey from the given DER encoded byte array.
|
RawPrivateKey(java.io.InputStream is)
Creates a raw PrivateKey from an InputStream.
|
Modifier and Type | Method and Description |
---|---|
protected void |
decode(byte[] privateKey)
Decodes a raw PrivateKey, encoded in DER format.
|
byte[] |
encode()
Returns the raw private key (not wrapped in a PKCS#8 PrivateKeyInfo)
as DER encoded ASN.1 object.
|
java.lang.String |
getAlgorithm()
Returns the name of the key algorithm.
|
java.lang.String |
toString()
Returns a string representation of this key.
|
clone, createPrivateKeyInfo, decode, equals, getAlgorithmID, getAttributes, getEncoded, getFormat, getPrivateKey, getPrivateKey, getPrivateKey, getPrivateKey, getPrivateKey, getPrivateKey, getPubKey, hashCode, setAttributes, setPubKey, toASN1Object, writeTo
public RawPrivateKey(byte[] pk) throws java.security.InvalidKeyException
pk
- the byte array holding the DER encoded private key infojava.security.InvalidKeyException
- if the key cannot be parsedpublic RawPrivateKey(ASN1Object obj) throws java.security.InvalidKeyException
obj
- the private key ASN.1 structurejava.security.InvalidKeyException
- if the key cannot be parsedpublic RawPrivateKey(java.io.InputStream is) throws java.io.IOException, java.security.InvalidKeyException
is
- the input stream from where the encoded PrivateKey shall be readjava.io.IOException
- if an I/O error occursjava.security.InvalidKeyException
- if the key cannot be parsedprotected void decode(byte[] privateKey) throws java.security.InvalidKeyException
This method only keeps the key encoding.
decode
in class PrivateKeyInfo
privateKey
- the private key as DER encoded ASN.1 objectjava.security.InvalidKeyException
- if the key cannot be parsedpublic byte[] encode()
This method typically may not be used by an application. Rather
it is used by the parent PKCS#8 PrivateKeyInfo.getEncoded()
method for encoding the private key.
encode
in class PrivateKeyInfo
public java.lang.String getAlgorithm()
getAlgorithm
in interface java.security.Key
getAlgorithm
in class PrivateKeyInfo
public java.lang.String toString()
toString
in class PrivateKeyInfo