use thiserror::Error;
#[derive(Debug, Clone, PartialEq, Eq, Error)]
pub enum CryptoError {
#[error("ciphertext too short: expected at least {expected} bytes, got {actual}")]
CiphertextTooShort {
expected: usize,
actual: usize,
},
#[error("invalid base64: {0}")]
InvalidBase64(#[from] base64::DecodeError),
#[error("unsupported version: {0}")]
UnsupportedVersion(u8),
#[error("decryption failed: wrong key or corrupted ciphertext")]
DecryptionFailed,
#[error("decrypted data is not valid UTF-8")]
InvalidUtf8(#[from] std::string::FromUtf8Error),
#[error("key derivation failed: {0}")]
KeyDerivation(String),
#[error("encryption failed")]
EncryptionFailed,
#[error("failed to acquire secure randomness")]
RandomnessFailed,
#[error("invalid key length: expected {expected} bytes, got {actual}")]
InvalidKeyLength {
expected: usize,
actual: usize,
},
#[error("unknown encoding: expected \"standard\" or \"url_safe_no_pad\"")]
InvalidEncoding,
}