feat(libSceJsc): implement WTF::SHA1::computeHash #19188
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/19188"
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 c1b3r-p3d1a on 2026-11-12T23:13:51Z.
What
Implements
WTF::SHA1::computeHash(std::array<uint8_t, 20>&)(ALtdQuwSy0A) in libSceJsc, which threw. It is ported from the non-Cocoa branch of WebKit's SHA1.cpp atc55364d53f97, the revision libSceJsc's string search code already follows. The newsrc/WtfSha1.cppstarts with that file's licence notice (BSD-3-Clause) under aDerived fromline.finalize,processBlockandresetare kept line for line: append0x80, pad to a second block when the cursor passes 56, write the bit count big-endian at 56, run the 80-round compression, store the five words big-endian in the digest, then reset the object to the initial hash with a zeroed buffer.static_asserts; it is the layout libSceNKWebKit'sWTF::SHA1already uses. libSceJsc exports neither the constructor noraddBytes, so the object comes from guest code or another module.std::invalid_argumentbefore anything is written.SHA1::hexDigeststill throws: it returns aCString, and libSceJsc creates noCStringyet.The debt entry records what is unverified (console WTF version and layout). The "callable NIDs" count drops from 331 to 330 and the export's row leaves the table.
Tested
Windows 11, WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh r7), Release.
jsc_wtf_sha1covers 8 states on a0xA5-poisoned object and digest. Six are messages that fit in one pending block: empty,abc, 55 bytes (the last length padded in one block), the 56-byte FIPS 180 message (two-block padding) and 63 bytes. Two are mid-stream states: 1000 bytes (15 blocks done, 40 pending) and the million-amessage (15625 blocks, none pending). Every expected digest comes from Pythonhashlib, and the mid-stream hash words from a separate pure-Python SHA-1. An 8th state uses a byte count of0x2000000000000001, whose bit count wraps to 8. After each call the test checks the reset state, then that a second call hashes the empty message. It also checks that a cursor of 64 throws with the object and digest untouched, and that null arguments throw.libSceJsc.prx:thisinrdi, the digest inrsi, the cursor read at0x40, the byte count at0x48, the hash words at0x50to0x60, and the reset stores cover the whole 104 bytes.SHA1.cpp(cmp).main3ba8523c06: all libSceJsc andpublic_headerstests pass (74 total);python tools/check_conventions.py --base origin/mainpasses.libSceJsc.prxis not copied over the one staged inbuild/tests(#17895), so I copied it there before each run.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)Note: #18951 removes the neighbouring
integerToSixCharacterHashStringstub, and every libSceJsc PR changes the "callable NIDs" count line indocs/dev/debt/libSceJsc.md. These are textual conflicts only; no other PR touchesSHA1. I will rebase and recompute the count when one of them merges first.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-13T00:24:09Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
Reviewed head
bcbbd4ecf4beb92e4ccff371100a06e5b15ccdfaagainstmain. No build and no test run in this pass. Repository searches at the pinned head:Results
WtfSha1.cpponlyDerived fromfilesFindings
Blocking
None.
Non-blocking
None.
Not verified
jsc_wtf_sha1was not built or run here. The author reports 73 libSceJsc tests passing on Windows 11 with GCC 15.2.0; that is the author's run, not mine.SHA1.cpp(cmp). The WebKit source is not in the repository, so this is not checked.hexDigestare unverified, as the description and debt entry state.Export.cpp,InventoryExports.hpp,libSceJsc.hpp,CMakeLists.txtanddocs/dev/debt/libSceJsc.mdwere read as diff hunks, not in full.To get this to a good state
Nothing is required. There are no optional points beyond the items under Not verified.