Skip to content

Enable STM32C5 hardware AES-GCM and SHA-2 and fix STM32 crypto detection - #12144

Open
dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:stm32c5_hw_hash_gcm
Open

dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:stm32c5_hw_hash_gcm

Conversation

@dgarske

@dgarske dgarske commented Nov 16, 2026

Copy link
Copy Markdown
Member

Description

Several STM32 parts name CMSIS registers differently from what the port tests, so hardware paths were silently skipped or wrongly enabled.

  • C5: alias CPHASE to GCMPH and HASH_DIGEST to HASH so HW GCM and SHA-2 are used; SHA-384/512 on parts with HASH_CR_ALGO_3.
  • N6, H7S, V8+SAES: add the missing SAES GCMPH/NPBLB aliases for HW GCM, and make the SAES aliases visible to CubeMX builds (H7S CubeMX did not compile).
  • F415/F417, H503, F2: stop enabling SHA-2, SHA-512 or GCM the silicon lacks.
  • WB/WL/WBA/G4 CubeMX: enable HAL GCM (G4 now uses the V2 HAL API it requires).
  • CubeMX GCM decrypt: compute E(K, J0) after the HAL run; the nested AES call gated the AES clock off under STM32_HW_CLOCK_AUTO, failing non-96-bit IVs.
  • settings.h: drop STM32_CRYPTO/STM32_HASH/WOLFSSL_STM32_PKA on C5/H5/U5/F7 parts without the peripheral.

Testing

wolfcrypt_test passes bare and CubeMX on NUCLEO-C5A3ZG, F439ZI, F767ZI, U385RG-Q, U545RE-Q, WL55JC and B-U585I-IOT02A, and bare on H563ZI and H7S3L8; on H7S3L8 CubeMX the AES tests pass. Other affected families are build-checked against the base; N6, V8, F415, H503, F2, WB, WBA and G4 with AES are not tested on hardware.

@dgarske dgarske self-assigned this Nov 16, 2026
Copilot AI balanced review requested due to automatic review settings November 16, 2026 16:40

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

New STM32 GCM hardware paths lack on-device testing, and unavailable CMSIS/HAL dependencies leave register semantics and authentication results requiring maintainer validation.

No open issues 🎉

What changed in this PR

This PR improves wolfCrypt’s STM32 hardware acceleration by enabling supported AES-GCM and SHA-2 paths and avoiding hardware paths on parts without the required capabilities.

Changes:

  • Adds STM32C5 and SAES register aliases and expands CubeMX GCM support.
  • Refines peripheral and algorithm detection, retaining software fallbacks where hardware support is absent.
  • Defers the CubeMX GCM-decrypt authentication-block encryption until after HAL processing to prevent premature AES clock shutdown.
File Description
wolfssl/​wolfcrypt/​settings.h Disables hardware AES, hashing, and PKA on parts lacking the corresponding peripherals.
wolfssl/​wolfcrypt/​port/​st/​stm32.h Adds register aliases and corrects hash capabilities, GCM detection, and HAL selection.
wolfcrypt/​src/​port/​st/​stm32.c Guards SHA-2 HMAC support and enables GCM fallback for unsupported CRYP variants.
wolfcrypt/​src/​aes.c Reorders GCM-decrypt tag computation and preserves errors before tag verification.

Review effort: Balanced

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

MemBrowse Memory Report · Explore what changed →

zephyr-frdm_rw612

  • FLASH: datas +16 B, log_const_area -8 B, rodata +104 B, text +13,192 B (+4.7%, 295,768 B / 67,108,864 B, total: 0% used)
  • RAM: bss +49 B, datas +16 B (+0.1%, 58,423 B / 983,040 B, total: 6% used)

No memory changes detected for:


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

@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 #12144

Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfcrypt-port-bugs, wolfssl-src, wolfssl-bugs
Coverage: 4 of 4 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

@dgarske
dgarske force-pushed the stm32c5_hw_hash_gcm branch from 111aa1f to 5dec225 Compare November 18, 2026 05:30
@dgarske dgarske assigned mattia-moffa and wolfSSL-Bot and unassigned dgarske Nov 18, 2026
@dgarske
dgarske requested a review from mattia-moffa November 18, 2026 05:31
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.

5 participants