Exploring STM32U3 Security

Secure Keystore and Key Wrapping Fundamentals

This presentation delves into the advanced security features of the STM32U3 microcontroller, focusing on its secure keystore capabilities and the innovative key wrapping techniques facilitated by the Coupling and Chaining Bridge (CCB).

What is a Keystore? What is Key Wrapping?

Keystore: Protects keys at rest and during execution.

Key Wrapping: The encapsulation of keys and templates with a unique device-dependent key.

Benefits of Key Wrapping:

How Does Key Wrapping Work?

  1. Device Hardware Unique Key (DHUK) Provisioning: A unique key is installed on the device during IC manufacturing.
  2. User Key Encryption: User keys are encrypted by the DHUK.
  3. Secure Storage: Keys can be stored safely.
  4. Decryption: Keys can only be decrypted by the device-dependent DHUK.

Key Features of Key Wrapping

How Key Wrapping Works: Detailed Process

  1. Key in-ST Provisioning: A Device Hardware Unique Key (DHUK) is provisioned by ST on each device and used to wrap other keys.
  2. Wrapping Process: The original key is encrypted using the DHUK, potentially with additional steps for integrity (e.g., authentication tags).
  3. Storage/Transmission: The wrapped key is stored or transmitted securely, protected by the DHUK.
  4. Unwrapping Process: When access to the original key is needed, it is decrypted using the DHUK, restoring the original key.

Key Wrapping Use Cases

Scenario:

  1. ST generates a unique secret (Hardware Unique Key - HUK) in a secure environment, installs it on the device, and locks it from application CPU access.
  2. OEM generates a secret (e.g., ECC or AES key) in its secure environment, injects it into the device, and wraps it with the HUK. The original key in clear is destroyed.
  3. The wrapped secret is stored in application memory, protected from recovery in clear.
  4. For encryption/decryption, the user provides the wrapped key to the Secure AES (SAES) and CCB. SAES unwraps the key, protecting its confidentiality, and uses it for encryption/decryption. The key in clear is flushed afterwards, with only SAES internal logic having access.

Key Definitions

STM32 Key Wrapping Mechanism for SAES

The side-channel protected SAES peripheral uses hardware secret keys (DHUK, BHK) to prevent critical application keys from being visible in clear text to the runtime application or debugger.

SAES can protect 128-bit and 256-bit keys used in SAES or AES peripherals. Use cases include encrypting and decrypting keys using hardware secret keys (key wrapping/unwrapping) and decrypting keys for the AES peripheral (shared key unwrapping).

System Benefits of SAES Key Wrapping

Key Wrapping for AES: Provisioning Step

This process encrypts a key using wrap mode or shared mode.

Steps:

  1. Select a hardware secret key (DHUK, BHK, XORK). The Key Derivation Function (KDF) depends on the KMOD & SAES protection (secure or nonsecure).
  2. Write the clear text key.
  3. Read the encrypted, wrapped key. If DHUK or XORK is selected, only this silicon can decrypt the key.
  4. Save the key in any flash memory.

The resulting encrypted key can be stored in any flash memory. The process involves selecting a hardware secret key and wrap mode, writing the clear text key to the SAES DATA IN register, running AES encryption, and reading the encrypted key from the DATA OUT register. For AES peripheral usage, the shared mode must be selected instead of the wrap mode.

Key Unwrapping for Secure Advanced Encryption Standard

Decrypting a key using wrap mode requires using the same mode and correct key. The result is stored in write-only key registers.

Steps:

  1. Select the correct hardware secret key (DHUK, BHK, XORK). KDF depends on KMOD & SAES protection.
  2. Write the wrapped, encrypted key.
  3. The decrypted, unwrapped key is written by SAES into key registers (write-only). DOUT returns zero. If key registers are written by software, the key is automatically erased.
  4. The application uses the key as needed.

The unwrapped key is automatically erased when software writes the key registers.

Overview of Public Key Cryptography (PKA): Key Features and Standards

Definition: Cryptographic systems using pairs of related keys: one public key and one private key.

Key Lengths: Supports up to 4160 bits for RSA/DH and 640 bits for elliptic curves.

Standards:

Security Features:

Supported Operations:

PKA supports standard algorithms like Modular Exponentiation, CRT exponentiation, RSA, ECC, DSA, and ECDSA through these operations.

Secure PKA Target Use Cases

The security of asymmetric cryptography relies heavily on the protection of the private key. Access to a private key allows decryption of confidential messages and forging of digital signatures.

Key Pair Generation: Involves generating public and private keys (e.g., ECC only).

Secure Key Import: Importing keys, often using RSA method.

Key Agreement: Combining keys to establish a shared secret.

Secure Attestation: Verifying identity or integrity using cryptographic methods (e.g., ECC method).

Wrapped private keys can be stored anywhere as they are only usable on the specific device. Software manipulating wrapped private keys cannot access their clear value, enhancing application robustness against attacks.

STM32 Key Wrapping Mechanism for Public Key Accelerator

The side-channel protected SAES peripheral, in conjunction with the Coupling and Chaining Bridge (CCB), provides a sophisticated security mechanism to protect private keys used in the PKA peripheral. This mechanism is similar to that used for SAES keys.

Use Cases:

The CCB protects private keys from CPU access, wraps them with unique device keys, and stores them securely.

Encrypting a Key with CCOP in CCB

This process encrypts a key using the CCOP in the CCB peripheral.

Steps:

  1. Select a hardware secret key (DHUK, DHUK XOR BHK). KDF depends on the CCOP in the CCB peripheral.
  2. Write the clear text key into PKA RAM.
  3. Read the clear text key from PKA RAM, which transfers it to SAES DATA IN. This read operation returns zero.
  4. Launch an AES encryption.
  5. Read the encrypted, wrapped key and save it in flash memory for secure storage.

Key Unwrapping for Public Key Accelerator

This process decrypts a key using the CCOP in the CCB peripheral.

Steps:

  1. Select the correct hardware secret key (DHUK, DHUK XOR BHK). KDF depends on the CCOP in the CCB peripheral.
  2. Write the wrapped, encrypted shared key.
  3. The decrypted, unwrapped shared key is written to write-only PKA by the CCB. DOUT returns zero.
  4. Use the key in PKA.

Before unwrapping, select the CCOP code in the CCB corresponding to the desired PKA operation. The process involves selecting the hardware secret key, writing the wrapped key, and the CCB writing the decrypted key to the write-only PKA.

List of Public Key Accelerator Wrapped Key Operations

This section details low-level PKA operations corresponding to high-level asymmetric cryptography use cases.

Table 2: ECDSA Signature Key Blob Usage

Table 3: ECC Key Blob Usage

Table 4: RSA Key Blob Usage

Before each blob usage, a blob creation is required.

AES-GCM Usage for Public Key Accelerator Key Wrapping

AES-GCM is a cryptographic method providing confidentiality and data integrity, combining AES encryption with Galois/Counter Mode for authenticated encryption. PKA key wrapping with CCB uses AES-GCM with a 256-bit key.

Under CCB supervision, PKA operation parameters and key material are authenticated and encrypted using AES-GCM. The reference tag, operation parameters, and wrapped key material must be stored. PKA uses the decrypted wrapped key with verified operation parameters only if the reference and computed AES-GCM tags match.

Primary STM32 Product Key Wrapping Property

This overview shows how key wrapping is managed across different STM32 devices using various Keystore IPs (DHUK, BHK, SAES, PKA).

STM32 Product Lineup and Keystore IP Usage:

Each product is optimized for its application, offering tailored security features and robust key management practices.

Documentation and Useful Links

For further details and implementation guidance, refer to application note AN6205, which covers topics like the need for PKA key wrapping, cryptographic functions involved, and functions proposed by STM32CubeMX.

PDF preview unavailable. Download the PDF instead.

v1 PDFCreator 2.4.1.13

Related Documents

Preview Introduction to Secure Firmware Install (SFI) for STM32 MCUs
This application note supports the secure firmware install (SFI) feature available on the STM32 MCUs. It explains how STMicroelectronics' SFI solution, along with its associated tools, can be used to protect OEM firmware during the contract manufacturing stage, ensuring confidentiality, authentication, and integrity.
Preview STM32H7RS Secure Firmware Install (SFI) - STMicroelectronics
An overview of STMicroelectronics' Secure Firmware Install (SFI) feature for STM32H7RS microcontrollers, detailing its security mechanisms, process, and toolsets for secure firmware programming.
Preview STM32 MCUs Secure Firmware Install (SFI) Overview
This application note provides an overview of the STM32 Secure Firmware Install (SFI) solution, detailing its principles, implementation, and use cases for protecting OEM firmware during contract manufacturing. It covers secure programming, encryption, and the role of hardware security modules.
Preview STM32U585xx Security Guidance for PSA Certified Level 3 with SESIP Profile
This user manual provides detailed security guidance for STMicroelectronics STM32U585xx microcontrollers, focusing on achieving compliance with SESIP Profile for PSA Certified Level 3. It covers essential preparative procedures, secure installation steps, and operational guidance for integrators, including configuration options, security measures, and modes of operation.
Preview Getting Started with STMicroelectronics X-CUBE-STSE01 Software Package
This user manual provides a guide to getting started with the X-CUBE-STSE01 software package from STMicroelectronics. It details the features and functionalities of the STSAFE-A110 and STSAFE-A120 secure element devices and the STSELib middleware for secure IoT and embedded applications.
Preview STSAFE-L010 Datasheet: Secure Authentication for Peripherals
Explore the STSAFE-L010, a secure element from STMicroelectronics designed for authentication and data management of consumables and peripherals. This datasheet details its features, security mechanisms, hardware specifications, communication interfaces, and package information.
Preview STMicroelectronics AN5510: Secure Secret Provisioning (SSP) for STM32MP1 Series
Explore the Secure Secret Provisioning (SSP) feature for STM32MP1 Series microcontrollers. This application note from STMicroelectronics details how to protect OEM secrets during manufacturing using SSP, HSM, and OTP technologies.
Preview Migrating between STM32U5 and STM32U3 MCUs
This application note provides a comprehensive guide for migrating applications between STM32U5 and STM32U3 series microcontrollers. It details the necessary steps, considering key aspects such as peripherals, performance, and power consumption, to ensure a smooth transition between these ultra-low-power Arm Cortex-M33 based MCUs.