Skip to main content

sigstore_tsa/
error.rs

1//! Error types for sigstore-tsa
2
3use thiserror::Error;
4
5/// Errors that can occur in TSA operations
6#[derive(Error, Debug)]
7pub enum Error {
8    /// HTTP request error
9    #[error("HTTP error: {0}")]
10    Http(String),
11
12    /// ASN.1 encoding/decoding error
13    #[error("ASN.1 error: {0}")]
14    Asn1(String),
15
16    /// Timestamp verification error
17    #[error("Timestamp verification error: {0}")]
18    Verification(String),
19
20    /// Invalid timestamp response
21    #[error("Invalid timestamp response: {0}")]
22    InvalidResponse(String),
23
24    /// Failed to parse timestamp response
25    #[error("Failed to parse timestamp response: {0}")]
26    ParseError(String),
27
28    /// Failed to verify timestamp signature
29    #[error("Failed to verify timestamp signature: {0}")]
30    SignatureVerificationError(String),
31
32    /// Timestamp message hash does not match signature
33    #[error("Timestamp message hash mismatch: expected {expected}, got {actual}")]
34    HashMismatch { expected: String, actual: String },
35
36    /// Timestamp response indicates failure status
37    #[error("Timestamp response indicates failure status")]
38    ResponseFailure,
39
40    /// No timestamp token in response
41    #[error("No timestamp token in response")]
42    NoToken,
43
44    /// No TSTInfo in timestamp token
45    #[error("No TSTInfo in timestamp token")]
46    NoTstInfo,
47
48    /// Leaf certificate does not have TimeStamping EKU
49    #[error("Leaf certificate does not have TimeStamping Extended Key Usage")]
50    InvalidEKU,
51
52    /// TSA certificate validation failed
53    #[error("TSA certificate validation failed: {0}")]
54    CertificateValidationError(String),
55
56    /// Timestamp parsing error
57    #[error("Timestamp parsing error: {0}")]
58    Parse(String),
59}
60
61/// Result type for TSA operations
62pub type Result<T> = std::result::Result<T, Error>;