commonware_cryptography/handshake/error.rs
1use core::ops::Range;
2use thiserror::Error;
3
4/// Errors relating to the handshake, or to encryption.
5#[derive(Error, Debug)]
6pub enum Error {
7 /// An error indicating that the handshake failed.
8 ///
9 /// We don't provide detail on why the handshake failed, following a common
10 /// precautionary principle. The basis of this reasoning is that:
11 ///
12 /// - the application can't meaningfully respond to different failure reasons,
13 /// - an adversary might gain an advantage by knowing the failure reason.
14 ///
15 /// In other words, there's only disadvantages and extra effort in doing so.
16 #[error("handshake failed")]
17 HandshakeFailed,
18 /// An error indicating that no more messages can (safely) be sent.
19 ///
20 /// In practice, you should never see this error, because the limit takes
21 /// an ultra-astronomical amount of messages to reach.
22 #[error("message encryption limited reached")]
23 MessageLimitReached,
24 /// Encryption failed for some reason.
25 ///
26 /// In practice, this error shouldn't happen.
27 #[error("encryption failed")]
28 EncryptionFailed,
29 /// Decryption failed.
30 ///
31 /// This can happen if the message was corrupted, for some reason.
32 #[error("decryption failed")]
33 DecryptionFailed,
34 /// The timestamp is not in the allowable bounds
35 #[error("timestamp {0} not in {1:?}")]
36 InvalidTimestamp(u64, Range<u64>),
37}