1#![no_std]
7
8#[cfg(feature = "alloc")]
9extern crate alloc;
10#[cfg(feature = "std")]
11extern crate std;
12
13pub mod dsa;
14pub mod kem;
15pub mod serdes;
16
17use core::fmt;
18
19#[derive(Debug, Clone, PartialEq, Eq)]
20pub enum Error {
21 InvalidKeyLength,
23 InvalidCiphertextLength,
25 InvalidSignatureLength,
27 InvalidParameter,
29 VerificationFailed,
31 DecodingError,
33 RngError,
35 NotImplemented,
37}
38
39impl fmt::Display for Error {
40 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
41 match self {
42 Error::InvalidKeyLength => write!(f, "invalid key length"),
43 Error::InvalidCiphertextLength => write!(f, "invalid ciphertext length"),
44 Error::InvalidSignatureLength => write!(f, "invalid signature length"),
45 Error::InvalidParameter => write!(f, "invalid parameter"),
46 Error::VerificationFailed => write!(f, "verification failed"),
47 Error::DecodingError => write!(f, "decoding error"),
48 Error::RngError => write!(f, "RNG error"),
49 Error::NotImplemented => write!(f, "not implemented"),
50 }
51 }
52}
53
54#[cfg(feature = "std")]
55impl std::error::Error for Error {}
56
57#[cfg(all(test, feature = "std"))]
58mod tests {
59 use super::Error;
60
61 fn assert_std_error<T: std::error::Error>() {}
62
63 #[test]
64 fn error_implements_std_error() {
65 assert_std_error::<Error>();
66 }
67}