1use crate::traits::kdf::KdfError;
6use crate::traits::asymmetric::KemError;
7use crate::traits::asymmetric::KeyAgreementError;
8use crate::traits::key::KeyError;
9use crate::traits::asymmetric::SignatureError;
10use crate::traits::symmetric::SymmetricError;
11
12#[cfg(feature = "std")]
13use thiserror::Error;
14
15#[cfg_attr(feature = "std", derive(Error))]
24#[derive(Debug, PartialEq, Eq)]
25pub enum Error {
26 #[cfg_attr(feature = "std", error("Key operation failed"))]
30 Key(#[cfg_attr(feature = "std", from)] KeyError),
31
32 #[cfg_attr(feature = "std", error("KEM operation failed"))]
36 Kem(#[cfg_attr(feature = "std", from)] KemError),
37
38 #[cfg_attr(feature = "std", error("Signature operation failed"))]
42 Signature(#[cfg_attr(feature = "std", from)] SignatureError),
43
44 #[cfg_attr(feature = "std", error("Aead encryption/decryption error"))]
48 Symmetric(#[cfg_attr(feature = "std", from)] SymmetricError),
49
50 #[cfg_attr(feature = "std", error("Key agreement operation failed"))]
54 KeyAgreement(#[cfg_attr(feature = "std", from)] KeyAgreementError),
55
56 #[cfg_attr(feature = "std", error("KDF error"))]
60 Kdf(#[cfg_attr(feature = "std", from)] KdfError),
61
62}
63
64#[cfg(not(feature = "std"))]
66impl From<KeyError> for Error {
67 fn from(e: KeyError) -> Self {
68 Error::Key(e)
69 }
70}
71
72#[cfg(not(feature = "std"))]
73impl From<KemError> for Error {
74 fn from(e: KemError) -> Self {
75 Error::Kem(e)
76 }
77}
78
79#[cfg(not(feature = "std"))]
80impl From<SignatureError> for Error {
81 fn from(e: SignatureError) -> Self {
82 Error::Signature(e)
83 }
84}
85
86#[cfg(not(feature = "std"))]
87impl From<SymmetricError> for Error {
88 fn from(e: SymmetricError) -> Self {
89 Error::Symmetric(e)
90 }
91}
92
93#[cfg(not(feature = "std"))]
94impl From<KeyAgreementError> for Error {
95 fn from(e: KeyAgreementError) -> Self {
96 Error::KeyAgreement(e)
97 }
98}
99
100#[cfg(not(feature = "std"))]
101impl From<KdfError> for Error {
102 fn from(e: KdfError) -> Self {
103 Error::Kdf(e)
104 }
105}