Interface SRP6IntegerVariable
-
- All Known Implementing Classes:
AbstractSRP6IntegerVariable,SRP6ClientPublicKey,SRP6ClientSharedSecret,SRP6CustomIntegerVariable,SRP6Multiplier,SRP6PrivateKey,SRP6RandomEphemeral,SRP6ScramblingParameter,SRP6ServerPublicKey,SRP6ServerSharedSecret,SRP6Verifier
public interface SRP6IntegerVariableAn SRP-6 Integer Variable.Objects that implement this interface represent SRP-6 integer variables. The full list of SRP-6 variables can be found in the
package docs.Mapping between integers and byte sequences
RFC2945 specifies a mapping (which RFC5054 follows) between byte sequences and integers:
...
An n-byte string S can be converted to an integer as follows:
i = S[n-1] + 256 * S[n-2] + 256^2 * S[n-3] + ... + 256^(n-1) * S[0]
...
Although the above mapping assumes big-endian byte order, objects implementing this interface must provide a little-endian representation as well. SRP-6 Integer Variables can be viewed both as little and big-endian byte sequences and it is up to the protocol implementor which representation to use.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default BigIntegerasNonNegativeBigInteger()Returns this SRP-6 Integer Variable as a non-negative BigInteger.Bytesbytes(ByteOrder preferredOrder)ReturnsthisSRP-6 Integer Variable as a byte sequence in the preferred byte order.default Bytesbytes(ByteOrder preferredOrder, int length)Returns a new byte sequence as a zero-padded result ofthis.bytes(preferredOrder).booleanequals(Object obj)Compares the specified object with this SRP-6 Integer Variable for equality.inthashCode()Returns the hash code value for this SRP-6 Integer Variable.
-
-
-
Method Detail
-
bytes
Bytes bytes(ByteOrder preferredOrder)
ReturnsthisSRP-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 representsthisSRP-6 Integer Variable- Returns:
- the byte sequence that represents
thisSRP-6 Integer Variable in the preferred byte order
-
bytes
default Bytes bytes(ByteOrder preferredOrder, int length) throws SRP6PaddingException
Returns a new byte sequence as a zero-padded result ofthis.bytes(preferredOrder).If
preferredOrderequals toByteOrder.BIG_ENDIAN, the sequence gets padded from the front, otherwise from the back.- Parameters:
preferredOrder- the preferred byte order of the byte sequence that representsthisSRP-6 Integer Variablelength- the length of the zero-padded byte sequence to return- Returns:
- a new zero-padded byte sequence that represents
thisSRP-6 Integer Variable in the preferred byte order - Throws:
SRP6PaddingException- iflengthis less than the length of the sequence returned bythis.bytes(preferredOrder)
-
asNonNegativeBigInteger
default BigInteger asNonNegativeBigInteger()
Returns this SRP-6 Integer Variable as a non-negative BigInteger.This method call is equivalent to:
new BigInteger(1, bytes(ByteOrder.BIG_ENDIAN).asArray())
- Returns:
thisSRP-6 Integer Variable as a non-negative BigInteger
-
equals
boolean equals(Object obj)
Compares the specified object with this SRP-6 Integer Variable for equality.Returns
trueif and only if the specified object is also an SRP-6 Integer Variable and both SRP-6 Integer Variables map to the same byte sequence. The mapping provided bybytes(ByteOrder)must be used.
-
hashCode
int hashCode()
Returns the hash code value for this SRP-6 Integer Variable.The hash code of an SRP-6 Integer Variable has to obey the general contract of
Object.hashCode(). That is, if two SRP-6 Integer Variables are equal, then they must have the same hash code.
-
-