Skip to content

[crypto, drivers, tests] Refactor crypto API to use StartOp/Process/EndOp pattern. Add null checks to all drivers#31

Open
AlexLanzano wants to merge 1 commit intowolfSSL:mainfrom
AlexLanzano:crypto-refactor
Open

[crypto, drivers, tests] Refactor crypto API to use StartOp/Process/EndOp pattern. Add null checks to all drivers#31
AlexLanzano wants to merge 1 commit intowolfSSL:mainfrom
AlexLanzano:crypto-refactor

Conversation

@AlexLanzano
Copy link
Copy Markdown
Member

No description provided.

@AlexLanzano AlexLanzano self-assigned this Apr 19, 2026
Copilot AI review requested due to automatic review settings April 19, 2026 15:14
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the wolfHAL crypto abstraction to a StartOp / Process / EndOp driver-vtable pattern, replaces the “not implemented” error code with WHAL_ENOTSUP across HAL APIs/docs/tests, and adds missing NULL-argument checks in several driver implementations.

Changes:

  • Replace WHAL_ENOTIMPL with WHAL_ENOTSUP in public headers, dispatch layers, documentation, and tests.
  • Redesign crypto API: remove per-board ops tables and introduce whal_CryptoDriver.{StartOp,Process,EndOp}; update STM32WB AES driver and crypto tests accordingly.
  • Add/standardize NULL checks in multiple platform drivers (watchdog, SysTick, RCC, DMA IRQ, flash, GPIO).

Reviewed changes

Copilot reviewed 37 out of 37 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
wolfHAL/uart/uart.h Update UART API docs to reference WHAL_ENOTSUP.
wolfHAL/timer/timer.h Update timer API docs to reference WHAL_ENOTSUP.
wolfHAL/spi/spi.h Update SPI API docs to reference WHAL_ENOTSUP.
wolfHAL/rng/rng.h Update RNG API docs to reference WHAL_ENOTSUP.
wolfHAL/gpio/gpio.h Update GPIO API docs to reference WHAL_ENOTSUP.
wolfHAL/flash/flash.h Update flash API docs to reference WHAL_ENOTSUP.
wolfHAL/error.h Replace WHAL_ENOTIMPL with WHAL_ENOTSUP and clarify semantics.
wolfHAL/crypto/stm32wb_aes.h Update STM32WB AES header to new Start/Process/End API.
wolfHAL/crypto/crypto.h Introduce crypto op IDs and vtable Start/Process/End API; remove ops table.
wolfHAL/clock/clock.h Update clock API docs to reference WHAL_ENOTSUP.
wolfHAL/block/block.h Update block API docs to reference WHAL_ENOTSUP.
tests/crypto/test_crypto.c Update tests to new crypto API; add GCM partial-block KAT; rename suite label.
tests/core/test_dispatch.c Update dispatch tests to expect WHAL_ENOTSUP.
src/watchdog/stm32wb_wwdg.c Add NULL check in Deinit.
src/watchdog/stm32wb_iwdg.c Add NULL check in Deinit.
src/uart/uart.c Dispatch: return WHAL_ENOTSUP on NULL driver / vtable entry.
src/uart/stm32wb_uart.c Async stubs return WHAL_ENOTSUP.
src/uart/stm32f4_uart.c Async stubs return WHAL_ENOTSUP.
src/uart/pic32cz_uart.c Async stubs return WHAL_ENOTSUP.
src/timer/timer.c Dispatch: return WHAL_ENOTSUP on NULL driver / vtable entry.
src/timer/systick.c Improve NULL checking; avoid taking regmap address before validation.
src/spi/spi.c Dispatch: return WHAL_ENOTSUP on NULL driver / vtable entry.
src/rng/rng.c Dispatch: return WHAL_ENOTSUP on NULL driver / vtable entry.
src/gpio/stm32wb_gpio.c Add NULL check in Deinit; tighten helper validation.
src/gpio/gpio.c Dispatch: return WHAL_ENOTSUP on NULL driver / vtable entry.
src/flash/stm32wb_flash.c Add NULL checks in Init/Deinit.
src/flash/flash.c Dispatch: return WHAL_ENOTSUP on NULL driver / vtable entry.
src/dma/stm32wb_dma.c Add NULL guard in IRQ handler.
src/crypto/stm32wb_aes.c Major refactor to Start/Process/End; add partial-block support handling for GCM/CCM.
src/crypto/crypto.c Implement crypto dispatch wrappers for Start/Process/End.
src/clock/stm32wb_rcc.c Add NULL checks for clkDev and clk arguments.
src/clock/clock.c Dispatch: return WHAL_ENOTSUP on NULL driver / vtable entry.
src/block/block.c Dispatch: return WHAL_ENOTSUP on NULL driver / vtable entry.
docs/writing_a_driver.md Update guidance to WHAL_ENOTSUP behavior for NULL vtable entries.
docs/getting_started.md Update error-code references/examples to WHAL_ENOTSUP.
boards/stm32wb55xx_nucleo/board.h Remove board-specific crypto op IDs enum.
boards/stm32wb55xx_nucleo/board.c Remove per-board crypto ops table; rely on driver Start/Process/End API.

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

Comment thread src/clock/clock.c
Comment thread src/crypto/crypto.c Outdated
Comment thread src/crypto/stm32wb_aes.c
Comment thread src/crypto/stm32wb_aes.c Outdated
Comment thread src/crypto/stm32wb_aes.c Outdated
Comment thread src/crypto/stm32wb_aes.c Outdated
Comment thread src/crypto/stm32wb_aes.c Outdated
@AlexLanzano AlexLanzano force-pushed the crypto-refactor branch 3 times, most recently from 0398b9f to 42d28a1 Compare April 19, 2026 21:04
…ndOp pattern. Add null checks to all drivers
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.

2 participants