Skip to main content

egide_crypto/
error.rs

1//! Cryptographic error types.
2
3use thiserror::Error;
4
5/// Errors that can occur during cryptographic operations.
6#[derive(Debug, Error)]
7pub enum CryptoError {
8    /// Key generation failed.
9    #[error("key generation failed: {0}")]
10    KeyGenerationFailed(String),
11
12    /// Encryption failed.
13    #[error("encryption failed: {0}")]
14    EncryptionFailed(String),
15
16    /// Decryption failed.
17    #[error("decryption failed: {0}")]
18    DecryptionFailed(String),
19
20    /// Signature creation failed.
21    #[error("signature creation failed: {0}")]
22    SignatureFailed(String),
23
24    /// Signature verification failed.
25    #[error("signature verification failed")]
26    VerificationFailed,
27
28    /// Invalid key format or size.
29    #[error("invalid key: {0}")]
30    InvalidKey(String),
31
32    /// Invalid input data.
33    #[error("invalid input: {0}")]
34    InvalidInput(String),
35
36    /// The system random number generator failed to produce output.
37    #[error("random number generator failed: {0}")]
38    RandomGenerationFailed(String),
39}