pub struct SymmetricKey { /* private fields */ }Expand description
Symmetric key for encryption/decryption
Implementations§
Source§impl SymmetricKey
impl SymmetricKey
Sourcepub fn from_bytes(bytes: &[u8; 32]) -> Self
pub fn from_bytes(bytes: &[u8; 32]) -> Self
Create from raw bytes
Derive symmetric key from shared secret using HKDF
Sourcepub fn derive_for_peer(shared_secret: &SharedSecret) -> Self
pub fn derive_for_peer(shared_secret: &SharedSecret) -> Self
Derive key for peer-to-peer encryption
Sourcepub fn encrypt(&self, plaintext: &[u8]) -> Result<EncryptedData, SecurityError>
pub fn encrypt(&self, plaintext: &[u8]) -> Result<EncryptedData, SecurityError>
Encrypt data with random nonce
Sourcepub fn decrypt(
&self,
encrypted: &EncryptedData,
) -> Result<Vec<u8>, SecurityError>
pub fn decrypt( &self, encrypted: &EncryptedData, ) -> Result<Vec<u8>, SecurityError>
Decrypt data
Trait Implementations§
Source§impl Clone for SymmetricKey
impl Clone for SymmetricKey
Source§fn clone(&self) -> SymmetricKey
fn clone(&self) -> SymmetricKey
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for SymmetricKey
impl RefUnwindSafe for SymmetricKey
impl Send for SymmetricKey
impl Sync for SymmetricKey
impl Unpin for SymmetricKey
impl UnsafeUnpin for SymmetricKey
impl UnwindSafe for SymmetricKey
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