feat(libSceLibreSsl3): implement the RSA, DH and DSA get0 key and parameter accessors #10490
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10490"
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-24T03:16:46Z.
What
Implements
RSA_get0_key,DH_get0_pqg,DH_get0_key,DSA_get0_pqgandDSA_get0_keyin libSceLibreSsl3, which threw and were declared without parameters.The module is LibreSSL 4.0.0 (firmware 13.40 measurements in #8981). Signatures, layouts and results follow that release's
rsa_local.h,rsa_lib.c,dh_local.h,dh_lib.c,dsa_local.handdsa_lib.c. Each writes the requested fields through the non-null output pointers and leaves the others alone:void RSA_get0_key(const RSA*, const BIGNUM** n, const BIGNUM** e, const BIGNUM** d)n(24),e(32),d(40)void DH_get0_pqg(const DH*, const BIGNUM** p, const BIGNUM** q, const BIGNUM** g)p(8),q(64),g(16)void DH_get0_key(const DH*, const BIGNUM** pub_key, const BIGNUM** priv_key)pub_key(32),priv_key(40)void DSA_get0_pqg(const DSA*, const BIGNUM** p, const BIGNUM** q, const BIGNUM** g)p(16),q(24),g(32)void DSA_get0_key(const DSA*, const BIGNUM** pub_key, const BIGNUM** priv_key)pub_key(40),priv_key(48)The structs are 152, 128 and 112 bytes. The offsets were checked with
static_asserts and againstoffsetoffrom the 4.0.0 headers compiled on x86-64; the 4.0.0RSAhas noenginefield, unlike the 2.5.4 one in libSceLibreSsl. LibreSSL reads the key only for the outputs requested: with every output null the call returns without reading it, and a null key throws only when an output is requested, where LibreSSL would dereference it. This library doesn't list the module's ownRSA_new,d2i_RSA_PUBKEYand the other key-creating exports yet, so on Linux a title's import of them binds to libSceLibreSsl, whoseRSAandDSAuse the 2.5.4 layout; the debt entry records it. On firmware 13.42 the module makes its own keys with these 4.0.0 offsets.The debt entry records the source and what is unverified. The pending-export count drops from 84 to 79, and the five names join the exclusion list.
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_libressl3_key_componentstest andcheck_conventions.pyrun on its own.guest_libressl3_key_componentstest, onLibreSsl3Rsa,LibreSsl3DhandLibreSsl3Dsaobjects whose every pointer field holds a distinct address. Each accessor returns exactly its slots, leaves outputs passed as null and untouched outputs alone, returns null for fields that are null, returns without reading a null key when every output is null, and throws for a null key when any output is requested.ctest -j16at the last commit: 2005/2006 pass.agc_driver_multisample_retirementfails the same way onmainon this machine.maine7e3e9c198, head 476c2c67c6. The branch still merged cleanly, but after #10706public_headersfails on the merge: the exports kept their(void)stubs ininclude/Api.hppand the test redeclared them. 476c2c67c6 (refactor(libSceLibreSsl3): declare the key component exports in the public header) puts the real signatures and their structs inlibSceLibreSsl3/include/Api.hppand drops the test's redeclarations. Full build andctest -j16: 2202/2203 pass;agc_driver_multisample_retirementfails the same way on thatmain.check_conventions.py --base upstream/mainpasses.main6e775f452a, head dfb0b57aa4, to resolve the conflicts withmainon the sharedCMakeLists.txtand debt-file lines; both sides are kept and the count is 84 minus this PR's exports. Review fixes cc8bfe4e93, 1a7514f850 and dfb0b57aa4 make a call with every output null return without reading the key, build the tests on the public structs and update the debt entry;guest_libressl3_key_componentspasses. Full build andctest -j16: 2268/2269 pass;agc_driver_multisample_retirementfails the same way on thatmain.check_conventions.py --base upstream/mainpasses.ctest -j16onmain6e775f452a: 2268/2269 pass;agc_driver_multisample_retirementfails the same way on thatmain.check_conventions.py --base upstream/mainpasses.main74acfad65b(after #10948), head 4d500b4753, to resolve the conflicts withmainon the sharedCMakeLists.txtand debt-file lines; both sides are kept and the count is 83 minus this PR's exports. Full build andctest -j16: 2431/2432 pass;agc_driver_multisample_retirementfails the same way on thatmain.check_conventions.py --base upstream/mainpasses.mainf2d874c1fd(after #10948, #13267, #13831, #13897 and #14171), head 2e1db140dc, to resolve the conflicts on the pending-export line of the debt file: the count and the exclusion list keepmain's names and add this PR's, and the count, 76, matches the stubs inExport.cpp. In the commit that declares theRSA_new,d2i_RSA_PUBKEY,EVP_PKEY_get1_RSAandPEM_read_RSAPrivateKeystubs,Export.cppandinclude/Api.hppconflicted with #13897 next toEVP_PKEY_get0_*: it keepsmain's implementedEVP_PKEY_get0_*and adds only theEVP_PKEY_get1_RSAstub, as before.libressl3_import_bindingpasses. Full build andctest -j16: 3158/3158 pass.check_conventions.py --base upstream/mainpasses.main4939814d79(after #9535 and #9970), head 873d832a64, to resolve the conflicts on the sharedExport.cpp,Api.hppand debt-file lines; both sides are kept.main'sERR_load_crypto_strings(#9535) is kept next to theDSA_get0_pqgandDSA_get0_keystubs these commits remove, and its typedOpenSSL_version(#9970) next to the addedPEM_read_RSAPrivateKeydeclaration.mainsays 76 pending exports with 74 stubs left, so the count is set to the 73 stubs left inExport.cpp. Full build andctest -j16: 3539/3539 pass.check_conventions.py --base upstream/mainpasses.mainb11c7bf84f(after #10557), head 7572543330, to resolve the conflicts on the sharedCMakeLists.txt,Api.hppand debt-file lines; both sides are kept,X509_PUBKEY_get0_paramstays in the exclusion list, and the count is set to the 72 stubs left inExport.cpp. Full build andctest -j16: 3884/3884 pass.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-24T03:18:39Z.
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-24T12:15:13Z.
Review: APPROVED
Reviewed head
f05c46e39d10a6d3a5cfe5eb481313ea460b49c3.I checked the five accessors against the pinned LibreSSL 4.0.0 structures and getter behavior. The asserted sizes/offsets for
RSA,DH, andDSAmatch their field order, and each accessor writes only non-null output pointers from the specified fields. The null-key exception path and output-selection tests are consistent with the stated compatibility approach. I found no blocking correctness issue in this diff.The PR reports focused accessor tests and a 2005/2006 full CTest run, with the remaining failure also present on main; I did not reproduce these runs locally. Current convention, labels, eligibility, and report checks pass; Linux, Windows, register-context, relinker, write-watch, and ASan jobs are skipped. The overlap report with #10557 lists shared build/export/debt files but no same exports; coordinate those file edits when composing the changes.
Imported from boykopovar/AnyPS5. Originally posted by ahmadmuj on 2026-10-25T19:17:15Z.
Review: COMMENTED
Checked head
dfb0b57aa4d2(base6e775f452ae9; also merges clean onto mainae7d59258ea7). Linux, GCC 13.3, Release.What I ran:
guest_libressl3_key_componentson the merge: pass.public_headers: pass.check_conventions.py: pass.rsa_st/dh_st/dsa_stfrom the 4.0.0*_local.hat ce488b78: 152/128/112 bytes, and every offset you read matches. The get0 bodies matchrsa_lib.c,dh_lib.canddsa_lib.c, and the new null-key handling is right.5576345be456, the 2.5.4 RSA in libSceLibreSsl) on top and ran a probe through both libraries.So on its own this is right for 4.0.0. The problem is where an l3 title gets its
RSAfrom, same pattern I raised on #10960:RSA_new,d2i_RSA_PUBKEY,EVP_PKEY_get1_RSA,PEM_read_RSAPrivateKeyetc. under the same NIDs as libSceLibreSsl. It has noRSA_set0_key, andrsa_stis private in 4.0.0, so a title can't build its own RSA. Every key that reachesRSA_get0_keycomes from one of those shared calls.LD_DEBUG=bindingson an exe that only needslibSceLibreSsl3.prx:PFxpQ6lkQP0(d2i_RSA_PUBKEY) andkADEz2eAE7c(RSA_new) bind tolibSceLibreSsl.prx,9RMSBpPZVdk(RSA_get0_key) binds tolibSceLibreSsl3.prx.ENGINE *engineat 24, sonis at 32.Composed run, 2048-bit key: l1
d2i_RSA_PUBKEY-> l3RSA_get0_key(rsa, &n, &e, &d)givesn = NULL,e= the modulus (top=32, low word0xd941211635074acf),d= 65537. Each field comes from one slot too early. Both PRs' own tests pass, so it only shows once both land.DSA has the same shift, read from the headers, not run: 2.5.4
dsa_sthasint write_paramsafterversion, sopis at 24, not 16. l3DSA_get0_pqgwould hand backwrite_params(1 afterDSA_new) asp. Nothing creates an l1 DSA yet, so that one is latent. DH is fine: the offsets are the same in 2.5.4 and 4.0.0.What I'd suggest: read RSA and DSA through the 2.5.4 layout (#10915's
LibreSslRsafor RSA). Titles can't see the 4.0.0 offsets anyway, and that's the object they actually get. The other way is to implement the l3 NIDs for every call that creates or frees these keys, which is a lot more surface. The debt line "No export of this module creates a key yet, so only keys the caller builds reach them" should change either way: the keys come from libSceLibreSsl.