Repository navigation
Pq fs 2026 part4 lab prep sha512 fixes - #11983
Open
kaleb-himes wants to merge 2 commits into
Open
kaleb-himes wants to merge 2 commits into
kaleb-himes wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the SHA-512 state and input preservation changes.
No open issues 🎉
What changed in this PR
This PR fixes unintended state and input mutation in wolfCrypt’s SHA-512 APIs.
Changes:
- Preserve SHA-512/224 hash state during
FinalRawby byte-reversing a temporary copy and zeroizing it afterward. - Use internal buffers in
wc_Sha512Transformto leave the caller’s input unchanged. - Add regression tests for input preservation and continued hashing after
FinalRaw.
| File | Description |
|---|---|
wolfcrypt/src/sha512.c |
Prevents mutation of hash state and caller input during raw digest and transform operations. |
tests/api/test_sha512.c |
Adds regression checks for both mutation bugs. |
Review effort: Balanced
|
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #11983
Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfssl-bugs
Coverage: 2 of 2 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
kaleb-himes
force-pushed
the
PQ-FS-2026-Part4-LabPrep-sha512-fixes
branch
from
November 4, 2026 12:05
4fc26f9 to
0115bd2
Compare
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.
Description
sha512: SHA-512/224 FinalRaw and Transform no longer modify state or input
Sha512FinalRaw: for SHA-512/224 (28-byte digest, not a multiple of 8) the
little-endian path byte-reversed sha512->digest in place before copying it
out, so wc_Sha512_224FinalRaw() corrupted the running hash. Any Update after
FinalRaw then produced the wrong digest. It now reverses into a local copy,
which is zeroized after use, as the other FinalRaw paths already do.
wc_Sha512Transform: on little-endian builds (generic C without AVX, ARM,
RISC-V, PPC) the function byte-reversed the caller's const data block in
place. The block is now copied or reversed into the existing scratch buffer
or sha->buffer instead, so the transform receives the same input on every
path and the caller's buffer is left unchanged.
Testing
Tests:
Transform.
checks the result is SHA-512/224("abc") from the FIPS 180-4 examples.
Verified (non-FIPS, --enable-opensslextra): both tests fail with master's
sha512.c (test_sha512.c:278 and :358) and pass with this change; make check
passes.
ppc64le Transform double byte-reversal is open as Fenrir F-17178 and is not
part of this fix.
Checklist