- java.lang.Object
-
- com.github.glusk.srp6_variables.AbstractSRP6IntegerVariable
-
- com.github.glusk.srp6_variables.SRP6PrivateKey
-
- All Implemented Interfaces:
SRP6IntegerVariable
public final class SRP6PrivateKey extends AbstractSRP6IntegerVariable
SRP-6 Private Key (x).This variable is computed as:
x = H(s | p)
whereH()is a one-way hash function,|a concatenation operator,sa random salt andpthe client's password [1].In an article that documents refinements to the protocol, another formula is used:
x = H(s | I | P)
whereIis cleartext username, or identity, andPcleartext password [2].RFC 2945 further specifies
xas:x = H(s | H(I | ":" | P))
whereIis cleartext username, or identity, andPcleartext password [3].Use of
Iwithinxavoids a malicious server from being able to learn if two users share the same password (refer to this SO question for more info).If there isn't a suitable constructor for your version of the protocol, you can set a custom private key like so:
// ByteOrder byteOrder = ... SRP6IntegerVariable x = new SRP6CustomIntegerVariable( new Hash( // custom args ), byteOrder );References:
-
[1] WU, Thomas. The Secure Remote Password Protocol.
http://www.scs.stanford.edu/nyu/05sp/sched/readings/srp.pdf, 1997. -
[2] WU, Thomas. SRP-6: Improvements and Refinements to the Secure
Remote Password Protocol.
http://srp.stanford.edu/srp6.ps, 2002. - [3] RFC 2945
-
-
Constructor Summary
Constructors Constructor Description SRP6PrivateKey(ImmutableMessageDigest hashFunction, Bytes salt, Bytes cleartextUsername, Bytes cleartextPassword, ByteOrder endianness)Constructs a new SRP-6 Private Key as specified in RFC 2945.SRP6PrivateKey(ImmutableMessageDigest hashFunction, Bytes salt, Bytes password, ByteOrder endianness)Constructs a new SRP-6 Private Key fromsaltandpassword.
-
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
-
SRP6PrivateKey
public SRP6PrivateKey(ImmutableMessageDigest hashFunction, Bytes salt, Bytes cleartextUsername, Bytes cleartextPassword, ByteOrder endianness)
Constructs a new SRP-6 Private Key as specified in RFC 2945.x = H(s | H(I | ":" | P))
- Parameters:
hashFunction- a one-way hash function - H()salt- SRP-6 variable: salt (s)cleartextUsername- SRP-6 variable: cleartext username - identity (I)cleartextPassword- SRP-6 variable: cleartext password (P)endianness- the byte order to use when converting the resulting hash to integer
-
SRP6PrivateKey
public SRP6PrivateKey(ImmutableMessageDigest hashFunction, Bytes salt, Bytes password, ByteOrder endianness)
Constructs a new SRP-6 Private Key fromsaltandpassword.x = H(s | p)
- Parameters:
hashFunction- a one-way hash function - H()salt- SRP-6 variable: salt (s)password- SRP-6 variable: password (p)endianness- the byte order to use when converting the resulting hash to integer
-
-
Method Detail
-
bytes
public Bytes bytes(ByteOrder preferredOrder)
Description copied from interface:SRP6IntegerVariableReturnsthisSRP-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
-
-