Top Description Fields Constructors Methods
org.bouncycastle.tls.crypto.impl.jcajce.srp

public Class SRP6Client

extends Object
Class Inheritance
Imports
java.math.BigInteger, java.security.SecureRandom, org.bouncycastle.tls.crypto.SRP6Group, .TlsHash

Implements the client side SRP-6a protocol. Note that this class is stateful, and therefore NOT threadsafe. This implementation of SRP is based on the optimized message sequence put forth by Thomas Wu in the paper "SRP-6: Improvements and Refinements to the Secure Remote Password Protocol, 2002"

Field Summary

Modifier and TypeField and Description
protected BigInteger
a

protected BigInteger
A

protected BigInteger
B

protected TlsHash
protected BigInteger
g

protected BigInteger
protected BigInteger
protected BigInteger
protected BigInteger
N

protected SecureRandom
protected BigInteger
S

protected BigInteger
u

protected BigInteger
x

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public BigInteger

Returns:

M1: the client side generated evidence message
calculateClientEvidenceMessage
()

Computes the client evidence message M1 using the previously received values.

private BigInteger
public BigInteger

Returns:

Client's verification message for the server
calculateSecret
(BigInteger
The server's credentials
serverB
)

Generates the secret S given the server's credentials

public BigInteger

Returns:

Key: the mutually authenticated symmetric session key
calculateSessionKey
()

Computes the final session key as a result of the SRP successful mutual authentication To be called after verifying the server evidence message M2.

public BigInteger

Returns:

Client's public value to send to server
generateClientCredentials
(byte[]
The salt used in the client's verifier.
salt
,
byte[]
The user's identity (eg. username)
identity
,
byte[]
The user's password
password
)

Generates client's credentials given the client's salt, identity and password

public void
init(BigInteger
The safe prime associated with the client's verifier
N
,
BigInteger
The group parameter associated with the client's verifier
g
,
TlsHash
The digest algorithm associated with the client's verifier
digest
,
SecureRandom
For key generation
random
)

Initialises the client to begin new authentication attempt

public void
init(SRP6Group group, TlsHash digest, SecureRandom random)

protected BigInteger
public boolean

Returns:

A boolean indicating if the server message M2 was the expected one.
verifyServerEvidenceMessage
(BigInteger
the server side generated evidence message
serverM2
)

Authenticates the server evidence message M2 received and saves it only if correct.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

aback to summary
protected BigInteger a
Aback to summary
protected BigInteger A
Bback to summary
protected BigInteger B
digestback to summary
protected TlsHash digest
gback to summary
protected BigInteger g
Keyback to summary
protected BigInteger Key
M1back to summary
protected BigInteger M1
M2back to summary
protected BigInteger M2
Nback to summary
protected BigInteger N
randomback to summary
protected SecureRandom random
Sback to summary
protected BigInteger S
uback to summary
protected BigInteger u
xback to summary
protected BigInteger x

Constructor Detail

SRP6Clientback to summary
public SRP6Client()

Method Detail

calculateClientEvidenceMessageback to summary
public BigInteger calculateClientEvidenceMessage() throws IllegalStateException

Computes the client evidence message M1 using the previously received values. To be called after calculating the secret S.

Returns:BigInteger

M1: the client side generated evidence message

calculateSback to summary
private BigInteger calculateS()
calculateSecretback to summary
public BigInteger calculateSecret(BigInteger serverB)

Generates the secret S given the server's credentials

Parameters
serverB:BigInteger

The server's credentials

Returns:BigInteger

Client's verification message for the server

Exceptions
IllegalArgumentException:
If server's credentials are invalid
calculateSessionKeyback to summary
public BigInteger calculateSessionKey() throws IllegalStateException

Computes the final session key as a result of the SRP successful mutual authentication To be called after verifying the server evidence message M2.

Returns:BigInteger

Key: the mutually authenticated symmetric session key

generateClientCredentialsback to summary
public BigInteger generateClientCredentials(byte[] salt, byte[] identity, byte[] password)

Generates client's credentials given the client's salt, identity and password

Parameters
salt:byte[]

The salt used in the client's verifier.

identity:byte[]

The user's identity (eg. username)

password:byte[]

The user's password

Returns:BigInteger

Client's public value to send to server

initback to summary
public void init(BigInteger N, BigInteger g, TlsHash digest, SecureRandom random)

Initialises the client to begin new authentication attempt

Parameters
N:BigInteger

The safe prime associated with the client's verifier

g:BigInteger

The group parameter associated with the client's verifier

digest:TlsHash

The digest algorithm associated with the client's verifier

random:SecureRandom

For key generation

initback to summary
public void init(SRP6Group group, TlsHash digest, SecureRandom random)
selectPrivateValueback to summary
protected BigInteger selectPrivateValue()
verifyServerEvidenceMessageback to summary
public boolean verifyServerEvidenceMessage(BigInteger serverM2) throws IllegalStateException

Authenticates the server evidence message M2 received and saves it only if correct.

Parameters
serverM2:BigInteger

the server side generated evidence message

Returns:boolean

A boolean indicating if the server message M2 was the expected one.