feat(libSceLibreSsl): implement the X509_STORE_CTX error, depth, current certificate and chain accessors #10447
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10447"
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-24T00:51:55Z.
What
Implements
X509_STORE_CTX_get_error,X509_STORE_CTX_set_error,X509_STORE_CTX_get_error_depth,X509_STORE_CTX_get_current_certandX509_STORE_CTX_get_chainin libSceLibreSsl, which threw and were declared without parameters.The module is LibreSSL 2.5.4 (firmware 13.40 measurements in #8981). Signatures, the
X509_STORE_CTXlayout and the results follow that release'sx509_vfy.handx509_vfy.c:int X509_STORE_CTX_get_error(X509_STORE_CTX*)errorvoid X509_STORE_CTX_set_error(X509_STORE_CTX*, int)errorand touches nothing elseint X509_STORE_CTX_get_error_depth(X509_STORE_CTX*)error_depthX509* X509_STORE_CTX_get_current_cert(X509_STORE_CTX*)current_certSTACK_OF(X509)* X509_STORE_CTX_get_chain(X509_STORE_CTX*)chain, without copying or taking a referenceThe struct is 240 bytes on LP64 (
chainat 160,error_depthat 180,errorat 184,current_certat 192,ex_dataat 232; 2.5.4'sCRYPTO_EX_DATAholds only the stack pointer).static_asserts check it. LibreSSL dereferences the context without checking it, so a null context throws. No export of this module creates or fills a context yet, so for now only contexts the caller builds reach these functions.The debt entry records the source and what is unverified, and the pending-export count drops from 357 to 352.
Tested
Ubuntu 26.04 (WSL2, kernel 6.18), GCC 15.2.0, Release, full build with
BUILD_TESTING=ONonmaine2b9700a9. There is one commit per function, in the orderget_error,set_error,get_error_depth,get_current_cert,get_chain. Each commit adds that function with its test block and debt update, and each was built and itsguest_libressl_x509_store_contexttest andcheck_conventions.pyrun on its own.guest_libressl_x509_store_contexttest: on a 240-byte buffer filled with 0xAA, each getter reads its own offset;set_errorwrites only the 4 bytes at 184 and doesn't changeerror_depth; the pointer getters return null and non-null values as stored; a null context throws for all five. Onmainthe first call throws.ctest -j16at the last commit: 2003/2004 pass.agc_driver_multisample_retirementfails the same way onmainon this machine. Onmain,agc_driver_sgpr_pattern_fill_keysalso failed once under-j16and passes on its own.main1e740a23a3(after #9033), head f59ce38328: 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 835eb4d04d, 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. 835eb4d04d (refactor(libSceLibreSsl): declare the X509_STORE_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 9d3827f68f, 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 3d1542748e, 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.mainc7b4878fa8(after #10373, #10376 and #10449), headd0927e2302, 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.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-24T00:52:05Z.
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-24T01:37:03Z.
Review: APPROVED
Reviewed exact head 0a5955af46bea727c08a0bb1f436f7d8daed4282. The 240-byte X509_STORE_CTX layout and offsets match the pinned LibreSSL 2.5.4 x509_vfy.h; x509_vfy.c confirms these accessors read or write only the named fields and return the stored chain/current certificate pointers without changing ownership. I found no open PR for the same five exports.
I compiled the exact changed implementation and supplied test with GCC 12.2, C++20, -Wall -Wextra -Werror; the focused test passed. This direct build used a temporary NotImplemented_nid_no_patch shim and does not validate full project linkage or exception integration. Exact-head conventions passed. Hosted eligibility, conventions, intake, labels and report checks pass; full Linux/Windows product jobs are skipped under repository policy. The PR declares its LibreSSL dependency ordering. No blocking behavior issue found.
Imported from boykopovar/AnyPS5. Originally posted by ahmadmuj on 2026-10-25T18:55:06Z.
Review: APPROVED
Reviewed head 0f8367b2 (base main
6e775f45). Ubuntu 24.04, GCC 13.3, Release, real build with no shim.What I ran:
libSceLibreSsl.prxand all 10guest_libressl_*tests; all pass.check_conventions.pypasses. I got the same result on the previous head fd3ea94 merged onto maina7a2eece. The PR's code is identical between the two heads; only the debt-file context moved.offsetoffor all 33 members of 2.5.4'sx509_store_ctx_stand ofLibreSslX509StoreContext. All match, size 240. That fits BunnyFl's 13.42 offsets.X509_verify_certin 4 cases: missing issuer, valid chain,set_error(23)after a failure, expired CA. I dumped the 240-byte ctx each time and fed the bytes to this PR's exports from the built prx. error, depth, current_cert and chain match 2.5.4's own getters in all 4. Example: in the expired-CA case both give error 10, depth 1, and current_cert = the CA, not the leaf.set_erroron those dumps changes only bytes 184-187. With error and error_depth swapped in a probe copy of the struct, 3 of the 4 cases differ, so the comparison isn't vacuous.error, set_error writingerrorDepth, get_chain readingcurrentCert. Each one fails the test (lines 80, 67, 105).Optional nit:
TestGetErrorDepthskips theOnlyChangedcheck that the other blocks do.Heads up: #9949 merged after your rebase, so this conflicts again in
CMakeLists.txt(theadd_librarysource list and the test block) and in the debt file.Not checked: Windows, the console (I have no dumps).