Class RBGNonce

java.lang.Object
org.cryptacular.generator.sp80038d.RBGNonce
All Implemented Interfaces:
Nonce

public class RBGNonce extends Object implements Nonce
RBG-based nonce generation strategy that uses a RBG component to produce values for the invocation field as described in NIST SP-800-38D, section 8.2.2.

NOTE: users of this class are responsible for counting number of invocations and enforcing the constraints described in section 8.3; namely the following:

The total number of invocations of the authenticated encryption function shall not exceed 232, including all IV lengths and all instances of the authenticated encryption function with the given key.

Instances of this class are thread safe.

Author:
Middleware Services
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new instance that produces 12-bytes (96-bits) of random data; that is, the fixed field of the nonce is null.
    RBGNonce(int randomLength)
    Creates a new instance that produces length bytes of random data; that is, the fixed field of the nonce is null.
    RBGNonce(String fixed, int randomLength)
    Creates a new instance using the given fixed field value.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    Generates a nonce value.
    int
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RBGNonce

      public RBGNonce()
      Creates a new instance that produces 12-bytes (96-bits) of random data; that is, the fixed field of the nonce is null.
    • RBGNonce

      public RBGNonce(int randomLength)
      Creates a new instance that produces length bytes of random data; that is, the fixed field of the nonce is null.
      Parameters:
      randomLength - Number of bytes in the random part of the nonce. MUST be at least 12.
    • RBGNonce

      public RBGNonce(String fixed, int randomLength)
      Creates a new instance using the given fixed field value.
      Parameters:
      fixed - User-defined fixed field value.
      randomLength - Number of bytes in the random part of the nonce. MUST be at least 12.
  • 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.