Expand description
Utilities for handling sensitive data that must be zeroed from memory on drop.
This module provides:
-
Re-exports of
zeroizecrate fundamentals (Zeroize,ZeroizeOnDrop,Zeroizing) so that downstream crates can depend onmz-orealone. -
SecureString: aStringwrapper that is zeroed on drop and redacted inDebug/Displayoutput. Use for passwords, tokens, and credentials. -
SecureVec: aVec<u8>wrapper that is zeroed on drop and redacted inDebug/Displayoutput. Use for raw key material and secret bytes.
§When to use
Use these types whenever a value contains secret material (passwords, keys, tokens, salts, nonces) that should not linger in process memory after use.
§Examples
use mz_ore::secure::{SecureString, SecureVec, Zeroizing};
// Wrap a password — zeroed on drop, redacted in logs
let password = SecureString::from("hunter2");
assert_eq!(password.unsecure(), "hunter2");
assert!(!format!("{:?}", password).contains("hunter2"));
// Wrap raw key bytes
let key = SecureVec::from(vec![0xDE, 0xAD, 0xBE, 0xEF]);
assert_eq!(key.unsecure(), &[0xDE, 0xAD, 0xBE, 0xEF]);
// Use Zeroizing<T> for temporary buffers
let buf = Zeroizing::new([0u8; 32]);Structs§
- Secure
String - A
Stringthat is zeroed from memory on drop and redacted inDebug/Displayoutput. - Secure
Vec - A
Vec<u8>that is zeroed from memory on drop and redacted inDebug/Displayoutput. - Zeroizing
Zeroizingis a a wrapper for anyZ: Zeroizetype which implements aDrophandler which zeroizes dropped values.
Traits§
- Zeroize
- Trait for securely erasing values from memory.
- Zeroize
OnDrop - Marker trait signifying that this type will
Zeroize::zeroizeitself onDrop.
Derive Macros§
- Zeroize
- Derive the
Zeroizetrait. - Zeroize
OnDrop - Derive the
ZeroizeOnDroptrait.