1use aes::cipher::block_padding::UnpadError;
2use hmac::digest::InvalidLength;
3use std::string::FromUtf8Error;
4use thiserror::Error;
5
6#[derive(Error, Debug)]
7pub enum CipherError {
8 #[error("Invalid key length")]
9 InvalidLength(#[from] InvalidLength),
10
11 #[error("Invalid cipher header, header byte should be `Salted__`")]
12 InvalidCipherHeader(),
13
14 #[error("Cipher text is too short")]
15 CipherTextIsTooShort(),
16
17 #[error("Invalid key")]
18 InvalidKey(#[from] UnpadError),
19
20 #[error("Invalid Base64 encoding")]
21 InvalidBase64Encoding(#[from] base64::DecodeError),
22
23 #[error("Invalid UTF-8 encoding")]
24 InvalidUtf8Encoding(#[from] FromUtf8Error),
25}