feat(libSceLibreSsl3): implement X509_STORE_CTX_init #19063
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/19063"
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 MatteoSid on 2026-11-12T18:20:26Z.
What
Implements
X509_STORE_CTX_init(NIDPYwVp6yeFp0) in libSceLibreSsl3, following LibreSSL 4.0.0'sX509_STORE_CTX_initand theX509_VERIFY_PARAM_new/inherit/lookupit calls. It uses the layouts this module already shares with libSceLibreSsl: the 240-byte context ofX509_STORE_CTX_new, the store ofX509_STORE_newand its verify parameters.errortoX509_V_ERR_INVALID_CALL(65), and stores the store, leaf and untrusted stack;verifyandverify_cbcome from the store when set, otherwise from the defaults;get_issuerandcheck_issuedalways get the defaults, as in 4.0.0. The other callback slots stay null;defaultentry (depth 100,X509_V_FLAG_TRUSTED_FIRST). Without a store it setsX509_VP_FLAG_DEFAULT | X509_VP_FLAG_ONCEfirst. Inheritance handles theDEFAULT,OVERWRITE,RESET_FLAGS,LOCKEDandONCEflags, the check-time rule, and copies of purpose, trust, depth, flags, host flags, host names, e-mail and IP address into new guest-heap allocations;X509ERR_R_MALLOC_FAILUREand returns 0. The parameters stay attached, as upstream, forX509_STORE_CTX_freeto release.X509_STORE_CTX_freenow releases owned parameters (noparent), including the host, peer name, e-mail and IP data. Before, it threw on them, which would have made every initialised context throw on free.The default
verify_cbis LibreSSL'snull_callback, which returnsok.internal_verify,X509_STORE_CTX_get1_issuerandcheck_issuedare internal functions that throw throughNotImplemented_nid_no_patchwhen called, the same way libSceLibreSsl'sX509_STOREobject comparator and file lookup do. Nothing in either module calls them yet, becauseX509_verify_certis a stub. Extra data stays libSceLibreSsl's null stack, which the forwardedX509_STORE_CTX_get_ex_datareads. No export can register a context-class constructor:SSL_get_ex_data_X509_STORE_CTX_idxregisters none.X509_VERIFY_PARAM_add0_tableis not exported, sodefaultis the only parameter table.Gaps, in a new debt entry: the default callbacks above; inheriting store policies throws (no
ASN1_OBJECTdeep copy); the 2.5.4 parameter layout keeps a separate identity allocation and has nopoisonedflag; errors go to the libSceLibreSsl queue without file or line. The existingX509_STORE_CTX_*entry now describes the new behaviour offree.X509StoreContext.cppfollowsx509_vfy.candx509_vpm.c, so it starts with both notices.Tested
Linux (Ubuntu 24.04 container, GCC 13.3), configured with
-DBUILD_TESTING=ON, Release, on headc03bf828ecbased onmain949ac1ffbf. I built every LibreSSL test target and the patched.prxfiles.ctest -R 'libressl|libre_ssl|crypto_memcmp|public_headers'passes all 213 tests.Windows: JJenkx ran
guest_libressl3_x509_store_contexton headc03bf828ecmerged ontomain(Windows 11, WinLibs GCC 15.2 UCRT, Release); it passes in 3 of 3 runs, none skipped (comment).guest_libressl3_x509_store_contextnow also checks:X509_STORE_newwith null leaf and untrusted, on a context filled with0xA5: every context field,verify_cbreturning itsok,X509_STORE_CTX_get_error65, nullX509_STORE_CTX_get_ex_data, parameters distinct from the store's with depth 100, flags0x8000, no inheritance flags and an empty identity, the store's reference count and parameters unchanged, nothing queued. The context allocates exactly the parameters and their identity, andfreereleases them along with a host and IP set on them afterwards;verifyandverify_cbcopied one at a time, and the other store callbacks ignored;USE_CHECK_TIMEthe default check time wins.LOCKEDskips the store, andOVERWRITEcopies everything;OVERWRITEwithout an e-mail, or with an e-mail but no IP; an IP of 3 or 0 bytes; an empty e-mail; an e-mail with a NUL inside its length. Each one returns 0, queues exactly0x0bfff041, keeps the context fields set, and leaks nothing;freeleaves no allocation.The old
freetest that set an ownedparamto a non-parameter marker is removed. That case now reads the parameters.All 24 mutations make the test fail (run before the last rebase, which changed no file of this PR): no error 65, no zeroing, either store callback ignored,
verify_cbreturning 1, a reused default, initial depth not -1, the default table skipped,ONCE/LOCKED/OVERWRITEignored, depth always copied, check time always copied, host flags skipped, hosts shared rather than copied, NUL-in-e-mail or empty e-mail accepted, IP length unchecked, e-mail skipped, no error queued, either failure ignored, owned parameters or their hosts leaked.nm -Don the patchedlibSceLibreSsl3.prxlistsPYwVp6yeFp0.tools/check_conventions.py --base origin/mainpasses.tools/pr_overlap.py --branchfinds no overlap with the open PRs it could compare, including #18946 and #19033. I checked the 15 that conflict withmainby hand (#12315, #14212, #14465, #15163, #15737, #16589, #16654, #16689, #16980, #16981, #17528, #17621, #17622, #17626, #18284). None of them changesX509_STORE_CTX_init,X509StoreContext.cppor theX509_STORE_CTXdebt entry. #12315 only has the old stub declaration as context. No title tested.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 PrivacyOnion on 2026-11-12T18:31:33Z.
Review: CHANGES_REQUESTED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
c03bf828ec:tools/check_conventions.pypassed;git diff --checkclean.guest_libressl3_x509_store_context_testsbuilt cleanly.guest_libressl3_x509_store_context):core/libs/prx/libSceLibreSsl3/Export.cpp,core/libs/prx/libSceLibreSsl3/include/Api.hpp,core/libs/prx/libSceLibreSsl3/src/X509StoreContext.cppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Requesting changes for the points above.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-12T19:16:10Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
c03bf828ecb774e0f62443066bd6eda4561d316e, basemain. No merged-preview check was run.Results
defaultParamcteston 213 testscheck_conventions.pyFindings
Blocking
None.
Non-blocking
core/libs/prx/libSceLibreSsl3/src/X509StoreContext.cpp:170:NewVerifyParam(line 188 forFreeVerifyParam, line 240 forInherit) repeats helpers thatcore/libs/prx/libSceLibreSsl/src/X509Store.cpp:137already has for the same struct. I did not check whether the two modules can share them.core/libs/prx/libSceLibreSsl3/src/X509StoreContext.cpp:288: thememsetinX509_STORE_CTX_initdrops anyparamalready attached to the context, so a second init on the same context leaks the first parameter set and its identity. Smallest fix: release an attachedparambefore thememset, or state in the debt entry that init must only run on a fresh context. I did not check upstream for this.Not verified
ctestrun, the 24 mutation runs andcheck_conventions.py. These come from the description and were not reproduced.int_x509_param_set1fails on a null e-mail or IP underOVERWRITE, as the failure tests assume. Not checked against upstream.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-13T03:12:31Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
2010cd66e5:tools/check_conventions.pypassed;git diff --checkclean.guest_libressl3_x509_store_context_testsbuilt cleanly.guest_libressl3_x509_store_context):core/libs/prx/libSceLibreSsl3/Export.cpp,core/libs/prx/libSceLibreSsl3/include/Api.hpp,core/libs/prx/libSceLibreSsl3/src/X509StoreContext.cppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Looks Good To Me