Bouncy Castle Cryptography Library 1.47

org.bouncycastle.openpgp
Class PGPEncryptedDataGenerator

java.lang.Object
  extended by org.bouncycastle.openpgp.PGPEncryptedDataGenerator
All Implemented Interfaces:
SymmetricKeyAlgorithmTags

public class PGPEncryptedDataGenerator
extends java.lang.Object
implements SymmetricKeyAlgorithmTags

Generator for encrypted objects.


Field Summary
static int S2K_SHA1
          Specifier for SHA-1 S2K PBE generator.
static int S2K_SHA224
          Specifier for SHA-224 S2K PBE generator.
static int S2K_SHA256
          Specifier for SHA-256 S2K PBE generator.
static int S2K_SHA384
          Specifier for SHA-384 S2K PBE generator.
static int S2K_SHA512
          Specifier for SHA-512 S2K PBE generator.
 
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)
          Deprecated. use constructor that takes a PGPDataEncryptorBuilder
PGPEncryptedDataGenerator(int encAlgorithm, boolean withIntegrityPacket, java.security.SecureRandom rand, java.lang.String provider)
          Deprecated. use constructor that takes a PGPDataEncryptorBuilder
PGPEncryptedDataGenerator(int encAlgorithm, java.security.SecureRandom rand, boolean oldFormat, java.security.Provider provider)
          Deprecated. use constructor that takes a PGPDataEncryptorBuilder
PGPEncryptedDataGenerator(int encAlgorithm, java.security.SecureRandom rand, boolean oldFormat, java.lang.String provider)
          Deprecated. use constructor that takes a PGPDataEncryptorBuilder
PGPEncryptedDataGenerator(int encAlgorithm, java.security.SecureRandom rand, java.security.Provider provider)
          Deprecated. use constructor that takes a PGPDataEncryptorBuilder
PGPEncryptedDataGenerator(int encAlgorithm, java.security.SecureRandom rand, java.lang.String provider)
          Deprecated. use constructor that takes a PGPDataEncryptor
PGPEncryptedDataGenerator(PGPDataEncryptorBuilder encryptorBuilder)
          Base constructor.
PGPEncryptedDataGenerator(PGPDataEncryptorBuilder encryptorBuilder, boolean oldFormat)
          Base constructor with the option to turn on formatting for PGP 2.6.x compatibility.
 
Method Summary
 void addMethod(char[] passPhrase)
          Deprecated. use addMethod that takes PGPKeyEncryptionMethodGenerator
 void addMethod(char[] passPhrase, int s2kDigest)
          Deprecated. use addMethod that takes PGPKeyEncryptionMethodGenerator
 void addMethod(PGPKeyEncryptionMethodGenerator method)
          Added a key encryption method to be used to encrypt the session data associated with this encrypted data.
 void addMethod(PGPPublicKey key)
          Deprecated. use addMethod that takes PGPKeyEncryptionMethodGenerator
 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
 

Field Detail

S2K_SHA1

public static final int S2K_SHA1
Specifier for SHA-1 S2K PBE generator.

See Also:
Constant Field Values

S2K_SHA224

public static final int S2K_SHA224
Specifier for SHA-224 S2K PBE generator.

See Also:
Constant Field Values

S2K_SHA256

public static final int S2K_SHA256
Specifier for SHA-256 S2K PBE generator.

See Also:
Constant Field Values

S2K_SHA384

public static final int S2K_SHA384
Specifier for SHA-384 S2K PBE generator.

See Also:
Constant Field Values

S2K_SHA512

public static final int S2K_SHA512
Specifier for SHA-512 S2K PBE generator.

See Also:
Constant Field Values
Constructor Detail

PGPEncryptedDataGenerator

public PGPEncryptedDataGenerator(int encAlgorithm,
                                 java.security.SecureRandom rand,
                                 java.lang.String provider)
Deprecated. use constructor that takes a PGPDataEncryptor

Base constructor.

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

PGPEncryptedDataGenerator

public PGPEncryptedDataGenerator(int encAlgorithm,
                                 java.security.SecureRandom rand,
                                 java.security.Provider provider)
Deprecated. use constructor that takes a PGPDataEncryptorBuilder

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,
                                 boolean withIntegrityPacket,
                                 java.security.SecureRandom rand,
                                 java.lang.String provider)
Deprecated. use constructor that takes a PGPDataEncryptorBuilder

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)
Deprecated. use constructor that takes a PGPDataEncryptorBuilder

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

Parameters:
encAlgorithm -
withIntegrityPacket -
rand -
provider -

PGPEncryptedDataGenerator

public PGPEncryptedDataGenerator(int encAlgorithm,
                                 java.security.SecureRandom rand,
                                 boolean oldFormat,
                                 java.lang.String provider)
Deprecated. use constructor that takes a PGPDataEncryptorBuilder

Base constructor.

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

PGPEncryptedDataGenerator

public PGPEncryptedDataGenerator(int encAlgorithm,
                                 java.security.SecureRandom rand,
                                 boolean oldFormat,
                                 java.security.Provider provider)
Deprecated. use constructor that takes a PGPDataEncryptorBuilder

Base constructor.

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

PGPEncryptedDataGenerator

public PGPEncryptedDataGenerator(PGPDataEncryptorBuilder encryptorBuilder)
Base constructor.

Parameters:
encryptorBuilder - builder to create actual data encryptor.

PGPEncryptedDataGenerator

public PGPEncryptedDataGenerator(PGPDataEncryptorBuilder encryptorBuilder,
                                 boolean oldFormat)
Base constructor with the option to turn on formatting for PGP 2.6.x compatibility.

Parameters:
encryptorBuilder - builder to create actual data encryptor.
oldFormat - PGP 2.6.x compatibility required.
Method Detail

addMethod

public void addMethod(char[] passPhrase)
               throws java.security.NoSuchProviderException,
                      PGPException
Deprecated. use addMethod that takes PGPKeyEncryptionMethodGenerator

Add a PBE encryption method to the encrypted object using the default algorithm (S2K_SHA1).

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

addMethod

public void addMethod(char[] passPhrase,
                      int s2kDigest)
               throws java.security.NoSuchProviderException,
                      PGPException
Deprecated. use addMethod that takes PGPKeyEncryptionMethodGenerator

Add a PBE encryption method to the encrypted object.

Parameters:
passPhrase - passphrase to use to generate key.
s2kDigest - digest algorithm to use for S2K calculation
Throws:
java.security.NoSuchProviderException
PGPException

addMethod

public void addMethod(PGPPublicKey key)
               throws java.security.NoSuchProviderException,
                      PGPException
Deprecated. use addMethod that takes PGPKeyEncryptionMethodGenerator

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

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

addMethod

public void addMethod(PGPKeyEncryptionMethodGenerator method)
Added a key encryption method to be used to encrypt the session data associated with this encrypted data.

Parameters:
method - key encryption method to use.

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

Bouncy Castle Cryptography Library 1.47