embassy-stm32

Crates

git

Versions

stm32wba55ug

Flavors

Module saes

Module saes 

Source
Expand description

Secure Advanced Encryption Standard (SAES) hardware accelerator

SAES provides the same cipher modes as AES but with enhanced security features for key management and protection. It’s particularly useful in secure boot scenarios and applications requiring hardware root of trust.

§Key Differences from AES

FeatureAESSAES
Key SourcesSoftware onlySoftware + Hardware (DHUK, BHK)
Key ProtectionBasicKEYPROT + isolation
Key SharingNoYes (with AES, other peripherals)
Key WrappingNoYes (wrapped/encrypted keys)
Security ContextStandardEnhanced/Secure

§Hardware Key Sources

  • DHUK (Derived Hardware Unique Key): Device-unique key derived from UID
  • BHK (Boot Hardware Key): Key loaded during secure boot
  • XOR: XOR combination of DHUK and BHK

These keys are never exposed to software and remain in secure hardware.

§Examples

§Using Software Keys (Same as AES)

use embassy_stm32::saes::{Saes, AesGcm, Direction};

let key = [0u8; 16];
let iv = [0u8; 12];
let cipher = AesGcm::new(&key, &iv);

let mut saes = Saes::new_blocking(p.SAES, Irqs);
let mut ctx = saes.start(&cipher, Direction::Encrypt);
// ... same as AES

§Using Hardware-Derived Keys

use embassy_stm32::saes::{Saes, AesGcm, Direction, HardwareKeySource};

let iv = [0u8; 12];
let cipher = AesGcm::new(&[], &iv); // No software key needed

let mut saes = Saes::new_blocking(p.SAES, Irqs);

// Use device-unique hardware key
let mut ctx = saes.start_with_hw_key(
    HardwareKeySource::DHUK,
    &cipher,
    Direction::Encrypt
);

// Hardware key is used automatically - never exposed to software
saes.payload_blocking(&mut ctx, &plaintext, &mut ciphertext, true);
saes.finish_blocking(ctx);

§Key Sharing Between Peripherals

use embassy_stm32::saes::{Saes, KeyShareTarget};

// After unwrapping a key with SAES, share it with AES peripheral
saes.share_key_with(KeyShareTarget::AES);
// Now AES peripheral can use the unwrapped key

§Security Features

  • Key Protection: KEYPROT flag prevents key readback
  • Hardware Keys: Never exposed to software, immune to memory dumps
  • Key Wrapping: Import encrypted keys securely
  • Peripheral Isolation: Keys can be shared without software access

§Availability

Important: SAES is only available on:

  • STM32WBA52 and higher
  • STM32WBA55
  • STM32WBA6x
  • NOT available on STM32WBA50

§Use Cases

  • Secure boot key management
  • Device-unique encryption (uses DHUK based on chip UID)
  • Key provisioning and wrapping
  • Multi-peripheral cryptographic workflows
  • High-security applications requiring hardware root of trust

§See Also

  • aes - Standard AES implementation (all WBA chips)
  • pka - Public Key Accelerator

Re-exports§

pub use crate::aes::AesCbc;
pub use crate::aes::AesCcm;
pub use crate::aes::AesCtr;
pub use crate::aes::AesEcb;
pub use crate::aes::AesGcm;
pub use crate::aes::Cipher;
pub use crate::aes::CipherAuthenticated;
pub use crate::aes::CipherSized;
pub use crate::aes::Context;
pub use crate::aes::Direction;
pub use crate::aes::Error;
pub use crate::aes::IVSized;
pub use crate::aes::KeySize;

Structs§

InterruptHandler
SAES interrupt handler.
Saes
SAES driver.

Enums§

HardwareKeySource
Hardware key source for SAES
KeyMode
Key mode for SAES
KeyShareTarget
Peripheral to share key with

Traits§

DmaIn
DmaIn DMA request trait
DmaOut
DmaOut DMA request trait
Instance
SAES instance trait.