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
sourceimpl<T> BorrowMut<T> for SecBox<T>where
T: Sized + Copy,
impl<T> BorrowMut<T> for SecBox<T>where
T: Sized + Copy,
sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> PartialEq<SecBox<T>> for SecBox<T>where
T: Sized + Copy + NoPaddingBytes,
impl<T> PartialEq<SecBox<T>> for SecBox<T>where
T: Sized + Copy + NoPaddingBytes,
impl<T> Eq for SecBox<T>where
T: Sized + Copy + NoPaddingBytes,
Auto Trait Implementations
impl<T> RefUnwindSafe for SecBox<T>where
T: RefUnwindSafe,
impl<T> Send for SecBox<T>where
T: Send,
impl<T> Sync for SecBox<T>where
T: Sync,
impl<T> Unpin for SecBox<T>
impl<T> UnwindSafe for SecBox<T>where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more