1use crate::constants::MAGIC_SLICE;
2use crate::constants::MIN_MESSAGE_LEN;
3use crate::constants::MIX_PARAMS_LEN;
4use chacha20::cipher::InvalidLength;
5use thiserror::Error;
6
7#[derive(Debug, Error, Clone)]
8pub enum OutfoxError {
9 #[error("Lengths mismatch, expected: {expected}, got: {got}")]
10 LenMismatch { expected: usize, got: usize },
11 #[error("{source}")]
12 ChaCha20InvalidLength {
13 #[from]
14 source: InvalidLength,
15 },
16 #[error("ChaCha20Poly1305 - {0}")]
17 ChaCha20Poly1305Error(String),
18 #[error("Key length must be 32 bytes")]
19 InvalidKeyLength,
20 #[error("Message length must be greater then {MIN_MESSAGE_LEN} bytes")]
21 InvalidMessageLength,
22 #[error("{source}")]
23 TryFromSlice {
24 #[from]
25 source: std::array::TryFromSliceError,
26 },
27 #[error("Header length must be {MIX_PARAMS_LEN}, got {0}")]
28 InvalidHeaderLength(usize),
29 #[error("Invalid magic bytes, expected: {:?}, got: {:?}", MAGIC_SLICE, 0)]
30 InvalidMagicBytes(Vec<u8>),
31}