use thiserror::Error;
#[derive(Error, Debug)]
pub enum Error {
#[error("HTTP error: {0}")]
Http(String),
#[error("ASN.1 error: {0}")]
Asn1(String),
#[error("Timestamp verification error: {0}")]
Verification(String),
#[error("Invalid timestamp response: {0}")]
InvalidResponse(String),
#[error("Failed to parse timestamp response: {0}")]
ParseError(String),
#[error("Failed to verify timestamp signature: {0}")]
SignatureVerificationError(String),
#[error("Timestamp message hash mismatch: expected {expected}, got {actual}")]
HashMismatch { expected: String, actual: String },
#[error("Timestamp response indicates failure status")]
ResponseFailure,
#[error("No timestamp token in response")]
NoToken,
#[error("No TSTInfo in timestamp token")]
NoTstInfo,
#[error("Leaf certificate does not have TimeStamping Extended Key Usage")]
InvalidEKU,
#[error("TSA certificate validation failed: {0}")]
CertificateValidationError(String),
#[error("Timestamp parsing error: {0}")]
Parse(String),
#[error(
"timestamp {time} is outside the validity period of the timestamp authority that signed it"
)]
TimestampOutsideValidity {
time: jiff::Timestamp,
},
}
pub type Result<T> = std::result::Result<T, Error>;