[−][src]Module srp::server
SRP server implementation
Usage
First receive user's username and public value a_pub
, retrieve from a
database UserRecord
for a given username, generate b
(e.g. 512 bits
long) and initialize SRP server instance:
ⓘThis example is not tested
use srp::groups::G_2048; let (username, a_pub) = conn.receive_handshake(); let user = db.retrieve_user_record(username); let b = [0u8; 64]; rng.fill_bytes(&mut b); let server = SrpServer::<Sha256>::new(&user, &a_pub, &b, &G_2048)?;
Next send to user b_pub
and salt
from user record:
ⓘThis example is not tested
let b_pub = server.get_b_pub(); conn.reply_to_handshake(&user.salt, b_pub);
And finally recieve user proof, verify it and send server proof in the reply:
ⓘThis example is not tested
let user_proof = conn.receive_proof(); let server_proof = server.verify(user_proof)?; conn.send_proof(server_proof);
To get the shared secret use get_key
method. As alternative to using
verify
method it's also possible to use this key for authentificated
encryption.
Structs
SrpServer | SRP server state |
UserRecord | Data provided by users upon registration, usually stored in the database. |