Package | net.tynril.crypto.srp6 |
Class | public class SRP6 |
Inheritance | SRP6 ![]() |
This strong authentication protocol is developed by Tom Wu of the Stanford University. All credits for designing and specifying this protocol goes to him.
The SRP-6a protocol is quite simple, and works like that:The whole details about the protocol are described on the official SRP page on the Stanford University website: http://srp.stanford.edu/design.html
This library was initially written by Samuel Lorétan, and is released under the Lesser GNU General Public License.
Property | Defined By | ||
---|---|---|---|
status : uint [read-only]
Get the current status of this instance. | SRP6 |
Method | Defined By | ||
---|---|---|---|
SRP6()
Creates a new instance of the SRP6 algorithm. | SRP6 | ||
computeClientToken():String
Step 1: Compute the client token 'A' to be sent
to the server along with the username. | SRP6 | ||
computeKeyProof(username:String, password:String):String
Step 3: Computes the key proof to be sent to the server,
using all previously set data and the password given by the user. | SRP6 | ||
dispose():void
Dispose of the SRP6 object, freeing any memory it is using. | SRP6 | ||
initialize(modulus:String = null, generator:String = null, multiplier:String = null, hash:IHash = null, prng:Class = null, radix:uint = 16):void
Step 0: Initialize this SRP6 instance with the given
arithmetic constants, or with the default constants. | SRP6 | ||
receiveSaltAndServerToken(salt:String, serverToken:String):Boolean
Step 2: Received the salt s and the
B token from the server. | SRP6 | ||
validateServerProof(proof:String):Boolean
Step 4: Validate the proof sent by the server. | SRP6 |
Constant | Defined By | ||
---|---|---|---|
STATUS_AUTHENTICATED : uint = 0x05 [static]
The proof of session key sent by the server is matching our
expectation, the session is valid and the server can be trusted. | SRP6 | ||
STATUS_ERROR : uint = 0xFF [static]
Something went wrong during the calculation. | SRP6 | ||
STATUS_HANDSHAKED : uint = 0x03 [static]
The salt and 'B' token were received from the server. | SRP6 | ||
STATUS_IDENTIFIED : uint = 0x02 [static]
The user has identified himself to the server by sending his or her
username and 'A' token. | SRP6 | ||
STATUS_INITIALIZED : uint = 0x01 [static]
The protocol was initialized and is ready to be used, starting with
the step one, computeClientToken. | SRP6 | ||
STATUS_PROOF_SENT : uint = 0x04 [static]
The proof of session key 'M' was sent to the server. | SRP6 | ||
STATUS_UNINITIALIZED : uint = 0x00 [static]
Initial status of the authentication protocol. | SRP6 |
status | property |
status:uint
[read-only] Get the current status of this instance.
public function get status():uint
SRP6 | () | Constructor |
public function SRP6()
Creates a new instance of the SRP6 algorithm. This instance will
need to be initialized by calling the initialize
method before usage. A single instance can be used multiple times,
if dispose
ed correctly.
computeClientToken | () | method |
public function computeClientToken():String
Step 1: Compute the client token 'A
' to be sent
to the server along with the username.
Changes the status of this SRP6 object to
STATUS_IDENTIFIED
.
String — A radix representation of the client token.
|
computeKeyProof | () | method |
public function computeKeyProof(username:String, password:String):String
Step 3: Computes the key proof to be sent to the server, using all previously set data and the password given by the user.
Changes the status of this SRP6 object to
STATUS_PROOF_SENT
.
Parameters
username:String — Username as entered by the user.
| |
password:String — Password as entered by the user.
|
String — A radix representation of the key proof.
|
dispose | () | method |
public function dispose():void
Dispose of the SRP6 object, freeing any memory it is using.
initialize | () | method |
public function initialize(modulus:String = null, generator:String = null, multiplier:String = null, hash:IHash = null, prng:Class = null, radix:uint = 16):void
Step 0: Initialize this SRP6 instance with the given arithmetic constants, or with the default constants.
Changes the status of this SRP6 object to
STATUS_INITIALIZED
.
Parameters
modulus:String (default = null ) — (N) A large safe prime (N = 2q+1 where 1 is prime)
All arithmetics is done modulo N.
| |
generator:String (default = null ) — (g) A generator modulo N.
| |
multiplier:String (default = null ) — (k) Multiplier parameter (k = H(N, g) in SRP-6a,
k = 3 for legacy SRP-6).
| |
hash:IHash (default = null ) — (H) The hash function to be used during
authentication. Defaults to SHA1.
| |
prng:Class (default = null ) — The pseudo-random generator to be used during
authentication. Defaults to ARC4.
| |
radix:uint (default = 16 ) — All token and values will be returned as a
string representing the number with the given
radix. Hexadecimal by default.
|
receiveSaltAndServerToken | () | method |
public function receiveSaltAndServerToken(salt:String, serverToken:String):Boolean
Step 2: Received the salt s
and the
B
token from the server.
Changes the status of this SRP6 object to
STATUS_HANDSHAKED
.
Parameters
salt:String — The salt received from the server, represented
as a radix string.
| |
serverToken:String — The B token as received from the
server, represented as a radix
string.
|
Boolean — true if the value received were
valid, false otherwise.
|
validateServerProof | () | method |
public function validateServerProof(proof:String):Boolean
Step 4: Validate the proof sent by the server.
Changes the status of this SRP6 object to
STATUS_AUTHENTICATED
if everything is fine, or to
STATUS_ERROR
if the proof was invalid.
Parameters
proof:String — The radix representation of the proof sent
by the server.
|
Boolean — true if the proof was okay, false
otherwise.
|
STATUS_AUTHENTICATED | Constant |
public static const STATUS_AUTHENTICATED:uint = 0x05
The proof of session key sent by the server is matching our
expectation, the session is valid and the server can be trusted.
This status is set once validateServerProof
was called.
This is the final status, no more step is required.
STATUS_ERROR | Constant |
public static const STATUS_ERROR:uint = 0xFF
Something went wrong during the calculation.
It can be one of the following case (depending on the previous state):
receiveSaltAndServerToken
was 0
,
which is an invalid value.
validateServerProof
wasn't matching our
expectations.STATUS_HANDSHAKED | Constant |
public static const STATUS_HANDSHAKED:uint = 0x03
The salt and 'B' token were received from the server. This status is
set once receiveSaltAndServerToken
was called. The
protocol is ready for the next step, computeKeyProof
.
STATUS_IDENTIFIED | Constant |
public static const STATUS_IDENTIFIED:uint = 0x02
The user has identified himself to the server by sending his or her
username and 'A' token. This status is set once
computeClientToken
was called. The protocol is ready for the
next step, receiveSaltAndServerToken
.
STATUS_INITIALIZED | Constant |
public static const STATUS_INITIALIZED:uint = 0x01
The protocol was initialized and is ready to be used, starting with
the step one, computeClientToken
.
STATUS_PROOF_SENT | Constant |
public static const STATUS_PROOF_SENT:uint = 0x04
The proof of session key 'M' was sent to the server. This status is
set once computeKeyProof
was called. The protocol is
ready for the next and final step, validateServerProof
.
STATUS_UNINITIALIZED | Constant |
public static const STATUS_UNINITIALIZED:uint = 0x00
Initial status of the authentication protocol. The
initialize
method must be called.