1
//! Message object passed between server and client during login and
2
//! registration.
3

            
4
use serde::{Deserialize, Serialize};
5

            
6
use crate::{cipher_suite, Config};
7

            
8
/// Send this to the server to drive the registration process. See
9
/// [`ServerRegistration::register()`](crate::ServerRegistration::register).
10
#[must_use = "Does nothing if not sent to the server"]
11
290
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
12
pub struct RegistrationRequest {
13
	/// [`Config`] used to create this [`RegistrationRequest`].
14
	pub(crate) config: Config,
15
	/// Wrapped [opaque-ke](opaque_ke) type.
16
	pub(crate) message: cipher_suite::RegistrationRequest,
17
}
18

            
19
impl RegistrationRequest {
20
	/// Returns [`Config`] used to create this [`RegistrationRequest`].
21
	#[must_use]
22
1
	pub const fn config(&self) -> Config {
23
1
		self.config
24
1
	}
25
}
26

            
27
/// Send this back to the client to drive the registration process. See
28
/// [`ClientRegistration::finish()`](crate::ClientRegistration::finish).
29
#[must_use = "Does nothing if not sent to the client"]
30
290
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
31
pub struct RegistrationResponse {
32
	/// [`Config`] used to create this [`RegistrationResponse`].
33
	pub(crate) config: Config,
34
	/// Wrapped [opaque-ke](opaque_ke) type.
35
	pub(crate) message: cipher_suite::RegistrationResponse,
36
}
37

            
38
impl RegistrationResponse {
39
	/// Returns [`Config`] used to create this [`RegistrationResponse`].
40
	#[must_use]
41
1
	pub const fn config(&self) -> Config {
42
1
		self.config
43
1
	}
44
}
45

            
46
/// Send this back to the server to finish the registration process. See
47
/// [`ServerRegistration::finish()`](crate::ServerRegistration::finish).
48
#[must_use = "Does nothing if not sent to the server"]
49
290
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
50
pub struct RegistrationFinalization {
51
	/// [`Config`] used to create this [`RegistrationFinalization`].
52
	pub(crate) config: Config,
53
	/// Wrapped [opaque-ke](opaque_ke) type.
54
	pub(crate) message: cipher_suite::RegistrationFinalization,
55
}
56

            
57
impl RegistrationFinalization {
58
	/// Returns [`Config`] used to create this [`RegistrationFinalization`].
59
	#[must_use]
60
1
	pub const fn config(&self) -> Config {
61
1
		self.config
62
1
	}
63
}
64

            
65
/// Send this to the server to drive the login process. See
66
/// [`ServerLogin::login()`](crate::ServerLogin::login).
67
#[must_use = "Does nothing if not sent to the server"]
68
290
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
69
pub struct LoginRequest {
70
	/// [`Config`] used to create this [`LoginRequest`].
71
	pub(crate) config: Config,
72
	/// Wrapped [opaque-ke](opaque_ke) type.
73
	pub(crate) message: cipher_suite::LoginRequest,
74
}
75

            
76
impl LoginRequest {
77
	/// Returns [`Config`] used to create this [`LoginRequest`].
78
	#[must_use]
79
1
	pub const fn config(&self) -> Config {
80
1
		self.config
81
1
	}
82
}
83

            
84
/// Send this back to the client to drive the login process. See
85
/// [`ClientLogin::finish()`](crate::ClientLogin::finish).
86
#[must_use = "Does nothing if not sent to the client"]
87
290
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
88
pub struct LoginResponse {
89
	/// [`Config`] used to create this [`LoginResponse`].
90
	pub(crate) config: Config,
91
	/// Wrapped [opaque-ke](opaque_ke) type.
92
	pub(crate) message: cipher_suite::LoginResponse,
93
}
94

            
95
impl LoginResponse {
96
	/// Returns [`Config`] used to create this [`LoginResponse`].
97
	#[must_use]
98
1
	pub const fn config(&self) -> Config {
99
1
		self.config
100
1
	}
101
}
102

            
103
/// Send this back to the server to finish the login process. See
104
/// [`ClientLogin::finish()`](crate::ClientLogin::finish).
105
#[must_use = "Does nothing if not sent to the server"]
106
290
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
107
pub struct LoginFinalization {
108
	/// [`Config`] used to create this [`LoginFinalization`].
109
	pub(crate) config: Config,
110
	/// Wrapped [opaque-ke](opaque_ke) type.
111
	pub(crate) message: cipher_suite::LoginFinalization,
112
}
113

            
114
impl LoginFinalization {
115
	/// Returns [`Config`] used to create this [`LoginFinalization`].
116
	#[must_use]
117
1
	pub const fn config(&self) -> Config {
118
1
		self.config
119
1
	}
120
}