feat(libSceLibreSsl): implement the MD4, MD5, SHA-1 and SHA-2 digests #9025
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9025"
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 HQasper on 2026-10-21T10:03:23Z.
What
All 399 libSceLibreSsl exports threw. This implements the 22 message digest exports, whose signatures and caller-allocated contexts are public and fixed in LibreSSL:
MD4,MD5,SHA1,SHA224,SHA256,SHA384andSHA512_Init/_Update/_Final, plus theSHA256one-shot.MD4_CTX,MD5_CTX,SHA_CTX,SHA256_CTXandSHA512_CTX, laid out as in LibreSSL's md4.h, md5.h and sha.h (92, 92, 96, 112 and 216 bytes, checked withstatic_assert). The bit count is kept inNl/Nh, the partial block indatawith its byte count innum, andmd_lenselects the digest length. A context the title copies or inspects therefore stays valid.Finalfollow LibreSSL's sources. The 32-bitFinalfunctions clearnumand the buffer.SHA256_Finalreturns 0 whenmd_lenis over 32 and truncates shorter lengths.SHA512_Finalreturns 0 for a null digest buffer or an unknown length.Updatewith length 0 returns 1 without readingdata.NotImplemented_nid_no_patch:SHA256with a null digest buffer (older versions return a static buffer, newer ones crash) andSHA512_Finalwith the SHA-512/224 or SHA-512/256 length (not in older versions). Null contexts, null input with a nonzero length, null digest buffers in the 32-bitFinalfunctions and anumthat is not below the block size throw. LibreSSL does not check these and would crash or overrun the buffer.Tested
Linux (Ubuntu 24.04 container, GCC 13, Release,
BUILD_TESTING=ON):guest_libressl_digest: passed. It covers each algorithm on the empty string,abc, the 448- and 896-bit FIPS messages, the 80-digit RFC message and one milliona. Each message is fed in chunks of 1, block size - 1, block size, block size + 1, 1000 and the whole message, and the results match the RFC 1320/1321 and FIPS 180 values, with the others cross-checked against Pythonhashliband OpenSSL 3.0.13. The test also checks thenumandNlfields after a partial update, a context copied mid-stream, themd_lencases and the throwing cases. With a mutated MD5 constant the test aborts.patched_libraries: passed. The patchedlibSceLibreSsl.prxexports the same 394_nid_postfixnames as before.python3 tools/check_conventions.py --base origin/main: passed.Note: this PR and the digest PR #9033 both add core/libs/prx/libSceLibreSsl/CMakeLists.txt and change the pending-export count in the debt file. Whichever merges second needs a small rebase. Open them in either order.
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 github-actions[bot] on 2026-10-21T10:04:14Z.
Progress report (
b6fe513→52a439b)📈 System libraries: 50.81% (+0.23%, +20 implemented functions)
✅ 20 implemented
MD4_Final_nid_postfixMD4_Init_nid_postfixMD4_Update_nid_postfixMD5_Final_nid_postfixMD5_Init_nid_postfixMD5_Update_nid_postfixSHA1_Final_nid_postfixSHA1_Init_nid_postfixSHA1_Update_nid_postfixSHA224_Final_nid_postfixSHA224_Init_nid_postfixSHA224_Update_nid_postfixSHA256_Final_nid_postfixSHA256_Init_nid_postfixSHA256_Update_nid_postfixSHA384_Final_nid_postfixSHA384_Init_nid_postfixSHA384_Update_nid_postfixSHA512_Init_nid_postfixSHA512_Update_nid_postfixImported from boykopovar/AnyPS5. Originally posted by ycbuzi on 2026-10-21T17:51:15Z.
Windows run of
52a439bc70merged ontomain745b394629(8d1afaa92b, clean), the platform the description lists as not tested. Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release,BUILD_TESTING=ON.Built
libSceLibreSslandguest_libressl_digest_testswith no errors or warnings.ctest --repeat until-fail:2onguest_libressl_digest: passes on both repeats. Not run: a title.