Skip to main content

Crate libcrux_aesgcm

Crate libcrux_aesgcm 

Source
Expand description

§AES-GCM

This crate implements AES-GCM-128 and AES-GCM-256. The crate provides optimized implementations for ARM and x86_64 platforms with support for AES hardware acceleration, as well as a bit-sliced portable implementation.

For general use, we provide a platform-multiplexing API via the AesGcm128Key and AesGcm256Key structs, which selects the most performant implementation at runtime.

Usage example:

// Multiplexed owned API
use libcrux_aesgcm::AeadConsts as _;
use libcrux_aesgcm::{AesGcm128, AesGcm128Key, AesGcm128Nonce, AesGcm128Tag, NONCE_LEN, TAG_LEN};

let k: AesGcm128Key = [0; AesGcm128::KEY_LEN].into();
let nonce: AesGcm128Nonce = [0; NONCE_LEN].into();
let mut tag: AesGcm128Tag = [0; TAG_LEN].into();

let pt = b"the quick brown fox jumps over the lazy dog";
let mut ct = [0; 43];
let mut pt_out = [0; 43];

k.encrypt(&mut ct, &mut tag, &nonce, b"", pt).unwrap();
k.decrypt(&mut pt_out, &nonce, b"", &ct, &tag).unwrap();
assert_eq!(pt, &pt_out);

We also provide access to lower-level AEAD APIs for the platform-multiplexing implementation with the AesGcm128 and AesGcm256 structs.

Users who want to use a platform-specific implementation directly can access them in the submodules aes_gcm_128::{portable, x64, neon}.

Modules§

aes_gcm_128
Implementations of AES-GCM 128
aes_gcm_256
Implementations of AES-GCM 256

Structs§

AesGcm128
Access to lower-level AEAD APIs for platform-multiplexed AES-GCM 128.
AesGcm256
Access to lower-level AEAD APIs for platform-multiplexed AES-GCM 256.
KeyGenError
An error occurred during key generation

Enums§

DecryptError
Error that can occur during decryption.
EncryptError
Error that can occur during encryption.

Constants§

AESGCM128_KEY_LEN
AES-GCM 128 key length.
AESGCM256_KEY_LEN
AES-GCM 256 key length.
NONCE_LEN
Nonce length.
TAG_LEN
Tag length.

Traits§

Aead
An Authenticated Encryption with Associated Data (AEAD) scheme. This trait is low-level and is mostly used for implementing other, more usable APIs.
AeadConsts
This trait captures the lengths of keys, tags and nonces used by an AEAD.

Type Aliases§

AesGcm128Key
An owned key for AES-GCM 128.
AesGcm128Nonce
An owned nonce for AES-GCM 128.
AesGcm128Tag
An owned tag for AES-GCM 128.
AesGcm256Key
An owned key for AES-GCM 256.
AesGcm256Nonce
An owned nonce for AES-GCM 256.
AesGcm256Tag
An owned tag for AES-GCM 256.