Class GeneralAuthParameters<T extends GeneralAuthParameters>

Type Parameters:
T - the actual parameters type that extends this class.
All Implemented Interfaces:
AuthenticationParameters<T>, AuthenticationParametersWithIV<T>, Parameters, ParametersWithIV<T>
Direct Known Subclasses:
AES.AuthParameters, ARIA.AuthParameters, Blowfish.AuthParameters, Camellia.AuthParameters, CAST5.AuthParameters, ChaCha20.AuthParameters, DES.AuthParameters, GOST28147.AuthParameters, IDEA.AuthParameters, Poly1305.AuthParameters, RC2.AuthParameters, SEED.AuthParameters, Serpent.AuthParameters, SHACAL2.AuthParameters, TripleDES.AuthParameters, Twofish.AuthParameters

public abstract class GeneralAuthParameters<T extends GeneralAuthParameters> extends GeneralParametersWithIV<T> implements AuthenticationParametersWithIV<T>
Base class for parameter classes for algorithms allow for authentication using MACs.
  • Field Details

    • macLenInBits

      protected final int macLenInBits
  • Constructor Details

    • GeneralAuthParameters

      protected GeneralAuthParameters(GeneralAlgorithm algorithm, int blockSize, byte[] iv, int macSizeInBits)
      Base Constructor that takes an iv (nonce) and a tag length.
      Parameters:
      algorithm - algorithm mode.
      blockSize - block size of the cipher in bytes.
      iv - iv, or nonce, to be used with this algorithm.
      macSizeInBits - length of the checksum tag in bits.
  • Method Details

    • getMACSizeInBits

      public int getMACSizeInBits()
      Return the size of the MAC these parameters are for.
      Specified by:
      getMACSizeInBits in interface AuthenticationParameters<T extends GeneralAuthParameters>
      Returns:
      the MAC size in bits.
    • withIV

      public T withIV(SecureRandom random, int ivLen)
      Return an implementation of our parameterized type with an IV constructed from the passed in SecureRandom.
      Specified by:
      withIV in interface AuthenticationParametersWithIV<T extends GeneralAuthParameters>
      Parameters:
      random - the SecureRandom to use as the source of IV data.
      ivLen - the length (in bytes) of the IV to be generated.
      Returns:
      a new instance of our parameterized type with a new IV.
    • withMACSize

      public T withMACSize(int macSizeInBits)
      Create a parameter set with the specified MAC size associated with it.
      Specified by:
      withMACSize in interface AuthenticationParameters<T extends GeneralAuthParameters>
      Parameters:
      macSizeInBits - bit length of the MAC length.
      Returns:
      the new parameter set.
    • create

      protected T create(GeneralAlgorithm algorithm, byte[] iv)