Expand description
secure-gate — Secure secret wrappers with explicit access & automatic zeroization
Secrets are automatically zeroized on drop (the inner type must implement Zeroize).
Explicit access only via RevealSecret/RevealSecretMut — no Deref, no accidental leaks.
Debug always prints [REDACTED].
Fixed<T>— stack-allocated, compile-time-sized secrets (keys, nonces, tokens)Dynamic<T>— heap-allocated, variable-length secrets (passwords, API keys, ciphertexts)
§Feature flags
alloc(default): Heap-allocatedDynamic<T>+ full zeroization of spare capacitystd: Fullstdsupport (impliesalloc)ct-eq:ConstantTimeEqconstant-time equality (subtle)rand:from_random()viaOsRng,from_rng()for customTryCryptoRng+TryRngCore;no_stdcompatible forFixed<T>(no heap required)cloneable:CloneableSecretopt-in cloningserde-serialize/serde-deserialize: Serde supportencoding-hex/encoding-base64/encoding-bech32/encoding-bech32m: Per-format encodingfull: All features
§no_std
no_std compatible. Fixed<T> works without alloc. Enable alloc (default) for
Dynamic<T>. For pure stack / embedded builds, use default-features = false.
See the README and SECURITY.md for full details.
Re-exports§
pub use traits::CloneableSecret;pub use traits::ConstantTimeEq;pub use traits::RevealSecret;pub use traits::RevealSecretMut;pub use traits::SerializableSecret;pub use traits::FromBase64UrlStr;pub use traits::FromBech32Str;pub use traits::FromBech32mStr;pub use traits::FromHexStr;pub use traits::ToBase64Url;pub use traits::ToBech32;pub use traits::ToBech32m;pub use traits::ToHex;pub use traits::SecureDecoding;pub use traits::SecureEncoding;
Modules§
- compat
- secrecy compatibility layers — drop-in replacements for the
secrecycrate. - traits
- Core traits for wrapper polymorphism - always available. Traits for polymorphic secret handling.
Macros§
- dynamic_
alias - Creates a type alias for
Dynamic<T>. - dynamic_
generic_ alias - Creates a generic type alias
Name<T>forDynamic<T>. - fixed_
alias - Creates a type alias for
Fixed<[u8; N]>. - fixed_
generic_ alias - Creates a const-generic type alias
Name<const N: usize>forFixed<[u8; N]>.
Structs§
- Dynamic
- Heap-allocated secret wrapper with explicit access and automatic zeroization on drop.
- Fixed
- Stack-allocated secret wrapper with explicit access and automatic zeroization on drop.
Enums§
- Base64
Error - Errors produced when decoding base64url strings.
- Bech32
Error - Errors produced when decoding Bech32 (BIP-173) or Bech32m (BIP-350) strings.
- Decoding
Error - Unified error type for multi-format decoding operations.
- From
Slice Error - Error returned when a byte slice cannot be converted to a fixed-size array.
- HexError
- Errors produced when decoding hexadecimal strings.
Constants§
- MAX_
DESERIALIZE_ BYTES - Default maximum byte length for
Dynamic<Vec<u8>>/Dynamic<String>deserialization (1 MiB).