- java.lang.Object
-
- java.security.spec.EncodedKeySpec
-
- java.security.spec.PKCS8EncodedKeySpec
-
- 实现的所有接口
-
KeySpec
public class PKCS8EncodedKeySpec extends EncodedKeySpec
此类表示根据ASN.1类型PrivateKeyInfo编码的私钥的ASN.1编码。PrivateKeyInfo语法在PKCS#8标准中定义如下:PrivateKeyInfo ::= SEQUENCE { version Version, privateKeyAlgorithm PrivateKeyAlgorithmIdentifier, privateKey PrivateKey, attributes [0] IMPLICIT Attributes OPTIONAL } Version ::= INTEGER PrivateKeyAlgorithmIdentifier ::= AlgorithmIdentifier PrivateKey ::= OCTET STRING Attributes ::= SET OF Attribute- 从以下版本开始:
- 1.2
- 另请参见:
-
Key,KeyFactory,KeySpec,EncodedKeySpec,X509EncodedKeySpec
-
-
构造方法摘要
构造方法 构造器 描述 PKCS8EncodedKeySpec(byte[] encodedKey)使用给定的编码密钥创建新的PKCS8EncodedKeySpec。PKCS8EncodedKeySpec(byte[] encodedKey, String algorithm)使用给定的编码密钥和算法创建新的PKCS8EncodedKeySpec。
-
-
-
构造方法详细信息
-
PKCS8EncodedKeySpec
public PKCS8EncodedKeySpec(byte[] encodedKey)
使用给定的编码密钥创建新的PKCS8EncodedKeySpec。- 参数
-
encodedKey- 密钥,假设根据PKCS#8标准编码。 复制数组的内容以防止后续修改。 - 异常
-
NullPointerException- 如果encodedKey为空。
-
PKCS8EncodedKeySpec
public PKCS8EncodedKeySpec(byte[] encodedKey, String algorithm)使用给定的编码密钥和算法创建新的PKCS8EncodedKeySpec。 当PKCS8EncodedKeySpec对象的后续调用者可能不知道私钥的算法时,此构造函数很有用。- 参数
-
encodedKey- 密钥,假设根据PKCS#8标准编码。 复制数组的内容以防止后续修改。 -
algorithm- 编码私钥的算法名称有关标准算法名称的信息,请参阅 Java Security Standard Algorithm Names Specification中的KeyFactory部分。 - 异常
-
NullPointerException- 如果encodedKey或algorithm为空。 -
IllegalArgumentException- 如果algorithm是空字符串"" - 从以下版本开始:
- 9
-
-
方法详细信息
-
getEncoded
public byte[] getEncoded()
返回根据PKCS#8标准编码的关键字节。- 重写:
-
getEncodedin classEncodedKeySpec - 结果
- PKCS#8编码的密钥。 每次调用此方法时返回一个新数组。
-
getFormat
public final String getFormat()
返回与此密钥规范关联的编码格式的名称。- Specified by:
-
getFormat在课程EncodedKeySpec - 结果
-
字符串
"PKCS#8"。
-
-