org.bouncycastle.openpgp

Class PGPEncryptedDataGenerator

Implemented Interfaces:
SymmetricKeyAlgorithmTags

public class PGPEncryptedDataGenerator
extends java.lang.Object
implements SymmetricKeyAlgorithmTags

Generator for encrypted objects.

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, SecureRandom rand, String provider)
Base constructor.
PGPEncryptedDataGenerator(int encAlgorithm, SecureRandom rand, boolean oldFormat, String provider)
Base constructor.
PGPEncryptedDataGenerator(int encAlgorithm, boolean withIntegrityPacket, SecureRandom rand, String provider)
Creates a cipher stream which will have an integrity packet associated with it.

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.
OutputStream
open(OutputStream out, byte[] buffer)
Return an outputstream which will encrypt the data as it is written to it.
OutputStream
open(OutputStream out, long length)
Return an outputstream which will encrypt the data as it is written to it.

Constructor Details

PGPEncryptedDataGenerator

public PGPEncryptedDataGenerator(int encAlgorithm,
                                 SecureRandom rand,
                                 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,
                                 SecureRandom rand,
                                 boolean oldFormat,
                                 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,
                                 boolean withIntegrityPacket,
                                 SecureRandom rand,
                                 String provider)
Creates a cipher stream which will have an integrity packet associated with it.

Parameters:
encAlgorithm -
withIntegrityPacket -
rand -
provider -

Method Details

addMethod

public void addMethod(char[] passPhrase)
            throws NoSuchProviderException,
                   PGPException
Add a PBE encryption method to the encrypted object.

Parameters:
passPhrase -

Throws:
PGPException -


addMethod

public void addMethod(PGPPublicKey key)
            throws NoSuchProviderException,
                   PGPException
Add a public key encrypted session key to the encrypted object.

Parameters:
key -

Throws:
PGPException -


close

public void close()
            throws IOException
Close off the encrypted object.


open

public OutputStream open(OutputStream out,
                         byte[] buffer)
            throws 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.

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:
PGPException -


open

public OutputStream open(OutputStream out,
                         long length)
            throws IOException,
                   PGPException
Return an outputstream which will encrypt the data as it is written to it.

Parameters:
out -
length -

Returns:
OutputStream

Throws:
PGPException -