feat(libSceNKWebKit): implement PAL::CryptoDigest #19330
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/19330"
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 B-Howell on 2026-11-13T03:54:14Z.
What
Implements the five
PAL::CryptoDigestexports that threw:create,addBytes,computeHashand the D1 and D2 destructors. They follow the PS5 WebKit source already pinned in the debt file: PlatformPlayStation.cmake buildscrypto/openssl/CryptoDigestOpenSSL.cpp, and CryptoDigest.h givesenum class Algorithm { SHA_1, SHA_224, SHA_256, SHA_384, SHA_512 }and a singlestd::unique_ptr<CryptoDigestContext> m_contextmember.PAL::CryptoDigestis the 8-bytem_contextpointer (static_asserts on size, alignment and offset). The context type is private to the module, as upstream.createreturns thestd::unique_ptrthrough the hidden result pointer. Like CryptoDigestOpenSSL.cpp, it returns null for any other algorithm value. The object is allocated with libcoperator new(_Znwm_nid_postfix, aslibwebrtc/src/CopyOnWriteBuffer.cppdoes), so the caller'sdeletefrees it. The context is allocated withWTF::fastMalloc, asWTF_MAKE_STRUCT_FAST_ALLOCATEDdoes upstream.The hashing reuses the existing libSceLibreSsl
SHA1_*,SHA224_*,SHA256_*,SHA384_*andSHA512_*functions, the same OpenSSL calls upstream makes. libSceNKWebKit now links libSceLibreSsl.computeHashreturns the existingNKWebKit::WtfAbi::Vector<uint8_t>with size and capacity equal to the digest length (20, 28, 32, 48 or 64).The destructors free the context and leave the object for the caller to free. A null object or context throws
std::invalid_argument, where upstream only asserts.The declarations move from
InventoryExports.hppandLegacyExports.hppto typed prototypes in the newPalCryptoDigestExports.hpp. The four inventory rows are removed from the debt file, and a debt entry records that the behaviour has not been compared with a console module.Tested
Ubuntu WSL2, GCC 11, Release, Ninja.
Red control: with the new test and typed header but the
Export.cppstubs still in place,nkwebkit_palcryptodigestfails:Subprocess aborted,_ZN3PAL12CryptoDigest6createENS0_9AlgorithmE not implemented.With this change, on
c3a0b4cfe66(maina6606d5bab7; the headcd8764bac85only shortens the debt entry):nkwebkit_palcryptodigestpasses 3/3. For each of the five algorithms it checks the published digests of"abc"and the empty message, the 448-bit two-block FIPS 180-2 message (the published example for SHA-1, SHA-224 and SHA-256; Pythonhashlibvalues for SHA-384 and SHA-512) and a 1000-byte message against Pythonhashlib. Each message is also fed in severaladdBytescalls, including zero-length ones and splits across block boundaries. It also checks the result vector's size and capacity, that algorithm values 5, 6, -1 andINT_MAXreturn null, that the object is the only guest-heap allocation and the caller'sdeletefrees it, and that D1 and D2 release the context.public_headerspasses 65/65;nkwebkit_noops,nkwebkit_palsessionidandnkwebkit_wtfpass.tools/progress.py: libraries done goes from 15578 on main to 15583 (+5) out of 39251.Debt: the table rows of the four inventory declarations this PR implements are removed (
createwas aLegacyExports.hppstub).On
2838612d3a1, an ordinary merge ofmainat82160bba912after #18538, conventions passed; doc-only conflict on the count line; count is main's stated 5949 minus this change's 4 removed stubs (5945). Main's code changes since the last merge are over 1,000 lines from this PR's hunks, so the earlier test results stand.On
f5340912c1c, an ordinary merge ofmainatc76eb6a2643after #19322 and #17764, conventions passed; doc-only union merge of the count line; count is main's stated 5940 minus this change's 4 removed stubs (5936). Main's nearest code change is 200 lines from this PR's hunks, so not rebuilt.On
9bfaa8d6101, an ordinary merge ofmainatc612c4c9e89after #19460 (PAL::fileSizeDescription, whose stub removal sits about 20 lines from ours): merged without a code conflict; count is main's stated 5939 minus this change's 4 removed stubs (5935). Windows 11, WinLibs GCC 15.2.0 r7 UCRT, Release:nkwebkit_palcryptodigestandnkwebkit_palfilesizeformatter3/3; conventions passed.On
fa3dcec83cc: merged main after #19603; count line removed. Ordinary merge ofmainat9b22c40f49a, conventions passed. The debt diff against main is now only this PR's entry and its 4 removed table rows. No code conflict and main changed none of this PR's other files, so not rebuilt.Checklist
Based on current
main; no other open PR implements the same functionsOne topic per PR; follow-ups go in a new PR
No comments in code except technical debt
Unimplemented paths throw (
NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt fileNo notes, investigation
.mdfiles or images added to the repository (attach them to this PR)New third-party code is a submodule built from source
Generic behaviour, not specific to one title
Depends on: none (#19305 also adds to
PalTypes.hppat the same place; whichever merges second needs a trivial merge)Fixes: none
Unblocks: none
GPUs tested: n/a
AI-assisted: yes