Class BcPGPDataEncryptorBuilder
java.lang.Object
org.bouncycastle.openpgp.operator.bc.BcPGPDataEncryptorBuilder
- All Implemented Interfaces:
PGPDataEncryptorBuilder
PGPDataEncryptorBuilder implementation that uses the Bouncy Castle lightweight API to
implement cryptographic primitives.-
Constructor Summary
ConstructorsConstructorDescriptionBcPGPDataEncryptorBuilder(int encAlgorithm) Constructs a new data encryptor builder for a specified cipher type. -
Method Summary
Modifier and TypeMethodDescriptionbuild(byte[] keyBytes) Builds a data encryptor using the algorithm configured for this builder.intintThe encryption algorithm used by data encryptors created by this builder.intGets the SecureRandom instance used by this builder.booleansetSecureRandom(SecureRandom random) Provide a user defined source of randomness.Specify we are using V5 AEAD.Specify we are using V6 AEAD.setWithAEAD(int aeadAlgorithm, int chunkSize) Sets whether the resulting encrypted data will be protected using an AEAD mode.setWithIntegrityPacket(boolean withIntegrityPacket) Sets whether the resulting encrypted data will be protected using an integrity packet.
-
Constructor Details
-
BcPGPDataEncryptorBuilder
public BcPGPDataEncryptorBuilder(int encAlgorithm) Constructs a new data encryptor builder for a specified cipher type.- Parameters:
encAlgorithm- one of thesupported symmetric cipher algorithms. May not beSymmetricKeyAlgorithmTags.NULL.
-
-
Method Details
-
setWithIntegrityPacket
Sets whether the resulting encrypted data will be protected using an integrity packet.- Specified by:
setWithIntegrityPacketin interfacePGPDataEncryptorBuilder- Parameters:
withIntegrityPacket- true if an integrity packet is to be included, false otherwise.- Returns:
- the current builder.
-
setUseV5AEAD
Description copied from interface:PGPDataEncryptorBuilderSpecify we are using V5 AEAD.- Specified by:
setUseV5AEADin interfacePGPDataEncryptorBuilder- Returns:
- the current builder
-
setUseV6AEAD
Description copied from interface:PGPDataEncryptorBuilderSpecify we are using V6 AEAD.- Specified by:
setUseV6AEADin interfacePGPDataEncryptorBuilder- Returns:
- the current builder
-
setWithAEAD
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.
- Specified by:
setWithAEADin interfacePGPDataEncryptorBuilder- Parameters:
aeadAlgorithm- the AEAD mode to use.chunkSize- the size of the chunks to be processed with each nonce.- Returns:
- builder
-
setSecureRandom
Provide a user defined source of randomness.If no SecureRandom is configured, a default SecureRandom will be used.
- Parameters:
random- the secure random to be used.- Returns:
- the current builder.
-
getAlgorithm
public int getAlgorithm()Description copied from interface:PGPDataEncryptorBuilderThe encryption algorithm used by data encryptors created by this builder.- Specified by:
getAlgorithmin interfacePGPDataEncryptorBuilder- Returns:
- one of the
symmetric encryption algorithms.
-
getAeadAlgorithm
public int getAeadAlgorithm()- Specified by:
getAeadAlgorithmin interfacePGPDataEncryptorBuilder
-
getChunkSize
public int getChunkSize()- Specified by:
getChunkSizein interfacePGPDataEncryptorBuilder
-
isV5StyleAEAD
public boolean isV5StyleAEAD()- Specified by:
isV5StyleAEADin interfacePGPDataEncryptorBuilder
-
getSecureRandom
Description copied from interface:PGPDataEncryptorBuilderGets the SecureRandom instance used by this builder.If a SecureRandom has not been explicitly configured, a default
SecureRandomis constructed and retained by the this builder.- Specified by:
getSecureRandomin interfacePGPDataEncryptorBuilder
-
build
Description copied from interface:PGPDataEncryptorBuilderBuilds a data encryptor using the algorithm configured for this builder.- Specified by:
buildin interfacePGPDataEncryptorBuilder- Parameters:
keyBytes- the bytes of the key to use for the cipher.- Returns:
- a data encryptor with an initialised cipher.
- Throws:
PGPException- if an error occurs initialising the configured encryption.
-