[][src]Struct secstr::SecVec

pub struct SecVec<T> where
    T: Sized + Copy
{ /* fields omitted */ }

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 in fmt::Debug and fmt::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]

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]

impl<T> BorrowMut<[T]> for SecVec<T> where
    T: Sized + Copy
[src]

impl<T: Clone> Clone for SecVec<T> where
    T: Sized + Copy
[src]

impl<T> Debug for SecVec<T> where
    T: Sized + Copy
[src]

impl<T> Display for SecVec<T> where
    T: Sized + Copy
[src]

impl<T> Drop for SecVec<T> where
    T: Sized + Copy
[src]

impl<T: Eq> Eq for SecVec<T> where
    T: Sized + Copy
[src]

impl<T, U> From<U> for SecVec<T> where
    U: Into<Vec<T>>,
    T: Sized + Copy
[src]

impl<T, U> Index<U> for SecVec<T> where
    T: Sized + Copy,
    Vec<T>: Index<U>, 
[src]

type Output = <Vec<T> as Index<U>>::Output

The returned type after indexing.

impl<T> PartialEq<SecVec<T>> for SecVec<T> where
    T: Sized + Copy
[src]

impl<T> StructuralEq for SecVec<T> where
    T: Sized + Copy
[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for SecVec<T> where
    T: RefUnwindSafe

impl<T> Send for SecVec<T> where
    T: Send

impl<T> Sync for SecVec<T> where
    T: Sync

impl<T> Unpin for SecVec<T> where
    T: Unpin

impl<T> UnwindSafe for SecVec<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.