Class SRP6CustomIntegerVariable

  • All Implemented Interfaces:
    SRP6IntegerVariable

    public final class SRP6CustomIntegerVariable
    extends AbstractSRP6IntegerVariable
    A Custom SRP-6 Integer Variable.

    Objects of this class can be used to mock a variable for testing purposes or to represent constants.

    You can also use this class to instantiate a custom variable if none of the other classes in this package seem suitable.

    • Constructor Detail

      • SRP6CustomIntegerVariable

        public SRP6CustomIntegerVariable​(BigInteger bi)
        Creates a new Custom SRP-6 Integer Variable from a BigInteger.

        Equivalent to:

         new SRP6CustomIntegerVariable(
             Bytes.wrapped(bi.toByteArray()),
             ByteOrder.BIG_ENDIAN
         )
         
        Parameters:
        bi - a BigInteger argument that represents this SRP-6 Integer Variable
      • SRP6CustomIntegerVariable

        public SRP6CustomIntegerVariable​(byte[] bytes,
                                         ByteOrder order)
        Creates a new Custom SRP-6 Integer Variable from the specified byte array and the desired byte order.

        Equivalent to:

         new SRP6CustomIntegerVariable(
             Bytes.wrapped(bytes),
             order
         )
         
        Parameters:
        bytes - the byte array that represents this SRP-6 Integer Variable
        order - the byte order of bytes
      • SRP6CustomIntegerVariable

        public SRP6CustomIntegerVariable​(Bytes bytes,
                                         ByteOrder order)
        Creates a new Custom SRP-6 Integer Variable from the specified byte sequence and the desired byte order.
        Parameters:
        bytes - the byte sequence that represents this SRP-6 Integer Variable
        order - the byte order of bytes
    • Method Detail

      • bytes

        public Bytes bytes​(ByteOrder preferredOrder)
        Description copied from interface: SRP6IntegerVariable
        Returns this SRP-6 Integer Variable as a byte sequence in the preferred byte order.

        The representation returned must be minimal. That is, all leading (or trailing, depending on the preferredOrder) zero bytes have to be trimmed.

        Number zero is hence defined as an empty byte sequence.

        Parameters:
        preferredOrder - the preferred byte order of the byte sequence that represents this SRP-6 Integer Variable
        Returns:
        the byte sequence that represents this SRP-6 Integer Variable in the preferred byte order