is new.
java.lang.Objectjavax.crypto.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 }
| 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
|
| PKCS8EncodedKeySpec |
getKeySpec
(
Cipher
Extract the enclosed PKCS8EncodedKeySpec object from the encrypted data and return it. |
PKCS8EncodedKeySpec
|
getKeySpec
(
Key
Extract the enclosed PKCS8EncodedKeySpec object from the encrypted data and return it.
|
PKCS8EncodedKeySpec
|
getKeySpec
(
Key
decryptKey,
Provider
Extract the enclosed PKCS8EncodedKeySpec object from the encrypted data and return it.
|
PKCS8EncodedKeySpec
|
getKeySpec
(
Key
decryptKey,
String
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 |
| Constructor Detail |
|---|
public EncryptedPrivateKeyInfo(byte[] encoded)
throws IOException
The contents of the array are copied to protect against subsequent modification.
public EncryptedPrivateKeyInfo(String algName,
byte[] encryptedData)
throws NoSuchAlgorithmException
Note: This constructor will use null as the value of the algorithm parameters. If the encryption algorithm has parameters whose value is not null, a different constructor, e.g. EncryptedPrivateKeyInfo(AlgorithmParameters, byte[]), should be used.
Note: the encrypedData is cloned when constructing this object. If encryption algorithm has associated parameters use the constructor with AlgorithmParameters as the parameter.
algName - encryption algorithm name. See Appendix A in the
Java Cryptography Extension Reference Guide
for information about standard Cipher algorithm names.
The contents of encrypedData are copied to protect against subsequent modification when constructing this object.
public EncryptedPrivateKeyInfo(AlgorithmParameters algParams,
byte[] encryptedData)
throws NoSuchAlgorithmException
Note: the encrypedData is cloned when constructing this object.
The contents of encrypedData are copied to protect against subsequent modification when constructing this object.
| Method Detail |
|---|
public String getAlgName()
Note: Standard name is returned instead of the specified one in the constructor when such mapping is available.
See Appendix A in the
Java Cryptography Extension Reference Guide
for information about standard Cipher algorithm names.
encryption
algorithm name. public AlgorithmParameters getAlgParameters()
public byte[] getEncryptedData()
the encrypted data. Returns a new array each time this method is called.
public PKCS8EncodedKeySpecgetKeySpec(Ciphercipher)
c)throws InvalidKeySpecException
Note: In order to successfully retrieve the enclosed PKCS8EncodedKeySpec object, cipher needs to be initialized to either Cipher.DECRYPT_MODE or Cipher.UNWRAP_MODE, with the same key and parameters used for generating the encrypted data.
Parameters:
cipher - the initialized cipher object which will be used for decrypting the encrypted data.
NullPointerException
- if cipher is null.
getKeySpec
public
PKCS8EncodedKeySpec
getKeySpec
(
Key
decryptKey) throws
NoSuchAlgorithmException
,
InvalidKeyException
Extract the enclosed PKCS8EncodedKeySpec object from the encrypted data and return it.
Parameters:
decryptKey - key used for decrypting the encrypted data.
Returns:
the PKCS8EncodedKeySpec object.
Throws:
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.
getKeySpec
public
PKCS8EncodedKeySpec
getKeySpec
(
Key
decryptKey,
String
providerName) throws
NoSuchProviderException
,
NoSuchAlgorithmException
,
InvalidKeyException
Extract the enclosed PKCS8EncodedKeySpec object from the encrypted data and return it.
Parameters:
decryptKey - key used for decrypting the encrypted data.
providerName - the name of provider whose Cipher implementation will be used.
Returns:
the PKCS8EncodedKeySpec object.
Throws:
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.
getKeySpec
public
PKCS8EncodedKeySpec
getKeySpec
(
Key
decryptKey,
Provider
provider) throws
NoSuchAlgorithmException
,
InvalidKeyException
Extract the enclosed PKCS8EncodedKeySpec object from the encrypted data and return it.
Parameters:
decryptKey - key used for decrypting the encrypted data.
provider - the name of provider whose Cipher implementation will be used.
Returns:
the PKCS8EncodedKeySpec object.
Throws:
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
Returns a new array each time this method is called.