Skip to main content

ades/
error.rs

1use thiserror::Error;
2
3/// Errors produced by the `ades` crate.
4#[derive(Debug, Error)]
5#[non_exhaustive]
6pub enum AdesError {
7    /// RSA key operation failed (key generation, key import).
8    #[error("RSA error: {0}")]
9    Rsa(#[from] rsa::Error),
10
11    /// Cryptographic signature operation failed.
12    #[error("signature error: {0}")]
13    Signature(#[from] signature::Error),
14
15    /// DER encoding or decoding failed (certificates, CMS structures).
16    #[error("DER error: {0}")]
17    Der(#[from] der::Error),
18
19    /// Certificate builder error (key mismatch, extension encoding, etc.).
20    #[error("certificate builder error: {0}")]
21    Builder(#[from] x509_cert::builder::Error),
22
23    /// Error returned by a [`crate::signer::Signer`] backend.
24    #[error("signer error: {0}")]
25    Signer(Box<dyn std::error::Error + Send + Sync + 'static>),
26
27    /// TSP (RFC 3161) request or response error.
28    #[error("TSP error: {0}")]
29    Tsp(String),
30
31    /// OCSP (RFC 6960) request or response error.
32    #[error("OCSP error: {0}")]
33    Ocsp(String),
34
35    /// PKCS#11 token or library error.
36    #[error("PKCS#11 error: {0}")]
37    Pkcs11(String),
38
39    /// Operation not yet implemented.
40    #[error("not implemented: {0}")]
41    NotImplemented(&'static str),
42}