pub struct SecureBox<T>where
T: Sized + Copy,{ /* private fields */ }
Expand description
A data type suitable for storing sensitive information such as passwords and private keys in memory, that implements:
- Automatic zeroing in
Drop
- Constant time comparison in
PartialEq
(does not short circuit on the first different character; but terminates instantly if strings have different length) - Outputting
***SECRET***
to prevent leaking secrets into logs infmt::Debug
andfmt::Display
- Automatic
mlock
to protect against leaking into swap (any unix) - Automatic
madvise(MADV_NOCORE/MADV_DONTDUMP)
to protect against leaking into core dumps (FreeBSD, DragonflyBSD, Linux)
Comparisons using the PartialEq
implementation are undefined behavior (and most likely wrong) if T
has any padding bytes.
Implementations§
Trait Implementations§
source§impl<T> BorrowMut<T> for SecureBox<T>where
T: Sized + Copy,
impl<T> BorrowMut<T> for SecureBox<T>where T: Sized + Copy,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> PartialEq for SecureBox<T>where
T: Sized + Copy + NoPaddingBytes,
impl<T> PartialEq for SecureBox<T>where T: Sized + Copy + NoPaddingBytes,
impl<T> Eq for SecureBox<T>where T: Sized + Copy + NoPaddingBytes,
Auto Trait Implementations§
impl<T> RefUnwindSafe for SecureBox<T>where T: RefUnwindSafe,
impl<T> Send for SecureBox<T>where T: Send,
impl<T> Sync for SecureBox<T>where T: Sync,
impl<T> Unpin for SecureBox<T>
impl<T> UnwindSafe for SecureBox<T>where T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more