Package com.github.glusk.srp6_variables
Class SRP6RandomEphemeral
- java.lang.Object
-
- com.github.glusk.srp6_variables.AbstractSRP6IntegerVariable
-
- com.github.glusk.srp6_variables.SRP6RandomEphemeral
-
- All Implemented Interfaces:
SRP6IntegerVariable
public final class SRP6RandomEphemeral extends AbstractSRP6IntegerVariable
SRP-6 Random Ephemeral (a, b).Use this class to generate random private ephemeral values
aandb(seepackage docs).This class generates a random value
rof the form:1 < r < N
whereNis the SRP-6 "prime" variable.The bit-length of this variable will be at least 256 bits, as recommended in: RFC 5054 | 3. Security Considerations.
This class is not thread-safe.
-
-
Constructor Summary
Constructors Constructor Description SRP6RandomEphemeral(SecureRandom rng, int desiredBitLength, SRP6IntegerVariable prime)Creates a new SRP-6 Random Ephemeral.SRP6RandomEphemeral(SecureRandom rng, SRP6IntegerVariable prime)Creates a new SRP-6 Random Ephemeral with default bit-length (256 bits).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Bytesbytes(ByteOrder preferredOrder)ReturnsthisSRP-6 Integer Variable as a byte sequence in the preferred byte order.-
Methods inherited from class com.github.glusk.srp6_variables.AbstractSRP6IntegerVariable
equals, hashCode
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.github.glusk.srp6_variables.SRP6IntegerVariable
asNonNegativeBigInteger, bytes
-
-
-
-
Constructor Detail
-
SRP6RandomEphemeral
public SRP6RandomEphemeral(SecureRandom rng, SRP6IntegerVariable prime)
Creates a new SRP-6 Random Ephemeral with default bit-length (256 bits).- Parameters:
rng- source of randomnessprime- SRP-6 Integer Variable: prime (N)
-
SRP6RandomEphemeral
public SRP6RandomEphemeral(SecureRandom rng, int desiredBitLength, SRP6IntegerVariable prime) throws IllegalArgumentException
Creates a new SRP-6 Random Ephemeral.- Parameters:
rng- source of randomnessdesiredBitLength- the desired bit-length ofthisvariableprime- SRP-6 Integer Variable: prime (N)- Throws:
IllegalArgumentException
-
-
Method Detail
-
bytes
public 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 - Throws:
IllegalStateException- If the set bit length is greater than the bit length ofprime. More formally if:Math.max(desiredBitLength, 256) > bitlength(prime)
-
-