PGPDataEncryptorBuilder implementation that sources cryptographic primitives using the
JCE APIs.
By default, cryptographic primitives will be loaded using the default JCE load order (i.e.
without specifying a provider).
A specific provider can be specified using one of the setProvider(String) methods.
| Modifier and Type | Class and Description |
|---|---|
| private class | |
| private class |
| Modifier and Type | Field and Description |
|---|---|
| private int | |
| private JceAEADUtil | |
| private int | |
| private final int | |
| private OperatorHelper | |
| private boolean | |
| private SecureRandom | |
| private boolean |
| Access | Constructor and Description |
|---|---|
| public | JcePGPDataEncryptorBuilder(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 JcePGPDataEncryptorBuilder | Returns: the current builder.the JCE provider to use. provider)Sets the JCE provider to source cryptographic primitives from. |
| public JcePGPDataEncryptorBuilder | Returns: the current builder.the name of the JCE provider to use. providerName)Sets the JCE provider to source cryptographic primitives from. |
| public JcePGPDataEncryptorBuilder | Returns: the current builder.the secure random to be used. random)Provide a user defined source of randomness. |
| public JcePGPDataEncryptorBuilder | setUseV5AEAD()
Implements org. Specify we are using V5 AEAD. |
| public JcePGPDataEncryptorBuilder | setUseV6AEAD()
Implements org. Specify we are using V6 AEAD. |
| public JcePGPDataEncryptorBuilder | setWithAEAD(int
the 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 JcePGPDataEncryptorBuilder | Returns: the current builder.true if an integrity packet is to be included, false otherwise. withIntegrityPacket)Implements org. Sets whether or not the resulting encrypted data will be protected using an integrity packet. |
| aeadAlgorithm | back to summary |
|---|---|
| private int aeadAlgorithm | |
| aeadHelper | back to summary |
|---|---|
| private JceAEADUtil aeadHelper | |
| chunkSize | back to summary |
|---|---|
| private int chunkSize | |
| encAlgorithm | back to summary |
|---|---|
| private final int encAlgorithm | |
| helper | back to summary |
|---|---|
| private OperatorHelper helper | |
| isV5StyleAEAD | back to summary |
|---|---|
| private boolean isV5StyleAEAD | |
| random | back to summary |
|---|---|
| private SecureRandom random | |
| withIntegrityPacket | back to summary |
|---|---|
| private boolean withIntegrityPacket | |
| JcePGPDataEncryptorBuilder | back to summary |
|---|---|
| public JcePGPDataEncryptorBuilder(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.
| |
| setProvider | back to summary |
|---|---|
| public JcePGPDataEncryptorBuilder setProvider(Provider provider) Sets the JCE provider to source cryptographic primitives from.
| |
| setProvider | back to summary |
|---|---|
| public JcePGPDataEncryptorBuilder setProvider(String providerName) Sets the JCE provider to source cryptographic primitives from.
| |
| setSecureRandom | back to summary |
|---|---|
| public JcePGPDataEncryptorBuilder 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 JcePGPDataEncryptorBuilder setUseV5AEAD() Implements org. Doc from org. Specify we are using V5 AEAD.
| |
| setUseV6AEAD | back to summary |
|---|---|
| public JcePGPDataEncryptorBuilder setUseV6AEAD() Implements org. Doc from org. Specify we are using V6 AEAD.
| |
| setWithAEAD | back to summary |
|---|---|
| public JcePGPDataEncryptorBuilder setWithAEAD(int aeadAlgorithm, int chunkSize) Implements org. Doc from 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 JcePGPDataEncryptorBuilder setWithIntegrityPacket(boolean withIntegrityPacket) Implements org. Sets whether or not the resulting encrypted data will be protected using an integrity packet.
| |
| Modifier and Type | Field and Description |
|---|---|
| private final Cipher | |
| 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 Cipher 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 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.
| |
| 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 Cipher 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.
| |