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
44
45
46
47
// Copyright lowRISC contributors (OpenTitan project).
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0

use std::path::PathBuf;
use thiserror::Error;

pub mod ecdsa;
pub mod rsa;
pub mod sha256;
pub mod spx;

#[derive(Debug, Error)]
pub enum Error {
    #[error("Invalid public key: {0:?}")]
    InvalidPublicKey(#[source] anyhow::Error),
    #[error("Invalid DER file: {der}")]
    InvalidDerFile {
        der: PathBuf,
        #[source]
        source: anyhow::Error,
    },
    #[error("Read failed: {file}")]
    ReadFailed {
        file: PathBuf,
        #[source]
        source: anyhow::Error,
    },
    #[error("Write failed: {file}")]
    WriteFailed {
        file: PathBuf,
        #[source]
        source: anyhow::Error,
    },
    #[error("Generate failed")]
    GenerateFailed(#[source] anyhow::Error),
    #[error("Invalid signature")]
    InvalidSignature(#[source] anyhow::Error),
    #[error("Sign failed")]
    SignFailed(#[source] anyhow::Error),
    #[error("Verification failed")]
    VerifyFailed(#[source] anyhow::Error),
    #[error("Failed to compute key component")]
    KeyComponentComputeFailed,
    #[error(transparent)]
    Other(#[from] anyhow::Error),
}