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§
impl !Freeze for SecretWords
impl RefUnwindSafe for SecretWords
impl Unpin for SecretWords
impl UnwindSafe for SecretWords
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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
.Source§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
.Source§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.Source§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.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more