···11-## SRP - SRP-6a Secure Remote Password protocol
11+## SRP -- SRP-6a Secure Remote Password protocol
2233-Implementation of the SRP-6a protocol (RFC 5054) for password-authenticated key exchange. Includes support for the 3072-bit group used by HomeKit.
33+Implementation of the SRP-6a protocol (RFC 5054) for password-authenticated
44+key exchange. Includes support for the 3072-bit group used by HomeKit.
4556## Installation
6777-`opam install srp` will install this library.
88+```
99+opam install srp
1010+```
1111+1212+## Usage
1313+1414+### Server setup (register a user)
1515+1616+```ocaml
1717+(* Server stores verifier, not the password *)
1818+let salt = (* random 16+ bytes *) in
1919+let verifier =
2020+ Srp.compute_verifier ~salt ~username:"alice" ~password:"secret"
2121+```
2222+2323+### Client authentication
2424+2525+```ocaml
2626+(* Client side: generate A and ephemeral key *)
2727+let client = Srp.Client.v ~username:"alice" ~password:"secret" in
2828+let a_pub = Srp.Client.public client in
2929+(* Send (username, A) to server *)
3030+3131+(* Server receives (username, A), looks up salt+verifier *)
3232+let server = Srp.Server.v ~verifier in
3333+let b_pub = Srp.Server.public server in
3434+(* Send (salt, B) to client *)
3535+3636+(* Both derive shared session key *)
3737+let client_key = Srp.Client.session_key client ~salt ~b_pub in
3838+let server_key = Srp.Server.session_key server ~username:"alice" ~a_pub
3939+```
4040+4141+## API
4242+4343+- `Srp.n` / `Srp.g` -- 3072-bit group parameters
4444+- `Srp.compute_verifier` -- Compute password verifier for server storage
4545+- `Srp.Client.v` / `Srp.Client.public` / `Srp.Client.session_key` -- Client state
4646+- `Srp.Server.v` / `Srp.Server.public` / `Srp.Server.session_key` -- Server state
847948## Reference
10491111-- [RFC 5054: Using the Secure Remote Password (SRP) Protocol for TLS Authentication](https://www.rfc-editor.org/rfc/rfc5054)
5050+- [RFC 5054](https://www.rfc-editor.org/rfc/rfc5054) -- Using SRP for TLS Authentication
12511313-## Documentation
5252+## Licence
14535454+ISC