logo

Module srp::server

source · []
Expand description

SRP server implementation

Usage

First receive user’s username and public value a_pub, retrieve from a database the salt and verifier for a given username. Generate b and public value b_pub.

use crate::srp::groups::G_2048;
use sha2::Sha256; // Note: You should probably use a proper password KDF

let server = SrpServer::<Sha256>::new(&G_2048);
let (username, a_pub) = get_client_request();
let (salt, v) = get_user(&username);
let mut b = [0u8; 64];
// rng.fill_bytes(&mut b);
let b_pub = server.compute_public_ephemeral(&b, &v);

Next send to user b_pub and salt from user record

Next process the user response:


let a_pub = get_client_response();
let verifier = server.process_reply(&b, v, &a_pub).unwrap();

And finally receive user proof, verify it and send server proof in the reply:


let client_proof = get_client_proof();
verifier.verify_client(&client_proof).unwrap();
send_proof(verifier.proof());

key contains shared secret key between user and the server. You can extract shared secret key using key() method.


verifier.key();

Structs

SRP server state

SRP server state after handshake with the client.