Skip to main content

oxicrypto_core/traits/
mod.rs

1pub mod aead;
2pub mod hash;
3pub mod kdf;
4pub mod kex;
5pub mod mac;
6pub mod pq;
7pub mod rng;
8pub mod sig;
9
10pub use aead::{Aead, StreamingAead};
11pub use hash::{Hash, StreamingHash};
12pub use kdf::{Kdf, PasswordHash, PasswordHashParams};
13pub use kex::KeyAgreement;
14pub use mac::{Mac, StreamingMac};
15pub use pq::Kem;
16pub use rng::Rng;
17#[cfg(feature = "alloc")]
18pub use sig::KeyGenerator;
19pub use sig::{Signer, Verifier};
20
21// ---------------------------------------------------------------------------
22// MaybeDebug — conditional Debug supertrait
23// ---------------------------------------------------------------------------
24//
25// When the `debug` Cargo feature is enabled every core trait additionally
26// requires `core::fmt::Debug` as a supertrait, making `Box<dyn Kdf>` etc.
27// printable.  Without the feature the bound is erased.
28//
29// Usage in trait definitions:
30//   `pub trait Kdf: Send + Sync + crate::traits::MaybeDebug { … }`
31
32#[cfg(feature = "debug")]
33pub trait MaybeDebug: core::fmt::Debug {}
34#[cfg(feature = "debug")]
35impl<T: core::fmt::Debug> MaybeDebug for T {}
36
37#[cfg(not(feature = "debug"))]
38pub trait MaybeDebug {}
39#[cfg(not(feature = "debug"))]
40impl<T> MaybeDebug for T {}