Repository navigation
SipHash: keep jumps within a single inline asm statement - #12284
Open
julek-wolfssl wants to merge 1 commit into
Open
julek-wolfssl wants to merge 1 commit into
julek-wolfssl wants to merge 1 commit into
Conversation
wc_SipHash() splits its inline assembly over several asm statements to keep each string under the C99 4095 char limit. Some jumps went from one statement into a label of the next. GCC does not support that: the compiler may place register moves between the statements that the jump skips. An msys2 build with GCC 16 got wrong digests. Keep the split, but move the boundaries so every jump stays in its own statement. On x86_64 the first statement now ends after the block loop. On aarch64 the 8 byte output check moves into the second statement. Add the "cc" clobber, since the assembly changes the flags. Fil-C does not allow pointers in inline assembly, so use the C code there.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the SipHash assembly-boundary changes.
No open issues 🎉
What changed in this PR
Fixes inline assembly boundaries in wc_SipHash() to prevent compiler-generated register moves from being skipped, addressing incorrect digests observed with GCC 16 on MSYS2.
Changes:
- Moves x86_64 and AArch64 assembly boundaries so jumps remain within one statement while preserving the string-length limit.
- Adds
"cc"clobbers to declare condition-flag changes. - Selects the portable C implementation for Fil-C.
| File | Description |
|---|---|
wolfcrypt/src/siphash.c |
Adjusts assembly boundaries and clobbers, adds Fil-C guards, and documents the constraints. |
Review effort: Balanced
|
Member
Author
|
retest this please |
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.
wc_SipHash() splits its inline assembly over several asm statements to stay under the C99 4095 character limit for string literals. Some jumps went from one statement into a label in the next. GCC does not support that, because the compiler may place register moves between the statements that the jump skips. An msys2 build with GCC 16 produced wrong digests.
"cc"clobber, since the assembly changes the flags.