tpm2_crypto/
error.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2// Copyright (c) 2025 Opinsys Oy
3// Copyright (c) 2024-2025 Jarkko Sakkinen
4
5use thiserror::Error;
6
7/// The top-level error type for cryptographic operations.
8#[derive(Debug, Error, PartialEq, Eq)]
9pub enum Error {
10    /// Hash algorithm is not supported in the context of use.
11    #[error("invalid hash algorithm")]
12    InvalidHash,
13    /// ECC curve is not supported in the context of use.
14    #[error("invalid ECC curve")]
15    InvalidEccCurve,
16    /// Invalid ECC public parameters.
17    #[error("invalid ECC parameters")]
18    InvalidEccParameters,
19    /// Invalid RSA public parameters.
20    #[error("invalid RSA parameters")]
21    InvalidRsaParameters,
22    /// A zero-length key was provided.
23    #[error("the provided key has zero length")]
24    KeyIsEmpty,
25    /// A cryptographic operation failed.
26    #[error("operation failed")]
27    OperationFailed,
28    /// Not enough memory available.
29    #[error("out of memory")]
30    OutOfMemory,
31    /// The provided HMAC does not match to the expected value.
32    #[error("permission denied")]
33    PermissionDenied,
34}