Class LongCounterNonce

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

public class LongCounterNonce extends Object implements Nonce
Simple counter nonce that uses a long integer counter internally and produces 8-byte nonces. Note that this component is suitable exclusively for ciphers with block length 8, e.g. Blowfish.

Instances of this class are thread safe.

Author:
Middleware Services
See Also:
  • Constructor Details

    • LongCounterNonce

      public LongCounterNonce()
      Creates a new instance whose counter values start at 1.
    • LongCounterNonce

      public LongCounterNonce(long start)
      Creates a new instance whose counter values start above the given value.
      Parameters:
      start - Start value.
  • 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.