Trait snow::types::Cipher

source ·
pub trait Cipher: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn set(&mut self, key: &[u8]);
    fn encrypt(
        &self,
        nonce: u64,
        authtext: &[u8],
        plaintext: &[u8],
        out: &mut [u8],
    ) -> usize;
    fn decrypt(
        &self,
        nonce: u64,
        authtext: &[u8],
        ciphertext: &[u8],
        out: &mut [u8],
    ) -> Result<usize, Error>;

    // Provided method
    fn rekey(&mut self) { ... }
}
Expand description

Cipher operations

Required Methods§

source

fn name(&self) -> &'static str

The string that the Noise spec defines for the primitive

source

fn set(&mut self, key: &[u8])

Set the key

source

fn encrypt( &self, nonce: u64, authtext: &[u8], plaintext: &[u8], out: &mut [u8], ) -> usize

Encrypt (with associated data) a given plaintext.

source

fn decrypt( &self, nonce: u64, authtext: &[u8], ciphertext: &[u8], out: &mut [u8], ) -> Result<usize, Error>

Decrypt (with associated data) a given ciphertext.

Provided Methods§

source

fn rekey(&mut self)

Rekey according to Section 4.2 of the Noise Specification, with a default implementation guaranteed to be secure for all ciphers.

Implementors§