secure_gate/
lib.rs

1// ==========================================================================
2// src/lib.rs
3// ==========================================================================
4
5// Allow unsafe_code when encoding or zeroize is enabled (encoding needs it for hex validation)
6#![cfg_attr(
7    not(any(
8        feature = "zeroize",
9        any(feature = "encoding-hex", feature = "encoding-base64")
10    )),
11    forbid(unsafe_code)
12)]
13#![doc = include_str!("../README.md")]
14
15extern crate alloc;
16
17// ── Core secret types (always available) ─────────────────────────────
18mod dynamic;
19mod fixed;
20
21pub use dynamic::Dynamic;
22pub use fixed::Fixed;
23
24// ── Cloning module ───────────────────────────────────────────────────
25pub mod clone;
26
27// ── Cloneable secret marker (opt-in for safe duplication) ────────────
28#[cfg(feature = "zeroize")]
29pub use clone::CloneableSecret;
30
31// ── Macros (always available) ────────────────────────────────────────
32mod macros;
33
34// ── Feature-gated modules (zero compile-time cost when disabled) ─────
35#[cfg(feature = "rand")]
36pub mod random;
37
38#[cfg(feature = "ct-eq")]
39pub mod eq;
40
41pub mod encoding;
42
43// ── Feature-gated re-exports ─────────────────────────────────────────
44#[cfg(feature = "rand")]
45pub use random::{DynamicRng, FixedRng};
46
47#[cfg(feature = "encoding-hex")]
48pub use encoding::hex::HexString;
49
50#[cfg(feature = "encoding-base64")]
51pub use encoding::base64::Base64String;
52
53#[cfg(any(feature = "encoding-hex", feature = "encoding-base64"))]
54pub use encoding::SecureEncodingExt;
55
56pub use fixed::FromSliceError;