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 mldsa;
10pub mod rsa;
11pub mod sha256;
12pub mod spx;
13
14#[derive(Debug, Error)]
15pub enum Error {
16    #[error("Invalid hash: {0}")]
17    InvalidHash(String),
18    #[error("Invalid public key: {0:?}")]
19    InvalidPublicKey(#[source] anyhow::Error),
20    #[error("Invalid DER file: {der}")]
21    InvalidDerFile {
22        der: PathBuf,
23        #[source]
24        source: anyhow::Error,
25    },
26    #[error("Read failed: {file}")]
27    ReadFailed {
28        file: PathBuf,
29        #[source]
30        source: anyhow::Error,
31    },
32    #[error("Write failed: {file}")]
33    WriteFailed {
34        file: PathBuf,
35        #[source]
36        source: anyhow::Error,
37    },
38    #[error("Generate failed")]
39    GenerateFailed(#[source] anyhow::Error),
40    #[error("Invalid signature")]
41    InvalidSignature(#[source] anyhow::Error),
42    #[error("Sign failed")]
43    SignFailed(#[source] anyhow::Error),
44    #[error("Verification failed")]
45    VerifyFailed(#[source] anyhow::Error),
46    #[error("Failed to compute key component")]
47    KeyComponentComputeFailed,
48    #[error(transparent)]
49    Other(#[from] anyhow::Error),
50}