pub struct SecretBytes<const N: usize>(/* private fields */);Expand description
Fixed-size secret byte container.
§Security Properties
- Automatic zeroization: Memory is overwritten with zeros when dropped.
- Redacted formatting:
fmt::Debugnever prints the underlying secret bytes. - No implicit
CopyorClone: Prevents accidental silent duplication on the stack. - Constant-time comparison:
SecretBytes::ct_eqcompares without short-circuiting.
Implementations§
Source§impl<const N: usize> SecretBytes<N>
impl<const N: usize> SecretBytes<N>
Sourcepub const fn expose_secret(&self) -> &[u8; N]
pub const fn expose_secret(&self) -> &[u8; N]
Explicitly borrows the underlying secret bytes.
Sourcepub fn expose_secret_mut(&mut self) -> &mut [u8; N]
pub fn expose_secret_mut(&mut self) -> &mut [u8; N]
Explicitly borrows the underlying secret bytes mutably.
Trait Implementations§
Source§impl<const N: usize> Debug for SecretBytes<N>
impl<const N: usize> Debug for SecretBytes<N>
Source§impl<const N: usize> Drop for SecretBytes<N>
impl<const N: usize> Drop for SecretBytes<N>
Auto Trait Implementations§
impl<const N: usize> Freeze for SecretBytes<N>
impl<const N: usize> RefUnwindSafe for SecretBytes<N>
impl<const N: usize> Send for SecretBytes<N>
impl<const N: usize> Sync for SecretBytes<N>
impl<const N: usize> Unpin for SecretBytes<N>
impl<const N: usize> UnsafeUnpin for SecretBytes<N>
impl<const N: usize> UnwindSafe for SecretBytes<N>
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