1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright lowRISC contributors (OpenTitan project).
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0

use thiserror::Error;

use crate::util::attribute::AttributeError;

#[derive(Debug, Error)]
pub enum HsmError {
    #[error("Token {0:?} not found")]
    TokenNotFound(String),
    #[error("Unknown user {0:?}. Expecting one of {{so, user}}")]
    UnknownUser(String),
    #[error("Key error:  {0}")]
    KeyError(String),
    #[error("Object already exists id={0:?} label={1:?}")]
    ObjectExists(String, String),
    #[error("Bad hash size: expected {0} bytes, but got {1} bytes")]
    HashSizeError(usize, usize),
    #[error("No search criteria. Specify an id or label")]
    NoSearchCriteria,
    #[error("Session required")]
    SessionRequired,
    #[error("Unsupported: {0}")]
    Unsupported(String),
    #[error(transparent)]
    AttributeError(#[from] AttributeError),
    #[error("Object not found for search {0}")]
    ObjectNotFound(String),
    #[error("Expected exactly one object. Found {0} objects for search {1}")]
    TooManyObjects(usize, String),
    #[error("Expected only owner permissions, but found permissions {0:o}")]
    FilePermissionError(u32),
    #[error("DER error: {0}")]
    DerError(String),
    #[error("This operation requires the acorn library")]
    AcornUnavailable,
    #[error("Parse error: {0}")]
    ParseError(String),
    #[error("Unknown application: {0}")]
    UnknownApplication(String),
}