Class Nonce


  • public class Nonce
    extends java.lang.Object
    Utility provides nonce operations.
    • Constructor Summary

      Constructors 
      Constructor Description
      Nonce()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] increaseNonce​(byte[] startNonce, byte[] endNonce)
      Increase the sequential NONCE by a value of 1.
      static byte[] splitNonceRange​(byte[] startNonce, byte[] endNonce)
      Returns the middle nonce in the provided range.
      • Methods inherited from class java.lang.Object

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

      • Nonce

        public Nonce()
    • Method Detail

      • increaseNonce

        public static byte[] increaseNonce​(byte[] startNonce,
                                           byte[] endNonce)
        Increase the sequential NONCE by a value of 1. This implementation assumes that the NONCE length is 8 bytes or fewer so it can fit in a long.
        Parameters:
        startNonce - The starting nonce.
        endNonce - The ending nonce in the sequence.
        Returns:
        The next nonce after incrementing.
        Throws:
        RangeExceededException - Thrown if the nonce exceeds its range
      • splitNonceRange

        public static byte[] splitNonceRange​(byte[] startNonce,
                                             byte[] endNonce)
        Returns the middle nonce in the provided range. Note: This assumes the nonce is 8 bytes, if you need to increase the nonce length then the long transient variables will not hold. In that case you will need to override with your own implementation.
        Parameters:
        startNonce - The starting nonce.
        endNonce - The ending nonce in the sequence.
        Returns:
        The byte array with the middle nonce.
        Throws:
        SecurityException - Thrown if there is a security exception