Class BigIntegerCounterNonce

java.lang.Object
org.cryptacular.generator.sp80038a.BigIntegerCounterNonce
All Implemented Interfaces:
Nonce

public class BigIntegerCounterNonce extends Object implements Nonce
Uses a BigInteger to back a counter in order to produce nonces of arbitrary length.

A common use case for this component is creation of IVs for ciphers with 16-byte block size, e.g. AES.

Instances of this class are thread safe.

Author:
Middleware Services
  • Constructor Details

    • BigIntegerCounterNonce

      public BigIntegerCounterNonce(BigInteger counter, int length)
      Creates a new instance with given parameters.
      Parameters:
      counter - Initial counter value.
      length - Maximum length of generated counter values in bytes.
  • Method Details

    • generate

      public byte[] generate() throws LimitException
      Description copied from interface: Nonce
      Generates a nonce value.
      Specified by:
      generate in interface Nonce
      Returns:
      Nonce bytes.
      Throws:
      LimitException - When a limit imposed by the nonce generation strategy, if any, is exceeded.
    • getLength

      public int getLength()
      Specified by:
      getLength in interface Nonce
      Returns:
      Length in bytes of generated nonce values.