public class EncryptedPrivateKeyInfo extends Object
EncryptedPrivateKeyInfo
类型中定义的# PKCS 8。
它的ASN. 1定义如下:
encryptedprivatekeyinfo::=序列{加密算法algorithmidentifier,加密的数据字符串}algorithmidentifier::=序列{算法对象标识符,参数定义的算法可选}
PKCS8EncodedKeySpec
Constructor and Description |
---|
EncryptedPrivateKeyInfo(AlgorithmParameters algParams, byte[] encryptedData)
构建了一个从加密算法和加密数据的参数
EncryptedPrivateKeyInfo 。
|
EncryptedPrivateKeyInfo(byte[] encoded)
构建(即解析)从一个
EncryptedPrivateKeyInfo ASN。1编码。
|
EncryptedPrivateKeyInfo(String algName, byte[] encryptedData)
构建了一个从加密算法和加密数据的名称
EncryptedPrivateKeyInfo 。
|
Modifier and Type | Method and Description |
---|---|
String |
getAlgName()
返回加密算法。
|
AlgorithmParameters |
getAlgParameters()
返回加密算法所使用的算法参数。
|
byte[] |
getEncoded()
返回该对象的ASN。1编码。
|
byte[] |
getEncryptedData()
返回加密数据。
|
PKCS8EncodedKeySpec |
getKeySpec(Cipher cipher)
从加密的数据提取封闭pkcs8encodedkeyspec对象并返回它。
|
PKCS8EncodedKeySpec |
getKeySpec(Key decryptKey)
从加密的数据提取封闭pkcs8encodedkeyspec对象并返回它。
|
PKCS8EncodedKeySpec |
getKeySpec(Key decryptKey, Provider provider)
从加密的数据提取封闭pkcs8encodedkeyspec对象并返回它。
|
PKCS8EncodedKeySpec |
getKeySpec(Key decryptKey, String providerName)
从加密的数据提取封闭pkcs8encodedkeyspec对象并返回它。
|
public EncryptedPrivateKeyInfo(byte[] encoded) throws IOException
EncryptedPrivateKeyInfo
ASN。1编码。
encoded
的ASN.1编码对象1。数组的内容被复制以防止后续的修改。
NullPointerException
-如果
encoded
是空的。
IOException
如果错误发生时,解析ASN.1编码1。
public EncryptedPrivateKeyInfo(String algName, byte[] encryptedData) throws NoSuchAlgorithmException
EncryptedPrivateKeyInfo
。
注:此构造函数将使用空值作为算法参数的值。如果加密算法参数的值不为空,不同的构造函数,例如encryptedprivatekeyinfo(算法参数,byte []),应使用。
algName
加密算法的名字。见附录A中的
Java Cryptography Architecture Reference Guide约标准密码算法名称信息。
encryptedData
加密的数据。
encrypedData
的内容复制到后续施工时防止修改此对象。
NullPointerException
-如果
algName
或
encryptedData
是空的。
IllegalArgumentException
-如果
encryptedData
是空的,即长度为0。
NoSuchAlgorithmException
-如果指定algname不支持。
public EncryptedPrivateKeyInfo(AlgorithmParameters algParams, byte[] encryptedData) throws NoSuchAlgorithmException
EncryptedPrivateKeyInfo
。
algParams
-加密算法参数。
algParams.getEncoded()
应该返回的ASN。1编码的字节的
EncryptedPrivateKeyInfo
型
AlgorithmIdentifer
组件的
parameters
场。
encryptedData
加密的数据。
encrypedData
的内容复制到后续施工时防止修改此对象。
NullPointerException
-如果
algParams
或
encryptedData
是空的。
IllegalArgumentException
-如果
encryptedData
是空的,即长度为0。
NoSuchAlgorithmException
-如果指定algname指定的
algParams
参数不支持。
public String getAlgName()
注:当可用的这样的映射时,标准名称将被返回,而不是在构造函数中指定的一个。见附录A中的 Java Cryptography Architecture Reference Guide约标准密码算法名称信息。
public AlgorithmParameters getAlgParameters()
public byte[] getEncryptedData()
public PKCS8EncodedKeySpec getKeySpec(Cipher cipher) throws InvalidKeySpecException
cipher
需要初始化,要么cipher.decrypt_mode或cipher.unwrap_mode,用于生成加密数据的密钥和参数相同。
cipher
-初始化密码对象将用于解密加密的数据。
NullPointerException
-如果
cipher
是空的。
InvalidKeySpecException
-如果给定的密码是不加密的数据和加密的数据已损坏,无法解密。
public PKCS8EncodedKeySpec getKeySpec(Key decryptKey) throws NoSuchAlgorithmException, InvalidKeyException
decryptKey
密钥用于解密加密的数据。
NullPointerException
-如果
decryptKey
是空的。
NoSuchAlgorithmException
如果不能找到合适的密码解密加密的数据。
InvalidKeyException
-如果
decryptKey
不能用来解密加密的数据或解密结果不是一个有效的pkcs8keyspec。
public PKCS8EncodedKeySpec getKeySpec(Key decryptKey, String providerName) throws NoSuchProviderException, NoSuchAlgorithmException, InvalidKeyException
decryptKey
密钥用于解密加密的数据。
providerName
-供应商的名称将用于密码体制的实现。
NullPointerException
-如果
decryptKey
或
providerName
是空的。
NoSuchProviderException
-如果没有提供
providerName
注册。
NoSuchAlgorithmException
如果不能找到合适的密码解密加密的数据。
InvalidKeyException
-如果
decryptKey
不能用来解密加密的数据或解密结果不是一个有效的pkcs8keyspec。
public PKCS8EncodedKeySpec getKeySpec(Key decryptKey, Provider provider) throws NoSuchAlgorithmException, InvalidKeyException
decryptKey
密钥用于解密加密的数据。
provider
-供应商的名称将用于密码体制的实现。
NullPointerException
-如果
decryptKey
或
provider
是空的。
NoSuchAlgorithmException
如果无法找到合适的密码来加密数据解密
provider
。
InvalidKeyException
-如果
decryptKey
不能用来解密加密的数据或解密结果不是一个有效的pkcs8keyspec。
public byte[] getEncoded() throws IOException
IOException
构建ASN.1编码1。
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.