embassy-crypto

Crates

git

Versions

default

Flavors

Skip to main content

Aes256Gcm

Trait Aes256Gcm 

Source
pub trait Aes256Gcm {
    type Context: Send + Sync + Clone;

    // Required methods
    fn init(key: &[u8; 32]) -> Self::Context;
    fn encrypt(
        ctx: &Self::Context,
        nonce: &[u8; 12],
        aad: &[u8],
        buffer: InOutBuf<'_, '_, u8>,
        tag: &mut [u8; 16],
    ) -> Result<(), Error>;
    fn decrypt(
        ctx: &Self::Context,
        nonce: &[u8; 12],
        aad: &[u8],
        buffer: InOutBuf<'_, '_, u8>,
        tag: &[u8; 16],
    ) -> Result<(), Error>;
}
Expand description

AES-256 GCM driver.

Required Associated Types§

Source

type Context: Send + Sync + Clone

Opaque storage for the implementation’s key schedule.

Required Methods§

Source

fn init(key: &[u8; 32]) -> Self::Context

Initialize with a 256-bit key.

Source

fn encrypt( ctx: &Self::Context, nonce: &[u8; 12], aad: &[u8], buffer: InOutBuf<'_, '_, u8>, tag: &mut [u8; 16], ) -> Result<(), Error>

Encrypt buffer and produce the authentication tag.

Source

fn decrypt( ctx: &Self::Context, nonce: &[u8; 12], aad: &[u8], buffer: InOutBuf<'_, '_, u8>, tag: &[u8; 16], ) -> Result<(), Error>

Verify the authentication tag and decrypt buffer.

The tag is verified in constant time; on mismatch this returns Error::InvalidSignature and the buffer contents are unspecified.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§