Struct t_rust_less_lib::memguard::SecretWords
source · [−]pub struct SecretWords { /* private fields */ }
Expand description
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
sourceimpl SecretWords
impl SecretWords
sourcepub fn from_secured(bytes: &[u8]) -> Self
pub fn from_secured(bytes: &[u8]) -> Self
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) -> SecretWords
pub fn zeroed(size: usize) -> SecretWords
pub fn is_empty(&self) -> bool
pub fn len(&self) -> usize
pub fn capacity(&self) -> usize
pub fn borrow(&self) -> Ref<'_>
pub fn borrow_mut(&mut self) -> RefMut<'_>
pub fn locks(&self) -> isize
Trait Implementations
sourceimpl Clone for SecretWords
impl Clone for SecretWords
sourceimpl Drop for SecretWords
impl Drop for SecretWords
sourceimpl From<&mut [Word]> for SecretWords
impl From<&mut [Word]> for SecretWords
sourceimpl From<&mut [u8]> for SecretWords
impl From<&mut [u8]> for SecretWords
impl Send for SecretWords
impl Sync for SecretWords
Auto Trait Implementations
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
impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read morefn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read morefn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read morefn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more