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 public key: {0:?}")]
16    InvalidPublicKey(#[source] anyhow::Error),
17    #[error("Invalid DER file: {der}")]
18    InvalidDerFile {
19        der: PathBuf,
20        #[source]
21        source: anyhow::Error,
22    },
23    #[error("Read failed: {file}")]
24    ReadFailed {
25        file: PathBuf,
26        #[source]
27        source: anyhow::Error,
28    },
29    #[error("Write failed: {file}")]
30    WriteFailed {
31        file: PathBuf,
32        #[source]
33        source: anyhow::Error,
34    },
35    #[error("Generate failed")]
36    GenerateFailed(#[source] anyhow::Error),
37    #[error("Invalid signature")]
38    InvalidSignature(#[source] anyhow::Error),
39    #[error("Sign failed")]
40    SignFailed(#[source] anyhow::Error),
41    #[error("Verification failed")]
42    VerifyFailed(#[source] anyhow::Error),
43    #[error("Failed to compute key component")]
44    KeyComponentComputeFailed,
45    #[error(transparent)]
46    Other(#[from] anyhow::Error),
47}