Struct noise_protocol::CipherState
source · [−]pub struct CipherState<C: Cipher> { /* private fields */ }
Expand description
A CipherState
can encrypt and decrypt data.
Mostly like CipherState
in the spec, but must be created with a key.
Panics
Encryption and decryption methods will panic if nonce reaches maximum u64, i.e., 2 ^ 64 - 1.
Implementations
sourceimpl<C> CipherState<C>where
C: Cipher,
impl<C> CipherState<C>where
C: Cipher,
sourcepub fn encrypt_ad(&mut self, authtext: &[u8], plaintext: &[u8], out: &mut [u8])
pub fn encrypt_ad(&mut self, authtext: &[u8], plaintext: &[u8], out: &mut [u8])
AEAD encryption.
sourcepub fn decrypt_ad(
&mut self,
authtext: &[u8],
ciphertext: &[u8],
out: &mut [u8]
) -> Result<(), ()>
pub fn decrypt_ad(
&mut self,
authtext: &[u8],
ciphertext: &[u8],
out: &mut [u8]
) -> Result<(), ()>
AEAD decryption.
sourcepub fn encrypt_vec(&mut self, plaintext: &[u8]) -> Vec<u8>
pub fn encrypt_vec(&mut self, plaintext: &[u8]) -> Vec<u8>
Encryption, returns ciphertext as Vec<u8>
.
sourcepub fn decrypt_vec(&mut self, ciphertext: &[u8]) -> Result<Vec<u8>, ()>
pub fn decrypt_vec(&mut self, ciphertext: &[u8]) -> Result<Vec<u8>, ()>
Decryption, returns plaintext as Vec<u8>
.
sourcepub fn get_next_n(&self) -> u64
pub fn get_next_n(&self) -> u64
Get the next value of n
. Could be used to decide on whether to re-key, etc.
Trait Implementations
Auto Trait Implementations
impl<C> RefUnwindSafe for CipherState<C>where
<C as Cipher>::Key: RefUnwindSafe,
impl<C> Send for CipherState<C>where
<C as Cipher>::Key: Send,
impl<C> Sync for CipherState<C>where
<C as Cipher>::Key: Sync,
impl<C> Unpin for CipherState<C>where
<C as Cipher>::Key: Unpin,
impl<C> UnwindSafe for CipherState<C>where
<C as Cipher>::Key: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more