Trait noise_protocol::Cipher
source · pub trait Cipher {
type Key: U8Array;
// Required methods
fn name() -> &'static str;
fn encrypt(
k: &Self::Key,
nonce: u64,
ad: &[u8],
plaintext: &[u8],
out: &mut [u8]
);
fn encrypt_in_place(
k: &Self::Key,
nonce: u64,
ad: &[u8],
in_out: &mut [u8],
plaintext_len: usize
) -> usize;
fn decrypt(
k: &Self::Key,
nonce: u64,
ad: &[u8],
ciphertext: &[u8],
out: &mut [u8]
) -> Result<(), ()>;
fn decrypt_in_place(
k: &Self::Key,
nonce: u64,
ad: &[u8],
in_out: &mut [u8],
ciphertext_len: usize
) -> Result<usize, ()>;
// Provided methods
fn key_len() -> usize { ... }
fn tag_len() -> usize { ... }
fn rekey(k: &Self::Key) -> Self::Key { ... }
}
Expand description
An AEAD.
Required Associated Types§
Required Methods§
sourcefn encrypt_in_place(
k: &Self::Key,
nonce: u64,
ad: &[u8],
in_out: &mut [u8],
plaintext_len: usize
) -> usize
fn encrypt_in_place( k: &Self::Key, nonce: u64, ad: &[u8], in_out: &mut [u8], plaintext_len: usize ) -> usize
AEAD encryption, but encrypt on one buffer. return the length of ciphertext.
Panics
If in_out.len() < plaintext_len + Self::tag_len()
Provided Methods§
Object Safety§
This trait is not object safe.