pub struct SecBox<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 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)

Comparisons using the PartialEq implementation are undefined behavior (and most likely wrong) if T has any padding bytes.

Implementations

Borrow the contents of the string.

Mutably borrow the contents of the string.

Trait Implementations

Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Formats the value using the given formatter. Read more
Executes the destructor for this type. Read more
The returned type after indexing.
Performs the indexing (container[index]) operation. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.