decomp: reconstruct MD5 endian-loaded rotation operands #965

Merged
coah80 merged 1 commits from agent/bittle/md5-reconstruction into main 2026-10-02 21:47:01 +00:00
coah80 commented 2026-10-02 21:46:32 +00:00 (Migrated from github.com)

Decompilation-first structural improvement

Reconstructs ProcessBlock's two byte-reversed message loads and separately associated rotation halves in a typed inline helper. Moves index-table initialization after the sequential first round, as in the target. No header, algorithm constants, API bodies, linker flags, data, or metadata changes. This is not a newly exact function or a claim of a previous MD5 correctness bug.

Independently checked original ProcessBlock offsets +0x3C/+0x40: two lwbrx results feed the right/left rotation halves. The four additions at +0x58/+0x5C/+0x64/+0x68 and right25/left7 shifts support the source boundary. No volatile/register tricks, new assembly, fake storage or compiler-option changes.

Fresh verification on 255f3e05

  • ProcessBlock 294→306 instructions against target306; fuzzy43.290848%→81.82026% (still non-exact).
  • MD5 unit decompiled/fuzzy61.945175%→87.80044%.
  • Existing3/4 exact functions and exact code600/1824 unchanged. All three public APIs also ctxdiff0.
  • Data456/456 unchanged; all448 .data bytes exact, existing one-byte .sdata marker plus target alignment zeros unchanged. Pool0/0 identical.
  • Parent reran3,088 standard-vector, seeded-message and chunking checks using unmodified production C with PPC intrinsic shims and external RFC1321 padding. GetDigest's platform-endian final stores are not exercised by that host test; its target instructions remain exact.
  • Full43U all_source/progress/report/DOL passed SHA1 26116613f624061ba99c8d1a299aaa6efa85670d.
  • All1027 allocated objects audited: only MD5.text changes,1776→1824 bytes; every data section and other object unchanged. No unit/report regressions.
  • Tests8/36/27/8 and main/leaf worktree/diff checks pass.

Remote treecc5b0f0cc778137ad42c120ebc95e5e3bd1b6c26 equals tested tree. AES unchanged. Exact matching and linking remain open; left for review, no merge performed.

Note

Reconstruct MD5 endian-loaded rotation operands in ProcessBlock

  • Adds an inline rotateSum helper in md5.c that reads each message word through two byte-reversed loads and builds the rotation from separate left- and right-shift sums
  • Rewrites the STEP macro to call rotateSum and pass the message-word pointer directly instead of an integer address
  • Moves initialization of the index-table pointer to just before the indexed second round; round constants, indices, and state accumulation are unchanged
  • Adds allhands-md5-rotation.attempts.md documenting the decompilation attempt, validation, and remaining diff against the target
  • Behavioral Change: with unchanged memory contents, the two loads yield the same word, so the MD5 output is equivalent to before

Macroscope summarized fd900aa.

## Decompilation-first structural improvement Reconstructs ProcessBlock's two byte-reversed message loads and separately associated rotation halves in a typed inline helper. Moves index-table initialization after the sequential first round, as in the target. No header, algorithm constants, API bodies, linker flags, data, or metadata changes. This is not a newly exact function or a claim of a previous MD5 correctness bug. Independently checked original ProcessBlock offsets +0x3C/+0x40: two lwbrx results feed the right/left rotation halves. The four additions at +0x58/+0x5C/+0x64/+0x68 and right25/left7 shifts support the source boundary. No volatile/register tricks, new assembly, fake storage or compiler-option changes. ## Fresh verification on 255f3e05 - ProcessBlock 294→306 instructions against target306; fuzzy43.290848%→81.82026% (still non-exact). - MD5 unit decompiled/fuzzy61.945175%→87.80044%. - Existing3/4 exact functions and exact code600/1824 unchanged. All three public APIs also ctxdiff0. - Data456/456 unchanged; all448 .data bytes exact, existing one-byte .sdata marker plus target alignment zeros unchanged. Pool0/0 identical. - Parent reran3,088 standard-vector, seeded-message and chunking checks using unmodified production C with PPC intrinsic shims and external RFC1321 padding. GetDigest's platform-endian final stores are not exercised by that host test; its target instructions remain exact. - Full43U all_source/progress/report/DOL passed SHA1 26116613f624061ba99c8d1a299aaa6efa85670d. - All1027 allocated objects audited: only MD5.text changes,1776→1824 bytes; every data section and other object unchanged. No unit/report regressions. - Tests8/36/27/8 and main/leaf worktree/diff checks pass. Remote treecc5b0f0cc778137ad42c120ebc95e5e3bd1b6c26 equals tested tree. AES unchanged. Exact matching and linking remain open; left for review, no merge performed. <!-- Macroscope's pull request summary starts here --> <!-- Macroscope will only edit the content between these invisible markers, and the markers themselves will not be visible in the GitHub rendered markdown. --> <!-- If you delete either of the start / end markers from your PR's description, Macroscope will append its summary at the bottom of the description. --> > [!NOTE] > ### Reconstruct MD5 endian-loaded rotation operands in `ProcessBlock` > - Adds an inline `rotateSum` helper in [md5.c](https://github.com/coah80/wii-ipl/pull/965/files#diff-dbadc0abfbe32c537af7f9f3221ac1d057cd9705ae3611325af96ae5627bce7d) that reads each message word through two byte-reversed loads and builds the rotation from separate left- and right-shift sums > - Rewrites the `STEP` macro to call `rotateSum` and pass the message-word pointer directly instead of an integer address > - Moves initialization of the index-table pointer to just before the indexed second round; round constants, indices, and state accumulation are unchanged > - Adds [allhands-md5-rotation.attempts.md](https://github.com/coah80/wii-ipl/pull/965/files#diff-6659973a379bef1c23dc9f7327ad1902eb5c4a016f6164f49f027ff3893f44ef) documenting the decompilation attempt, validation, and remaining diff against the target > - Behavioral Change: with unchanged memory contents, the two loads yield the same word, so the MD5 output is equivalent to before > > <!-- Macroscope's review summary starts here --> > > <sup><a href="https://app.macroscope.com">Macroscope</a> summarized fd900aa.</sup> > <!-- Macroscope's review summary ends here --> > <!-- Macroscope's pull request summary ends here -->
coah80 commented 2026-10-02 21:46:58 +00:00 (Migrated from github.com)

Reviewed and merged: rebased on main, full build ok, DOL sha1 26116613f624061ba99c8d1a299aaa6efa85670d, 0 regressions, 0 forbidden patterns.

Reviewed and merged: rebased on main, full build ok, DOL sha1 26116613f624061ba99c8d1a299aaa6efa85670d, 0 regressions, 0 forbidden patterns.
Sign in to join this conversation.