pqcrypto_traits/
lib.rs

1//! Supporting Traits for the pqcrypto crates.
2
3#![no_std]
4
5#[cfg(feature = "std")]
6extern crate std;
7
8/// Convenience wrapper for Result
9pub type Result<T> = core::result::Result<T, Error>;
10
11/// Errors that may arise when constructing keys or signatures.
12#[derive(Clone, Copy, Debug)]
13#[non_exhaustive]
14pub enum Error {
15    BadLength {
16        name: &'static str,
17        actual: usize,
18        expected: usize,
19    },
20}
21
22impl core::fmt::Display for Error {
23    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
24        match self {
25            Error::BadLength {
26                name,
27                actual,
28                expected,
29            } => write!(
30                f,
31                "error: {} expected {} bytes, got {}",
32                name, expected, actual
33            ),
34        }
35    }
36}
37
38#[cfg(feature = "std")]
39impl std::error::Error for Error {}
40
41pub mod kem;
42pub mod sign;