Initial Authentication via Secure Remote Password (SRP)
Initial authentication via the SRP protocol will be deprecated in a future release. Existing users are advised to migrate to the new OPAQUE-3DH aPAKE protocol.
The initial authentication process uses a WebSocket connection to the /api/auth endpoint. The rough process is as follows:
Let us examine the process in more detail.
Message Format
Each message is a JSON object containing the following fields:
status: Current authentication status. Can beOK,ERR, or null.binary: Whether the included data is binary data. Can betrueorfalse.data: Message data. Ifbinaryis true, this field is a Base64 encoded byte array. Otherwise, it is a ASCII string.
Here are two examples of messages:
{
"status": "OK",
"binary": false,
"data": "U is OK"
}
{
"status": null,
"binary": true,
"data": "AQ=="
}
Specification
The specification of how the authentication process works is very technical and is described below.
Let
- denote the SRP prime according to RFC5054, Appendix A;
- denote the SRP generator according to RFC5054, Appendix A;
- denote the SRP multiplier according to RFC5054, Section 2.6;
- denote the SRP- key generated on the client-side; and
- be the verifier value.
and should be treated as secrets. The server should never have access to , and no one other than the server and client should have access to .
The initial authentication process is as follows:
-
Client sends its username to the server.
-
Server checks whether it has a record of the requested username.
- If username is not found, server sends message with status
ERRand dataUser does not exist. Terminate connection.
- If username is not found, server sends message with status
-
Server sends message with status
OKand the SRP group size (in bits) as an ASCII string (e.g.,1024). -
Server generates its ephemeral values (private value and public value ) and sends the public value to the client (specifying
binary = true). -
Client checks the received .
- If is invalid (e.g., ), client sends message with status
ERR(data can be anything). Client can choose to terminate the connection, or wait for server to try another .
- If is invalid (e.g., ), client sends message with status
-
Client generates its ephemeral values (private value and public value ) and sends the public value to the server (specifying
binary = true) with statusOK. -
Server checks received .
- If is invalid (e.g., ), sends message with status
ERR(data can be anything). Server can choose to terminate the connection, or wait for client to try another .
- If is invalid (e.g., ), sends message with status
-
Both client and server computes where refers to concatenation. Note that and have been padded to SRP group size bits using zero padding on the left.
- If server detects , it sends message with status
ERRand dataShared U value is 0and then terminates the connection. - If client detects , it can just choose to close the connection.
- If server detects , it sends message with status
-
Server sends message with status
OKand dataU is OK. -
Client and server each computes their premaster value:
- Client:
- Server:
The master is computed by computing SHA3-256 of the premaster, padded to the SRP group size bits using zero padding.
-
Client computes , where means XOR and is SHA3-256.
-
Client sends to the server (setting
binary = true) with statusOK. -
Server computes its own value using the same formula (using in place of ), and checks with the received .
- If they do not match, sends message with status
ERRand dataM1 values do not match, terminating the connection.
- If they do not match, sends message with status
-
Server computes , where means XOR and is SHA3-256.
-
Server sends to the client (setting
binary = true) with statusOK. -
Client computes its own value using the same formula (using in place of ), and checks with the received .
- If they do not match, client terminates the connection.
-
Client sends message with status
OKwith no data. -
Server prepares authentication token in the form of a JSON Web Token (JWT) and encrypts it with the shared master key using AES-GCM-256.
-
Server sends message with no status and JSON data containing three fields:
nonce,token, andtag, each as a Base64 encoded byte array:nonce: A random valuetoken: The encrypted JWTtag: The authentication tag
-
Both sides close the connection.
The full code that implements the server-side checking can be found in the comms.py file.