|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.crypto.EncryptedPrivateKeyInfo
public class EncryptedPrivateKeyInfo
This class implements the EncryptedPrivateKeyInfo
type as
defined in PKCS #8.
Its ASN.1 definition is as follows:
EncryptedPrivateKeyInfo ::= SEQUENCE { encryptionAlgorithm AlgorithmIdentifier, encryptedData OCTET STRING } AlgorithmIdentifier ::= SEQUENCE { algorithm OBJECT IDENTIFIER, parameters ANY DEFINED BY algorithm OPTIONAL }
TODO: This class is not fully implemented, yet!
Field Summary | |
---|---|
private byte[] |
encodedData_
The ASN.1 encoded data. |
private byte[] |
encryptedData_
The encrypted data. |
Constructor Summary | |
---|---|
EncryptedPrivateKeyInfo(AlgorithmParameters algParams,
byte[] encryptedData)
Constructs an EncryptedPrivateKeyInfo from the
encryption algorithm parameters and the encrypted data. |
|
EncryptedPrivateKeyInfo(byte[] encoded)
Constructs (i.e., parses) an EncryptedPrivateKeyInfo
from its ASN.1 encoding. |
|
EncryptedPrivateKeyInfo(String algName,
byte[] encryptedData)
Constructs an EncryptedPrivateKeyInfo from the
encryption algorithm name and the encrypted data. |
Method Summary | |
---|---|
String |
getAlgName()
Returns the encryption algorithm. |
AlgorithmParameters |
getAlgParameters()
Returns the algorithm parameters used by the encryption algorithm. |
byte[] |
getEncoded()
Returns the ASN.1 encoding of this object. |
byte[] |
getEncryptedData()
Returns a copy of the encrypted data. |
PKCS8EncodedKeySpec |
getKeySpec(Cipher cipher)
Extract the enclosed PKCS8EncodedKeySpec object from the encrypted data and return it. |
PKCS8EncodedKeySpec |
getKeySpec(Key decryptKey)
Extract the enclosed PKCS8EncodedKeySpec object from the encrypted data and return it. |
PKCS8EncodedKeySpec |
getKeySpec(Key decryptKey,
Provider provider)
Extract the enclosed PKCS8EncodedKeySpec object from the encrypted data and return it. |
PKCS8EncodedKeySpec |
getKeySpec(Key decryptKey,
String providerName)
Extract the enclosed PKCS8EncodedKeySpec object from the encrypted data and return it. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private byte[] encryptedData_
private byte[] encodedData_
Constructor Detail |
---|
public EncryptedPrivateKeyInfo(byte[] encoded) throws IOException
EncryptedPrivateKeyInfo
from its ASN.1 encoding.
encoded
- the ASN.1 encoding of this object.
IOException
- if error occurs when parsing the ASN.1 encoding.
NullPointerException
- if the encoded
is null.public EncryptedPrivateKeyInfo(String algName, byte[] encryptedData) throws NoSuchAlgorithmException
EncryptedPrivateKeyInfo
from the
encryption algorithm name and the encrypted data.
Note: the encrypedData
is cloned when constructing
this object. If encryption algorithm has associated parameters use
the constructor with AlgorithmParameters as the parameter.
algName
- algorithm name.encryptedData
- encrypted data.
NullPointerException
- if algName
or
encryptedData
is null.
IllegalArgumentException
- if encryptedData
is
empty, i.e. 0-length.
NoSuchAlgorithmException
- if the specified algName is not
supported.public EncryptedPrivateKeyInfo(AlgorithmParameters algParams, byte[] encryptedData) throws NoSuchAlgorithmException
EncryptedPrivateKeyInfo
from the
encryption algorithm parameters and the encrypted data.
Note: the encrypedData
is cloned when constructing
this object.
algParams
- the algorithm parameters for the encryption
algorithm. algParams.getEncoded()
should return the
ASN.1 encoded bytes of the parameters
field of the
AlgorithmIdentifer
component of the
EncryptedPrivateKeyInfo
type.encryptedData
- encrypted data.
NullPointerException
- if algParams
or
encryptedData
is null.
IllegalArgumentException
- if encryptedData
is
empty, i.e. 0-length.
NoSuchAlgorithmException
- if the specified
algName
of the specified algParams parameter is not
supported.Method Detail |
---|
public String getAlgName()
public AlgorithmParameters getAlgParameters()
public byte[] getEncryptedData()
public PKCS8EncodedKeySpec getKeySpec(Cipher cipher) throws InvalidKeySpecException
cipher
- the cipher.
NullPointerException
- if cipher
is null.
InvalidKeySpecException
- if the given cipher is inappropriate
for the encrypted data or the encrypted data is corrupted and cannot
be decrypted.public PKCS8EncodedKeySpec getKeySpec(Key decryptKey) throws NoSuchAlgorithmException, InvalidKeyException
decryptKey
- key used for decrypting the encrypted data.
NullPointerException
- if decryptKey
is null.
NoSuchAlgorithmException
- if cannot find appropriate
cipher to decrypt the encrypted data.
InvalidKeyException
- if decryptKey
cannot be used to decrypt the encrypted data or the decryption
result is not a valid PKCS8KeySpec.public PKCS8EncodedKeySpec getKeySpec(Key decryptKey, String providerName) throws NoSuchProviderException, NoSuchAlgorithmException, InvalidKeyException
decryptKey
- key used for decrypting the encrypted data.providerName
- the name of provider whose Cipher
implementation will be used.
NullPointerException
- if decryptKey
or providerName
is null.
NoSuchProviderException
- if no provider
providerName
is registered.
NoSuchAlgorithmException
- if cannot find appropriate
cipher to decrypt the encrypted data.
InvalidKeyException
- if decryptKey
cannot be used to decrypt the encrypted data or the decryption
result is not a valid PKCS8KeySpec.public PKCS8EncodedKeySpec getKeySpec(Key decryptKey, Provider provider) throws NoSuchAlgorithmException, InvalidKeyException
decryptKey
- key used for decrypting the encrypted data.provider
- the name of provider whose Cipher implementation
will be used.
NullPointerException
- if decryptKey
or provider
is null.
NoSuchAlgorithmException
- if cannot find appropriate
cipher to decrypt the encrypted data in provider
.
InvalidKeyException
- if decryptKey
cannot be used to decrypt the encrypted data or the decryption
result is not a valid PKCS8KeySpec.public byte[] getEncoded() throws IOException
IOException
- if error occurs when constructing its ASN.1 encoding.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |