For the latest news and information visit The GNU Crypto project

## javax.crypto
Class EncryptedPrivateKeyInfo

    java.lang.Object
      |
      +--javax.crypto.EncryptedPrivateKeyInfo

public class EncryptedPrivateKeyInfo
extends java.lang.Object

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(java.security.AlgorithmParameters algParams, byte[] encryptedData)` Constructs an `EncryptedPrivateKeyInfo` from the encryption algorithm parameters and the encrypted data.
`EncryptedPrivateKeyInfo(byte[] encoded)`
`EncryptedPrivateKeyInfo(java.lang.String algName, byte[] encryptedData)`

Method Summary
`java.lang.String` `getAlgName()` Returns the encryption algorithm.
`java.security.AlgorithmParameters` `getAlgParameters()` Returns the algorithm parameters used by the encryption algorithm.
`byte[]` `getEncoded()` Returns the ASN.1 encoding of this object.
`byte[]` `getEncryptedData()` Returns a copy of the encrypted data.
`java.security.spec.PKCS8EncodedKeySpec` `getKeySpec(Cipher c)` 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

### EncryptedPrivateKeyInfo

    public EncryptedPrivateKeyInfo(byte[] encoded)
                            throws java.lang.NullPointerException,
                                   java.io.IOException

### EncryptedPrivateKeyInfo

    public EncryptedPrivateKeyInfo(java.lang.String algName,
                                   byte[] encryptedData)
                            throws java.lang.NullPointerException,
                                   java.lang.IllegalArgumentException,
                                   java.security.NoSuchAlgorithmException

### EncryptedPrivateKeyInfo

    public EncryptedPrivateKeyInfo(java.security.AlgorithmParameters algParams,
                                   byte[] encryptedData)
                            throws java.lang.NullPointerException,
                                   java.lang.IllegalArgumentException,
                                   java.security.NoSuchAlgorithmException

  Constructs an `EncryptedPrivateKeyInfo` from the encryption algorithm parameters and the encrypted data.

  Note: the `encrypedData` is cloned when constructing this object.

Parameters:
  `algParams` - 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` - encrypted data.
Throws:
  `java.lang.NullPointerException` - if `algParams` or `encryptedData` is null.
  `java.lang.IllegalArgumentException` - if `encryptedData` is empty, i.e. 0-length.
  `java.security.NoSuchAlgorithmException` - if the specified algName of the specified `algParams` parameter is not supported.

Method Detail

### getAlgName

    public java.lang.String getAlgName()

  Returns the encryption algorithm.

### getAlgParameters

    public java.security.AlgorithmParameters getAlgParameters()

  Returns the algorithm parameters used by the encryption algorithm.

### getEncryptedData

    public byte[] getEncryptedData()

  Returns a copy of the encrypted data.

### getKeySpec

    public java.security.spec.PKCS8EncodedKeySpec getKeySpec(Cipher c)
                                                      throws java.security.spec.InvalidKeySpecException

  Extract the enclosed PKCS8EncodedKeySpec object from the encrypted data and return it.

  Returns:
    the PKCS8EncodedKeySpec object.
  Throws:
    `java.security.spec.InvalidKeySpecException` - if the given cipher is inappropriate for the encrypted data or the encrypted data is corrupted and cannot be decrypted.

### getEncoded

    public byte[] getEncoded()
                      throws java.io.IOException

  Returns the ASN.1 encoding of this object.

  Throws:
    `java.io.IOException` - if error occurs when constructing its ASN.1 encoding.

For the latest news and information visit The GNU Crypto project

Copyright © 2001, 2002, 2003, 2004 Free Software Foundation, Inc.