public class EncryptedPrivateKeyInfo
extends Object
| java.lang.Object | |
| ↳ | javax.crypto.EncryptedPrivateKeyInfo |
该类实现PKCS#8中定义的 EncryptedPrivateKeyInfo类型。
其ASN.1定义如下:
EncryptedPrivateKeyInfo ::= SEQUENCE {
encryptionAlgorithm AlgorithmIdentifier,
encryptedData OCTET STRING }
AlgorithmIdentifier ::= SEQUENCE {
algorithm OBJECT IDENTIFIER,
parameters ANY DEFINED BY algorithm OPTIONAL }
也可以看看:
Public constructors |
|
|---|---|
EncryptedPrivateKeyInfo(byte[] encoded) 从ASN.1编码构造(即解析) |
|
EncryptedPrivateKeyInfo(String algName, byte[] encryptedData) 从加密算法名称和加密数据构造一个 |
|
EncryptedPrivateKeyInfo(AlgorithmParameters algParams, byte[] encryptedData) 根据加密算法参数和加密数据构造一个 |
|
Public methods |
|
|---|---|
String |
getAlgName() 返回加密算法。 |
AlgorithmParameters |
getAlgParameters() 返回加密算法使用的算法参数。 |
byte[] |
getEncoded() 返回此对象的ASN.1编码。 |
byte[] |
getEncryptedData() 返回加密的数据。 |
PKCS8EncodedKeySpec |
getKeySpec(Key decryptKey) 从加密的数据中提取封闭的PKCS8EncodedKeySpec对象并返回。 |
PKCS8EncodedKeySpec |
getKeySpec(Key decryptKey, Provider provider) 从加密的数据中提取封闭的PKCS8EncodedKeySpec对象并返回。 |
PKCS8EncodedKeySpec |
getKeySpec(Key decryptKey, String providerName) 从加密的数据中提取封闭的PKCS8EncodedKeySpec对象并返回。 |
PKCS8EncodedKeySpec |
getKeySpec(Cipher cipher) 从加密的数据中提取封闭的PKCS8EncodedKeySpec对象并返回。 |
Inherited methods |
|
|---|---|
java.lang.Object
|
|
EncryptedPrivateKeyInfo (byte[] encoded)
从ASN.1编码构造(即解析) EncryptedPrivateKeyInfo 。
| Parameters | |
|---|---|
encoded |
byte: the ASN.1 encoding of this object. The contents of the array are copied to protect against subsequent modification. |
| Throws | |
|---|---|
NullPointerException |
if the encoded is null. |
IOException |
if error occurs when parsing the ASN.1 encoding. |
EncryptedPrivateKeyInfo (String algName, byte[] encryptedData)
从加密算法名称和加密数据构造一个 EncryptedPrivateKeyInfo 。
注意:这个构造函数将使用null作为算法参数的值。 如果加密算法的参数值不为null,则应使用不同的构造函数,例如EncryptedPrivateKeyInfo(AlgorithmParameters,byte [])。
| Parameters | |
|---|---|
algName |
String: encryption algorithm name. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard Cipher algorithm names. |
encryptedData |
byte: encrypted data. The contents of encrypedData are copied to protect against subsequent modification when constructing this object. |
| Throws | |
|---|---|
NullPointerException |
if algName or encryptedData is null. |
IllegalArgumentException |
if encryptedData is empty, i.e. 0-length. |
NoSuchAlgorithmException |
if the specified algName is not supported. |
EncryptedPrivateKeyInfo (AlgorithmParameters algParams, byte[] encryptedData)
根据加密算法参数和加密数据构造一个 EncryptedPrivateKeyInfo 。
| Parameters | |
|---|---|
algParams |
AlgorithmParameters: 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 |
byte: encrypted data. The contents of encrypedData are copied to protect against subsequent modification when constructing this object. |
| Throws | |
|---|---|
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. |
String getAlgName ()
返回加密算法。
注意:当这样的映射可用时,标准名称将在构造函数中返回而不是指定的名称。 有关标准密码算法名称的信息,请参阅Java Cryptography Architecture Reference Guide中的附录A.
| Returns | |
|---|---|
String |
the encryption algorithm name. |
AlgorithmParameters getAlgParameters ()
返回加密算法使用的算法参数。
| Returns | |
|---|---|
AlgorithmParameters |
the algorithm parameters. |
byte[] getEncoded ()
返回此对象的ASN.1编码。
| Returns | |
|---|---|
byte[] |
the ASN.1 encoding. Returns a new array each time this method is called. |
| Throws | |
|---|---|
IOException |
if error occurs when constructing its ASN.1 encoding. |
byte[] getEncryptedData ()
返回加密的数据。
| Returns | |
|---|---|
byte[] |
the encrypted data. Returns a new array each time this method is called. |
PKCS8EncodedKeySpec getKeySpec (Key decryptKey)
从加密的数据中提取封闭的PKCS8EncodedKeySpec对象并返回。
| Parameters | |
|---|---|
decryptKey |
Key: key used for decrypting the encrypted data. |
| Returns | |
|---|---|
PKCS8EncodedKeySpec |
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. |
PKCS8EncodedKeySpec getKeySpec (Key decryptKey, Provider provider)
从加密的数据中提取封闭的PKCS8EncodedKeySpec对象并返回。
| Parameters | |
|---|---|
decryptKey |
Key: key used for decrypting the encrypted data. |
provider |
Provider: the name of provider whose Cipher implementation will be used. |
| Returns | |
|---|---|
PKCS8EncodedKeySpec |
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. |
PKCS8EncodedKeySpec getKeySpec (Key decryptKey, String providerName)
从加密的数据中提取封闭的PKCS8EncodedKeySpec对象并返回。
| Parameters | |
|---|---|
decryptKey |
Key: key used for decrypting the encrypted data. |
providerName |
String: the name of provider whose Cipher implementation will be used. |
| Returns | |
|---|---|
PKCS8EncodedKeySpec |
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. |
PKCS8EncodedKeySpec getKeySpec (Cipher cipher)
从加密的数据中提取封闭的PKCS8EncodedKeySpec对象并返回。
注意:为了成功检索封装的PKCS8EncodedKeySpec对象,需要将cipher初始化为Cipher.DECRYPT_MODE或Cipher.UNWRAP_MODE,并使用与生成加密数据相同的密钥和参数。
| Parameters | |
|---|---|
cipher |
Cipher: the initialized cipher object which will be used for decrypting the encrypted data. |
| Returns | |
|---|---|
PKCS8EncodedKeySpec |
the PKCS8EncodedKeySpec object. |
| Throws | |
|---|---|
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. |