easy_srp/
messages.rs

1//! Contains the four messages that client and server would exchange as part
2//! of the SRP6a protocol. These messages are included for clarity and not
3//! used directly by the `easy-srp` library.
4
5use serde::{Deserialize, Serialize};
6
7/// First message (from client to server)
8/// 
9/// Contains `username` and the ephemeral public key of the client
10/// `client_public_key`.
11#[derive(Debug, Clone)]
12#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
13pub struct ClientServerMessage1 {
14  pub username: String,
15  #[serde(with = "crate::util::base64_vec_u8")]
16  pub client_public_key: Vec<u8>,
17}
18
19/// Seconds message (from server to client)
20/// 
21/// Contains the `salt`` stored by the server and the server's ephermal
22/// public key `server_public_key`
23#[derive(Debug, Clone)]
24#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
25pub struct ServerClientMessage2 {
26  #[serde(with = "crate::util::base64_vec_u8")]
27  pub salt: Vec<u8>,
28  #[serde(with = "crate::util::base64_vec_u8")]
29  pub server_public_key: Vec<u8>,
30}
31
32/// Third message (from client to server)
33/// 
34/// Contains the client's `client_proof`. The server must not send anything
35/// encrypted by the common secret key before the client proof has been
36/// verified.
37#[derive(Debug, Clone)]
38#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
39pub struct ClientServerMessage3 {
40  #[serde(with = "crate::util::base64_vec_u8")]
41  pub client_proof: Vec<u8>,
42}
43
44/// Forth message (from server to client)
45/// 
46/// Contains the server's `server_proof`. After verifying this proof, both
47/// server and client may start using their common secret key.
48#[derive(Debug, Clone)]
49#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
50pub struct ServerClientMessage4 {
51  #[serde(with = "crate::util::base64_vec_u8")]
52  pub server_proof: Vec<u8>,
53}