Wrapper crate for the srp for easy usage
Overview
The srp crate provides the means for using
SRP6a athentication.
This crate wraps the srp crate to make the authentication workflows
more obvious easy to use.
This is done via the following means:
- provide
Workflowstructs for the 3 typical workflows:- generation of initial registration data
- client authentication
- server authentication
- name methods
step#with increasing number#, so it is obvious in which phase of the authentication the method needs to be called. - include automatic random value generation (for ephemeral keys and salt)
Features
- Support for the web via WebAssembly. Therefore, this crate can be used with WASM-based web-UI frameworks like yew.
- Easy to use.
Available rust/cargo features
client: Include client classes (ClientAuthenticationWorkflow,ClientRegistrationWorkflow, ...).server: Include server classes (ServerAuthenticationWorkflow, etc.)base64: Include the base64 crate and providebase64serialization for various byte array parameters.serialization: Include the serde crate and addSerializeandDeserializeto various structs. This also enables thebase64feature.js: This crate uses the getrandom crate for generating random numbers (salt, client/server ephemeral key).getrandomsupports a variety of platforms, including web browsers (in WebAssembly). Ifeasy-srpis used inside the browser, use thejsfeature to makegetrandomuse theCrypto.getRandomValues()JavaScript method for random number generation.
Usage
SRP6a protocol
User registration
- User enters
usernameandpassword - Client generates random
salt - Client computes
verifierfrom the obove credentials - Client sends
username,saltandverifierto the server via a secure channel. - Server stores these three credentials.
User authentication
| Client | Server | |
|---|---|---|
(username, pub_a) |
-> | |
| <- | (salt, pub_b) |
|
(proof_a) |
-> | |
| <- | (proof_b) |
- client sends
(username, pub_a)to server. - server looks up
(salt, verifier) - server computes an ephemeral private key
band derives its public keypub_b. - server sends
(salt, pub_b)to the client. - client calculates proof
proof_aand sends(proof_a)to the server. - server verifies
proof_a - server computes its own proof
proof_band sends it to the client - client verifies
proof_b - both sides are now able to calculate a common secret key. the size of
the key depends on the used digest, e.g. 256 bits (32 bytes) for
SHA256
Generate client registration data
Client example
Server example
Dependencies
The following dependencies are included intentionally (aka directly):
- srp
- digest (also included transitively
via
srp) - getrandom
- base64 (feature
base64) - serde (feature
serde)
Additional dependencies may be included transitively.