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§
Source§impl<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 encrypt_ad_in_place(
&mut self,
authtext: &[u8],
in_out: &mut [u8],
plaintext_len: usize,
) -> usize
pub fn encrypt_ad_in_place( &mut self, authtext: &[u8], in_out: &mut [u8], plaintext_len: usize, ) -> usize
AEAD encryption in place.
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 decrypt_ad_in_place(
&mut self,
authtext: &[u8],
in_out: &mut [u8],
ciphertext_len: usize,
) -> Result<usize, ()>
pub fn decrypt_ad_in_place( &mut self, authtext: &[u8], in_out: &mut [u8], ciphertext_len: usize, ) -> Result<usize, ()>
AEAD decryption in place.
Sourcepub fn encrypt_in_place(
&mut self,
in_out: &mut [u8],
plaintext_len: usize,
) -> usize
pub fn encrypt_in_place( &mut self, in_out: &mut [u8], plaintext_len: usize, ) -> usize
Encryption in place.
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_in_place(
&mut self,
in_out: &mut [u8],
ciphertext_len: usize,
) -> Result<usize, ()>
pub fn decrypt_in_place( &mut self, in_out: &mut [u8], ciphertext_len: usize, ) -> Result<usize, ()>
Decryption in place.
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> Freeze for CipherState<C>
impl<C> RefUnwindSafe for CipherState<C>
impl<C> Send for CipherState<C>
impl<C> Sync for CipherState<C>
impl<C> Unpin for CipherState<C>
impl<C> UnwindSafe for CipherState<C>
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