esp_hal

Module aes

Source
Available on crate feature unstable only.
Expand description

§Advanced Encryption Standard (AES).

§Overview

The AES accelerator is a hardware device that speeds up computation using AES algorithm significantly, compared to AES algorithms implemented solely in software. The AES accelerator has two working modes, which are Typical AES and AES-DMA.

§Configuration

The AES peripheral can be configured to encrypt or decrypt data using different encryption/decryption modes.

When using AES-DMA, the peripheral can be configured to use different block cipher modes such as ECB, CBC, OFB, CTR, CFB8, and CFB128.

§Examples

§Encrypting and decrypting a message

Simple example of encrypting and decrypting a message using AES-128:

let mut block = [0_u8; 16];
block[..plaintext.len()].copy_from_slice(plaintext);

let mut aes = Aes::new(peripherals.AES);
aes.process(&mut block, Mode::Encryption128, keybuf);

// The encryption happens in-place, so the ciphertext is in `block`

aes.process(&mut block, Mode::Decryption128, keybuf);

// The decryption happens in-place, so the plaintext is in `block`

§AES-DMA

Visit the AES-DMA test for a more advanced example of using AES-DMA mode.

§Implementation State

  • AES-DMA mode is currently not supported on ESP32 and ESP32S2
  • AES-DMA Initialization Vector (IV) is currently not supported

Structs§

  • AES peripheral container
  • Marker type for AES-128
  • Marker type for AES-192
  • Marker type for AES-256

Enums§

  • State matrix endianness
  • Represents the various key sizes allowed for AES encryption and decryption.
  • Defines the operating modes for AES encryption and decryption.

Traits§