feat(libSceNKWebKit): implement WTF::SHA1 construction and hex digest #15866
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15866"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by KernelPanicNT on 2026-11-04T20:29:10Z.
What
Implements three
libSceNKWebKitexports that calledNotImplemented_nid_no_patch:WTF::SHA1::SHA1()(C1f4Y+BVScAccand C2Dq5bk2mU2xw) andWTF::SHA1::computeHexDigest()(Ow27qMGiCBU). They follow WebKit's non-CocoaSHA1.handSHA1.cpp:uint8_t m_buffer[64]at 0,size_t m_cursorat 64,uint64_t m_totalBytesat 72 anduint32_t m_hash[5]at 80, modelled asNKWebKit::WtfAbi::SHA1inWtfStringAbi.hppand pinned withstatic_assert.reset(): cursor and byte count 0, the RFC 3174 initial hash, buffer cleared.computeHexDigest()runscomputeHash(): it pads the current state (the buffer up to the cursor, the byte count and the hash words), processes the last block or blocks, writes the big-endian digest and resets the object. ThenhexDigest()returns a 40-character uppercase CString. The CString goes through the hidden return pointer, as the tree's other CString-returning WTF exports do, and is allocated withCString::newUninitialized.std::invalid_argumentbefore anything is written. Upstream has only a debugASSERTthere, and a release build writes pastm_buffer. This follows how the tree already handles WTF assertions over invalid memory, for example in the FastBitVector entry of the debt file.addBytesandcomputeHashare not in the module's export inventory, so a guest only reaches the digest through an object it filled through this layout. A new debt entry says the layout and digest were not checked against a console module. The three NID rows leave the list of throwing inventory exports.These three stubs sit next to the
WTF::LockandWTF::Mutexstubs that #14921, #14922 and #14923 remove. Those PRs leave these functions as they are, but whichever PR merges second will need a small rebase ofExport.cppandInventoryExports.hpp.Source of the behaviour
SHA1.h#L85-L96(non-Cocoa members). Exported members:#L51and#L82.computeHash,finalize,processBlockandreset:SHA1.cpp#L100-L202.hexDigestandcomputeHexDigest:#L206-L223.71faad83f847forSHA1.hand18c4fe832553forSHA1.cpp) from WebKit9809c1a27c82untilSHA1.hnext changes inc614496679dc.SHA1.cppis the same blob from7bab10c8f472until484500b2c078. This is the same text the existing NKWebKit debt entries cite as their pinned WebKit source.Export.cpp#L19771-L19781,InventoryExports.hpp#L1915-L1917, and names and NIDs atlibSceNKWebKit.md#L1859-L1861.WtfStringAbi.hpp#L46-L68,WtfString.cpp#L694(String::ascii) and#L808(CString::newUninitialized).libSceNKWebKit.md#L11(FastBitVector).Tested
Linux (GitHub Codespace, GCC), on
main9ab6a281ea. The newnkwebkit_sha1test passes andnkwebkit_wtfstill passes; the new files build without warnings. The test checks:abc, 55 and 63 bytes, and the 56-byte FIPS message, each with zero and with stale bytes after the cursor. These cover both padding branches.SIZE_MAXthrow with the object unchanged.Negative control: the same test with
Export.cpp,InventoryExports.hpp,WtfExports.hppandWtfStringAbi.hppfrommainand withoutWtfSha1.cppdoes not build, andctestfails. Two mutations of the implementation, lowercase hex digits and no reset after the digest, also make the test fail.tools/progress.py: +3 implemented functions (libSceNKWebKit 1309/11248 -> 1312/11248).tools/check_conventions.pypasses.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by ahmadmuj on 2026-11-06T12:21:05Z.
Review: COMMENTED
Checked head
6e2453c72ba86df76703a68a7487f7ef46b12b19, PR base638187daeceacf1fff34c172ebd3f135fd7dbbb8, and main2d2d60a959a7abc7b3a34b0341a40eae2af1d298.On Ubuntu 24.04 / WSL2, GCC 13.3, Release:
cmake --build builds/anyps5-pr-15866 --target nkwebkit_sha1_tests -j 6andctest --test-dir builds/anyps5-pr-15866 -R '^nkwebkit_sha1$' -Vpass.0xA5unused buffer bytes: 16 payload runs and 32 empty digests after reset. It checks every named reset field, adjacent guards, CString length/refcount/terminator, and exact digest bytes. Each CString leaves scope before the next digest._ZN3WTF4SHA1C1Ev not implemented.I checked the non-Cocoa implementation and layout against WebKit SHA1.cpp and SHA1.h. Expected strings come independently from Python
hashlib.sha1.One regression-test suggestion: add a high-bit payload around the padding boundary. For 55 bytes defined by
byte[i] = (i * 37 + 0x80) & 255, the expected digest is45D049142CD1784AD869A7EE26BB653D8D78CD0C. As a control, I masked only payload bytes withbuffer[i] &= 0x7fbeforeFinalize. Your current test still passes, but this vector fails with7560B6E42942DCE3837BFBDC21FC7C38EAB75916. Restoring the source makes both tests pass. The probe also checks lengths 56 and 63, plus80 00 ff 41.The current implementation passes these cases. This is a coverage suggestion, not a production defect. Console layout and execution remain unverified, as the debt entry states.
Imported from boykopovar/AnyPS5. Originally posted by ahmadmuj on 2026-11-06T17:19:05Z.
Review: COMMENTED
Follow-up on head
6e2453c72ba86df76703a68a7487f7ef46b12b19with main4c03784113f5378f87a198aa6d9f330611f24421(integration treeefd21d3aee1c4f6d08f12146dfc5791dbcf283e4).The source merge applies, but the integrated module fails to compile on Ubuntu 24.04/WSL2, GCC 13.3, Release. The isolated existing production object fails without compiling the new regression test:
Both paths are under
core/libs/prx/libSceNKWebKit/.WtfValueExports.hppincludesWtfStringAbi.hppthroughWtfExports.hpp, so both definitions reach the same translation unit. Main commit7287e745b011e32c1c03b117fccd1655e01c2b03adds the definition inWtfValueExports.hpp.I checked the saved compile command, failure log, and snapshot bytes against the integration tree. Main
8fa2f2f8881b537b24062bd377badebae8d97abfchanges only Audiodec files since that pin. I did not repeat the unchanged build.This blocks my test-only follow-up for the binary vectors from the earlier review. The new test does not cause the failure. No GPU or console claim.