public class BcPGPDataEncryptorBuilder extends java.lang.Object implements PGPDataEncryptorBuilder
PGPDataEncryptorBuilder implementation that uses the Bouncy Castle lightweight API to
implement cryptographic primitives.| Constructor and Description |
|---|
BcPGPDataEncryptorBuilder(int encAlgorithm)
Constructs a new data encryptor builder for a specified cipher type.
|
| Modifier and Type | Method and Description |
|---|---|
PGPDataEncryptor |
build(byte[] keyBytes)
Builds a data encryptor using the algorithm configured for this builder.
|
int |
getAeadAlgorithm() |
int |
getAlgorithm()
The encryption algorithm used by data encryptors created by this builder.
|
int |
getChunkSize() |
java.security.SecureRandom |
getSecureRandom()
Gets the SecureRandom instance used by this builder.
|
boolean |
isV5StyleAEAD() |
BcPGPDataEncryptorBuilder |
setSecureRandom(java.security.SecureRandom random)
Provide a user defined source of randomness.
|
BcPGPDataEncryptorBuilder |
setUseV5AEAD()
Specify we are using V5 AEAD.
|
BcPGPDataEncryptorBuilder |
setUseV6AEAD()
Specify we are using V6 AEAD.
|
BcPGPDataEncryptorBuilder |
setWithAEAD(int aeadAlgorithm,
int chunkSize)
Sets whether the resulting encrypted data will be protected using an AEAD mode.
|
BcPGPDataEncryptorBuilder |
setWithIntegrityPacket(boolean withIntegrityPacket)
Sets whether the resulting encrypted data will be protected using an integrity packet.
|
public BcPGPDataEncryptorBuilder(int encAlgorithm)
encAlgorithm - one of the supported symmetric cipher
algorithms. May not be SymmetricKeyAlgorithmTags.NULL.public BcPGPDataEncryptorBuilder setWithIntegrityPacket(boolean withIntegrityPacket)
setWithIntegrityPacket in interface PGPDataEncryptorBuilderwithIntegrityPacket - true if an integrity packet is to be included, false otherwise.public BcPGPDataEncryptorBuilder setUseV5AEAD()
PGPDataEncryptorBuildersetUseV5AEAD in interface PGPDataEncryptorBuilderpublic BcPGPDataEncryptorBuilder setUseV6AEAD()
PGPDataEncryptorBuildersetUseV6AEAD in interface PGPDataEncryptorBuilderpublic BcPGPDataEncryptorBuilder setWithAEAD(int aeadAlgorithm, int chunkSize)
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.
setWithAEAD in interface PGPDataEncryptorBuilderaeadAlgorithm - the AEAD mode to use.chunkSize - the size of the chunks to be processed with each nonce.public BcPGPDataEncryptorBuilder setSecureRandom(java.security.SecureRandom random)
If no SecureRandom is configured, a default SecureRandom will be used.
random - the secure random to be used.public int getAlgorithm()
PGPDataEncryptorBuildergetAlgorithm in interface PGPDataEncryptorBuildersymmetric encryption algorithms.public int getAeadAlgorithm()
getAeadAlgorithm in interface PGPDataEncryptorBuilderpublic int getChunkSize()
getChunkSize in interface PGPDataEncryptorBuilderpublic boolean isV5StyleAEAD()
isV5StyleAEAD in interface PGPDataEncryptorBuilderpublic java.security.SecureRandom getSecureRandom()
PGPDataEncryptorBuilder
If a SecureRandom has not been explicitly configured, a default SecureRandom is
constructed and retained by the this builder.
getSecureRandom in interface PGPDataEncryptorBuilderpublic PGPDataEncryptor build(byte[] keyBytes) throws PGPException
PGPDataEncryptorBuilderbuild in interface PGPDataEncryptorBuilderkeyBytes - the bytes of the key to use for the cipher.PGPException - if an error occurs initialising the configured encryption.