Skip to main content

zlicenser_protocol/
error.rs

1#[derive(Debug, thiserror::Error)]
2pub enum Error {
3    #[error("CBOR encode error: {0}")]
4    Encode(String),
5
6    #[error("CBOR decode error: {0}")]
7    Decode(String),
8
9    #[error("AEAD decryption failed")]
10    Decrypt,
11
12    #[error("signature verification failed")]
13    SignatureInvalid,
14
15    #[error("Shamir error: {0}")]
16    Shamir(String),
17
18    #[error("protocol version mismatch: expected {expected}, got {actual}")]
19    VersionMismatch { expected: u16, actual: u16 },
20
21    #[error("malformed message: {0}")]
22    Malformed(&'static str),
23
24    // fingerprint errors
25    #[error("hardware identifier collection failed: {0}")]
26    Collection(String),
27
28    #[error("fingerprint reconstruction failed: recovered {recovered} shares, need {threshold}")]
29    InsufficientIdentifiers { recovered: usize, threshold: usize },
30
31    // TSA errors
32    #[error("TSA token parse error: {0}")]
33    TsaParse(String),
34
35    #[error("TSA token verification failed: {0}")]
36    TsaVerification(String),
37
38    #[error("TSA provider not in allowlist")]
39    TsaUntrustedProvider,
40}