1use thiserror::Error;
4
5#[derive(Error, Debug)]
6pub enum SecurityError {
7 #[error("Key not found: {0}")]
8 KeyNotFound(String),
9
10 #[error("Invalid attestation: {0}")]
11 InvalidAttestation(String),
12
13 #[error("Policy violation: {0}")]
14 PolicyViolation(String),
15
16 #[error("Cryptographic error: {0}")]
17 CryptoError(String),
18
19 #[error("HSM error: {0}")]
20 HsmError(String),
21
22 #[error("KMS error: {0}")]
23 KmsError(String),
24
25 #[error("KBS error: {0}")]
26 KbsError(String),
27
28 #[error("Tier mismatch: requested {requested}, available {available}")]
29 TierMismatch { requested: u8, available: u8 },
30
31 #[error("Session expired")]
32 SessionExpired,
33
34 #[error("Rate limit exceeded")]
35 RateLimitExceeded,
36
37 #[error("Serialization error: {0}")]
38 SerializationError(#[from] serde_json::Error),
39
40 #[error("IO error: {0}")]
41 IoError(#[from] std::io::Error),
42
43 #[error("Other error: {0}")]
44 Other(#[from] anyhow::Error),
45}
46
47pub type Result<T> = std::result::Result<T, SecurityError>;