Skip to content

Bug fixes - #57

Merged
aidangarske merged 18 commits into
wolfSSL:mainfrom
AlexLanzano:bug-fixes
Oct 8, 2026
Merged

aidangarske merged 18 commits into
wolfSSL:mainfrom
AlexLanzano:bug-fixes

Conversation

@AlexLanzano

Copy link
Copy Markdown
Member

Summary

Fixes for the verified Fenrir findings on wolfHAL, plus the follow-ups from a Skoll review of those fixes. Each of the 195 findings was checked against the code and the
reference manuals in the repo: 96 are fixed here, 33 are closed as false positives or by design, 1 is won't fix (13102, Sharp SCS timing), and the rest are deferred, mostly
test-coverage gaps.

Commits are grouped by driver area so each can be reviewed and bisected on its own.

Changes

Crypto

  • WBA/U5 AES split from WB (1254cc7): the newer AES IP has a different register layout. WBA/U5 now have their own driver: CCF through ISR/ICR, a KEYVALID wait,
    two-step ECB/CBC decrypt key preparation, and KEIF-safe key zeroing.
  • N6 CRYP (1254cc7): polls IFNF before each AAD block; key zeroing is KERF-safe.
  • PKA (853473b): on timeout, aborts the operation before wiping operands, so the wipe isn't ignored and no stale flags are left behind.
  • CCM/GCM (3797ed9, all of WB, WBA/U5, N6):
    • AAD of 0xFF00 bytes or more uses the 0xFFFE + 4-byte length encoding from SP 800-38C.
    • A payload that doesn't fit in B0 is rejected.
    • Streaming CCM checks that Start's tag length and payload length match Process and Finalize.
    • GCM/CCM reject any Process call after a partial block.
  • Dispatch (3797ed9): the crypto dispatchers return EINVAL for a NULL device, matching the other dispatch layers. WBA HASH Oneshot checks its input before touching
    the core.

Flash

  • Unlock and errors (6a56a5d):
    • Unlock skips the key sequence if the flash is already unlocked, and fails if LOCK stays set.
    • FLASH_SR errors are checked after program/erase.
    • WBA polls WDW before BSY; the L1 SetLatency polls are bounded.
  • Write path (0b0037b): WB alignment checks fixed. The source buffer is read bytewise via whal_LoadLe32, so an unaligned buffer no longer faults on the Cortex-M0+.
    Flash is programmed through volatile pointers.
  • PIC32CZ (1a1aafb): region bounds checks added, zero-length erase returns early, controller errors return EHARDWARE.
  • Bounds overflow (8c12172): every on-chip driver's region check is rewritten so addr + dataSz can't wrap.
  • External storage (e6acddb):
    • SPI-NOR rejects 3-byte ranges that would cross 16 MB, and Lock/Unlock preserve the other SR1 bits.
    • SD-over-SPI reports stop-sequence errors and releases CS on failure.

Ethernet (603b9d7, H5 and N6)

  • RX drops frames that have errors, span multiple buffers, or are too long for the RX buffer.
  • dsb is issued before the DMA tail-pointer writes.
  • Start validates speed and duplex.
  • LAN8742A routes MDIO through the configured MAC and powers down in Deinit.

UART / DMA

  • DMA-UART (a2accc5):
    • Busy is checked before the zero-length shortcut, so a blocking call can't abort another transfer.
    • New Deinit that stops both channels (WB, WBA).
    • The WBA TX bounce byte is now per instance.
  • Also in a2accc5: F4/L1 Send waits for TC, and GPDMA REQSEL is 8 bits wide for U5/N6.
  • GPDMA Stop (8c12172): aborts an active channel with suspend, idle wait and reset (RM0493 17.4.4), since software can't clear EN.
  • Direct-mapping flags (72d3ba8): forwarded in the WBA SPI, N6 WWDG and WBA UART-DMA stubs.

I2C / GPIO (506a155, 8c12172)

  • WB-family I2C derives TIMINGR from the requested frequency; the result is unchanged at 100 kHz, 400 kHz and 1 MHz. It also waits for TC before STOP or a repeated START.
  • L1 I2C:
    • Rejects NULL message buffers.
    • Clears ACK/POS on error.
    • Waits for a pending STOP before StartCom, and software-resets only a bus that stays busy.
  • GPIO (WB, WB0) rejects pin indexes past the configured table.

Timers / watchdog / RNG

  • SysTick (086d506, 8c12172): RELOAD is programmed with cyclesPerTick - 1 and range-checked, and CVR is cleared.
  • Also in 086d506: WWDG rejects counter and window values below 0x40, and LPTIM PWM rejects 0%/100% duty and periods below 2.
  • RNG (244b921):
    • Generate fails on the latched SEIS flag; WB runs the RM0434 recovery.
    • WBA/U5/N6 program RNG_HTCR with the Configuration C value.
    • WB0 checks FAULT.

Docs: return codes, parameter contracts and stale comments are corrected across the touched headers.

Tests

  • New: Test_Flash_OutOfBounds (generic, all on-chip flash) and a WB write-while-locked test.
  • Updated: the GPIO out-of-range index check and the LPTIM PWM limits.

Testing

Board Result
STM32WB55 Nucleo 53/53 (also run with DMA=1 and a BMI270 on I2C)
STM32WBA55 Nucleo 47/47
STM32U5A5 Nucleo 47/47
STM32H563 Nucleo 15/15
STM32N657 Nucleo 54/54
STM32C031 Nucleo 12/12
STM32F091 Nucleo 12/12
STM32F302 Nucleo 12/12
STM32L152 Nucleo 13/13
STM32F411 Blackpill 7/7
STM32WB05 Nucleo 10/10
PIC32CZ Curiosity Ultra 11/11

Fenrir findings fixed (96)

Commit Findings
1254cc7 Split WBA AES from WB, fix CRYP AAD flow control 11386
853473b Abort the PKA on timeout before wiping operands 8428, 11373, 11382, 13106
6a56a5d Guard flash unlock, check status errors, test write-while-locked 6636, 6638, 8436, 8457, 9358, 10178, 12356, 13107, 13748
0b0037b Fix write alignment checks and source/destination access 6084, 6086, 8439, 10181, 11365, 13746, 13747
1a1aafb Bound PIC32CZ flash ops, fix error codes, add out-of-bounds test 6079, 6087, 6089, 8439, 8442, 8455
603b9d7 Bound Ethernet RX, add DMA barriers, fix PHY MDIO device 6088, 8440, 8441, 8463, 9351, 9352, 9357, 10190, 10191, 10192, 10193, 12344, 13123, 13124
a2accc5 Fix DMA-UART zero-length and teardown, F4 TC wait, GPDMA REQSEL width 8458, 8465, 9364, 10184, 11367, 11371, 11372, 12357
506a155 Scale I2C timing to requested freq, fix L1 I2C recovery, bound GPIO index 6195, 6637, 8466, 9353, 9359, 9360, 10183, 11368, 11374, 13101, 13781
086d506 Fix SysTick reload and counter, WWDG lower bounds, LPTIM PWM limits 8452, 8456, 9361, 9363, 11369, 11370, 13103, 13784
244b921 Check latched RNG errors, program WBA HTCR, check WB0 FAULT 6919, 9362, 11375, 11384, 13780
e6acddb Bound SPI-NOR 3-byte ranges, preserve SR1 on lock, report SD stop errors 6093, 8446, 8454, 10207
72d3ba8 Forward direct-mapping flags in WBA SPI, N6 WWDG and WBA UART-DMA 8450, 8451, 11364
3797ed9 CCM long AAD and length checks, streaming chunk and binding checks, dispatch and doc fixes 6077, 6090, 6091, 6187, 6455, 6924, 8462, 9354, 9355, 9356, 10179,
10195, 10196, 10203, 10205, 11383, 12366

All 96 IDs: 6077, 6079, 6084, 6086, 6087, 6088, 6089, 6090, 6091, 6093, 6187, 6195, 6455, 6636, 6637, 6638, 6919, 6924, 8428, 8436, 8439, 8440, 8441, 8442, 8446, 8450,
8451, 8452, 8454, 8455, 8456, 8457, 8458, 8462, 8463, 8465, 8466, 9351, 9352, 9353, 9354, 9355, 9356, 9357, 9358, 9359, 9360, 9361, 9362, 9363, 9364, 10178, 10179, 10181,
10183, 10184, 10190, 10191, 10192, 10193, 10195, 10196, 10203, 10205, 10207, 11364, 11365, 11367, 11368, 11369, 11370, 11371, 11372, 11373, 11374, 11375, 11382, 11383,
11384, 11386, 12344, 12356, 12357, 12366, 13101, 13103, 13106, 13107, 13123, 13124, 13746, 13747, 13748, 13780, 13781, 13784

… control

- WBA/U5 AES: own driver; CCF via ISR/ICR, wait for KEYVALID, two-step
  ECB/CBC decrypt key prep, KEIF-safe key zeroing
- N6 CRYP: poll IFNF before each AAD block, KERF-safe key zeroing
- Clear EN, clear flags and re-enable on WaitForProcEnd timeout so
  ZeroOperand is not ignored and no stale PROCENDF/RAMERRF remains
- Fix ZeroOperand comment and result-size docs ("exactly", not "at
  least")
…le-locked

- Skip the key sequence when already unlocked and return EHARDWARE if
  LOCK stays set (WB, WBA, U5, H5, F4, F0/F3, C0)
- Check FLASH_SR errors after program/erase on WB, F0/F3, C0
- Clear PER on the WB erase error path
- Poll WDW before BSY on WBA; bound the L1 SetLatency polls
- Document Lock/Unlock as device-wide
- Add a WB test that writing while locked fails and leaves flash unchanged
…ite alignment checks and source/destination access

- WB: require 8-byte addr/dataSz for writes only (was 16-byte, applied
  to erase, and never checked dataSz)
- Read the source buffer bytewise via new whal_LoadLe32 so unaligned
  buffers no longer fault (C0 Cortex-M0+) (WB, C0, WBA, H5, U5, F4)
- Program flash through volatile pointers (WB, C0, WBA, H5, F4)
…codes, add out-of-bounds test

- PIC32CZ: reject Read/Write/Erase outside the flash region, return
  early on zero-length erase, report controller errors as EHARDWARE,
  read the source bytewise via whal_LoadLe32
- Document PIC32CZ Lock as applying no protection
- Add a generic on-chip test that out-of-region Read/Write/Erase return
  EINVAL; add flash region macros for PIC32CZ and F411
…, fix PHY MDIO device

- Drop RX frames that have errors, span multiple buffers, or report a
  length larger than the RX buffer (H5, N6)
- Add dsb before DMA tail-pointer kicks on H5 and the N6 RX error path
- Validate speed and duplex in Start (H5, N6)
- LAN8742A: route MDIO through the configured MAC instead of NULL;
  power the PHY down in Deinit
- Fix PHY Init, N6 Send, and N6/H5 IP description docs
…x DMA-UART zero-length and teardown, F4 TC wait, GPDMA REQSEL width

- Widen GPDMA REQSEL to 8 bits so U5/N6 request IDs >= 64 are not
  truncated
- DMA-UART: check busy before the zero-length shortcut so blocking calls
  never wait on or abort another transfer (WB, WBA)
- DMA-UART: add Deinit that stops both DMA channels and resets transfer
  state (WB, WBA); keep the WBA 1-byte TX bounce per instance
- F4/L1 UART Send waits for TC after the last byte
- Fix F0 UART Send and DMA callback docs
… requested freq, fix L1 I2C recovery, bound GPIO index

- I2C (WB family): derive SCL low/high from the requested frequency
  instead of only the speed mode; wait for TC before STOP or a repeated
  START
- I2C (L1): reject NULL message buffers, clear ACK/POS and STOP on
  errors, software-reset a bus left busy before StartCom
- GPIO (WB, WB0): reject pin indexes past the configured pin table; add
  an out-of-range index check to the GPIO test
- Fix WB SPI frame-size, GPIO AFR and whal_Reg_Update docs
…load and counter, WWDG lower bounds, LPTIM PWM limits

- SysTick: program RELOAD with cyclesPerTick - 1 and range-check it;
  clear CVR in Init and implement Reset
- WWDG (F0/F3, WB/WBA/U5/N6): reject counter or window below 0x40, which
  would reset the MCU immediately
- LPTIM PWM: reject period < 2 and 0% / 100% duty, which the LPTIM
  cannot produce (ARR must exceed CMP); update the platform test
- Fix NVIC NULL-priority and IWDG start-order docs
…atched RNG errors, program WBA HTCR, check WB0 FAULT

- Fail Generate on the latched SEIS flag, not just SECS (WB, WBA/U5/N6,
  H5); WB runs the RM0434 seed-error recovery, the others clear SEIS
  as required with auto-reset enabled
- WBA/U5/N6: program RNG_HTCR with the Configuration C value during
  CONDRST
- WB0: return EHARDWARE when RNG_SR.FAULT reports a bad noise sequence
- Fix WB, WBA and WB0 RNG return-value docs
…ve SR1 on lock, report SD stop errors

- SPI-NOR 3-byte commands reject ranges that would cross 16 MB
- SPI-NOR Lock/Unlock change only the block-protect bits, keeping the
  other SR1 bits (SRP0, TB/SEC, QE)
- SD multi-block Read/Write return stop-sequence failures
- SD CsAssert releases CS when its dummy byte fails
… in WBA SPI, N6 WWDG and WBA UART-DMA

- WBA SPI and N6 WWDG stubs forward their DIRECT_API_MAPPING flags to
  the reused driver, like their sibling stubs
- WBA UART-DMA maps its functions to the generic whal_Uart_* names and
  hides the vtable under WHAL_CFG_STM32WBA_UART_DMA_DIRECT_API_MAPPING
…ng AAD and length checks, streaming chunk and binding checks, dispatch and doc fixes

- CCM: encode AAD lengths >= 0xFF00 as 0xFFFE + 4 bytes; reject payloads
  whose length does not fit in B0 (WB, WBA/U5, N6)
- Streaming CCM: bind Start's tag length and payload length to Process
  and Finalize; GCM/CCM: reject Process after a partial block
- Crypto dispatchers return EINVAL for a NULL device
- WBA HASH Oneshot validates input before touching the core
- Document CTR multiple-of-16 lengths, exact digest sizes, HMAC key
  lifetime and per-algorithm operations
…flash bounds, L1 I2C STOP wait, GPDMA abort, doc sync

- Flash: rewrite region checks so addr + dataSz cannot wrap (all
  on-chip drivers)
- L1 I2C StartCom waits for BUSY to clear and only software-resets a
  bus that stays busy past the timeout
- GPDMA Stop aborts an active channel with suspend, idle wait and
  reset, since software cannot clear EN (WBA, U5, N6); WBA UART-DMA
  Deinit returns Stop errors before resetting transfer state
- SysTick Init rejects cyclesPerTick below 2
- Document the streaming CTR/GCM/CCM rules in the WB, WBA and N6 AES
  headers, and the full WB/C0 flash Write/Erase return codes

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Zero-length F4 UART sends can now time out, and the new flash tests do not exercise the arithmetic-overflow regression.

2 open findings
What changed in this PR

Fixes verified hardware-driver issues across crypto, flash, DMA, communications, networking, timers, watchdogs, and RNG implementations.

Changes:

  • Hardens bounds checks, validation, timeout handling, and hardware error reporting.
  • Corrects DMA, AES, flash, Ethernet, I2C, UART, RNG, and timer behavior.
  • Updates public contracts and expands flash, GPIO, and PWM tests.
File Description
wolfHAL/​watchdog/​stm32wb_iwdg.h Clarifies IWDG startup.
wolfHAL/​uart/​stm32wba_uart_dma.h Documents DMA teardown and bounce storage.
wolfHAL/​uart/​stm32wb_uart.h Exposes wrapped Deinit.
wolfHAL/​uart/​stm32wb_uart_dma.h Documents DMA-aware Deinit.
wolfHAL/​uart/​stm32f0_uart.h Corrects send documentation.
wolfHAL/​timer/​systick.h Documents reload constraints.
wolfHAL/​spi/​stm32wb_spi.h Corrects frame-width support.
wolfHAL/​rng/​stm32wba_rng.h Corrects return contracts.
wolfHAL/​rng/​stm32wb0_rng.h Documents hardware faults.
wolfHAL/​rng/​stm32wb_rng.h Documents RNG recovery errors.
wolfHAL/​reg.h Clarifies positioned register values.
wolfHAL/​pwm/​stm32wb_lptim_pwm.h Documents PWM limits.
wolfHAL/​irq/​cortex_m4_nvic.h Clarifies default priority behavior.
wolfHAL/​i2c/​stm32l1_i2c.h Documents bus recovery.
wolfHAL/​flash/​stm32wb_flash.h Expands flash contracts.
wolfHAL/​flash/​stm32l1_flash.h Documents latency timeout.
wolfHAL/​flash/​stm32h5_flash.h Documents unlock failures.
wolfHAL/​flash/​stm32f4_flash.h Documents unlock failures.
wolfHAL/​flash/​stm32f0_flash.h Clarifies unlock failure.
wolfHAL/​flash/​stm32c0_flash.h Expands flash errors.
wolfHAL/​flash/​pic32cz_flash.h Corrects operation contracts.
wolfHAL/​flash/​flash.h Clarifies whole-device locking.
wolfHAL/​eth/​stm32n6_eth.h Documents N6 MAC differences.
wolfHAL/​eth/​stm32h5_eth.h Clarifies Start validation.
wolfHAL/​eth_phy/​lan8742a_eth_phy.h Corrects PHY lifecycle docs.
wolfHAL/​eth_phy/​eth_phy.h Updates PHY initialization contract.
wolfHAL/​endian.h Adds little-endian loading.
wolfHAL/​dma/​stm32wba_gpdma.h Documents request widths.
wolfHAL/​dma/​dma.h Documents callbacks and timeout.
wolfHAL/​crypto/​stm32wba_aes.h Defines dedicated WBA AES API.
wolfHAL/​crypto/​stm32wb_pka.h Tightens result-size contracts.
wolfHAL/​crypto/​stm32wb_aes.h Adds streaming-state constraints.
wolfHAL/​crypto/​stm32u5_aes.h Re-aliases U5 to WBA AES.
wolfHAL/​crypto/​stm32n6_cryp.h Adds CCM/GCM state constraints.
wolfHAL/​crypto/​pka.h Tightens generic PKA contracts.
wolfHAL/​crypto/​crypto.h Corrects crypto parameter contracts.
tests/​pwm/​test_stm32wb_pwm.c Tests valid PWM boundaries.
tests/​gpio/​test_gpio.c Tests out-of-range pins.
tests/​flash/​test_stm32wb_flash.c Tests locked writes.
tests/​flash/​test_flash.c Adds flash bounds tests.
src/​watchdog/​stm32wb_wwdg.c Validates WWDG thresholds.
src/​watchdog/​stm32n6_wwdg.c Forwards direct mapping.
src/​watchdog/​stm32f0_wwdg.c Validates WWDG thresholds.
src/​uart/​stm32wba_uart_dma.c Fixes DMA state and teardown.
src/​uart/​stm32wb_uart.c Preserves wrapped Deinit.
src/​uart/​stm32wb_uart_dma.c Adds DMA-aware Deinit.
src/​uart/​stm32f4_uart.c Waits for transmission completion.
src/​timer/​systick.c Corrects reload and reset.
src/​spi/​stm32wba_spi.c Forwards direct mapping.
src/​rng/​stm32wba_rng.c Configures health tests.
src/​rng/​stm32wb0_rng.c Detects noise-source faults.
src/​rng/​stm32wb_rng.c Adds seed-error recovery.
src/​rng/​stm32h5_rng.c Detects latched seed errors.
src/​pwm/​stm32wb_lptim_pwm.c Rejects impossible duty cycles.
src/​i2c/​stm32wb_i2c.c Scales timing and waits for TC.
src/​i2c/​stm32l1_i2c.c Improves validation and recovery.
src/​gpio/​stm32wb0_gpio.c Bounds-checks pin indexes.
src/​gpio/​stm32wb_gpio.c Bounds-checks pin indexes.
src/​flash/​stm32wba_flash.c Hardens bounds and programming.
src/​flash/​stm32wb0_flash.c Prevents range overflow.
src/​flash/​stm32wb_flash.c Fixes alignment and errors.
src/​flash/​stm32u5_flash.c Hardens bounds and source access.
src/​flash/​stm32l1_flash.c Bounds latency polling.
src/​flash/​stm32h5_flash.c Hardens bounds and programming.
src/​flash/​stm32f4_flash.c Hardens bounds and programming.
src/​flash/​stm32f0_flash.c Checks controller errors.
src/​flash/​stm32c0_flash.c Checks controller errors.
src/​flash/​spi_nor_flash.c Preserves status and bounds addresses.
src/​flash/​pic32cz_flash.c Adds bounds and hardware errors.
src/​eth/​stm32n6_eth.c Validates and bounds Ethernet frames.
src/​eth/​stm32h5_eth.c Adds DMA barriers and validation.
src/​eth_phy/​lan8742a_eth_phy.c Routes MDIO and powers down PHY.
src/​dma/​stm32wba_gpdma.c Corrects request width and abort.
src/​crypto/​stm32wba_hash.c Validates input before hardware access.
src/​crypto/​stm32wb_pka.c Aborts timed-out operations.
src/​crypto/​stm32wb_aes.c Hardens CCM/GCM streaming.
src/​crypto/​stm32u5_aes.c Uses dedicated WBA AES implementation.
src/​crypto/​stm32n6_cryp.c Hardens CRYP CCM/GCM handling.
src/​crypto/​sha256.c Distinguishes invalid devices.
src/​crypto/​sha224.c Distinguishes invalid devices.
src/​crypto/​sha1.c Distinguishes invalid devices.
src/​crypto/​hmac_sha256.c Distinguishes invalid devices.
src/​crypto/​hmac_sha224.c Distinguishes invalid devices.
src/​crypto/​hmac_sha1.c Distinguishes invalid devices.
src/​crypto/​aes_gmac.c Distinguishes invalid devices.
src/​crypto/​aes_gcm.c Distinguishes invalid devices.
src/​crypto/​aes_ecb.c Distinguishes invalid devices.
src/​crypto/​aes_ctr.c Distinguishes invalid devices.
src/​crypto/​aes_ccm.c Distinguishes invalid devices.
src/​crypto/​aes_cbc.c Distinguishes invalid devices.
src/​block/​sdhc_spi_block.c Propagates stop-sequence failures.
boards/​stm32wba55cg_nucleo/​wolfHAL_board.h Uses WBA AES singletons.
boards/​stm32u5a5zj_nucleo/​wolfHAL_board.h Uses WBA-backed AES state.
boards/​stm32f411_blackpill/​wolfHAL_board.h Defines flash region bounds.
boards/​pic32cz_curiosity_ultra/​wolfHAL_board.h Defines flash region bounds.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/uart/stm32f4_uart.c
Comment thread tests/flash/test_flash.c
…send, test bounds wraparound

- F4/L1 UART Send returns success for zero bytes instead of polling TC
- Flash out-of-bounds test adds Read/Write/Erase sizes that make
  addr + dataSz wrap, so the overflow-safe bounds check is covered

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

N6 CCM still performs unguarded FIFO writes, WBA UART teardown can leave RX active, and I2C accepts out-of-spec frequencies.

0 open findings

2 resolved since last review
Previously missed (4)

In code that hasn't changed since last review

Medium severity Poll IFNF before writing the first AAD header block

src/​crypto/​stm32n6_cryp.c:1320

This poll only protects the second and later AAD blocks; the first header block is written at line 1313 without checking IFNF. If the input FIFO is not ready immediately after entering the header phase, that write can overrun it, so poll before every block as the PR description requires.

This issue also appears on line 1506 of the same file.

Medium severity Reject frequencies above 1 MHz before calculating TIMINGR

src/​i2c/​stm32wb_i2c.c:181

Frequencies above 1 MHz enter this branch and are now used to scale the Fast-mode Plus minimum timings downward, although this driver documents support only up to 1 MHz. Reject comCfg->freq > 1000000 in StartCom before calculating TIMINGR; otherwise callers can program out-of-spec bus timings.

Medium severity Stop RX even when stopping TX fails

src/​uart/​stm32wba_uart_dma.c:296

Returning immediately when stopping TX fails leaves the RX channel running, despite this Deinit contract promising to stop both channels. Attempt both stops, preserve the first error, and only then return it.

Low severity Add non-symmetric byte-order coverage for little-endian loads

wolfHAL/​endian.h:48

The existing endian unit suite exercises every big-endian load/store boundary, but the new little-endian loader has no corresponding test. Add at least a non-symmetric byte pattern test so byte-order regressions in this flash-critical helper are caught.

🧠 Review effort: Balanced

…dian loads

- WB-family I2C StartCom returns EINVAL for freq above 1 MHz instead of
  scaling Fast-mode Plus timings below the spec minimums
- Add whal_LoadLe32 cases to the core endian suite
@AlexLanzano

Copy link
Copy Markdown
Member Author

🔵 Needs a closer look

N6 CCM still performs unguarded FIFO writes, WBA UART teardown can leave RX active, and I2C accepts out-of-spec frequencies.

0 open findings

2 resolved since last review

Previously missed (4)
In code that hasn't changed since last review

Medium severity Poll IFNF before writing the first AAD header block
src/​crypto/​stm32n6_cryp.c:1320

This poll only protects the second and later AAD blocks; the first header block is written at line 1313 without checking IFNF. If the input FIFO is not ready immediately after entering the header phase, that write can overrun it, so poll before every block as the PR description requires.

This issue also appears on line 1506 of the same file.

Medium severity Reject frequencies above 1 MHz before calculating TIMINGR
src/​i2c/​stm32wb_i2c.c:181

Frequencies above 1 MHz enter this branch and are now used to scale the Fast-mode Plus minimum timings downward, although this driver documents support only up to 1 MHz. Reject comCfg->freq > 1000000 in StartCom before calculating TIMINGR; otherwise callers can program out-of-spec bus timings.

Medium severity Stop RX even when stopping TX fails
src/​uart/​stm32wba_uart_dma.c:296

Returning immediately when stopping TX fails leaves the RX channel running, despite this Deinit contract promising to stop both channels. Attempt both stops, preserve the first error, and only then return it.

Low severity Add non-symmetric byte-order coverage for little-endian loads
wolfHAL/​endian.h:48

The existing endian unit suite exercises every big-endian load/store boundary, but the new little-endian loader has no corresponding test. Add at least a non-symmetric byte pattern test so byte-order regressions in this flash-critical helper are caught.

🧠 Review effort: Balanced

I addressed "Reject frequencies above 1 MHz before calculating TIMINGR" and "Add non-symmetric byte-order coverage for little-endian loads"
The other two issues are not real.

@aidangarske aidangarske left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Skoll Multi-Scan Review

Modes: review + review-security

Overall recommendation: REQUEST_CHANGES
Findings: 3 total — 1 posted, 2 skipped
1 finding(s) posted as inline comments (see file-level comments below)

Posted findings

  • [High] [review-security] Shared RNG driver programs the wrong health-test configuration — src/rng/stm32wba_rng.c:81-113

Skipped findings

  • [Medium] Add regression coverage for new CCM and GCM boundaries
  • [Medium] Exercise the new GPDMA abort state machine

Review generated by Skoll

Comment thread src/rng/stm32wba_rng.c Outdated

@aidangarske aidangarske left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks really good a couple of nits though before I merge

Comment thread src/rng/stm32wba_rng.c Outdated
Comment thread src/rng/stm32wb_rng.c
Comment thread src/i2c/stm32l1_i2c.c
Comment thread src/crypto/stm32wba_aes.c
- Add cr, htcr and nscr to the WBA and H5 RNG cfg; Init writes them during CONDRST
- Set per-board values from AN4230 Table 3 (WBA55, U5A5, N657, H563)
- Drop the hardcoded configuration C (WBA/U5/N6) and H563 values from the drivers
- Add Test_AesEcb_KnownAnswer128 (NIST SP 800-38A F.1.1/F.1.2)
- Add Test_AesCbc_KnownAnswer128 (NIST SP 800-38A F.2.1/F.2.2)
- Each test encrypts and checks the result against the NIST ciphertext, then decrypts back to the plaintext
@aidangarske
aidangarske merged commit 9897729 into wolfSSL:main Oct 8, 2026
59 of 60 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.

3 participants