[][src]Trait noise_protocol::Cipher

pub trait Cipher {
    type Key: U8Array;
    fn name() -> &'static str;
fn encrypt(
        k: &Self::Key,
        nonce: u64,
        ad: &[u8],
        plaintext: &[u8],
        out: &mut [u8]
    );
fn decrypt(
        k: &Self::Key,
        nonce: u64,
        ad: &[u8],
        ciphertext: &[u8],
        out: &mut [u8]
    ) -> Result<(), ()>; fn key_len() -> usize { ... }
fn tag_len() -> usize { ... }
fn rekey(k: &Self::Key) -> Self::Key { ... } }

An AEAD.

Associated Types

type Key: U8Array

Type of key.

Loading content...

Required methods

fn name() -> &'static str

Name of this cipher function.

fn encrypt(
    k: &Self::Key,
    nonce: u64,
    ad: &[u8],
    plaintext: &[u8],
    out: &mut [u8]
)

AEAD encryption.

Panics

If out.len() != plaintext.len() + Self::tag_len()

fn decrypt(
    k: &Self::Key,
    nonce: u64,
    ad: &[u8],
    ciphertext: &[u8],
    out: &mut [u8]
) -> Result<(), ()>

AEAD decryption.

Panics

If out.len() != ciphertext.len() - Self::tag_len()

Loading content...

Provided methods

fn key_len() -> usize

Length of key.

fn tag_len() -> usize

Length of auth tag.

All ciphers specified in the spec has tag length 16.

fn rekey(k: &Self::Key) -> Self::Key

Rekey. Returns a new cipher key as a pseudorandom function of k.

Loading content...

Implementors

Loading content...