Skip to content

Fix STM32 CubeMX AES-GCM AAD over-read from HAL word reads (ST SA0076) - #11102

Merged
JacobBarthelmeh merged 1 commit into
wolfSSL:masterfrom
dgarske:stm32_sa0076
Aug 14, 2026
Merged

Fix STM32 CubeMX AES-GCM AAD over-read from HAL word reads (ST SA0076)#11102
JacobBarthelmeh merged 1 commit into
wolfSSL:masterfrom
dgarske:stm32_sa0076

Conversation

@dgarske

@dgarske dgarske commented Aug 6, 2026

Copy link
Copy Markdown
Member

Description

Fix STM32 CubeMX AES-GCM AAD over-read from HAL word reads (ST SA0076)

This fix mitigates an issue in the STM32Cube HAL CRYP driver (fixed in CubeU5 1.9.0 / HAL CRYP v1.6.3)

Fixes ZD 22274

Testing

Validated on hardware (NUCLEO-U385RG-Q with the CubeMX HAL crypto driver): AES-GCM known-answer tests with no AAD, 20-byte, 13-byte and 5-byte AAD all pass, byte-identical before and after the change.

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

@dgarske dgarske self-assigned this Aug 6, 2026
Copilot AI lite review requested due to automatic review settings August 6, 2026 22:08

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.

Pull request overview

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Mitigates an STM32Cube HAL CRYP AES-GCM issue (ST SA0076) where AAD can be over-read due to HAL performing trailing 32-bit word reads, by ensuring the AAD buffer provided to HAL is word-padded without altering the GHASH length reported to the peripheral.

Changes:

  • Introduces STM_CRYPT_HEADER_PAD_WIDTH to express the HAL’s word read/pad granularity (default 4 bytes).
  • Updates STM32 AES-GCM encrypt/decrypt paths to allocate/copy a zero-padded AAD buffer sized to a word boundary while keeping the HAL-reported AAD length unchanged.
  • Adds cleanup to avoid leaking the allocated AAD buffer when the HW mutex lock fails.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
wolfssl/wolfcrypt/port/st/stm32.h Adds a configurable pad-width macro for STM32 HAL AAD word-padding behavior.
wolfcrypt/src/aes.c Pads AAD buffers up to word size for STM32 AES-GCM, and frees temp buffers on mutex-lock failure.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread wolfcrypt/src/aes.c Outdated
Comment thread wolfcrypt/src/aes.c Outdated
Comment thread wolfssl/wolfcrypt/port/st/stm32.h

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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@dgarske

dgarske commented Aug 12, 2026

Copy link
Copy Markdown
Member Author

Jenkins retest this please

@dgarske dgarske assigned wolfSSL-Bot and unassigned dgarske Aug 12, 2026
@JacobBarthelmeh
JacobBarthelmeh merged commit e677fab into wolfSSL:master Aug 14, 2026
381 checks passed
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.

4 participants