fix(libSceLibreSsl): follow LibreSSL 2.5.4 and 4.0.0 for null digest buffers and SHA-512/t lengths #10484
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10484"
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 jacob6769 on 2026-10-24T03:02:24Z.
What
Three digest paths threw because the LibreSSL version of each module was unknown. Console measurements in discussion #8981 pin the versions:
libSceLibreSslis LibreSSL 2.5.4 (the module image holds "LibreSSL 2.5.4"), andlibSceLibreSsl3is LibreSSL 4.0.0 (OpenSSL_version(0)returns "LibreSSL 4.0.0"). The paths now do what those releases do:SHA256with a null digest buffer (libSceLibreSsl) writes into a static 32-byte buffer and returns it, as LibreSSL 2.5.4'sSHA256does. The buffer is shared between calls, like LibreSSL's.SHA512_Finalwith a digest length other than 48 or 64 (libSceLibreSsl) returns 0 without writing the digest. LibreSSL 2.5.4'sSHA512_Finalhas cases only for SHA-384 and SHA-512. It returns 0 fromdefault, which includes the SHA-512/224 and SHA-512/256 lengths that used to throw.MD5andSHA1with a null digest buffer (libSceLibreSsl3) throwstd::invalid_argumentinstead ofNotImplemented. LibreSSL 4.0.0'sMD5andSHA1have no static buffer and pass the null pointer to*_Final, which writes through it. Other unchecked inputs in these modules already throwstd::invalid_argumentin this way.The two debt entries drop the version-dependent paths. The
libSceLibreSsl3entry keeps the null-buffer exception, which differs from the console's crash.tools/progress.py:libSceLibreSsl46 to 48 of 399 (SHA256,SHA512_Final),libSceLibreSsl31 to 3 of 87 (MD5,SHA1).No open PR changes these functions or
src/Digest.cppin either module.tools/pr_overlap.pyreports no shared exports. Its only overlaps are neighbouring lines in the two debt files: other open LibreSSL PRs add entries next tolibSceLibreSsl.mdline 6 orlibSceLibreSsl3.mdline 10. Whichever PR lands second rebases.Tested
Windows 11, WinLibs MinGW-w64 GCC 15.2.0, Release,
BUILD_TESTING=ON.guest_libressl_digest:SHA256with a null buffer returns a pointer that is not the caller's buffer and holds the SHA-256 of "abc". A second call returns the same pointer, now holding the digest of the empty string.SHA512_Finalwithmd_lenset to 28 or 32 returns 0 and leaves the output untouched.guest_libressl3_digest:MD5andSHA1with a null buffer, andSHA1with null input of nonzero length, must throwstd::invalid_argumentspecifically.Digest.cppfiles reverted tomain, both tests fail:SHA512_Finalthrowsnot implemented, andMD5throws an exception that is notstd::invalid_argument. With this change, both pass.ctest -R "^guest_(libressl|crypto)": 11/11 passed, including the AES, error-queue, ASN.1 and cipher tests frommain. The full suite was not run.tools/check_conventions.py(with this title and body) andtools/check_test_registration.py buildpass.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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-24T05:17:56Z.
Review: APPROVED
Checked against main
7966e590ef, LibreSSL libressl-v2.5.4 (sha/sha256.c, sha/sha512.c) and libressl-v4.0.0 (md5/md5.c, sha/sha1.c):SHA256usesstatic unsigned char m[...]; if (md == NULL) md=m;, which matches the new static buffer.SHA512_Finalchecksmd==0after the final block, then switches onmd_lenwith only the 48 and 64 cases anddefault: return 0. Returning 0 for 28 and 32 without writing matches it, and so does the existing order of the null check and the length check.MD5andSHA1passmdstraight to*_Final, so throwingstd::invalid_argumentfor a null buffer fits the module's "throws where LibreSSL faults" convention.libressl-v2.5.4andlibressl-v4.0.0tags would match the behaviour the code now follows.Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T15:57:58Z.
Review: APPROVED
Reviewed the changed digest paths against the cited LibreSSL 2.5.4 and 4.0.0 behavior and current module split. The static SHA256 fallback, SHA512_Final default return without digest writes, and libSceLibreSsl3 null-output exception behavior match the described sources; the tests cover the relevant output and error cases. The current head merges cleanly with upstream main (
3fcb5e4d76), and conventions plus diff checks pass. I compiled and ran both focused digest tests directly with GCC 12.2.0 (linking the shared MD5/SHA1 primitive implementation for the SSL3 test); both passed. The Windows CTest results and broader test results are author-reported, not reproduced here.