Class BcPGPDataEncryptorBuilder

    • Constructor Summary

      Constructors 
      Constructor Description
      BcPGPDataEncryptorBuilder​(int encAlgorithm)
      Constructs a new data encryptor builder for a specified cipher type.
    • Method Detail

      • setWithIntegrityPacket

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

        public BcPGPDataEncryptorBuilder setWithAEAD​(int aeadAlgorithm,
                                                     int chunkSize)
        Description copied from interface: PGPDataEncryptorBuilder
        Sets whether or not 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:
        setWithAEAD in interface PGPDataEncryptorBuilder
        Parameters:
        aeadAlgorithm - the AEAD mode to use.
        chunkSize - the size of the chunks to be processed with each nonce.
      • setSecureRandom

        public BcPGPDataEncryptorBuilder setSecureRandom​(java.security.SecureRandom random)
        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.
      • getSecureRandom

        public java.security.SecureRandom getSecureRandom()
        Description copied from interface: PGPDataEncryptorBuilder
        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.

        Specified by:
        getSecureRandom in interface PGPDataEncryptorBuilder
      • build

        public PGPDataEncryptor build​(byte[] keyBytes)
                               throws PGPException
        Description copied from interface: PGPDataEncryptorBuilder
        Builds a data encryptor using the algorithm configured for this builder.
        Specified by:
        build in interface PGPDataEncryptorBuilder
        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.