feat(libSceLibreSsl): implement SSL_get_session, SSL_get_current_cipher, SSL_get_certificate and SSL_get_privatekey #10482
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10482"
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:58:08Z.
What
Implements
SSL_get_session,SSL_get_current_cipher,SSL_get_certificateandSSL_get_privatekeyin 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.h,ssl_lib.candssl_sess.c:SSL_SESSION* SSL_get_session(const SSL*)sessionconst SSL_CIPHER* SSL_get_current_cipher(const SSL*)session->cipher, or null without a sessionX509* SSL_get_certificate(const SSL*)cert->key->x509, or null without acertEVP_PKEY* SSL_get_privatekey(SSL*)cert->key->privatekey, or null without acertThe layouts are 232 bytes for
SSL(certat 80,sessionat 128), 232 forSSL_SESSION(cipherat 168), 256 forCERT(keyat 0) and 24 forCERT_PKEY(x509,privatekey,digest). They were checked withstatic_asserts and againstoffsetoffrom the 2.5.4 headers compiled on x86-64. LibreSSL dereferences the connection, and acertwithout a currentkey, without checking them, so those throw. No export of this module creates a connection yet, so for now only connections built by the caller reach these functions.#10481 reads other fields of the same
SSLlayout. This PR uses its own file and struct names, so the two don't overlap.The debt entry records the source and what is unverified, and the pending-export count drops from 357 to 353.
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_ssl_sessiontest andcheck_conventions.pyrun on its own.guest_libressl_ssl_sessiontest.SSL_get_sessionreturns null and then the session.SSL_get_current_cipherreturns null without a session and for a session without a cipher, then the cipher.SSL_get_certificateandSSL_get_privatekeyreturn null without acert, throw for acertwith a nullkey, return null for a current key slot that is empty while other slots are filled, and return the field of the slotkeypoints to. A null connection throws in all four.ctest -j16at the last commit: 2005/2006 pass.agc_driver_multisample_retirementfails the same way onmainon this machine.main1e740a23a3(after #9033), head 6019901cd3: 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 22e3528d21, 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. 22e3528d21 (refactor(libSceLibreSsl): declare the SSL session 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 3490c6466f, 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 cb01c796d7, 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 ef10d1206e) 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 b085649461, 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 5a2955849a, 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), head 2b437c81d1, 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 286 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 b42ed63c0b, 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 257 stubs left inExport.cpp. Full build andctest -j16: 3538/3538 pass.check_conventions.py --base upstream/mainpasses.main4f41f4c375, head 2d52a50d44, 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. 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:59:51Z.
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:58:50Z.
Review: APPROVED
Reviewed the four accessors against the cited LibreSSL 2.5.4 structures. The current session, cipher and key fields/offsets match the static assertions; getters handle absent session/cert as null and the current-key path as described. The head merges cleanly with current upstream main, and conventions/diff checks pass. I compiled and ran
GuestLibreSslSslSession.cppwithSslSession.cppdirectly using GCC 12.2.0; it passed. The full build/test results are author-reported; hosted product jobs are skipped.Imported from boykopovar/AnyPS5. Originally posted by ahmadmuj on 2026-10-25T18:49:17Z.
Review: APPROVED
Reviewed head
57dc6f7977be9f2e4d3b559ba5814b32f163bf9b, merged locally onto maina7a2eece499ef8925c93765dbbcc9f4d9461a2f0. The merge conflicts only in the debt file's first lines (the count next to main's updated Digest line); I took main's lines with 341 to build. Main has since moved to58c9977e3b, which only adds an unrelated NpTrophy test, same conflict.What I ran, Linux x86-64, GCC 13.3, Release:
guest_libressl_*tests pass, includingguest_libressl_ssl_session.check_conventions.py --base origin/main, theconventions_*/pr_overlap*ctests (47) andpublic_headers*(65) pass.cert->keyreturning null instead of throwing,SSL_get_certificatereturningprivatekey, the cipher getter always returning null, and a nullsslnot throwing each fail the test (lines 86, 93, 74, 58). Restored, it passes.offsetofprobe against the compiled LibreSSL 2.5.4ssl.handssl/ssl_locl.h:SSL232 (cert 80, session 128),SSL_SESSION232 (cipher 168),CERT256 (key 0),CERT_PKEY24 (x509 0, privatekey 8). All yourstatic_asserts agree.SslSession.cppas is and linked it with the 2.5.4libssl.a. Then I called your 4 getters and the real ones on 13 real connection states, on both the liveSSLand a 232-byte copy of it. The states included a freshSSL_new, RSA cert+key, a session with and without a cipher, RSA then EC (sokeyis slot 5 whilepkeys[0]still holds RSA), an EC cert from theSSL_CTX,SSL_set_SSL_CTX,SSL_dupandset_session(NULL). All 52 results are identical.ssl_lib.candssl_sess.c. The two throws are where 2.5.4 dereferences without a check.Two small things, neither blocks:
TestCertdoesn't match the realcert_st. In 2.5.4,pkeysstarts at 80 and has 7 slots (SSL_PKEY_NUMis 7, aftervalid, the masks and the DH/ECDH fields). The test puts 8 slots at offset 8, and it reaches 256 only by coincidence. The getters only followkey, so the results are unaffected, but the test describes a layout that doesn't exist. Something likeTestCertKey* key; unsigned char beforePkeys[72]; TestCertKey pkeys[7]; int references;withstatic_assert(offsetof(TestCert, pkeys) == 80)would match.LibreSslSessionConnectionand #10481'sLibreSslare two views of the samessl_st, with the same size and the same cert and session offsets. You already note that in the body. Like on #10485, whichever lands second could switch to the other's type, soApi.hppkeeps a singleSSL.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:33Z.
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.