opentitanlib/crypto/
mod.rs

1// Copyright lowRISC contributors (OpenTitan project).
2// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3// SPDX-License-Identifier: Apache-2.0
4
5use std::path::PathBuf;
6use thiserror::Error;
7
8pub mod ecdsa;
9pub mod rsa;
10pub mod sha256;
11pub mod spx;
12
13#[derive(Debug, Error)]
14pub enum Error {
15    #[error("Invalid hash: {0}")]
16    InvalidHash(String),
17    #[error("Invalid public key: {0:?}")]
18    InvalidPublicKey(#[source] anyhow::Error),
19    #[error("Invalid DER file: {der}")]
20    InvalidDerFile {
21        der: PathBuf,
22        #[source]
23        source: anyhow::Error,
24    },
25    #[error("Read failed: {file}")]
26    ReadFailed {
27        file: PathBuf,
28        #[source]
29        source: anyhow::Error,
30    },
31    #[error("Write failed: {file}")]
32    WriteFailed {
33        file: PathBuf,
34        #[source]
35        source: anyhow::Error,
36    },
37    #[error("Generate failed")]
38    GenerateFailed(#[source] anyhow::Error),
39    #[error("Invalid signature")]
40    InvalidSignature(#[source] anyhow::Error),
41    #[error("Sign failed")]
42    SignFailed(#[source] anyhow::Error),
43    #[error("Verification failed")]
44    VerifyFailed(#[source] anyhow::Error),
45    #[error("Failed to compute key component")]
46    KeyComponentComputeFailed,
47    #[error(transparent)]
48    Other(#[from] anyhow::Error),
49}