Overview | Package | Class | Tree | Deprecated | Index | Help
| Bouncy Castle Cryptography Library 1.45
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.bouncycastle.openpgp
Class PGPEncryptedDataGenerator

    java.lang.Object
      org.bouncycastle.openpgp.PGPEncryptedDataGenerator

All Implemented Interfaces:
  SymmetricKeyAlgorithmTags

    public class PGPEncryptedDataGenerator

extends java.lang.Object
implements SymmetricKeyAlgorithmTags

Generator for encrypted objects.

Field Summary

Fields inherited from interface org.bouncycastle.bcpg.SymmetricKeyAlgorithmTags
`AES_128, AES_192, AES_256, BLOWFISH, CAST5, DES, IDEA, NULL, SAFER, TRIPLE_DES, TWOFISH`

Constructor Summary
`PGPEncryptedDataGenerator(int encAlgorithm, boolean withIntegrityPacket, java.security.SecureRandom rand, java.security.Provider provider)`
`PGPEncryptedDataGenerator(int encAlgorithm, boolean withIntegrityPacket, java.security.SecureRandom rand, java.lang.String provider)` Creates a cipher stream which will have an integrity packet associated with it.
`PGPEncryptedDataGenerator(int encAlgorithm, java.security.SecureRandom rand, boolean oldFormat, java.security.Provider provider)`
`PGPEncryptedDataGenerator(int encAlgorithm, java.security.SecureRandom rand, boolean oldFormat, java.lang.String provider)` Base constructor.
`PGPEncryptedDataGenerator(int encAlgorithm, java.security.SecureRandom rand, java.security.Provider provider)`
`PGPEncryptedDataGenerator(int encAlgorithm, java.security.SecureRandom rand, java.lang.String provider)` Base constructor.

Method Summary
`void` | `addMethod(char[] passPhrase)` Add a PBE encryption method to the encrypted object.
`void` | `addMethod(PGPPublicKey key)` Add a public key encrypted session key to the encrypted object.
`void` | `close()` Close off the encrypted object - this is equivalent to calling close on the stream returned by the open() method.
`java.io.OutputStream` | `open(java.io.OutputStream out, byte[] buffer)` Return an outputstream which will encrypt the data as it is written to it.
`java.io.OutputStream` | `open(java.io.OutputStream out, long length)` Return an outputstream which will encrypt the data as it is written to it.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### PGPEncryptedDataGenerator

    public PGPEncryptedDataGenerator(int encAlgorithm,
                                     java.security.SecureRandom rand,
                                     java.lang.String provider)

  Base constructor.

  Parameters:
    `encAlgorithm` - the symmetric algorithm to use.
    `rand` - source of randomness
    `provider` - the provider to use for encryption algorithms.

### PGPEncryptedDataGenerator

    public PGPEncryptedDataGenerator(int encAlgorithm,
                                     java.security.SecureRandom rand,
                                     java.security.Provider provider)

### PGPEncryptedDataGenerator

    public PGPEncryptedDataGenerator(int encAlgorithm,
                                     boolean withIntegrityPacket,
                                     java.security.SecureRandom rand,
                                     java.lang.String provider)

  Creates a cipher stream which will have an integrity packet associated with it.

  Parameters:
    `encAlgorithm` -
    `withIntegrityPacket` -
    `rand` -
    `provider` -

### PGPEncryptedDataGenerator

    public PGPEncryptedDataGenerator(int encAlgorithm,
                                     boolean withIntegrityPacket,
                                     java.security.SecureRandom rand,
                                     java.security.Provider provider)

### PGPEncryptedDataGenerator

    public PGPEncryptedDataGenerator(int encAlgorithm,
                                     java.security.SecureRandom rand,
                                     boolean oldFormat,
                                     java.lang.String provider)

  Base constructor.

  Parameters:
    `encAlgorithm` - the symmetric algorithm to use.
    `rand` - source of randomness
    `oldFormat` - PGP 2.6.x compatability required.
    `provider` - the provider to use for encryption algorithms.

### PGPEncryptedDataGenerator

    public PGPEncryptedDataGenerator(int encAlgorithm,
                                     java.security.SecureRandom rand,
                                     boolean oldFormat,
                                     java.security.Provider provider)

Method Detail

### addMethod

    public void addMethod(char[] passPhrase)
                   throws java.security.NoSuchProviderException,
                          PGPException

  Add a PBE encryption method to the encrypted object.

  Parameters:
    `passPhrase` -
  Throws:
    `java.security.NoSuchProviderException`
    `PGPException`

### addMethod

    public void addMethod(PGPPublicKey key)
                   throws java.security.NoSuchProviderException,
                          PGPException

  Add a public key encrypted session key to the encrypted object.

  Parameters:
    `key` -
  Throws:
    `java.security.NoSuchProviderException`
    `PGPException`

### open

    public java.io.OutputStream open(java.io.OutputStream out,
                                     long length)
                              throws java.io.IOException,
                                     PGPException

  Return an outputstream which will encrypt the data as it is written to it.

  The stream created can be closed off by either calling close() on the stream or close() on the generator. Closing the returned stream does not close off the OutputStream parameter out.

  Parameters:
    `out` -
    `length` -
  Returns:
    OutputStream
  Throws:
    `java.io.IOException`
    `PGPException`

### open

    public java.io.OutputStream open(java.io.OutputStream out,
                                     byte[] buffer)
                              throws java.io.IOException,
                                     PGPException

  Return an outputstream which will encrypt the data as it is written to it. The stream will be written out in chunks according to the size of the passed in buffer.

  The stream created can be closed off by either calling close() on the stream or close() on the generator. Closing the returned stream does not close off the OutputStream parameter out.

  Note: if the buffer is not a power of 2 in length only the largest power of 2 bytes worth of the buffer will be used.

  Parameters:
    `out` -
    `buffer` - the buffer to use.
  Returns:
    OutputStream
  Throws:
    `java.io.IOException`
    `PGPException`

### close

    public void close()
               throws java.io.IOException

  Close off the encrypted object - this is equivalent to calling close on the stream returned by the open() method.

  Note: This does not close the underlying output stream, only the stream on top of it created by the open() method.

  Throws:
    `java.io.IOException`

Overview | Package | Class | Tree | Deprecated | Index | Help
| Bouncy Castle Cryptography Library 1.45
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD