Fixes for STM32 CubeMX with crypto callback only (AES and ECC)#10970
Open
dgarske wants to merge 3 commits into
Open
Fixes for STM32 CubeMX with crypto callback only (AES and ECC)#10970dgarske wants to merge 3 commits into
dgarske wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request adds STM32 CubeMX/HAL support for routing AES operations through wolfCrypt’s crypto-callback framework so WOLF_CRYPTO_CB_ONLY_AES can work on HAL-based STM32 builds (notably enabling AES-GCM key setup by providing an AES-ECB callback handler).
Changes:
- Added a CubeMX/HAL AES crypto-callback device (register/unregister + AES-ECB handling) and extended the existing CubeMX CCB crypto-callback device to also dispatch cipher callbacks.
- Fixed STM32U3 CubeMX PKA HAL include selection and improved compatibility when both “bare” STM32 code and Cube HAL HASH headers are present in the same translation unit.
- Documented usage for
WOLF_CRYPTO_CB_ONLY_AESon CubeMX/HAL builds in the STM32 port README.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
wolfssl/wolfcrypt/port/st/stm32.h |
Avoids HASH macro redefinition conflicts with Cube HAL headers; declares CubeMX AES crypto-callback device APIs. |
wolfcrypt/src/port/st/stm32.c |
Implements CubeMX AES crypto-callback device (AES-ECB) and routes cipher callbacks through the existing CubeMX CCB device; adds STM32U3 PKA includes. |
wolfcrypt/src/port/st/README.md |
Adds documentation describing how to enable/register the AES crypto-callback device for WOLF_CRYPTO_CB_ONLY_AES. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
dgarske
force-pushed
the
stm32_cubemx_aes_cb
branch
from
July 23, 2026 19:37
0ec80fa to
fe62f3b
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
wolfcrypt/src/port/st/README.md:101
- The example snippet always calls
wc_Stm32_DhukRegister(devId), but on CubeMX/HAL that symbol is only available whenWOLFSSL_STM32_CCBis enabled. For the non-CCB case (described immediately below), the snippet should instead callwc_Stm32_CubeAesRegister(devId)(or show a conditional) to avoid a link/compile mismatch for readers copying the example.
wc_Stm32_DhukRegister(devId); /* once; serves AES + ECDSA (+ CCB) */
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Brings the STM32 CubeMX/HAL crypto-callback device up to parity with the bare device so
WOLF_CRYPTO_CB_ONLY_AESandWOLF_CRYPTO_CB_ONLY_ECC(software crypto stripped for code size) work on the HAL build with hardware AES and hardware ECDSA. Previously the CubeMX device did CCB ECDSA sign only -- no AES, no ECDSA verify, no normal-key sign -- so those stripped configs failed.Features
wc_Stm32_CubeAesRegister): services AES-ECB on the HAL, which keys AES-GCM; bulk GCM runs on the native HAL GCM engine. FixesWOLF_CRYPTO_CB_ONLY_AESon CubeMX.stm32_ecc_sign/verify_hash_ex) for normal keys, and CCB-protected sign viaHAL_CCB. FixesWOLF_CRYPTO_CB_ONLY_ECCon CubeMX (that macro compiles out the directecc.cPKA path, so the callback provides HW ECDSA). One devId (wc_Stm32_DhukRegister) serves AES + ECDSA + CCB.Fixes
WOLFSSL_STM32U3arm to the CubeMX PKA include chain instm32.c(was#error Please add the hal_pk.h include).#ifndef-guarded the bare HASH-legacy macros instm32.hsoWOLFSSL_STM32_BAREcoexists with the ST Cube HAL headers in one TU (e.g. Zephyr).Docs
wolfcrypt/src/port/st/README.md: "HW crypto via crypto callback" section covering AES + ECDSA, the required app-side HAL PKA setup (extern hpka+HAL_PKA_Init), and the note that CCB key provisioning needs software keygen (do it in a non-CB_ONLY_ECCbuild; CCB sign then runs stripped).Testing
On NUCLEO-U385RG-Q (CubeMX/HAL),
Result: 0 (PASS):cubecrypto(customer shape:WOLFSSL_STM32_PKA+ CCB +CB_ONLY_ECC+CB_ONLY_AES): HW ECDSA sign + verify + tamper-reject (RFC 6979 P-256 key, via PKA through the callback), and AES-GCM KAT.ccbregression (non-CB_ONLY): CCB keygen + sign + verify + wrapped-key import all pass -- the ECDSA additions don't regress the CCB path.cubeaes: AES-GCM (McGrew TC3/TC4) match vectors, decrypt + tamper-reject.wolfSSL/wolfssl-examples-stm32#16