feat(libSceLibreSsl3): implement RSA component ownership setters #14992
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14992"
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 atharvjairath on 2026-11-02T08:31:30Z.
What
Calls to
RSA_set0_key,RSA_set0_factorsandRSA_set0_crt_paramsnow transfer BIGNUM ownership into the corresponding RSA fields. Supplying too few mandatory components returns zero before changing the object. Replacing an owned component clears its storage throughBN_clear_free. Borrowed static limb storage stays under its original owner’s control.The implementation uses the 152-byte RSA and 24-byte BIGNUM layouts. The parent library has BIGNUM constructors and destructors. Interoperation across its forwarding exports and these setters still needs verification. LibreSSL 4.0.0 RSA setters · BIGNUM disposal
An omitted component retains the existing field. A null RSA object or a negative owned limb capacity throws before mutation. Console ABI, malformed pointers and aliased ownership remain documented limits.
The source scanner classifies 23/276 bodies as implemented on main and 27/276 on this branch. The difference is the 4 exports above. The scanner classifies source bodies and does not measure firmware compatibility. The additional export inventory has 171 pending entries (161 named, 10 known only by NID).
Integration order is #14992 → #15031 → #15045 → #15119 → #15406. This branch is based directly on main
6d173c1a1978. Each branch keeps its own changes. The order allows the shared CMake registrations and debt counts to be reconciled after each merge.Tested
Validated head
bc7b197f78b9against main6d173c1a1978.7ad9749ed0preserved the exact branch and upstream diffs. Runtime results above are pinned to the tested base.Earlier ownership runs and negative controls are archived at their tested commits. The remaining lifetime gap is a forwarded parent constructor followed by the setter and destructor in the guest.
Both loader runs printed
RSA ownership: 144 matrix cases, 39790 checks, 847 cleared allocations, zero live allocations.Earlier validation on f7212289bbd0 and the historical commits cited below
Current refreshed head
f7212289bbd01fd608e290b6cfec264e8be236a7on frozen maind1ae628bc2f62459cce1e9872ba5632c938c71f2. Only debt documentation conflicted. Every original owned production/API/CMake/fixture addition and deletion is preserved; upstream ASN1_TIME_diff and all main unions remain intact. Prior reviews and CI are pinned to older heads below.-j1), 12/12 passed in 36.97s.d1ae628integration, with full dependency-input equality and hashes retained. They were not rebuilt separately for each of these four PRs. The separate signature integration ran 44 Linux and 14 focused Windows tests; those are not this PR’s suite counts. This refresh does not rerun the separate parent/error-string/packaged protocol-NID groups.These are focused module tests, not independent native Windows, full-product, packaged-module/NID, title/homebrew or physical-console validation. Known unrelated Wine limitations remain unresolved; no assertion, timeout, gate or runtime workaround changed. The default-off oracle was not enabled. Warnings remain. No new native CI result or current approval is inferred from older heads.
Historical native Windows CI job125279575645/run41443267437 audited on main
0278ca983148dbb9b8b54a267b2aeab0ce8aff37plus OLD head376db33f6d29241aa5cfdf6cb710bc1e7f5e8683: 1,962 Passed / 952 Skipped / zero Failed across 2,914 unique result rows, 147.19s; all 44 LibreSSL registrations including RSA passed. Separate full-build/runtime/skip-audit/graph steps were skipped. This is pinned native CI unit/runtime evidence, not a run or approval of the refreshed head. Original local Linux 40/40 and Windows PE 11/11 remain archived at 77bf/88e804. The earlier 45-minute cancellation is historical and was superseded by that successful old-head run.Receipts:
/private/tmp/anyps5-advance-20261103-0127/conflict-refresh/14992and the sharedvalidation-evidence.tar.gz,common-input-equality.json,heads-rebased.json,manual-shared-review.txt,peers-finaland reproducible harness/scripts. Previous local/native evidence remains in the linked Nov2 receipts with its original pins.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)Overlap report before the branch refresh was pushed
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.
main)docs/dev/debt/libSceLibreSsl3.mdL35, L215docs/dev/debt/libSceLibreSsl3.mdL35docs/dev/debt/libSceLibreSsl3.mdL35core/libs/prx/libSceLibreSsl3/AdditionalExports.cppL259-266core/libs/prx/libSceLibreSsl3/include/Api.hppL193-194docs/dev/debt/libSceLibreSsl3.mdL35, L215core/libs/prx/libSceLibreSsl3/AdditionalExports.cppL6-17core/libs/prx/libSceLibreSsl3/include/Api.hppL123-125docs/dev/debt/libSceLibreSsl3.mdL35, L215BN_clear_freeRSA_set0_crt_paramsRSA_set0_factorsRSA_set0_keycore/libs/prx/libSceLibreSsl3/src/RsaSetters.cppcore/libs/prx/libSceLibreSsl3/tests/RsaSetters.cppdocs/dev/debt/libSceLibreSsl3.mdL35, L75-76core/libs/prx/libSceLibreSsl3/AdditionalExports.cppL648-655core/libs/prx/libSceLibreSsl3/include/Api.hppL288-289docs/dev/debt/libSceLibreSsl3.mdL35, L75-76docs/dev/debt/libSceLibreSsl3.mdL35, L215docs/dev/debt/libSceLibreSsl3.mdL35docs/dev/debt/libSceLibreSsl3.mdL35docs/dev/debt/libSceLibreSsl3.mdL35docs/dev/debt/libSceLibreSsl3.mdL35docs/dev/debt/libSceLibreSsl3.mdL35docs/dev/debt/libSceLibreSsl3.mdL35docs/dev/debt/libSceLibreSsl3.mdL35docs/dev/debt/libSceLibreSsl3.mdL35docs/dev/debt/libSceLibreSsl3.mdL35core/libs/prx/libSceLibreSsl3/AdditionalExports.cppL14-21core/libs/prx/libSceLibreSsl3/include/Api.hppL125-126docs/dev/debt/libSceLibreSsl3.mdL35docs/dev/debt/libSceLibreSsl3.mdL35docs/dev/debt/libSceLibreSsl3.mdL35docs/dev/debt/libSceLibreSsl3.mdL35docs/dev/debt/libSceLibreSsl3.mdL35, L76-77docs/dev/debt/libSceLibreSsl3.mdL35Some 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.
core/libs/prx/libSceLibreSsl3/CMakeLists.txtcore/libs/prx/libSceLibreSsl3/include/Api.hppdocs/dev/debt/libSceLibreSsl3.mdcore/libs/prx/libSceLibreSsl3/CMakeLists.txtcore/libs/prx/libSceLibreSsl3/include/Api.hppdocs/dev/debt/libSceLibreSsl3.mdcore/libs/prx/libSceLibreSsl3/CMakeLists.txtcore/libs/prx/libSceLibreSsl3/include/Api.hppdocs/dev/debt/libSceLibreSsl3.mdcore/libs/prx/libSceLibreSsl3/CMakeLists.txtcore/libs/prx/libSceLibreSsl3/include/Api.hppdocs/dev/debt/libSceLibreSsl3.mdcore/libs/prx/libSceLibreSsl3/CMakeLists.txtcore/libs/prx/libSceLibreSsl3/include/Api.hppdocs/dev/debt/libSceLibreSsl3.mdcore/libs/prx/libSceLibreSsl3/CMakeLists.txtcore/libs/prx/libSceLibreSsl3/include/Api.hppdocs/dev/debt/libSceLibreSsl3.mdcore/libs/prx/libSceLibreSsl3/CMakeLists.txtdocs/dev/debt/libSceLibreSsl3.mdcore/libs/prx/libSceLibreSsl3/CMakeLists.txtcore/libs/prx/libSceLibreSsl3/include/Api.hppdocs/dev/debt/libSceLibreSsl3.mdcore/libs/prx/libSceLibreSsl3/CMakeLists.txtcore/libs/prx/libSceLibreSsl3/include/Api.hppcore/libs/prx/libSceLibreSsl3/include/Key.hppdocs/dev/debt/libSceLibreSsl3.mdcore/libs/prx/libSceLibreSsl3/include/Api.hppdocs/dev/debt/libSceLibreSsl3.mdcore/libs/prx/libSceLibreSsl3/AdditionalExports.cppcore/libs/prx/libSceLibreSsl3/CMakeLists.txtcore/libs/prx/libSceLibreSsl3/include/Api.hppdocs/dev/debt/libSceLibreSsl3.mddocs/dev/debt/libSceLibreSsl3.mdcore/libs/prx/libSceLibreSsl3/AdditionalExports.cppcore/libs/prx/libSceLibreSsl3/include/Api.hppdocs/dev/debt/libSceLibreSsl3.mdcore/libs/prx/libSceLibreSsl3/AdditionalExports.cppcore/libs/prx/libSceLibreSsl3/CMakeLists.txtcore/libs/prx/libSceLibreSsl3/include/Api.hppdocs/dev/debt/libSceLibreSsl3.mdcore/libs/prx/libSceLibreSsl3/AdditionalExports.cppcore/libs/prx/libSceLibreSsl3/CMakeLists.txtcore/libs/prx/libSceLibreSsl3/include/Api.hppcore/libs/prx/libSceLibreSsl3/include/Key.hppcore/libs/prx/libSceLibreSsl3/src/RsaSetters.cppcore/libs/prx/libSceLibreSsl3/tests/RsaSetters.cppdocs/dev/debt/libSceLibreSsl3.mdcore/libs/prx/libSceLibreSsl3/AdditionalExports.cppcore/libs/prx/libSceLibreSsl3/CMakeLists.txtcore/libs/prx/libSceLibreSsl3/include/Api.hppdocs/dev/debt/libSceLibreSsl3.mdcore/libs/prx/libSceLibreSsl3/AdditionalExports.cppcore/libs/prx/libSceLibreSsl3/CMakeLists.txtcore/libs/prx/libSceLibreSsl3/include/Api.hppdocs/dev/debt/libSceLibreSsl3.mdcore/libs/prx/libSceLibreSsl3/AdditionalExports.cppcore/libs/prx/libSceLibreSsl3/CMakeLists.txtcore/libs/prx/libSceLibreSsl3/include/Api.hppdocs/dev/debt/libSceLibreSsl3.mdcore/libs/prx/libSceLibreSsl3/include/Api.hppdocs/dev/debt/libSceLibreSsl3.mdcore/libs/prx/libSceLibreSsl3/AdditionalExports.cppcore/libs/prx/libSceLibreSsl3/CMakeLists.txtcore/libs/prx/libSceLibreSsl3/include/Api.hppdocs/dev/debt/libSceLibreSsl3.mdcore/libs/prx/libSceLibreSsl3/AdditionalExports.cppcore/libs/prx/libSceLibreSsl3/CMakeLists.txtcore/libs/prx/libSceLibreSsl3/include/Api.hppdocs/dev/debt/libSceLibreSsl3.mdcore/libs/prx/libSceLibreSsl3/CMakeLists.txtcore/libs/prx/libSceLibreSsl3/include/Api.hppdocs/dev/debt/libSceLibreSsl3.mdcore/libs/prx/libSceLibreSsl3/CMakeLists.txtdocs/dev/debt/libSceLibreSsl3.mdcore/libs/prx/libSceLibreSsl3/AdditionalExports.cppcore/libs/prx/libSceLibreSsl3/CMakeLists.txtcore/libs/prx/libSceLibreSsl3/include/Api.hppdocs/dev/debt/libSceLibreSsl3.mdcore/libs/prx/libSceLibreSsl3/CMakeLists.txtcore/libs/prx/libSceLibreSsl3/include/Api.hppdocs/dev/debt/libSceLibreSsl3.mdcore/libs/prx/libSceLibreSsl3/AdditionalExports.cppcore/libs/prx/libSceLibreSsl3/CMakeLists.txtcore/libs/prx/libSceLibreSsl3/include/Api.hppdocs/dev/debt/libSceLibreSsl3.mdcore/libs/prx/libSceLibreSsl3/AdditionalExports.cppcore/libs/prx/libSceLibreSsl3/CMakeLists.txtcore/libs/prx/libSceLibreSsl3/include/Api.hppdocs/dev/debt/libSceLibreSsl3.mdcore/libs/prx/libSceLibreSsl3/AdditionalExports.cppcore/libs/prx/libSceLibreSsl3/CMakeLists.txtcore/libs/prx/libSceLibreSsl3/include/Api.hppdocs/dev/debt/libSceLibreSsl3.mdcore/libs/prx/libSceLibreSsl3/AdditionalExports.cppcore/libs/prx/libSceLibreSsl3/CMakeLists.txtcore/libs/prx/libSceLibreSsl3/include/Api.hppdocs/dev/debt/libSceLibreSsl3.mdcore/libs/prx/libSceLibreSsl3/AdditionalExports.cppcore/libs/prx/libSceLibreSsl3/CMakeLists.txtcore/libs/prx/libSceLibreSsl3/include/Api.hppdocs/dev/debt/libSceLibreSsl3.mdcore/libs/prx/libSceLibreSsl3/CMakeLists.txtImported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-02T11:45:10Z.
Review: APPROVED
Looks right against the cited LibreSSL 4.0.0 source (
ce488b78).RSA_set0_key,RSA_set0_factorsandRSA_set0_crt_paramsreturn 0 before any change when a required component is missing on both sides. Otherwise they free each replaced component and store the supplied one, keeping omitted ones, exactly as inrsa_lib.c.BN_clear_freeisBN_free. It frees the limbs (freezero(d, dmax * 8)) unlessBN_FLG_STATIC_DATA(2) is set, then wipes the struct and frees it only whenBN_FLG_MALLOCED(1) is set. YourAllocated/StaticDatavalues and the 24-byte{d, top, dmax, neg, flags}layout match.Tested on Windows 11, WinLibs GCC 15.2.0, Release, with head
77bf9cdd90merged ontomain:guest_libressl3_rsa_settersandpublic_headerspass. Onmainall four exports throw, andRsaSetters.cppis new, so the control is the throwing stubs.Non-blocking:
free_nid_postfix, but libSceLibreSsl3'sBN_new/BN_freeforward to the parent libSceLibreSsl (ParentExports.cpp), where both still throw. Whatever later implements the parent'sBN_newhas to allocate the struct and limbs from the same guest heap, withBN_FLG_MALLOCEDset, or these setters will free foreign memory. One line in the debt entry would keep that coupling visible.BN_freedoesn't wipe the limbs, which isn't observable), so the contract holds either way, but naming the firmware's actual LibreSSL version, if known, would help.