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§
source§impl 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§
source§impl Clone for SecretWords
impl Clone for SecretWords
source§impl Drop for SecretWords
impl Drop for SecretWords
source§impl From<&mut [Word]> for SecretWords
impl From<&mut [Word]> for SecretWords
source§impl From<&mut [u8]> for SecretWords
impl From<&mut [u8]> for SecretWords
impl Send for SecretWords
impl Sync for SecretWords
Auto Trait Implementations§
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn 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>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn 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.§fn 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.