Crate secure_gate

Crate secure_gate 

Source
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 zeroize feature)
  • Macros: fixed_alias!, dynamic_alias!, secure!, secure_zeroizing! for beautiful syntax

§Features

  • zeroize: Enables auto-wiping on drop
  • serde: Optional serialization support
  • Works in no_std + alloc environments

§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.
DynamicZeroizing
Fixed
A zero-cost, stack-allocated wrapper for sensitive data.

Traits§

Zeroize
Trait for securely erasing values from memory.
ZeroizeOnDrop
Marker trait signifying that this type will Zeroize::zeroize itself on Drop.

Type Aliases§

FixedZeroizing
Zeroizing

Derive Macros§

Zeroize
Derive the Zeroize trait.
ZeroizeOnDrop
Derive the ZeroizeOnDrop trait.