feat(libSceLibreSsl): implement EVP_CIPHER_CTX_init, EVP_CIPHER_CTX_new and EVP_CIPHER_CTX_set_padding #10488
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10488"
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 alvaroelpob on 2026-10-24T03:12:47Z.
What
Implements
EVP_CIPHER_CTX_init,EVP_CIPHER_CTX_newandEVP_CIPHER_CTX_set_paddingin libSceLibreSsl, which threw and were declared without parameters.The module is LibreSSL 2.5.4 (firmware 13.40 measurements in #8981). Signatures, layout and results follow that release's
evp.handevp_enc.c:void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX*)EVP_CIPHER_CTX* EVP_CIPHER_CTX_new(void)calloc(1, 168), through the guestcallocas the module would through libcint EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX*, int pad)EVP_CIPH_NO_PADDING(0x100) in the 64-bitflagsat 112 whenpadis nonzero, sets it otherwise, and returns 1The 168-byte size is the one measured for
EVP_CIPHER_CTX_initin #8981. The layout (numat 88,flagsat 112,finalat 136) was checked withstatic_asserts and againstoffsetoffrom the 2.5.4 headers compiled on x86-64. LibreSSL dereferences a null context ininitandset_paddingwithout checking it, so that throws.#9571 forward-declares its own cipher context type for CMAC. This PR uses its own file and struct name, and changes none of its exports.
The debt entry records the source and what is unverified, and the pending-export count drops from 357 to 354.
Tested
Ubuntu 26.04 (WSL2, kernel 6.18), GCC 15.2.0, Release, full build with
BUILD_TESTING=ONonmain379b1dca3. There is one commit per function, and each adds that function with its test block and debt update. Each was built and itsguest_libressl_evp_cipher_ctxtest andcheck_conventions.pyrun on its own.guest_libressl_evp_cipher_ctxtest.EVP_CIPHER_CTX_initzeroes exactly 168 bytes of a 0xAA buffer and leaves the next 16 alone.EVP_CIPHER_CTX_newreturns four zeroed 168-byte guest heap blocks that are written and freed again.EVP_CIPHER_CTX_set_paddingsets 0x100 for 0 (twice) and clears it for 1 and -5, keeps the other flag bits0xFFFFFFFF000000FF, returns 1, and touches no byte outsideflags. A null context throws ininitandset_padding.ctest -j16at the last commit: 2005/2006 pass.agc_driver_multisample_retirementfails the same way onmainon this machine.main1e740a23a3(after #9033), head 4f073fa757: the conflicts were only theadd_librarysource list, the end of the test block, the pending-export count and the last debt entry; both sides are kept and the count is 357 minus this PR's exports. Full build andctest -j16: 2043/2044 pass;agc_driver_multisample_retirementfails the same way on thatmain.check_conventions.py --base upstream/mainpasses.maine7e3e9c198, head 6b1e364fc2, to resolve the conflict from #9529 on the sharedCMakeLists.txtand debt-file lines; both sides are kept and the count is 353 minus this PR's exports. 6b1e364fc2 (refactor(libSceLibreSsl): declare the EVP_CIPHER_CTX exports in the public header) puts the real signatures and their structs inlibSceLibreSsl/include/Api.hppand drops the test's redeclarations, whichpublic_headersrequires since #10706. Full build andctest -j16: 2202/2203 pass;agc_driver_multisample_retirementfails the same way on thatmain.check_conventions.py --base upstream/mainpasses.mainae7d59258e(after #9949), head 9a3cb4ef57, to resolve the conflicts withmainon the sharedCMakeLists.txtand debt-file lines; both sides are kept and the count is 342 minus this PR's exports. Full build andctest -j16: 2275/2276 pass;agc_driver_multisample_retirementfails the same way on thatmain.check_conventions.py --base upstream/mainpasses.main2dbe9b99f5(after #9745, #9870 and #11111), head f9a8c85d8d, to resolve the conflicts withmainon the sharedCMakeLists.txtand debt-file lines; both sides are kept and the count is 340 minus this PR's exports. Full build andctest -j16: 2370/2371 pass;agc_driver_multisample_retirementfails the same way on thatmain.check_conventions.py --base upstream/mainpasses.main88795ed448(after #10248; head 94203537ac) to resolve the conflicts on the shared debt-file lines; both sides are kept and the count is 335 minus this PR's exports. Full build andctest -j16: 2383/2384 pass;agc_driver_multisample_retirementfails the same way on thatmain.check_conventions.py --base upstream/mainpasses.mainc7b4878fa8(after #10373, #10376 and #10449), head 4ec014c6b2, to resolve the conflicts withmainon the sharedCMakeLists.txt,Api.hppand debt-file lines; both sides are kept and the count is 319 minus this PR's exports. Full build andctest -j16: 2394/2395 pass;agc_driver_multisample_retirementfails the same way on thatmain.check_conventions.py --base upstream/mainpasses.main474030e584(after #13562), head acab57400f, to resolve the conflict on the pending-export count in the debt file; the count is 292 minus this PR's exports. Full build andctest -j16: 3062/3062 pass.check_conventions.py --base upstream/mainpasses.maincf79276fee(after #13820), head16d0e81b02, to resolve the conflict on the pending-export count in the debt file.mainstill says 292 although #13820 removed two stubs, leaving 290, so the count is now set to the 287 stubs left inExport.cpp. It also restores the PS5 3.20 export table link,b2a77c09cd71c01f34c790cfbe98c751a13262ad, which the previous rebase had written without its zeros. Full build andctest -j16: 3107/3107 pass (log_filefailed once on #10486 and passed on five reruns and a second full run).check_conventions.py --base upstream/mainpasses.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 copilot-pull-request-reviewer[bot] on 2026-10-24T03:14:26Z.
Review: COMMENTED
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T12:15:33Z.
Review: APPROVED
Reviewed head
03cb3efab33b5daf4b3f51e8f4348750967a049f.I checked the context size/field offsets and the three behaviors against the pinned LibreSSL 2.5.4 declarations and implementation: initialization clears the complete context, creation uses the guest
calloc, andset_paddingchanges onlyEVP_CIPH_NO_PADDINGwhile returning 1. The overlap with #9571 is in shared files; this diff leaves its CMAC exports untouched. I found no blocking correctness issue in the reviewed code.The PR reports focused context tests and a 2005/2006 full CTest run, with the remaining failure also present on main; I did not reproduce those runs locally. Current convention, labels, eligibility, and report checks pass. Linux, Windows, register-context, relinker, write-watch, and ASan jobs are skipped.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T08:59:26Z.
Review: CHANGES_REQUESTED
Re-check — changes requested\n\nThe new report is useful: it says the implementation functions were preserved through the merge and the full test suite has the same single known failure as its tested main, with conventions passing. However, the tested integration point is
4c7d275bef; current upstream main isaaccd0ba39, and this PR head is 44 commits behind it.\n\nPlease update onto current main, preserve the implementation and debt-count changes, recount the pending exports against the resulting Export.cpp, and rerun the relevant LibreSSL tests plus conventions on the exact updated head. The earlier approval was for the prior head and does not cover this stale integration point. I did not rerun these checks locally.