Skip to main content

firecloud_crypto/
error.rs

1//! Crypto error types
2
3use thiserror::Error;
4
5#[derive(Error, Debug)]
6pub enum CryptoError {
7    #[error("Encryption failed: {0}")]
8    Encryption(String),
9
10    #[error("Decryption failed: {0}")]
11    Decryption(String),
12
13    #[error("Key derivation failed: {0}")]
14    KeyDerivation(String),
15
16    #[error("Invalid key size: expected {expected}, got {actual}")]
17    InvalidKeySize { expected: usize, actual: usize },
18
19    #[error("Invalid nonce size")]
20    InvalidNonceSize,
21
22    #[error("Signature verification failed")]
23    SignatureVerification,
24
25    #[error("Random number generation failed")]
26    RandomGeneration,
27
28    // Legacy aliases for backwards compatibility
29    #[error("Encryption failed: {0}")]
30    EncryptionFailed(String),
31
32    #[error("Decryption failed: {0}")]
33    DecryptionFailed(String),
34
35    #[error("Invalid key length: expected {expected}, got {actual}")]
36    InvalidKeyLength { expected: usize, actual: usize },
37
38    #[error("Invalid nonce length")]
39    InvalidNonceLength,
40}
41
42pub type CryptoResult<T> = Result<T, CryptoError>;