Repository navigation
feat(libSceLibreSsl): implement SSL_get_session, SSL_get_current_cipher, SSL_get_certificate and SSL_get_privatekey - #10482
Conversation
Progress report (151a2cb → a6ec924)📈 System libraries: 27.08% (+0.01%, +4 implemented functions) ✅ 4 implemented
Changed libraries (implemented exports)
|
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
0c5b52a to
6019901
Compare
MarcZX10
left a comment
There was a problem hiding this comment.
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.cpp with SslSession.cpp directly using GCC 12.2.0; it passed. The full build/test results are author-reported; hosted product jobs are skipped.
6019901 to
22e3528
Compare
|
Rebased on |
ahmadmuj
left a comment
There was a problem hiding this comment.
Reviewed head 57dc6f7977be9f2e4d3b559ba5814b32f163bf9b, merged locally onto main a7a2eece499ef8925c93765dbbcc9f4d9461a2f0. 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 to 58c9977e3b, which only adds an unrelated NpTrophy test, same conflict.
What I ran, Linux x86-64, GCC 13.3, Release:
- Built the libSceLibreSsl test targets on the merged tree: all 10
guest_libressl_*tests pass, includingguest_libressl_ssl_session.check_conventions.py --base origin/main, theconventions_*/pr_overlap*ctests (47) andpublic_headers*(65) pass. - Red controls: a null
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.- Differential: I compiled
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. - Null handling matches
ssl_lib.candssl_sess.c. The two throws are where 2.5.4 dereferences without a check.
Two small things, neither blocks:
- The test's
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 SSL in this module yet, as the debt entry says.
57dc6f7 to
1899090
Compare
|
Rebased on |
|
The layout matches firmware 13.42's
|
1899090 to
3490c64
Compare
2d52a50 to
25aeb6f
Compare
|
@MarcZX10 Rebased on |
25aeb6f to
7efb1fc
Compare
|
Hi @alvaroelpob, thanks for keeping this branch current. #10481 has now landed, and This branch adds a second view of the same object, Could you switch these four to |
|
@oneandonlydean Done in b190203: To pick up #10481 the branch is rebased on main d48f11a. That rebase replaces your merge of main (bcbce32), which brought no changes of its own beyond main and the branch. Rebasing put the pending-export count back to main's 170, so da87403 sets it to the 166 stubs left in |
bcbce32 to
b190203
Compare
b190203 to
6aa4750
Compare
|
@MarcZX10 Rebased on |
|
Hi @alvaroelpob, main moved on and #11553 removed the LibreSsl pending-exports count line your PR also edited, so I merged main into your branch and kept main's line. Nothing else changed. |
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=ONonmain379b1dc. 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.main1e740a2 (after feat(libSceLibreSsl): implement the low-level AES functions #9033), head 6019901: 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.maine7e3e9c, head 22e3528, to resolve the conflict from feat(libSceLibreSsl): implement the per-thread error queue #9529 on the sharedCMakeLists.txtand debt-file lines; both sides are kept and the count is 353 minus this PR's exports. 22e3528 (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 refactor(libs): add full export headers for libs #10706. Full build andctest -j16: 2202/2203 pass;agc_driver_multisample_retirementfails the same way on thatmain.check_conventions.py --base upstream/mainpasses.mainae7d592 (after feat(libSceLibreSsl): implement the OCSP status and reason strings #9949), head 3490c64, 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.main2dbe9b9 (after feat(libSceLibreSsl): return the measured version from SSLeay #9745, feat(libSceLibreSsl): implement TLS alert descriptions #9870 and fix(libSceLibreSsl): reject null strings in the ASN.1 accessors as invalid arguments #11111), head cb01c79, 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.main88795ed (after feat(libSceLibreSsl): implement the CRYPTO locking and thread id callbacks #10248; head ef10d12) 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.mainc7b4878 (after feat(libSceLibreSsl): implement sk_num, sk_value, sk_pop and sk_pop_free #10373, feat(libSceLibreSsl): implement UI_METHOD creation and its opener, writer, reader and closer accessors #10376 and feat(libSceLibreSsl): implement RSA_flags and RSA_size #10449), head b085649, 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.main474030e (after feat(libSceLibreSsl): implement OBJ_create and free added objects in OBJ_cleanup #13562), head 5a29558, 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.maincf79276 (after fix(libSceLibreSsl): preserve SHA-512 initialization buffers #13820), head 2b437c8, to resolve the conflict on the pending-export count in the debt file.mainstill says 292 although fix(libSceLibreSsl): preserve SHA-512 initialization buffers #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 feat(libSceLibreSsl): implement UI_get0_user_data, UI_get_string_type and UI_get_input_flags #10486 and passed on five reruns and a second full run).check_conventions.py --base upstream/mainpasses.main4939814 (after feat(libressl3): report OpenSSL version strings #9970, feat(libressl): implement X509 extension getters #10078 and feat(libSceLibreSsl): implement EVP_CIPHER_CTX_init, EVP_CIPHER_CTX_new and EVP_CIPHER_CTX_set_padding #10488), head b42ed63, 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.main4f41f4c, head 2d52a50, 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, andmain4f41f4c passes 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)