pub struct SecretKey<const N: usize> { /* private fields */ }Expand description
A fixed-size secret key that is automatically zeroed when dropped.
SecretKey<N> wraps a [u8; N] and implements Zeroize +
ZeroizeOnDrop, ensuring that key material does not linger in memory
after the value goes out of scope.
§Examples
use oxicrypto_core::SecretKey;
let key = SecretKey::<32>::from_slice(&[0xAA; 32]).expect("wrong length");
assert_eq!(key.as_bytes().len(), 32);
// key is zeroed automatically when droppedImplementations§
Source§impl<const N: usize> SecretKey<N>
impl<const N: usize> SecretKey<N>
Sourcepub fn from_slice(slice: &[u8]) -> Result<Self, CryptoError>
pub fn from_slice(slice: &[u8]) -> Result<Self, CryptoError>
Create a SecretKey from a byte slice.
Returns CryptoError::InvalidKey if slice.len() != N.
Trait Implementations§
Auto Trait Implementations§
impl<const N: usize> Freeze for SecretKey<N>
impl<const N: usize> RefUnwindSafe for SecretKey<N>
impl<const N: usize> Send for SecretKey<N>
impl<const N: usize> Sync for SecretKey<N>
impl<const N: usize> Unpin for SecretKey<N>
impl<const N: usize> UnsafeUnpin for SecretKey<N>
impl<const N: usize> UnwindSafe for SecretKey<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