pub struct ChannelKey { /* private fields */ }Expand description
The AES-256-GCM key for channel targets.
Implementations§
Source§impl ChannelKey
impl ChannelKey
Sourcepub fn derive(secret_key: &str) -> ChannelKey
pub fn derive(secret_key: &str) -> ChannelKey
HMAC-SHA256 of the fixed label, keyed by secret_key: 32 bytes.
Sourcepub fn encrypt(&self, plaintext: &[u8]) -> Vec<u8> ⓘ
pub fn encrypt(&self, plaintext: &[u8]) -> Vec<u8> ⓘ
Nonce (12 random bytes) followed by the ciphertext and tag.
Sourcepub fn decrypt(&self, bytes: &[u8]) -> Result<Vec<u8>, CryptoError>
pub fn decrypt(&self, bytes: &[u8]) -> Result<Vec<u8>, CryptoError>
Reverses ChannelKey::encrypt; fails on a wrong key or any changed byte.
Trait Implementations§
Source§impl Clone for ChannelKey
impl Clone for ChannelKey
Auto Trait Implementations§
impl Freeze for ChannelKey
impl RefUnwindSafe for ChannelKey
impl Send for ChannelKey
impl Sync for ChannelKey
impl Unpin for ChannelKey
impl UnsafeUnpin for ChannelKey
impl UnwindSafe for ChannelKey
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