embassy-stm32

Crates

git

Versions

stm32g441mb

Flavors

Skip to main content

Module aes

Module aes 

Source
Expand description

Advanced Encryption Standard (AES) hardware accelerator.

This module drives the on-chip AES block. Two hardware revisions are supported, selected automatically from the target chip:

  • aes_v2 (STM32G0, G4, L5, U0, WL) — blocking driver. On these parts the AES engine either shares its interrupt line with another peripheral (e.g. RNG) or has no dedicated line at all, so only a polling/blocking API is offered.
  • aes_v3b (STM32H5, WBA) — blocking driver plus an interrupt/DMA-backed async API.

Both revisions expose the same cipher types and the same start / aad_blocking / payload_blocking / finish_blocking blocking flow, so blocking code is portable across them.

§Supported cipher modes

ModePaddingAuthUse case
ECBRequiredNoKeys only (not recommended for data)
CBCRequiredNoFile/disk encryption
CTRNoNoStreaming data, random access
GCMNoYesRecommended — modern applications
GMACNoYesAuthentication without encryption
CCMNoYesResource-constrained devices

§Key sizes

  • 128-bit (16 bytes) and 256-bit (32 bytes).
  • 192-bit keys are not supported by this hardware.

§IV / nonce requirements

  • CBC: random, unique per message.
  • CTR: must never repeat with the same key.
  • GCM/GMAC: 96-bit (12 bytes), unique per message. IV reuse is catastrophic.

Structs§

Aes
AES driver.
AesCbc
AES-CBC Cipher Mode
AesCcm
AES-CCM Cipher Mode (Counter with CBC-MAC)
AesCtr
AES-CTR Cipher Mode
AesEcb
AES-ECB Cipher Mode
AesGcm
AES-GCM Cipher Mode
AesGmac
AES-GMAC Cipher Mode (Galois Message Authentication Code)
Context
Stores the state of the AES peripheral for a cipher operation.
InterruptHandler
Interrupt handler for the async AES API.

Enums§

Direction
AES cipher direction
Error
AES error
KeySize
AES key size

Traits§

Cipher
This trait encapsulates all cipher-specific behavior.
CipherAuthenticated
This trait enables restriction of a header phase to authenticated ciphers only.
CipherSized
This trait enables restriction of ciphers to specific key sizes.
IVSized
This trait enables restriction of initialization vectors to sizes compatible with a cipher mode.
Instance
AES instance trait.
InterruptableInstance
Marks an AES instance that has its own dedicated interrupt vector.