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// ── Cloneable secret marker (opt-in for safe duplication) ────────────
25#[cfg(feature = "zeroize")]
26pub use cloneable::CloneableSecret;
27#[cfg(feature = "zeroize")]
28pub mod cloneable;
29#[cfg(feature = "zeroize")]
30pub use cloneable::{CloneableArray, CloneableString, CloneableVec};
31
32// ── Macros (always available) ────────────────────────────────────────
33mod macros;
34
35// ── Feature-gated modules (zero compile-time cost when disabled) ─────
36#[cfg(feature = "rand")]
37pub mod random;
38
39#[cfg(feature = "ct-eq")]
40pub mod eq;
41
42pub mod encoding;
43
44// ── Feature-gated re-exports ─────────────────────────────────────────
45#[cfg(feature = "rand")]
46pub use random::{DynamicRng, FixedRng};
47
48#[cfg(feature = "encoding-hex")]
49pub use encoding::hex::HexString;
50
51#[cfg(feature = "encoding-base64")]
52pub use encoding::base64::Base64String;
53
54#[cfg(feature = "encoding-bech32")]
55pub use encoding::bech32::Bech32String;
56
57#[cfg(any(feature = "encoding-hex", feature = "encoding-base64"))]
58pub use encoding::SecureEncodingExt;
59
60pub use fixed::FromSliceError;