[crypto, drivers, tests] Refactor crypto API to use StartOp/Process/EndOp pattern. Add null checks to all drivers#31
Conversation
There was a problem hiding this comment.
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_ENOTIMPLwithWHAL_ENOTSUPin 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.
0398b9f to
42d28a1
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 37 out of 37 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
1070314 to
b42234a
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 37 out of 37 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
b42234a to
c663daa
Compare
…ndOp pattern. Add null checks to all drivers
No description provided.