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;
17pub use sig::{KeyGenerator, Signer, Verifier};
18
19// ---------------------------------------------------------------------------
20// MaybeDebug — conditional Debug supertrait
21// ---------------------------------------------------------------------------
22//
23// When the `debug` Cargo feature is enabled every core trait additionally
24// requires `core::fmt::Debug` as a supertrait, making `Box<dyn Kdf>` etc.
25// printable.  Without the feature the bound is erased.
26//
27// Usage in trait definitions:
28//   `pub trait Kdf: Send + Sync + crate::traits::MaybeDebug { … }`
29
30#[cfg(feature = "debug")]
31pub trait MaybeDebug: core::fmt::Debug {}
32#[cfg(feature = "debug")]
33impl<T: core::fmt::Debug> MaybeDebug for T {}
34
35#[cfg(not(feature = "debug"))]
36pub trait MaybeDebug {}
37#[cfg(not(feature = "debug"))]
38impl<T> MaybeDebug for T {}