[−][src]Struct secstr::SecVec
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)
Be careful with SecStr::from
: if you have a borrowed string, it will be copied.
Use SecStr::new
if you have a Vec<u8>
.
Methods
impl<T> SecVec<T> where
T: Sized + Copy,
[src]
T: Sized + Copy,
pub fn new(cont: Vec<T>) -> Self
[src]
pub fn unsecure(&self) -> &[T]
[src]
Borrow the contents of the string.
pub fn unsecure_mut(&mut self) -> &mut [T]
[src]
Mutably borrow the contents of the string.
pub fn zero_out(&mut self)
[src]
Overwrite the string with zeros. This is automatically called in the destructor.
Trait Implementations
impl<T> Borrow<[T]> for SecVec<T> where
T: Sized + Copy,
[src]
T: Sized + Copy,
impl<T> BorrowMut<[T]> for SecVec<T> where
T: Sized + Copy,
[src]
T: Sized + Copy,
fn borrow_mut(&mut self) -> &mut [T]
[src]
impl<T: Clone> Clone for SecVec<T> where
T: Sized + Copy,
[src]
T: Sized + Copy,
impl<T> Debug for SecVec<T> where
T: Sized + Copy,
[src]
T: Sized + Copy,
impl<T> Display for SecVec<T> where
T: Sized + Copy,
[src]
T: Sized + Copy,
impl<T> Drop for SecVec<T> where
T: Sized + Copy,
[src]
T: Sized + Copy,
impl<T: Eq> Eq for SecVec<T> where
T: Sized + Copy,
[src]
T: Sized + Copy,
impl<T, U> From<U> for SecVec<T> where
U: Into<Vec<T>>,
T: Sized + Copy,
[src]
U: Into<Vec<T>>,
T: Sized + Copy,
impl<T, U> Index<U> for SecVec<T> where
T: Sized + Copy,
Vec<T>: Index<U>,
[src]
T: Sized + Copy,
Vec<T>: Index<U>,
type Output = <Vec<T> as Index<U>>::Output
The returned type after indexing.
fn index(&self, index: U) -> &Self::Output
[src]
impl<T> PartialEq<SecVec<T>> for SecVec<T> where
T: Sized + Copy,
[src]
T: Sized + Copy,
impl<T> StructuralEq for SecVec<T> where
T: Sized + Copy,
[src]
T: Sized + Copy,
Auto Trait Implementations
impl<T> RefUnwindSafe for SecVec<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for SecVec<T> where
T: Send,
T: Send,
impl<T> Sync for SecVec<T> where
T: Sync,
T: Sync,
impl<T> Unpin for SecVec<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for SecVec<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,