1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum Error {
5 #[cfg(feature = "rust-hpke")]
6 #[error("a problem occurred with the AEAD")]
7 Aead(#[from] aead::Error),
8 #[cfg(feature = "nss")]
9 #[error("a problem occurred during cryptographic processing: {0}")]
10 Crypto(#[from] crate::nss::Error),
11 #[error("an error was found in the format")]
12 Format,
13 #[cfg(feature = "rust-hpke")]
14 #[error("a problem occurred with HPKE: {0}")]
15 Hpke(#[from] ::bitcoin_hpke::HpkeError),
16 #[error("an internal error occurred")]
17 Internal,
18 #[error("the wrong type of key was provided for the selected KEM")]
19 InvalidKeyType,
20 #[error("the wrong KEM was specified")]
21 InvalidKem,
22 #[error("io error: {0}")]
23 Io(#[from] std::io::Error),
24 #[error("the key ID was invalid")]
25 KeyId,
26 #[error("a field was truncated")]
27 Truncated,
28 #[error("the configuration was not supported")]
29 Unsupported,
30 #[error("the configuration contained too many symmetric suites")]
31 TooManySymmetricSuites,
32}
33
34impl From<std::num::TryFromIntError> for Error {
35 fn from(_v: std::num::TryFromIntError) -> Self {
36 Self::TooManySymmetricSuites
37 }
38}
39
40pub type Res<T> = Result<T, Error>;