1use thiserror::Error;
4
5#[derive(Error, Debug)]
6pub enum PqcError {
7 #[error("KEM operation failed: {0}")]
8 KemError(String),
9
10 #[error("Signature operation failed: {0}")]
11 SignatureError(String),
12
13 #[error("KDF operation failed: {0}")]
14 KdfError(String),
15
16 #[error("Unsupported algorithm: {0}")]
17 UnsupportedAlgorithm(String),
18
19 #[error("Attestation failed: {0}")]
20 AttestationError(String),
21
22 #[error("Wire protocol error: {0}")]
23 WireProtocolError(String),
24
25 #[error("RNG error: {0}")]
26 RngError(String),
27
28 #[error("Invalid key size: expected {expected}, got {actual}")]
29 InvalidKeySize { expected: usize, actual: usize },
30
31 #[error("Policy violation: {0}")]
32 PolicyViolation(String),
33
34 #[error("IO error: {0}")]
35 IoError(#[from] std::io::Error),
36
37 #[error("Serialization error: {0}")]
38 SerializationError(#[from] serde_json::Error),
39
40 #[error("Other error: {0}")]
41 Other(#[from] anyhow::Error),
42}
43
44pub type Result<T> = std::result::Result<T, PqcError>;