1use thiserror::Error;
6
7use crate::util::attribute::AttributeError;
8
9#[derive(Debug, Error)]
10pub enum HsmError {
11 #[error("Token {0:?} not found")]
12 TokenNotFound(String),
13 #[error("Unknown user {0:?}. Expecting one of {{so, user}}")]
14 UnknownUser(String),
15 #[error("Key error: {0}")]
16 KeyError(String),
17 #[error("Object already exists id={0:?} label={1:?}")]
18 ObjectExists(String, String),
19 #[error("Bad hash size: expected {0} bytes, but got {1} bytes")]
20 HashSizeError(usize, usize),
21 #[error("No search criteria. Specify an id or label")]
22 NoSearchCriteria,
23 #[error("Session required")]
24 SessionRequired,
25 #[error("Unsupported: {0}")]
26 Unsupported(String),
27 #[error(transparent)]
28 AttributeError(#[from] AttributeError),
29 #[error("Object not found for search {0}")]
30 ObjectNotFound(String),
31 #[error("Expected exactly one object. Found {0} objects for search {1}")]
32 TooManyObjects(usize, String),
33 #[error("Expected only owner permissions, but found permissions {0:o}")]
34 FilePermissionError(u32),
35 #[error("DER error: {0}")]
36 DerError(String),
37 #[error("This operation requires an spx module")]
38 SpxUnavailable,
39 #[error("Parse error: {0}")]
40 ParseError(String),
41 #[error("Unknown application: {0}")]
42 UnknownApplication(String),
43}