Skip to main content

Aead

Trait Aead 

Source
pub trait Aead: Algorithm {
    const KEY_LEN: usize;
    const NONCE_LEN: usize;
    const TAG_LEN: usize;

    // Required methods
    fn new(key: &[u8]) -> Result<Self>
       where Self: Sized;
    fn seal_detached(
        &self,
        nonce: &[u8],
        aad: &[u8],
        in_out: &mut [u8],
        tag: &mut [u8],
    ) -> Result<()>;
    fn open_detached(
        &self,
        nonce: &[u8],
        aad: &[u8],
        in_out: &mut [u8],
        tag: &[u8],
    ) -> Result<()>;
}
Expand description

An authenticated cipher with associated data.

Required Associated Constants§

Source

const KEY_LEN: usize

Key length in bytes.

Source

const NONCE_LEN: usize

Nonce length in bytes.

Source

const TAG_LEN: usize

Authentication tag length in bytes.

Required Methods§

Source

fn new(key: &[u8]) -> Result<Self>
where Self: Sized,

Bind a key to a cipher instance.

Source

fn seal_detached( &self, nonce: &[u8], aad: &[u8], in_out: &mut [u8], tag: &mut [u8], ) -> Result<()>

Encrypt in_out in place and write the tag to tag.

Source

fn open_detached( &self, nonce: &[u8], aad: &[u8], in_out: &mut [u8], tag: &[u8], ) -> Result<()>

Verify tag and decrypt in_out in place.

On failure in_out is zeroized before returning, so a caller that ignores the error cannot expose unauthenticated plaintext.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§