pub struct SecretKey(/* private fields */);Expand description
Opaque, zeroized 256-bit key material.
Implementations§
Source§impl SecretKey
impl SecretKey
Sourcepub fn generate() -> Result<Self, CryptError>
pub fn generate() -> Result<Self, CryptError>
Draws fresh 256-bit key material from the operating system’s cryptographic random source.
§Errors
Returns CryptError::RandomnessUnavailable when the OS entropy
source cannot be read. Callers must fail rather than fall back: a
predictable data key is indistinguishable from no encryption.
Sourcepub fn from_slice(bytes: &[u8]) -> Result<Self, CryptError>
pub fn from_slice(bytes: &[u8]) -> Result<Self, CryptError>
Copies a byte slice into zeroized storage.
§Errors
Returns CryptError::InvalidKeyLength unless bytes is 32 bytes.
Trait Implementations§
impl Eq for SecretKey
impl StructuralPartialEq for SecretKey
Auto Trait Implementations§
impl Freeze for SecretKey
impl RefUnwindSafe for SecretKey
impl Send for SecretKey
impl Sync for SecretKey
impl Unpin for SecretKey
impl UnsafeUnpin for SecretKey
impl UnwindSafe for SecretKey
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