public abstract class SRP6Session extends Object implements Serializable
Modifier and Type | Field and Description |
---|---|
protected BigInteger |
A
The client public value 'A'.
|
protected BigInteger |
B
The server public value 'B'.
|
protected ClientEvidenceRoutine |
clientEvidenceRoutine
Custom routine for the client evidence message 'M1' computation.
|
protected SRP6CryptoParams |
config
The crypto configuration.
|
protected URoutine |
hashedKeysRoutine
Custom routine for the hashed keys 'u' computation.
|
protected BigInteger |
k
The multiplier 'k'.
|
protected long |
lastActivity
The last activity timestamp, from System.currentTimeMillis().
|
protected BigInteger |
M1
The client evidence message 'M1'.
|
protected BigInteger |
M2
The server evidence message 'M2'.
|
protected SecureRandom |
random
Source of randomness.
|
protected BigInteger |
s
The password salt 's'.
|
protected BigInteger |
S
The shared session key 'S'.
|
protected ServerEvidenceRoutine |
serverEvidenceRoutine
Custom routine for the server evidence message 'M2' computation.
|
protected int |
timeout
The SRP-6a authentication session timeout in seconds.
|
protected BigInteger |
u
The random scrambling parameter 'u'.
|
protected String |
userID
The identity 'I' of the authenticating user.
|
Constructor and Description |
---|
SRP6Session()
Creates a new SRP-6a authentication session, session timeouts are
disabled.
|
SRP6Session(int timeout)
Creates a new SRP-6a authentication session.
|
Modifier and Type | Method and Description |
---|---|
Object |
getAttribute(String key)
Gets a session attribute.
|
BigInteger |
getClientEvidenceMessage()
Gets the client evidence message 'M1'.
|
ClientEvidenceRoutine |
getClientEvidenceRoutine()
Gets the custom routine to compute the client evidence message 'M1'.
|
SRP6CryptoParams |
getCryptoParams()
Gets the SRP-6a crypto parameters for this session.
|
URoutine |
getHashedKeysRoutine()
Gets the custom routine to compute hashed keys 'u' a 'H(A | B)'.
|
long |
getLastActivityTime()
Gets the last session activity timestamp, in milliseconds since
midnight, January 1, 1970 UTC (see System.currentTimeMillis()).
|
BigInteger |
getPublicClientValue()
Gets the public client value 'A'.
|
BigInteger |
getPublicServerValue()
Gets the public server value 'B'.
|
BigInteger |
getSalt()
Gets the password salt 's'.
|
BigInteger |
getServerEvidenceMessage()
Gets the server evidence message 'M2'.
|
ServerEvidenceRoutine |
getServerEvidenceRoutine()
Gets the custom routine to compute the server evidence message 'M2'.
|
BigInteger |
getSessionKey(boolean doHash)
Gets the shared session key 'S' or its hash H(S).
|
int |
getTimeout()
Gets the SRP-6a authentication session timeout.
|
String |
getUserID()
Gets the identity 'I' of the authenticating user.
|
boolean |
hasTimedOut()
Returns
true if the session has timed out, based on the
timeout configuration and the last activity timestamp. |
void |
setAttribute(String key,
Object value)
Sets a session attribute.
|
void |
setClientEvidenceRoutine(ClientEvidenceRoutine routine)
Sets a custom routine to compute the client evidence message 'M1'.
|
void |
setHashedKeysRoutine(URoutine hashedKeysRoutine)
Sets a custom routine to compute hashed keys 'u' a 'H(A | B)'.
|
void |
setServerEvidenceRoutine(ServerEvidenceRoutine routine)
Sets a custom routine to compute the server evidence message 'M2'.
|
protected void |
updateLastActivityTime()
Updates the last activity timestamp.
|
protected SRP6CryptoParams config
protected final SecureRandom random
protected final int timeout
protected long lastActivity
protected BigInteger s
protected BigInteger A
protected BigInteger B
protected BigInteger u
protected BigInteger k
protected BigInteger S
protected BigInteger M1
protected BigInteger M2
protected ClientEvidenceRoutine clientEvidenceRoutine
protected ServerEvidenceRoutine serverEvidenceRoutine
protected URoutine hashedKeysRoutine
public SRP6Session(int timeout)
timeout
- The SRP-6a authentication session timeout in seconds.
If the authenticating counterparty (server or client)
fails to respond within the specified time the
session will be closed. If zero timeouts are
disabled.public SRP6Session()
protected void updateLastActivityTime()
public long getLastActivityTime()
public boolean hasTimedOut()
true
if the session has timed out, based on the
timeout configuration and the last activity timestamp.true
if the session has timed out, else
false
.public SRP6CryptoParams getCryptoParams()
null
if undefined.public String getUserID()
null
if undefined.public int getTimeout()
public void setClientEvidenceRoutine(ClientEvidenceRoutine routine)
SRP6ClientSession.State.STEP_2
or
SRP6ServerSession.State.STEP_2
.routine
- The client evidence message 'M1' routine or
null
to use the default
SRP6Routines.computeClientEvidence(java.security.MessageDigest, java.math.BigInteger, java.math.BigInteger, java.math.BigInteger)
.public ClientEvidenceRoutine getClientEvidenceRoutine()
null
if the default
SRP6Routines.computeClientEvidence(java.security.MessageDigest, java.math.BigInteger, java.math.BigInteger, java.math.BigInteger)
is used.public void setServerEvidenceRoutine(ServerEvidenceRoutine routine)
SRP6ClientSession.State.STEP_3
or
SRP6ServerSession.State.STEP_2
.routine
- The server evidence message 'M2' routine or
null
to use the default
SRP6Routines.computeServerEvidence(java.security.MessageDigest, java.math.BigInteger, java.math.BigInteger, java.math.BigInteger)
.public ServerEvidenceRoutine getServerEvidenceRoutine()
null
if the default
SRP6Routines.computeServerEvidence(java.security.MessageDigest, java.math.BigInteger, java.math.BigInteger, java.math.BigInteger)
is used.public URoutine getHashedKeysRoutine()
null
if the default
SRP6Routines.computeU(java.security.MessageDigest, java.math.BigInteger, java.math.BigInteger, java.math.BigInteger)
is to be used.public void setHashedKeysRoutine(URoutine hashedKeysRoutine)
SRP6ServerSession.State.STEP_2
.hashedKeysRoutine
- The hashed keys 'u' routine or null
to use the default
SRP6Routines.computeU(java.security.MessageDigest, java.math.BigInteger, java.math.BigInteger, java.math.BigInteger)
.public BigInteger getSalt()
null
.public BigInteger getPublicClientValue()
null
.public BigInteger getPublicServerValue()
null
.public BigInteger getClientEvidenceMessage()
null
.public BigInteger getServerEvidenceMessage()
null
.public BigInteger getSessionKey(boolean doHash)
doHash
- If true
the hash H(S) of the session key will
be returned instead of the raw value.null
will be returned if authentication failed or the method is
invoked in a session state when the session key 'S' has not
been computed yet.public void setAttribute(String key, Object value)
getAttribute(java.lang.String)
.key
- The attribute key. Must not be null
.value
- The attribute value. May be null
.public Object getAttribute(String key)
setAttribute(java.lang.String, java.lang.Object)
.key
- The attribute key. Must not be null
.null
if none was found by the
specified key or its value is null
.Copyright © 2015 Connect2id Ltd.. All Rights Reserved.