java.lang.Objectjavax.crypto.EncryptedPrivateKeyInfo
public class EncryptedPrivateKeyInfo
      此类实现 EncryptedPrivateKeyInfo 类型,如在 PKCS #8 中定义的那样。 
它的 ASN.1 定义如下:
 EncryptedPrivateKeyInfo ::=  SEQUENCE {
     encryptionAlgorithm   AlgorithmIdentifier,
     encryptedData   OCTET STRING }
 
 AlgorithmIdentifier  ::=  SEQUENCE  {
     algorithm              OBJECT IDENTIFIER,
     parameters             ANY DEFINED BY algorithm OPTIONAL  }
  
  
PKCS8EncodedKeySpec
   | 构造方法摘要 | |
|---|---|
EncryptedPrivateKeyInfo(AlgorithmParameters algParams, byte[] encryptedData) 根据加密算法参数和加密数据构造 EncryptedPrivateKeyInfo。 |  
    |
EncryptedPrivateKeyInfo(byte[] encoded) 根据其 ASN.1 编码构造(即解析) EncryptedPrivateKeyInfo。 |  
    |
EncryptedPrivateKeyInfo(String algName, byte[] encryptedData) 根据加密算法名称和加密数据构造 EncryptedPrivateKeyInfo。 |  
    |
| 方法摘要 | |
|---|---|
  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 对象从加密的数据中抽取出来并将其返回。  |  
    
| 从类 java.lang.Object 继承的方法 | 
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |  
    
| 构造方法详细信息 | 
|---|
public EncryptedPrivateKeyInfo(byte[] encoded)
                        throws IOException 
  EncryptedPrivateKeyInfo。 
    
encoded - 此对象的 ASN.1 编码。该数组的内容被复制,以免后续修改。 
     NullPointerException - 如果 
      encoded 为 null。 
     IOException - 如果在解析 ASN.1 编码过程中出现错误。
     public EncryptedPrivateKeyInfo(String algName, byte[] encryptedData) throws NoSuchAlgorithmException
EncryptedPrivateKeyInfo。 
    注:此构造方法将用 null 充当算法参数的值。如果加密算法所带的参数不为 null,则应换一种构造方法使用,例如,EncryptedPrivateKeyInfo(AlgorithmParameters, byte[])。
algName - 加密算法名称。有关标准 Cipher 算法名称的信息,请参见 
       Java Cryptography Architecture Reference Guide 中的附录 A。
     encryptedData - 加密数据。
      encrypedData 的内容被复制,以免构造此对象时出现后续修改。 
     NullPointerException - 如果 
      algName 或 
      encryptedData 为 null。 
     IllegalArgumentException - 如果 
      encryptedData 为空,即长度为 0。 
     NoSuchAlgorithmException - 如果指定的 algName 不受支持。
     public EncryptedPrivateKeyInfo(AlgorithmParameters algParams, byte[] encryptedData) throws NoSuchAlgorithmException
EncryptedPrivateKeyInfo。 
    
algParams - 供加密算法使用的算法参数。
      algParams.getEncoded() 应返回 
      EncryptedPrivateKeyInfo 类型的 
      AlgorithmIdentifer 部分的 
      parameters 字段的 ASN.1 编码字节。
     encryptedData - 加密数据。
      encrypedData 的内容被复制,以免构造此对象时的后续修改。 
     NullPointerException - 如果 
      algParams 或 
      encryptedData 为 null。 
     IllegalArgumentException - 如果 
      encryptedData 为空,即长度为 0。 
     NoSuchAlgorithmException - 如果的指定的 
      algParams 参数的指定 algName 不受支持。
     | 方法详细信息 | 
|---|
public String getAlgName()
注:如果有这样的映射可用,则返回标准名称而不是指定的名称。有关标准 Cipher 算法名称的信息,请参见 Java Cryptography Architecture Reference Guide 中的附录 A。
public AlgorithmParameters getAlgParameters()
public byte[] getEncryptedData()
public PKCS8EncodedKeySpec getKeySpec(Cipher cipher) throws InvalidKeySpecException
cipher 初始化为 Cipher.DECRYPT_MODE 或 Cipher.UNWRAP_MODE。 
    
cipher - 将用于对加密的数据进行解密的初始化密码对象。 
     NullPointerException - 如果 
      cipher 为 null。 
     InvalidKeySpecException - 如果给定的密码不适合加密的数据,或者加密的数据已损坏,无法解密。
     public PKCS8EncodedKeySpec getKeySpec(Key decryptKey) throws NoSuchAlgorithmException, InvalidKeyException
decryptKey - 在对加密的数据进行解密时所使用的密钥。 
     NullPointerException - 如果 
      decryptKey 为 null。 
     NoSuchAlgorithmException - 如果无法找到合适的密码对加密的数据进行解密。 
     InvalidKeyException - 如果无法用 
      decryptKey 对加密的数据进行解密,或者解密结果不是有效的 PKCS8KeySpec。
     public PKCS8EncodedKeySpec getKeySpec(Key decryptKey, String providerName) throws NoSuchProviderException, NoSuchAlgorithmException, InvalidKeyException
decryptKey - 在对加密的数据进行解密时所使用的密钥。
     providerName - 其 Cipher 实现将被使用的提供者的名称。 
     NullPointerException - 如果 
      decryptKey 或 
      providerName 为 null。 
     NoSuchProviderException - 如果没有注册任何名称为 
      providerName 的提供者。 
     NoSuchAlgorithmException - 如果无法找到合适的密码对加密的数据进行解密。 
     InvalidKeyException - 如果无法用 
      decryptKey 对加密的数据进行解密,或者解密结果不是有效的 PKCS8KeySpec。
     public PKCS8EncodedKeySpec getKeySpec(Key decryptKey, Provider provider) throws NoSuchAlgorithmException, InvalidKeyException
decryptKey - 在对加密的数据进行解密时所使用的密钥。
     provider - 其 Cipher 实现将被使用的提供者的名称。 
     NullPointerException - 如果 
      decryptKey 或 
      provider 为 null。 
     NoSuchAlgorithmException - 如果在 
      provider 中无法找到合适的密码对加密的数据进行解密。 
     InvalidKeyException - 如果无法用 
      decryptKey 对加密的数据进行解密,或者解密结果不是有效的 PKCS8KeySpec。
     
public byte[] getEncoded()
                  throws IOException 
  
IOException - 如果在构造 ASN.1 编码过程中发生错误。