feat(libSceLibreSsl): implement the SSL context, BIO, version, verify result, shutdown and want accessors #10481
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10481"
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-24T02:54:11Z.
What
Implements
SSL_get_SSL_CTX,SSL_get_rbio,SSL_get_wbio,SSL_version,SSL_get_verify_result,SSL_get_shutdownandSSL_wantin libSceLibreSsl, which threw and were declared without parameters.The module is LibreSSL 2.5.4 (firmware 13.40 measurements in #8981). Signatures, layouts and results follow that release's
ssl.h,ssl_locl.handssl_lib.c:SSL_CTX* SSL_get_SSL_CTX(const SSL*)ctxBIO* SSL_get_rbio(const SSL*)rbioBIO* SSL_get_wbio(const SSL*)wbioint SSL_version(const SSL*)versionlong SSL_get_verify_result(const SSL*)verify_result, 64-bit aslongis on the consoleint SSL_get_shutdown(const SSL*)internal->shutdownint SSL_want(const SSL*)internal->rwstateThe layouts are 232 bytes for
SSL(rbioat 16,wbioat 24,ctxat 152,verify_resultat 160,internalat 224) and 432 forssl_internal_st(rwstateat 156,shutdownat 168). They were checked withstatic_asserts and againstoffsetoffrom the 2.5.4 headers compiled on x86-64. LibreSSL dereferences the connection, and the internal state for the last two, without checking them, so a null for either throws. No export of this module creates a connection yet, so for now only connections built by the caller reach these functions.The debt entry records the source and what is unverified, and the pending-export count drops from 357 to 350.
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_ssltest andcheck_conventions.pyrun on its own.guest_libressl_ssltest. The pointer getters return null and then their own field, not a neighbour:ctxnext tosession,rbionext towbio, andwbionext torbioandbbio.SSL_versionreturns 0, 0x0303 and 0xFEFF.SSL_get_verify_resultreturns 0, 20, a value above 32 bits and -1.SSL_get_shutdownreturns 0, 1 and 3 withrwstateset, andSSL_wantreturns 0, 1 and 3 withshutdownset. A null connection throws in all seven, and a null internal state throws in the last two.ctest -j16at the last commit: 2005/2006 pass.agc_driver_multisample_retirementfails the same way onmainon this machine.main1e740a23a3(after #9033), head 2ca51b6d21: 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 a519efda1f, 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. a519efda1f (refactor(libSceLibreSsl): declare the SSL accessor 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), headb7ceda9cb4, 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), head2473e1c7e3, 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 42008aa41f) 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 6cdb701e70, 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 b651889acc, 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), head52c8fbdfa8, 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 283 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.main4939814d79(after #9970, #10078 and #10488), head 475d97d50e, to resolve the conflicts on the sharedCMakeLists.txt,Export.cpp,Api.hppand debt-file lines; both sides are kept. The count is set to the 254 stubs left inExport.cpp. Full build andctest -j16: 3538/3538 pass.check_conventions.py --base upstream/mainpasses.main4f41f4c375, head 2b8a0d5d5d, to resolve the conflicts on the sharedCMakeLists.txt,Export.cppand debt-file lines; both sides are kept and the debt count is recomputed fromExport.cpp.mainnow declaresnamespace LibreSslinBio.hpp, so the SSL struct is renamedLibreSslSslin every commit; layout andstatic_asserts are unchanged. Full build andctest -j16: 3796/3800 pass;guest_sce_net,guest_poll,guest_select_waitandguest_memoryfailed under that load, pass when run alone, andmain4f41f4c375passes all 3799 with-j16on the same machine.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-24T02:56:33Z.
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-24T15:59:15Z.
Review: APPROVED
Reviewed the seven SSL getters against the cited LibreSSL 2.5.4 layout. The field offsets and 64-bit verify-result return are represented explicitly and covered by the static assertions/tests; the internal shutdown/rwstate getters validate the internal pointer as expected. Current head merges cleanly with upstream main, and conventions/diff checks pass. I compiled and ran
GuestLibreSslSsl.cppwithSsl.cppdirectly using GCC 12.2.0; it passed. Broader Linux test results are author-reported; hosted product jobs are skipped.Imported from boykopovar/AnyPS5. Originally posted by ahmadmuj on 2026-10-25T18:05:53Z.
Review: APPROVED
Reviewed head
a153cf7eef08453eab25a956d80262c01661495b, merged locally onto main7a25f87620a9b862dc194dd0f659686b0f6cc8b0. The merge conflicts only in the debt file's first two lines (the pending count next to main's updated Digest line); I took main's lines there to build, it's docs only.What I ran, Linux x86-64, GCC 13.3, Release:
libSceLibreSslandguest_libressl_ssl_testson the merged tree:guest_libressl_sslpasses.check_conventions.py --base origin/mainpasses.SSL_wantreturningshutdowninstead ofrwstate, the test fails at line 131; restored, it passes.107a5b52...6efa, matches the published list) and compiled anoffsetofprobe against its realssl.handssl/ssl_locl.h.ssl_stis 232 bytes with rbio 16, wbio 24, session 128, ctx 152, verify_result 160 (8-bytelong), internal 224.ssl_internal_stis 432 bytes with rwstate 156 and shutdown 168. Every other named field inLibreSslmatches too, so all yourstatic_asserts agree with the compiled headers.SSLand itsssl_internal_stbytes into a buffer, and called your 7 exports from the builtlibSceLibreSsl.prxnext to the 2.5.4 getters. The states were a freshSSL_new, a client mid-handshake on memory BIOs (wbio swapped for the buffering BIO,SSL_READING, verify 20, both shutdown bits) and a TLS 1.1 server sharing one BIO (0x0302, verify -1, received shutdown). All 21 results are identical.libressl-v2.5.4tag, that neither struct has#if-guarded members, and that 338 throwing stubs remain inExport.cpp, which matches the new count.Approving. Not checked: console behaviour, Windows, and a title, since nothing creates an
SSLin this module yet, as the debt entry says.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T08:59:34Z.
Review: DISMISSED
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.Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-04T14:52:02Z.
Review: APPROVED
@alvaroelpob thanks for the invite. The seven getters read the right fields, and the one offset I couldn't confirm in my earlier comment now checks out too.
Firmware: I ran firmware 13.42's
system/common/lib/libSceLibreSsl.sprxversions ofSSL_wantandSSL_get_shutdownagain under an emulator, with imports stubbed, not measured on a console. Every 4-byte word of theSSLand of the object its pointer at +0xe0 names held its own offset.SSL_wantreturned the word at +0x9c (156) of that object andSSL_get_shutdownthe word at +0xa8 (168). Those matchoffsetof(LibreSslSslInternal, rwstate)andshutdowninSsl.cpp. The other five offsets matched in the earlier run. The two sizes still aren't touched by these calls.What I ran: head
2b8a0d5d5dmerged ontomainb11c7bf84f(merge2ec9ac0bc0), Windows 11, WinLibs GCC, Release,BUILD_TESTING=ON:guest_libressl_sslandpublic_headers: 2 of 2 pass.SSL_wantreturningshutdowninstead ofrwstateinSsl.cpp,guest_libressl_sslfails. A plain negative control doesn't apply: the functions live insrc/Ssl.cpp, a file this PR adds.check_conventions.py --base upstream/mainpasses.pr_overlap.py --branch: #11143 implements the same seven exports in the same new files, but it is stacked on this PR and saysDepends on: #10481, as #15278 does. #12729 and #12730 stack on #11143. The other overlaps are the sharedCMakeLists.txt,Export.cpp,Api.hppand debt-file lines that most libSceLibreSsl PRs touch.Two small things, neither blocking:
Depends onstill lists #9446 and #9571, which are merged, and six open PRs (#10395, #10418, #10448, #10450, #10477, #10478). This head merges ontomainand passes without them (runs above). I haven't checked each one, but the open six look like ordering on the shared lines rather than code this PR needs. If that's so, could the line saynone? Otherwise it holds this PR behind them.Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-05T17:57:39Z.
Review: APPROVED
@alvaroelpob re-approving at
593267d064, after the merge ofmain.What changed since my approval at
2b8a0d5d5d:core/libs/prx/libSceLibreSsl/src/Ssl.cppandcore/libs/tests/GuestLibreSslSsl.cppare byte-identical between the two heads (git diff --statis empty for both). The new head adds a merge ofmain(593267d064).What I ran: this head merged onto
mainfc23faa40a(merge55c027a4a4, clean), Windows 11 Pro 10.0.26300, WinLibs GCC, Release:guest_libressl_sslandpublic_headerspass (2 of 2);SSL_versionreturningversion + 1(the pattern matched once):guest_libressl_sslfails withLibreSSL SSL check failed at line 90.Overlap (
tools/pr_overlap.py --branchon this head): no overlap with open pull requests.AI-assisted: yes (Claude Code)