[][src]Struct t_rust_less_lib::memguard::SecretBytes

pub struct SecretBytes { /* fields omitted */ }

Strictly memory protected bytes contain sensitive data.

This implementation borrows a lot of code and ideas from:

  • https://crates.io/crates/memsec
  • https://crates.io/crates/secrets
  • https://download.libsodium.org/doc/memory_management

secrets is not good enough because it relies on libsodium which breaks the desired portability of this library (at least at the time of this writing).

memsec is not good enough because it focuses on protecting a generic type T which size is known at compile-time. In this library we are dealing with dynamic amounts of sensitive data and there is no point in securing a Vec<u8> via memsec ... all we would achieve is protecting the pointer to sensitive data in unsecured space.

Implementations

impl SecretBytes[src]

pub fn from_secured(bytes: &[u8]) -> Self[src]

Copy from slice of bytes.

This is not a regular From implementation because the caller has to ensure that the original bytes are zeroed out (or are already in some secured memspace. This different signature should be a reminder of that.

pub fn with_capacity(capacity: usize) -> SecretBytes[src]

pub fn with_capacity_for_chars(capacity_for_chars: usize) -> SecretBytes[src]

pub fn zeroed(size: usize) -> SecretBytes[src]

pub fn random<T>(rng: &mut T, size: usize) -> SecretBytes where
    T: RngCore + CryptoRng
[src]

pub fn is_empty(&self) -> bool[src]

pub fn len(&self) -> usize[src]

pub fn capacity(&self) -> usize[src]

pub fn borrow(&self) -> Ref<'_>[src]

pub fn borrow_mut(&mut self) -> RefMut<'_>[src]

pub fn locks(&self) -> isize[src]

Trait Implementations

impl Clone for SecretBytes[src]

impl Debug for SecretBytes[src]

impl Drop for SecretBytes[src]

impl<'_> From<&'_ mut [u8]> for SecretBytes[src]

impl From<String> for SecretBytes[src]

impl From<Vec<u8>> for SecretBytes[src]

impl Send for SecretBytes[src]

impl Sync for SecretBytes[src]

Auto Trait Implementations

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> Same<T> for T

type Output = T

Should always be Self

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

type Owned = T

The resulting type after obtaining ownership.

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.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,