Repository navigation
20261027-WC_SHA256_TSCRATCH_SIZE - #955
Conversation
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #955
Scan targets checked: wolfboot-src, wolfboot-bugs
Coverage: 1 of 1 in-scope changed file(s) opened by the reviewer
Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Reported findings require changes before merge.
Review tier: Lite
There was a problem hiding this comment.
🟡 Changes recommended
The fallback array allocates only 64 bytes while advertising 128 bytes, allowing scratch writes and XFREE() scrubbing to overflow the buffer.
1 open issue
What changed in this PR
Updates wolfBoot’s static hash allocation pools to accommodate wolfSSL’s larger SHA-256 transform scratch buffer, addressing image-hashing allocation failures.
Changes:
- Uses wolfSSL scratch-size constants when available, with fallbacks for older and FIPS bundles.
- Applies the sizing to SHA-256 slots across signature configurations and the Ed25519 SHA-512 slot.
- Preserves fallback sizing for SHA-384 and SHA3-384.
| File | Description |
|---|---|
| src/xmalloc.c | Updates hash-buffer dimensions and pool sizes to track wolfSSL transform scratch requirements. |
Review effort: Balanced
9bfff14 to
b23a59b
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #955
Scan targets checked: wolfboot-src, wolfboot-bugs
Coverage: 1 of 1 in-scope changed file(s) opened by the reviewer
Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Reported findings require changes before merge.
Review tier: Lite
There was a problem hiding this comment.
🟡 Changes recommended
ED25519 configurations using SHA-256 or SHA3-384 omit sha512.h, making WC_SHA512_TSCRATCH_SIZE unavailable and forcing the hard-coded fallback instead of the intended future-proof sizing.
1 open issue
1 resolved since last review
Review effort: Balanced
…tants wolfSSL's SHA-256 C transform now takes a caller-owned scratch struct (message schedule plus working variables) allocated once per Update/Final call under WOLFSSL_SMALL_STACK, sized WC_SHA256_TSCRATCH_SIZE (288 bytes) rather than one 256-byte block of schedule per transform. The static sha_block slot, pinned at HASH_BLOCK_SIZE words, no longer fits the request, so XMALLOC() returns NULL and image hashing fails with MEMORY_E (observed as "Failure -1: Hdr 1, Hash 0, Sig 0" in the library smoke test). Size sha_block by WC_SHA256_TSCRATCH_SIZE when the included wolfSSL defines it, falling back to the historical HASH_BLOCK_SIZE words for older wolfSSL and FIPS bundles that predate the constant; gate the ED25519 pool's sha512_block on WC_SHA512_TSCRATCH_SIZE the same way (same value today), including sha512.h for ED25519 builds, since the hash-selection chain otherwise pulls in only the image hash's header and would leave the constant invisible. Every slot entry now advertises sizeof() of its backing array, so a slot can never claim more than its storage. SHA-384 and SHA3-384 slots keep the fallback sizing unchanged.
b23a59b to
9616231
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #955
Scan targets checked: wolfboot-src, wolfboot-bugs
Coverage: 1 of 1 in-scope changed file(s) opened by the reviewer
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
Review tier: Lite
Fenrir's latest completed scan found no issues; clearing the prior automated change request.


src/xmalloc.c: size the SHA slots by wolfSSL's transform-scratch constantswolfSSL's SHA-256 C transform now takes a caller-owned scratch struct (message schedule plus working variables) allocated once per Update/Final call under
WOLFSSL_SMALL_STACK, sizedWC_SHA256_TSCRATCH_SIZE(288 bytes) rather than one 256-byte block of schedule per transform. The static sha_block slot, pinned atHASH_BLOCK_SIZEwords, no longer fits the request, soXMALLOC()returns NULL and image hashing fails withMEMORY_E(observed as "Failure -1: Hdr 1, Hash 0, Sig 0" in the library smoke test).Size sha_block by
WC_SHA256_TSCRATCH_SIZEwhen the included wolfSSL defines it, falling back to the historicalHASH_BLOCK_SIZEwords for older wolfSSL and FIPS bundles that predate the constant; likewise gate the ED25519 pool's sha512_block onWC_SHA512_TSCRATCH_SIZE(the same size today, so this half is future-proofing, not a behavior change). SHA-384 and SHA3-384 slots keep the fallback sizing unchanged.Merge before wolfSSL/wolfssl#11434