pub struct SecretKey { /* private fields */ }Expand description
A cryptographic key is automatically zeroed on drop
Implementations§
Source§impl SecretKey
impl SecretKey
Sourcepub fn from_bytes(bytes: Vec<u8>, algorithm: Algorithm) -> Result<Self>
pub fn from_bytes(bytes: Vec<u8>, algorithm: Algorithm) -> Result<Self>
Create a new SecretKey from raw bytes
#Errors Return error if the key doesn’t match the algorithm
Sourcepub fn generate(algorithm: Algorithm) -> Result<Self>
pub fn generate(algorithm: Algorithm) -> Result<Self>
Generate a new random key for the given algorithm
Sourcepub fn expose_secret(&self) -> &[u8] ⓘ
pub fn expose_secret(&self) -> &[u8] ⓘ
Expose the raw key material
#Safety This exposes the raw key raw materials. The caller is responsible for ensuring it doesn’t leak
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SecretKey
impl RefUnwindSafe for SecretKey
impl Send for SecretKey
impl Sync for SecretKey
impl Unpin 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