[−][src]Struct noise_protocol::CipherState
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.
Methods
impl<C> CipherState<C> where
C: Cipher,
[src]
C: Cipher,
pub fn name() -> &'static str
[src]
Name of cipher, e.g. “ChaChaPoly”.
pub fn new(key: &[u8], n: u64) -> Self
[src]
Create a new CipherState
with a key
and a nonce n
.
pub fn rekey(&mut self)
[src]
Rekey. Set our key to REKEY(old key)
.
pub fn encrypt_ad(&mut self, authtext: &[u8], plaintext: &[u8], out: &mut [u8])
[src]
AEAD encryption.
pub fn decrypt_ad(
&mut self,
authtext: &[u8],
ciphertext: &[u8],
out: &mut [u8]
) -> Result<(), ()>
[src]
&mut self,
authtext: &[u8],
ciphertext: &[u8],
out: &mut [u8]
) -> Result<(), ()>
AEAD decryption.
pub fn encrypt(&mut self, plaintext: &[u8], out: &mut [u8])
[src]
Encryption.
pub fn encrypt_vec(&mut self, plaintext: &[u8]) -> Vec<u8>
[src]
Encryption, returns ciphertext as Vec<u8>
.
pub fn decrypt(&mut self, ciphertext: &[u8], out: &mut [u8]) -> Result<(), ()>
[src]
Decryption.
pub fn decrypt_vec(&mut self, ciphertext: &[u8]) -> Result<Vec<u8>, ()>
[src]
Decryption, returns plaintext as Vec<u8>
.
pub fn get_next_n(&self) -> u64
[src]
Get the next value of n
. Could be used to decide on whether to re-key, etc.
pub fn extract(self) -> (C::Key, u64)
[src]
Get underlying cipher and nonce.
This is useful for e.g. WireGuard. Because packets may be lost or arrive out of order, they would likely want to deal with nonces themselves.
Trait Implementations
impl<C> Clone for CipherState<C> where
C: Cipher,
[src]
C: Cipher,
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Auto Trait Implementations
impl<C> RefUnwindSafe for CipherState<C> where
<C as Cipher>::Key: RefUnwindSafe,
<C as Cipher>::Key: RefUnwindSafe,
impl<C> Send for CipherState<C> where
<C as Cipher>::Key: Send,
<C as Cipher>::Key: Send,
impl<C> Sync for CipherState<C> where
<C as Cipher>::Key: Sync,
<C as Cipher>::Key: Sync,
impl<C> Unpin for CipherState<C> where
<C as Cipher>::Key: Unpin,
<C as Cipher>::Key: Unpin,
impl<C> UnwindSafe for CipherState<C> where
<C as Cipher>::Key: UnwindSafe,
<C as Cipher>::Key: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,