PGPDataEncryptorBuilder implementation that uses the Bouncy Castle lightweight API to
implement cryptographic primitives.
| Modifier and Type | Class and Description |
|---|---|
| private class | |
| private class |
| Modifier and Type | Field and Description |
|---|---|
| private int | |
| private int | |
| private int | |
| private boolean | |
| private SecureRandom | |
| private boolean |
| Access | Constructor and Description |
|---|---|
| public | BcPGPDataEncryptorBuilder(int
one of the encAlgorithm)supported symmetric cipher
algorithms. May not be SymmetricKeyAlgorithmTags#NULL.Constructs a new data encryptor builder for a specified cipher type. |
| Modifier and Type | Method and Description |
|---|---|
| public PGPDataEncryptor | build(byte[]
the bytes of the key to use for the cipher. keyBytes)Implements org. Builds a data encryptor using the algorithm configured for this builder. |
| public int | |
| public int | getAlgorithm()
Implements org. The encryption algorithm used by data encryptors created by this builder. |
| public int | |
| public SecureRandom | getSecureRandom()
Implements org. Gets the SecureRandom instance used by this builder. |
| public boolean | |
| public BcPGPDataEncryptorBuilder | Returns: the current builder.the secure random to be used. random)Provide a user defined source of randomness. |
| public BcPGPDataEncryptorBuilder | setUseV5AEAD()
Implements org. Specify we are using V5 AEAD. |
| public BcPGPDataEncryptorBuilder | setUseV6AEAD()
Implements org. Specify we are using V6 AEAD. |
| public BcPGPDataEncryptorBuilder | Returns: builderthe AEAD mode to use. aeadAlgorithm, int the size of the chunks to be processed with each nonce. chunkSize)Implements org. Sets whether the resulting encrypted data will be protected using an AEAD mode. |
| public BcPGPDataEncryptorBuilder | Returns: the current builder.true if an integrity packet is to be included, false otherwise. withIntegrityPacket)Implements org. Sets whether the resulting encrypted data will be protected using an integrity packet. |
| aeadAlgorithm | back to summary |
|---|---|
| private int aeadAlgorithm | |
| chunkSize | back to summary |
|---|---|
| private int chunkSize | |
| encAlgorithm | back to summary |
|---|---|
| private int encAlgorithm | |
| isV5StyleAEAD | back to summary |
|---|---|
| private boolean isV5StyleAEAD | |
| random | back to summary |
|---|---|
| private SecureRandom random | |
| withIntegrityPacket | back to summary |
|---|---|
| private boolean withIntegrityPacket | |
| BcPGPDataEncryptorBuilder | back to summary |
|---|---|
| public BcPGPDataEncryptorBuilder(int encAlgorithm) Constructs a new data encryptor builder for a specified cipher type.
| |
| build | back to summary |
|---|---|
| public PGPDataEncryptor build(byte[] keyBytes) throws PGPException Implements org. Doc from org. Builds a data encryptor using the algorithm configured for this builder.
| |
| getAeadAlgorithm | back to summary |
|---|---|
| public int getAeadAlgorithm() Implements org.
| |
| getAlgorithm | back to summary |
|---|---|
| public int getAlgorithm() Implements org. Doc from org. The encryption algorithm used by data encryptors created by this builder.
| |
| getChunkSize | back to summary |
|---|---|
| public int getChunkSize() Implements org.
| |
| getSecureRandom | back to summary |
|---|---|
| public SecureRandom getSecureRandom() Implements org. Doc from org. Gets the SecureRandom instance used by this builder.
If a SecureRandom has not been explicitly configured, a default
| |
| isV5StyleAEAD | back to summary |
|---|---|
| public boolean isV5StyleAEAD() Implements org.
| |
| setSecureRandom | back to summary |
|---|---|
| public BcPGPDataEncryptorBuilder setSecureRandom(SecureRandom random) Provide a user defined source of randomness. If no SecureRandom is configured, a default SecureRandom will be used.
| |
| setUseV5AEAD | back to summary |
|---|---|
| public BcPGPDataEncryptorBuilder setUseV5AEAD() Implements org. Doc from org. Specify we are using V5 AEAD.
| |
| setUseV6AEAD | back to summary |
|---|---|
| public BcPGPDataEncryptorBuilder setUseV6AEAD() Implements org. Doc from org. Specify we are using V6 AEAD.
| |
| setWithAEAD | back to summary |
|---|---|
| public BcPGPDataEncryptorBuilder setWithAEAD(int aeadAlgorithm, int chunkSize) Implements org. Sets whether the resulting encrypted data will be protected using an AEAD mode. The chunkSize is used as a power of two, result in blocks (1 << chunkSize) containing data with an extra 16 bytes for the tag. The minimum chunkSize is 6.
| |
| setWithIntegrityPacket | back to summary |
|---|---|
| public BcPGPDataEncryptorBuilder setWithIntegrityPacket(boolean withIntegrityPacket) Implements org. Sets whether the resulting encrypted data will be protected using an integrity packet.
| |
| Modifier and Type | Field and Description |
|---|---|
| private final AEADBlockCipher | |
| private final boolean | |
| private final byte[] | |
| private final byte[] |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public int | |
| public int | getBlockSize()
Implements org. Gets the block size of the underlying cipher used by this encryptor. |
| public int | |
| public PGPDigestCalculator | getIntegrityCalculator()
Implements org. Obtains the integrity check calculator configured for this encryptor instance. |
| public byte[] | |
| public OutputStream | getOutputStream(OutputStream
the stream to wrap and write encrypted data to. out)Implements org. Constructs an encrypting output stream that encrypts data using the underlying cipher of this encryptor. |
| c | back to summary |
|---|---|
| private final AEADBlockCipher c | |
| isV5StyleAEAD | back to summary |
|---|---|
| private final boolean isV5StyleAEAD | |
| iv | back to summary |
|---|---|
| private final byte[] iv | |
| keyBytes | back to summary |
|---|---|
| private final byte[] keyBytes | |
| MyAeadDataEncryptor | back to summary |
|---|---|
| pack-priv MyAeadDataEncryptor(byte[] keyBytes) throws PGPException Create a new data decryptor using AEAD. If the OpenPGP v5 style AEAD is used, keyBytes contains the key. The IV is randomly generated. If however OpenPGP v6 style AEAD is used, keyBytes contains M+N-8 bytes. The first M bytes contain the key, the remaining N-8 bytes contain the IV.
| |
| getAEADAlgorithm | back to summary |
|---|---|
| public int getAEADAlgorithm() Implements org.
| |
| getBlockSize | back to summary |
|---|---|
| public int getBlockSize() Implements org. Doc from org. Gets the block size of the underlying cipher used by this encryptor.
| |
| getChunkSize | back to summary |
|---|---|
| public int getChunkSize() Implements org.
| |
| getIntegrityCalculator | back to summary |
|---|---|
| public PGPDigestCalculator getIntegrityCalculator() Implements org. Doc from org. Obtains the integrity check calculator configured for this encryptor instance.
| |
| getIV | back to summary |
|---|---|
| public byte[] getIV() Implements org.
| |
| getOutputStream | back to summary |
|---|---|
| public OutputStream getOutputStream(OutputStream out) Implements org. Doc from org. Constructs an encrypting output stream that encrypts data using the underlying cipher of this encryptor. The cipher instance in this encryptor is used for all output streams obtained from this method, so it should only be invoked once.
| |
| Modifier and Type | Field and Description |
|---|---|
| private final BufferedBlockCipher |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public int | getBlockSize()
Implements org. Gets the block size of the underlying cipher used by this encryptor. |
| public PGPDigestCalculator | getIntegrityCalculator()
Implements org. Obtains the integrity check calculator configured for this encryptor instance. |
| public OutputStream | getOutputStream(OutputStream
the stream to wrap and write encrypted data to. out)Implements org. Constructs an encrypting output stream that encrypts data using the underlying cipher of this encryptor. |
| c | back to summary |
|---|---|
| private final BufferedBlockCipher c | |
| MyPGPDataEncryptor | back to summary |
|---|---|
| pack-priv MyPGPDataEncryptor(byte[] keyBytes) throws PGPException | |
| getBlockSize | back to summary |
|---|---|
| public int getBlockSize() Implements org. Doc from org. Gets the block size of the underlying cipher used by this encryptor.
| |
| getIntegrityCalculator | back to summary |
|---|---|
| public PGPDigestCalculator getIntegrityCalculator() Implements org. Doc from org. Obtains the integrity check calculator configured for this encryptor instance.
| |
| getOutputStream | back to summary |
|---|---|
| public OutputStream getOutputStream(OutputStream out) Implements org. Doc from org. Constructs an encrypting output stream that encrypts data using the underlying cipher of this encryptor. The cipher instance in this encryptor is used for all output streams obtained from this method, so it should only be invoked once.
| |