pub struct ShieldedBox<T: ?Sized> { /* private fields */ }
Expand description
A flex-alloc Box
container type which applies
additional protections around the allocated memory, and is encrypted when
not currently being accessed.
- The memory is allocated using
SecureAlloc
and flagged to remain resident in physical memory (usingmlock
/VirtualLock
). - When released, the allocated memory is securely zeroed.
- When not currently being accessed by the methods of the
ExposeProtected
trait, the allocated memory pages are flagged for protection from other processes using (mprotect
/VirtualProtect
). - When not currently being accessed, the allocated memory is encrypted using the ChaCha8 encryption cipher. A large (16Kb) buffer of randomized bytes is used as associated data during the encryption and decryption process.
Trait Implementations§
Source§impl<T: ?Sized> Debug for ShieldedBox<T>
impl<T: ?Sized> Debug for ShieldedBox<T>
Source§impl<T: Default> Default for ShieldedBox<T>
impl<T: Default> Default for ShieldedBox<T>
Source§impl<T: ?Sized> Drop for ShieldedBox<T>
impl<T: ?Sized> Drop for ShieldedBox<T>
Source§impl<T: ?Sized> ExposeProtected for ShieldedBox<T>
impl<T: ?Sized> ExposeProtected for ShieldedBox<T>
Source§fn expose_read<F>(&self, f: F)
fn expose_read<F>(&self, f: F)
Expose the protected value for reading.
Source§fn expose_write<F>(&mut self, f: F)
fn expose_write<F>(&mut self, f: F)
Expose the protected value for updating.
Source§impl<T: ?Sized> From<Box<T, SecureAlloc>> for ShieldedBox<T>
impl<T: ?Sized> From<Box<T, SecureAlloc>> for ShieldedBox<T>
Source§impl<T> From<T> for ShieldedBox<T>
impl<T> From<T> for ShieldedBox<T>
Source§impl<T> From<Vec<T, SecureAlloc>> for ShieldedBox<[T]>
impl<T> From<Vec<T, SecureAlloc>> for ShieldedBox<[T]>
impl<T: Send + ?Sized> Send for ShieldedBox<T>
impl<T: Sync + ?Sized> Sync for ShieldedBox<T>
impl<T: ?Sized> ZeroizeOnDrop for ShieldedBox<T>
Auto Trait Implementations§
impl<T> !Freeze for ShieldedBox<T>
impl<T> !RefUnwindSafe for ShieldedBox<T>
impl<T> Unpin for ShieldedBox<T>where
T: ?Sized,
impl<T> UnwindSafe for ShieldedBox<T>where
T: RefUnwindSafe + ?Sized,
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
Mutably borrows from an owned value. Read more
Source§impl<T, W> ProtectedInit for W
impl<T, W> ProtectedInit for W
Source§fn init<F>(f: F) -> Self
fn init<F>(f: F) -> Self
For a concrete type implementing
FillBytes
, initialize with the
standard indicator value and call the closure f
with a mutable
reference to the contained value before applying protections.Source§fn init_default<F>(f: F) -> Self
fn init_default<F>(f: F) -> Self
Initialize with the default value for
Self::Target
, and call the
closure f
with a mutable reference to the contained value before
applying protections.Source§fn init_random<F>(rng: impl RngCore, f: F) -> Self
fn init_random<F>(rng: impl RngCore, f: F) -> Self
Initialize with a randomized value for
Self::Target
, and call the
closure f
with a mutable reference to the contained value before
applying protections.Source§fn init_take<F>(from: &mut Self::Target, f: F) -> Self
fn init_take<F>(from: &mut Self::Target, f: F) -> Self
Initialize by copying the value contained in
from
and zeroizing the
existing copy. Call the closure f
with a mutable reference to the
contained value before applying protections.Source§fn init_with<F>(f: F) -> Self
fn init_with<F>(f: F) -> Self
Initialize by calling the closure
f
, store the resulting
instance of Self::Target
and apply protections.Source§fn try_init_with<F, E>(f: F) -> Result<Self, E>
fn try_init_with<F, E>(f: F) -> Result<Self, E>
Initialize by calling the fallible closure
f
, store the resulting
instance of Self::Target
and apply protections. On failure, return
the error type E
.Source§impl<T, W> ProtectedInitSlice for W
impl<T, W> ProtectedInitSlice for W
Source§fn init_slice<F>(len: usize, f: F) -> Self
fn init_slice<F>(len: usize, f: F) -> Self
For a concrete type implementing
FillBytes
, initialize a slice
of length len
with the standard indicator value and call the closure
f
with a mutable reference to the slice before applying protections.Source§fn init_default_slice<F>(len: usize, f: F) -> Self
fn init_default_slice<F>(len: usize, f: F) -> Self
Initialize with a slice of length
len
containing the default value for
Self::Item
, and call the closure f
with a mutable reference to the
slice before applying protections.Source§fn init_random_slice<F>(len: usize, rng: impl RngCore, f: F) -> Self
fn init_random_slice<F>(len: usize, rng: impl RngCore, f: F) -> Self
Initialize with a randomized slice of length
len
, and call the
closure f
with a mutable reference to the slice before
applying protections.Source§fn init_take_slice<F>(from: &mut [Self::Item], f: F) -> Self
fn init_take_slice<F>(from: &mut [Self::Item], f: F) -> Self
Initialize by copying the slice
from
and zeroizing the existing
copy. Call the closure f
with a mutable reference to the contained
slice before applying protections.Source§fn random_slice(len: usize, rng: impl RngCore) -> Self
fn random_slice(len: usize, rng: impl RngCore) -> Self
Create a new protected instance containing a random slice of length
len
.Source§fn take_slice(from: &mut [Self::Item]) -> Selfwhere
Self::Item: DefaultIsZeroes,
fn take_slice(from: &mut [Self::Item]) -> Selfwhere
Self::Item: DefaultIsZeroes,
Create a new protected slice instance by copying and zeroizing an
existing slice.