Expand description
§secure-gate: Zero-cost secure wrappers for secrets
Provides safe, ergonomic handling of sensitive data in memory with zero runtime overhead.
- Fixed<T>: Stack-allocated for fixed-size secrets (e.g., keys, nonces)
- Dynamic<T>: Heap-allocated for dynamic secrets (e.g., passwords, vectors)
- Zeroizing variants: Automatic memory wiping on drop (with
zeroizefeature) - Macros:
fixed_alias!,dynamic_alias!,secure!,secure_zeroizing!for beautiful syntax
§Features
zeroize: Enables auto-wiping on dropserde: Optional serialization support- Works in
no_std+allocenvironments
§Quick Start
use secure_gate::{Dynamic, Fixed, fixed_alias, dynamic_alias};
fixed_alias!(Aes256Key, 32);
dynamic_alias!(Password, String);
let key: Aes256Key = [42u8; 32].into();
let pw: Password = "hunter2".into();
assert_eq!(key.expose_secret()[0], 42);
assert_eq!(pw.expose_secret(), "hunter2");See individual modules for details.
Macros§
- dynamic_
alias - Define a dynamic (heap) secret alias.
- fixed_
alias - Define a fixed-size secret alias with beautiful constructor syntax
- secure
- Create a secret — works for fixed-size arrays and heap types.
- secure_
zeroizing - Create a zeroizing secret (auto-wiped on drop)
Structs§
- Dynamic
- A zero-cost, heap-allocated wrapper for sensitive data.
- Dynamic
Zeroizing - Fixed
- A zero-cost, stack-allocated wrapper for sensitive data.
Traits§
- Zeroize
- Trait for securely erasing values from memory.
- Zeroize
OnDrop - Marker trait signifying that this type will
Zeroize::zeroizeitself onDrop.
Type Aliases§
Derive Macros§
- Zeroize
- Derive the
Zeroizetrait. - Zeroize
OnDrop - Derive the
ZeroizeOnDroptrait.