Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
secure-gate
Experimental crate — under active development
Zero-overhead, no_std-compatible secret wrappers with configurable zeroization.
Current status: The crate is in an experimental phase. The public API is stabilizing, but breaking changes are still possible (especially in the 0.5.0 release). Use in production with caution.
v0.4.2 – 2025-11-20
This release fixes a long-standing regression and brings the crate to a stable, fully-tested state.
Fixed
- #27: Restored
.expose_secret()and.expose_secret_mut()onSecurePasswordandSecurePasswordBuilder SecurePasswordBuildernow supports full mutation and.build()SecureStackPasswordis now truly zero-heap usingzeroize::Zeroizing<[u8; 128]>- All accessors work correctly under
--no-default-features
Added
expose_secret_bytes()andexpose_secret_bytes_mut()(gated behindunsafe-wipe)- Comprehensive regression test suite (
tests/password_tests.rs) with 8+ guards
Improved
- Zero warnings under
cargo clippy --all-features -- -D warnings - All tests pass on every feature combination
Features
| Feature | Effect |
|---|---|
zeroize |
Enables zeroization via secrecy + zeroize (on by default) |
stack |
Zero-allocation fixed-size secrets using Zeroizing<T> (on by default) |
unsafe-wipe |
Enables full allocation wiping (including spare capacity) |
serde |
Serialization support |
full |
All features above |
no_std+alloccompatible- Redacted
DebugandSerializeoutput - Test coverage includes timing safety and slack wiping
Installation
[]
= "0.4.2"
Enable full wiping:
= { = "0.4.2", = ["unsafe-wipe"] }
Quick Start
use ;
// Immutable password
let pw: SecurePassword = "hunter2".into;
assert_eq!;
// Mutable builder
let mut builder = from;
builder.expose_secret_mut.push_str;
let pw: SecurePassword = builder.build;
// Fixed-size keys (stack-allocated when `stack` enabled)
let key = secure!;
let key = key32;
Accessors
let s: &str = gate.expose_secret; // password types
let s: &mut String = gate.expose_secret_mut; // builder only
let raw: &T = gate.expose; // generic access
Migration from 0.3.x
All existing code continues to compile via the deprecated module.
The underlying type has changed from Secure<T> / HeapSecure<T> to SecureGate<T>.
// Old
let s = new;
// New
let s = new;
type SG<T> = ;
let s = SGnew;
Planned for 0.5.0
The current API has overlapping accessor names (.expose() vs .expose_secret() etc.).
A future 0.5.0 release will simplify this significantly — likely removing the expose_secret* methods in favor of a cleaner, more consistent design.
License
Dual-licensed under MIT OR Apache-2.0, at your option.