[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
Open
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
…ndOp pattern. Add null checks to all drivers
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.
No description provided.