Skip to main content

smith_attestation/
errors.rs

1//! Error types for Smith attestation system
2
3use thiserror::Error;
4
5/// Attestation system errors
6#[derive(Error, Debug)]
7pub enum AttestationError {
8    #[error("Cryptographic signing error: {0}")]
9    SigningError(String),
10
11    #[error("Signature verification failed: {0}")]
12    VerificationError(String),
13
14    #[error("Invalid signature format: {0}")]
15    InvalidSignature(String),
16
17    #[error("Capability bundle error: {0}")]
18    PolicyError(String),
19
20    #[error("SLSA provenance error: {0}")]
21    ProvenanceError(String),
22
23    #[error("Cosign integration error: {0}")]
24    CosignError(String),
25
26    #[error("I/O error: {0}")]
27    IoError(String),
28
29    #[error("Configuration error: {0}")]
30    ConfigError(String),
31
32    #[error("Security policy violation: {0}")]
33    SecurityError(String),
34
35    #[error("Attestation metadata error: {0}")]
36    MetadataError(String),
37
38    #[error("Supply chain integrity error: {0}")]
39    SupplyChainError(String),
40}
41
42/// Result type for attestation operations
43pub type Result<T> = std::result::Result<T, AttestationError>;
44
45impl From<std::io::Error> for AttestationError {
46    fn from(err: std::io::Error) -> Self {
47        AttestationError::IoError(err.to_string())
48    }
49}
50
51impl From<serde_json::Error> for AttestationError {
52    fn from(err: serde_json::Error) -> Self {
53        AttestationError::MetadataError(format!("JSON serialization error: {}", err))
54    }
55}