A PGPEncryptedDataGenerator is used by configuring one or more encryption
methods, and then invoking one of the open functions to create an OutputStream that raw data can
be supplied to for encryption:
open(OutputStream, long) to create a packet containing a single encrypted object.open(OutputStream, byte[]) to create an
packet consisting of a series of encrypted objects (partials).
Raw data is not typically written directly to the OutputStream obtained from a
PGPEncryptedDataGenerator. The OutputStream is usually wrapped by a
PGPLiteralDataGenerator, and often with a PGPCompressedDataGenerator between.
Once plaintext data for encryption has been written to the constructed OutputStream, writing of
the encrypted object stream is completed by closing the OutputStream obtained from the
open() method, or equivalently invoking close() on this generator.
| Modifier and Type | Class and Description |
|---|---|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private OutputStream | |
| private PGPDataEncryptorBuilder | |
| private int | |
| private PGPDigestCalculator | |
| private OutputStream | |
| private List | |
| private boolean | |
| private BCPGOutputStream | |
| private SecureRandom | |
| public static final int | S2K_SHA1
Specifier for SHA-1 S2K PBE generator. |
| public static final int | S2K_SHA224
Specifier for SHA-224 S2K PBE generator. |
| public static final int | S2K_SHA256
Specifier for SHA-256 S2K PBE generator. |
| public static final int | S2K_SHA384
Specifier for SHA-384 S2K PBE generator. |
| public static final int | S2K_SHA512
Specifier for SHA-512 S2K PBE generator. |
| Access | Constructor and Description |
|---|---|
| public | PGPEncryptedDataGenerator(PGPDataEncryptorBuilder
builder to create actual data encryptor. encryptorBuilder)Base constructor. |
| public | PGPEncryptedDataGenerator(PGPDataEncryptorBuilder
builder to create actual data encryptor. encryptorBuilder, boolean PGP 2.6.x compatibility required. oldFormat)Base constructor with the option to turn on formatting for PGP 2.6.x compatibility. |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| public void | addMethod(PGPKeyEncryptionMethodGenerator
key encryption method to use. method)Add a key encryption method to be used to encrypt the session data associated with this encrypted data. |
| public void | close()
Implements org. open() methods.
|
| private byte[] | |
| private OutputStream | Returns: the generator's output stream.the stream to write encrypted packets to. out, long the length of the data to be encrypted. Ignored if buffer is non
length, byte[] null.a buffer to use to buffer and write partial packets. buffer)Create an OutputStream based on the configured methods. |
| public OutputStream | Returns: the output stream to write data to for encryption.the stream to write encrypted packets to. out, long the length of the data to be encrypted. length)Create an OutputStream based on the configured methods to write a single encrypted object of known length. |
| public OutputStream | Returns: the output stream to write data to for encryption.the stream to write encrypted packets to. out, byte[] a buffer to use to buffer and write partial packets. The returned stream takes
ownership of the buffer and will use it to buffer plaintext data for encryption. buffer)Create an OutputStream which will encrypt the data as it is written to it. |
| cOut | back to summary |
|---|---|
| private OutputStream cOut | |
| dataEncryptorBuilder | back to summary |
|---|---|
| private PGPDataEncryptorBuilder dataEncryptorBuilder | |
| defAlgorithm | back to summary |
|---|---|
| private int defAlgorithm | |
| digestCalc | back to summary |
|---|---|
| private PGPDigestCalculator digestCalc | |
| genOut | back to summary |
|---|---|
| private OutputStream genOut | |
| methods | back to summary |
|---|---|
| private List<E> methods | |
| oldFormat | back to summary |
|---|---|
| private boolean oldFormat | |
| pOut | back to summary |
|---|---|
| private BCPGOutputStream pOut | |
| rand | back to summary |
|---|---|
| private SecureRandom rand | |
| S2K_SHA1 | back to summary |
|---|---|
| public static final int S2K_SHA1 Specifier for SHA-1 S2K PBE generator. | |
| S2K_SHA224 | back to summary |
|---|---|
| public static final int S2K_SHA224 Specifier for SHA-224 S2K PBE generator. | |
| S2K_SHA256 | back to summary |
|---|---|
| public static final int S2K_SHA256 Specifier for SHA-256 S2K PBE generator. | |
| S2K_SHA384 | back to summary |
|---|---|
| public static final int S2K_SHA384 Specifier for SHA-384 S2K PBE generator. | |
| S2K_SHA512 | back to summary |
|---|---|
| public static final int S2K_SHA512 Specifier for SHA-512 S2K PBE generator. | |
| PGPEncryptedDataGenerator | back to summary |
|---|---|
| public PGPEncryptedDataGenerator(PGPDataEncryptorBuilder encryptorBuilder) Base constructor.
| |
| PGPEncryptedDataGenerator | back to summary |
|---|---|
| public PGPEncryptedDataGenerator(PGPDataEncryptorBuilder encryptorBuilder, boolean oldFormat) Base constructor with the option to turn on formatting for PGP 2.6.x compatibility.
| |
| addCheckSum | back to summary |
|---|---|
| private void addCheckSum(byte[] sessionInfo) | |
| addMethod | back to summary |
|---|---|
| public void addMethod(PGPKeyEncryptionMethodGenerator method) Add a key encryption method to be used to encrypt the session data associated with this encrypted data.
| |
| close | back to summary |
|---|---|
| public void close() throws IOException Implements org. Close off the encrypted object - this is equivalent to calling close on the stream returned
by the Note This does not close the underlying output stream, only the stream on top of it
created by the
| |
| createSessionInfo | back to summary |
|---|---|
| private byte[] createSessionInfo(int algorithm, byte[] keyBytes) | |
| open | back to summary |
|---|---|
| private OutputStream open(OutputStream out, long length, byte[] buffer) throws IOException, PGPException, IllegalStateException Create an OutputStream based on the configured methods.
If the supplied buffer is non 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.
| |
| open | back to summary |
|---|---|
| public OutputStream open(OutputStream out, long length) throws IOException, PGPException Create an OutputStream based on the configured methods to write a single encrypted object of known length. 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.
| |
| open | back to summary |
|---|---|
| public OutputStream open(OutputStream out, byte[] buffer) throws IOException, PGPException Create an OutputStream which will encrypt the data as it is written to it. The stream of encrypted data will be written out in chunks (partial packets) 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.
| |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Overrides org. Implements java. |
| ClosableBCPGOutputStream | back to summary |
|---|---|
| public ClosableBCPGOutputStream(OutputStream out, int symmetricKeyEnc, byte[] buffer) throws IOException | |
| ClosableBCPGOutputStream | back to summary |
|---|---|
| public ClosableBCPGOutputStream(OutputStream out, int symmetricKeyEnc, long length, boolean oldFormat) throws IOException | |
| ClosableBCPGOutputStream | back to summary |
|---|---|
| public ClosableBCPGOutputStream(OutputStream out, int symEncIntegrityPro, long length) throws IOException | |
| close | back to summary |
|---|---|
| public void close() throws IOException Overrides org. Implements java. Doc from java. Closes this output stream and releases any system resources
associated with this stream. The general contract of
| |