Skip to main content

flamberge_crypto/
error.rs

1use thiserror::Error;
2
3/// Errors from the crypto primitives.
4#[derive(Debug, Error)]
5pub enum CryptoError {
6    #[error("invalid key length: expected {expected} bytes, got {got}")]
7    KeyLength { expected: usize, got: usize },
8
9    #[error("invalid IV length: expected {expected} bytes, got {got}")]
10    IvLength { expected: usize, got: usize },
11
12    #[error("input length {0} is not a multiple of the {1}-byte block size")]
13    NotBlockAligned(usize, usize),
14
15    #[error("invalid PKCS#7 padding (wrong key?)")]
16    BadPadding,
17
18    #[error("RSA operation failed: {0}")]
19    Rsa(String),
20}