Interface PGPDataEncryptorBuilder

All Known Implementing Classes:
BcPGPDataEncryptorBuilder, JcePGPDataEncryptorBuilder

public interface PGPDataEncryptorBuilder
A builder for PGPDataEncryptor instances, which can be used to encrypt data objects.
  • Method Details

    • getAlgorithm

      int getAlgorithm()
      The encryption algorithm used by data encryptors created by this builder.
      Returns:
      one of the symmetric encryption algorithms.
    • getAeadAlgorithm

      int getAeadAlgorithm()
    • getChunkSize

      int getChunkSize()
    • isV5StyleAEAD

      boolean isV5StyleAEAD()
    • build

      PGPDataEncryptor build(byte[] keyBytes) throws PGPException
      Builds a data encryptor using the algorithm configured for this builder.
      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.
    • build

      PGPDataEncryptor build(byte[] key, byte[] salt) throws PGPException
      Builds a data encryptor for OpenPGP v2 SEIPD (AEAD), deriving the message key and IV from the supplied session key and salt per RFC 9580 sec. 5.13.2, using this builder's crypto stack. Only meaningful when the builder is configured for v2 SEIPD (v6) AEAD; the derivation is owned here rather than by the caller so it runs through the same provider as the cipher.
      Parameters:
      key - the session key.
      salt - the 32-octet salt carried in the v2 SEIPD packet.
      Returns:
      a data encryptor with an initialised AEAD cipher.
      Throws:
      PGPException - if an error occurs deriving the message key or initialising the cipher.
    • getSecureRandom

      SecureRandom getSecureRandom()
      Gets the SecureRandom instance used by this builder.

      If a SecureRandom has not been explicitly configured, a default SecureRandom is constructed and retained by the this builder.

    • setWithIntegrityPacket

      PGPDataEncryptorBuilder setWithIntegrityPacket(boolean withIntegrityPacket)
      Sets whether or not the resulting encrypted data will be protected using an integrity packet.
      Parameters:
      withIntegrityPacket - true if an integrity packet is to be included, false otherwise.
      Returns:
      the current builder.
    • setWithAEAD

      PGPDataEncryptorBuilder setWithAEAD(int aeadAlgorithm, int chunkSize)
      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.
      Parameters:
      aeadAlgorithm - the AEAD mode to use.
      chunkSize - the size of the chunks to be processed with each nonce.
      Returns:
      the current builder
    • setUseV5AEAD

      PGPDataEncryptorBuilder setUseV5AEAD()
      Specify we are using V5 AEAD.
      Returns:
      the current builder
    • setUseV6AEAD

      PGPDataEncryptorBuilder setUseV6AEAD()
      Specify we are using V6 AEAD.
      Returns:
      the current builder