Skip to content

stm32h563: add ENABLE_HWCRYPTO for STM32H573 AES, HASH and RNG - #206

Open
dgarske wants to merge 2 commits into
wolfSSL:masterfrom
dgarske:stm32h5_hwcrypto
Open

dgarske wants to merge 2 commits into
wolfSSL:masterfrom
dgarske:stm32h5_hwcrypto

Conversation

@dgarske

@dgarske dgarske commented Dec 2, 2026

Copy link
Copy Markdown
Member

Adds an opt-in ENABLE_HWCRYPTO=1 build option to the STM32H563 port for the STM32H573I-DK. It runs TLS crypto on the STM32H573 AES, HASH and RNG peripherals through wolfCrypt's register-level STM32 port (WOLFSSL_STM32_BARE, wolfcrypt/src/port/st/stm32.c). No wolfSSL change is needed.

Depends on #205 (BOARD=stm32h573i_dk); this branch is stacked on it.

What it changes

  • Makefile:
    • ENABLE_HWCRYPTO=1 adds stm32.c and passes WOLFSSL_STM32_HWCRYPTO, STM32H573xx and the STM32CubeH5 CMSIS include paths to the wolfSSL objects only.
    • It requires BOARD=stm32h573i_dk, because the STM32H563 has no AES peripheral.
    • STM32CUBE_FW_H5 defaults to the newest tree under ~/STM32Cube/Repository.
  • user_settings.h: under WOLFSSL_STM32_HWCRYPTO, enables STM32_CRYPTO, STM32_HASH and STM32_RNG with a Hash-DRBG seeded by the hardware RNG, in place of CUSTOM_RAND_GENERATE_BLOCK. ECC stays on the SP Cortex-M assembly, which completes the handshake faster than the PKA.
  • README.md: a Hardware Crypto section with the build command and measured handshake times.

Builds without ENABLE_HWCRYPTO are byte-identical to before. Checked for the NUCLEO default, the DK default, the full TLS/HTTPS/SSH/MQTT builds for both boards, and TZEN=1.

Hardware / test status

Validated on the STM32H573I-DK (TZEN=0, bench LAN, DHCP) with ENABLE_HWCRYPTO=1:

  • The wolfCrypt test passed on target with the same settings.
  • TLS 1.3 echo on 8443 worked with AES-128-GCM, AES-256-GCM and ChaCha20-Poly1305 (openssl s_client).
  • HTTPS on 443 returned 200, SSH login and info worked, and an MQTT broker publish/subscribe on 8883 went through.
  • The handshake is about a quarter faster than the software build; the README has the table.

Scope

WOLFSSL_STM32_PKA works with this option but is left off, because it is slower than the SP assembly for P-256 here. TZEN=1 is not supported: the non-secure application would need wolfBoot to release the crypto peripherals.

Copilot AI balanced review requested due to automatic review settings December 2, 2026 23:33
@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown

MemBrowse Memory Report · Explore what changed →

stm32h563-freertos-https

  • FLASH: .text +584 B (+0.2%, 285,036 B / 2,064,384 B, total: 14% used)

stm32h563-full

  • FLASH: .text +552 B (+0.2%, 356,740 B / 2,064,384 B, total: 17% used)

stm32h563-https

  • FLASH: .text +584 B (+0.2%, 282,116 B / 2,064,384 B, total: 14% used)

stm32h563-tzen-ssh

  • FLASH: .text +552 B (+0.2%, 321,508 B / 654,336 B, total: 49% used)

No memory changes detected for:


Catch memory regressions in CI with MemBrowse. Free for open source.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

On-target validation is needed because wolfCrypt seeding and wolfIP_getrandom share an RNG across preemptive FreeRTOS tasks under SINGLE_THREADED settings, a combination not covered by reported hardware tests.

No open issues 🎉

What changed in this PR

Adds opt-in hardware cryptography to the STM32H563 wolfIP port, building on STM32H573I-DK support from #205.

Changes:

  • Enables hardware AES, HASH and RNG-backed Hash-DRBG while retaining software ECC.
  • Adds build validation, CMSIS include paths and configuration-change rebuild tracking.
  • Documents board selection, hardware-crypto usage and measured handshake times.
File Description
src/​port/​stm32h563/​user_settings.h Selects hardware crypto and Hash-DRBG when enabled.
src/​port/​stm32h563/​README.md Documents DK builds, hardware requirements and performance.
src/​port/​stm32h563/​Makefile Adds hardware-crypto flags, dependencies, checks and rebuild stamps.
src/​port/​stm32h563/​main.c Selects DK-specific console and Ethernet pins.
src/​port/​stm32h563/​.gitignore Ignores board and hardware-crypto build stamps.

Review effort: Balanced

@dgarske dgarske self-assigned this Dec 2, 2026
@dgarske
dgarske requested review from wolfSSL-Fenrir-bot and a balanced review from Copilot December 2, 2026 23:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the opt-in STM32H573 hardware-crypto changes.

No open issues 🎉

Review effort: Balanced

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #206

Scan targets checked: wolfip-src, wolfip-bugs
Not reviewed (no scan target covers them): src/port/stm32h563/.gitignore, src/port/stm32h563/Makefile, src/port/stm32h563/README.md
Coverage: 2 of 2 in-scope changed file(s) opened by the reviewer

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Max

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants