fix(libSceLibreSsl): preserve SHA-512 initialization buffers #13820
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/13820"
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 Ninot1Quyi on 2026-10-31T08:01:30Z.
What
SHA384_InitandSHA512_Initcurrently zero all 216 context bytes, including the 128-byte block buffer that LibreSSL 2.5.4 leaves unchanged. Reset only the chaining state, bit counters, buffered-byte count and digest length, preserving the caller-visible working buffer on first initialization and reinitialization. This closes the existing buffer-initialization debt; digest outputs remain unchanged.The behavior follows LibreSSL 2.5.4
sha512.c, the reference already used by this library. The existing console-verification limitation is retained. The optional oracle now compares every context byte after initialization and each update instead of excluding the unused part of the SHA-384/SHA-512 buffer.Overlap:
tools/pr_overlap.py --branch fix/libressl-sha512-init-bufferscanned 1,603 open PRs and reported 16 debt-file conflicts plus 28 comparisons blocked by unrelated base conflicts. All 44 shared patches were inspected from their merge bases; none changes this production digest implementation or its guest fixture. The four sharedOracle.cppbranches (#13266, #13285, #13546, #13547) add X.509 decode/store/encoding/free comparisons and leaveSameContextandCompareDigestsunchanged. There is no landing dependency; subsequent merges must retain both the unrelated debt entries and this resolved buffer-initialization change.Tested
Linux x86-64, GCC 13.3:
guest_libressl*tests pass, including the complete digest fixture linked to the actual guest libraries. The standalone production-source fixture also passes the existing known vectors, million-byte message and chunked updates.abcand empty digests after reinitialization.Digest.cppand separately links against main's reallibSceLibreSsl.prx/libc.prx; both abort withwide init preserves the block buffer(exit 134). Restoring the fixed production source passes./proc/2/taskin this traced runtime; no leak-check pass is claimed.python3 tools/check_conventions.py --base origin/mainandgit diff --checkpass.The optional LibreSSL 2.5.4 oracle runs 46,521 comparisons. SHA-384 and SHA-512 each have zero differences across 600 Init, 600 Update and 600 Final comparisons with the stricter full-context check (3,600 total). The overall oracle still fails on six pre-existing AES key-schedule comparisons: untouched main reproduces the identical six failures. A separate probe confirms that the reference x86 assembly and the existing portable implementation store every active key-schedule word in opposite byte order; result codes, rounds, unused storage and all tested AES mode outputs agree. This SHA initialization PR does not change AES behavior. No Windows, title or PS5 hardware run is claimed.
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 MarcZX10 on 2026-10-31T08:18:19Z.
Review: APPROVED
Reviewed — looks good
The two SHA-384/SHA-512 initializers now reset the same fields as pinned LibreSSL 2.5.4 while preserving the block buffer, and the regression tests cover both initialization and reinitialization.
What I ran
Reviewed head
592aca8e115ccdd0ccb45d5c88a30a89c94c396aagainst the PR base828ac0b2ae74aac181ba128fb59b08a1534f2041; a merge preview against currentmaine8c25dd3baa6e78531d5eee067fec5cbe8af3dcfwas clean. Local environment: Linux x86-64, Python 3.11.2; no compiler used. I ran:I compared the changed initializer fields with the pinned LibreSSL source and manually confirmed both tests’ CMake registration. The heuristic warns about the C++ files because it searches for literal path strings; CMake registers
guest_libressl_digestand the optionalguest_libressl_oracletargets.Results
mainguest_libressl*tests passed; sanitizer and SHA oracle results are reported belowThe no-build precheck’s optional ABI/test-quality helpers were not present in its isolated checkout. This change does not alter exports or public declarations, so ABI auditing is not applicable. I did not independently run C++ tests.
Raw output from local checks
Negative control
main’s productionDigest.cppwide init preserves the block buffer(exit 134); not independently reproduced here.libSceLibreSsl.prxandlibc.prxFindings
Blocking: None found.
Non-blocking: The PR reports six unrelated AES oracle differences, also reproduced on unchanged
main; the SHA-384/SHA-512 oracle comparisons report zero differences. I did not independently reproduce those results.Sources
SHA384_InitandSHA512_InitNot verified
I did not run the C++ build, guest tests, sanitizer checks, oracle comparisons, or console/title tests locally. The Linux test, sanitizer, oracle, and negative-control results are author-reported; Windows CI passed. The PR head remained
592aca8e115ccdd0ccb45d5c88a30a89c94c396awhen I submitted this review.