1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use core::fmt;
/// Errors that can occur during the protocol
#[non_exhaustive]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum Error {
/// Some points such as the Neutral or Identity point are illegal
IllegalPointError,
/// Wrapper around `password_hash`'s error type, for propagating errors should they occur
PasswordHashing(password_hash::Error),
/// PasswordHasher produced an empty hash.
HashEmpty,
/// PasswordHasher produced a hash of an invalid size (size was not 32 or 64 bytes)
HashSizeInvalid,
/// Failure during Explicit Mutual Authentication
MutualAuthFail,
/// The username:password string would overflow the buffer size allocated for hashing the password
/// Note: this error can only occur when using the *_alloc APIs
UsernameOrPasswordTooLong,
/// The SSID provided is too short to be secure, SSIDs must be at least 16 bytes long
/// Note: this error can only occur if the SSID establishment phase is bypassed
InsecureSsid,
/// This error happens when a long term keypair for a user is stored in a [`PartialAugDatabase`](crate::PartialAugDatabase)
/// but the user doesn't exist, this operation has no meaning and as such is an error.
#[cfg(feature = "partial_augmentation")]
UserNotRegistered,
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Error::IllegalPointError => write!(f, "illegal point encountered"),
Error::PasswordHashing(error) => write!(f, "error while hashing password: {}", error),
Error::HashEmpty => write!(f, "password hash empty"),
Error::HashSizeInvalid => write!(f, "password hash invalid, should be 32 or 64 bytes"),
Error::MutualAuthFail => write!(
f,
"explicit mutual authentication failed, authenticators didn't match"
),
Error::UsernameOrPasswordTooLong => write!(f, "username or password too long"),
Error::InsecureSsid => write!(
f,
"provided SSID is insecure - SSIDs must be at least 16 bytes long"
),
#[cfg(feature = "partial_augmentation")]
Error::UserNotRegistered => write!(
f,
"user must be registered before a long-term keypair can be stored"
),
}
}
}
/// Result type
pub type Result<T> = core::result::Result<T, Error>;