feat(libSceLibreSsl): implement the RSA public-key calls on the RSA object #10915
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10915"
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 EagleBearerYS on 2026-10-25T09:48:50Z.
What
Implements six libSceLibreSsl RSA public-key exports on the
RSAobject of #10449, following LibreSSL 2.5.4 (rsa_lib.c,rsa_eay.c,rsa_crpt.c,rsa_pk1.c,rsa_oaep.c,rsa_none.c,rsa_sign.c,x_pubkey.c,rsa_ameth.c,tasn_dec.c), the version the module's debt entries name:RSA_new,RSA_free: the key from the guest heap with the default"Eric Young's PKCS#1 RSA"method, reference counting,finish, andBN_clear_freeof eachBIGNUM.d2i_RSA_PUBKEY: decodes a SubjectPublicKeyInfo with LibreSSL's DER/BER rules onto a new key.RSA_public_encrypt,RSA_public_decrypt: dispatch through the key method; the default method's checks, PKCS#1 v1.5, OAEP (SHA-1) and no padding, with the arithmetic on mbedtls.RSA_verify: the method'srsa_verifyunderRSA_FLAG_SIGN_VER, otherwise PKCS#1 v1.5 decryption, theNID_md5_sha1case and theX509_SIGchecks, with the NIDs of the 15 digest objects of LibreSSL 2.5.4's table.RSA_verify_PKCS1_PSSandRSA_padding_add_PKCS1_PSSkeep throwing: they need anEVP_MD, which #9448 adds. BER forms LibreSSL also accepts, SSLv23 and X9.31 padding, moduli over 8192 bits, a custombn_mod_exp, negativeBIGNUMs and a digest type and object both outside the table throw. Four new entries indocs/dev/debt/libSceLibreSsl.mdrecord these and the error queue these calls don't fill.On
main: #10449 merged asc8809e82e4, so this PR's six commits now sit onmain895ead67f7, which carries alvaroelpob's three. The fifth sets the debt file's pending-exports count to the exportsExport.cppstill leaves throwing, and each merge ofmainrecounts it: 190 at this head (the line onmainsays 196, which matches itsExport.cpp).Related: #9446 (
BIGNUM), #9448 (EVP_MD, for the PSS calls), #10570, #10418, #10398 (EVP_PKEY).Tested
guest_libressl_rsaandguest_libressl_runtimepass 10 of 10 on Linux and on Windows, 0 skipped.5576345be4(run): the count commit, docs only.guest_libressl_rsaandguest_libressl_runtimepass 10 of 10. Linux: 2 run, 2 pass, 0 skip, 0 fail. Windows: 2 run, 2 pass, 0 skip, 0 fail. Suites: libc and libkernel pass on Linux (144 and 207) and on Windows (171 and 223). The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.guest_libressl_rsagains eight cases on the NIST CAVP FIPS 186-3 SigGen15 2048-bit key:RSA_new/RSA_freefields, references,finishandBIGNUMfreeing;d2i_RSA_PUBKEYon that key's SubjectPublicKeyInfo, a truncated encoding refused, and 53 encoding variants;RSA_public_decryptandRSA_verifywith the CAVP PKCS#1 v1.5 signature, and a tampered one failing;RSA_public_encryptwith OAEP and v1.5: 256-byte output, two encryptions differ, and each decrypts with the private exponent to a valid block;X509_SIGvariants and each digest object.ctestas an unprivileged user: 2,213 tests, 2,118 passed, 90 skipped and 5 failed. The five need IPv6, which that machine lacks:guest_net_buffer_validation,guest_socket_options,guest_socket_stream_options,guest_socket_address_lengthandguest_tcp.dc07fde9eb, this PR's five commits rebased onto #10449'se44f645642(run), after alvaroelpob rebased #10449 onto currentmain. The code is unchanged: the debt entries keep their place after #10449's RSA entry, now followed bymain's Functional section, and the count commit sets 334, theNotImplementedexports left in Export.cpp.guest_libressl_rsa,guest_libressl_runtimeandpublic_headerspass 10 runs in a row. Linux: 3 run, 3 pass, 0 skip, 0 fail. Windows: 3 run, 3 pass, 0 skip, 0 fail. Suites: libc and libkernel pass on Linux (144 and 208) and on Windows (171 and 224). The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.RSA_flags, by @BunnyFl (comment): the 13.42libSceLibreSsl.sprxcode, run in an emulator on structures whose every 4-byte word holds its own offset (two identical runs), reads the method pointer at +0x10 of theRSAand returns the int at +0x48 of the method, and gives 0 for a nullRSA. That matches this PR'sstatic_asserts formethandLibreSslRsaMethod::flags; the other fields aren't read by that call.4df79a235e, a merge ofmain4e38e23882(run).main's9a848d0b99implements the TLS alert descriptions and lowers the pending-export count indocs/dev/debt/libSceLibreSsl.mdfrom 342 to 341, on the line this PR's count commit sets. The merge keepsmain's change and sets the count to 333, theNotImplemented_nid_no_patchexports left in the mergedExport.cpp. Nothing else conflicted, and this PR's other changed lines are the same. The 13guest_libressltests pass 10 runs in a row. Linux: 13 run, 13 pass, 0 skip, 0 fail. Windows: 13 run, 13 pass, 0 skip, 0 fail. Suites: libc and libkernel pass on Linux (145 and 210) and on Windows (174 and 231). The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.ac22fabb9dand939a194466, after oneandonlydean's review and a merge ofmain84e91df418(run).ac22fabb9ddrops the RSA test's checks that pinned unimplemented features as throwing, as oneandonlydean asked:RSA_freewith an ENGINE, ex_data, blinding or Montgomery context set, the BER forms ind2i_RSA_PUBKEYand in a signature's DigestInfo, X9.31 decryption, SSLv23 encryption, moduli over 8192 bits, a custombn_mod_exp(with itsOtherModExpfixture), and digest types with no object. The production refusals and their debt entries stay, and so do the null-pointer, malformed-input and invalid-length checks.939a194466mergesmain, whose #9745 (SSLeay) lowers the pending-export count indocs/dev/debt/libSceLibreSsl.mdto 340, on the line this PR sets; the merge keeps it and sets 332, theNotImplemented_nid_no_patchexports left in the mergedExport.cpp. Nothing else conflicted.guest_libressl_rsa, the otherguest_libressltests and the tests for the files the merge changes, 24 of them, pass 10 runs in a row. Linux: 24 run, 24 pass, 0 skip, 0 fail. Windows: 24 run, 24 pass, 0 skip, 0 fail. Suites: libc and libkernel pass on Linux (145 and 211) and on Windows (174 and 232). The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.7cfe819145, a merge ofmain18ef6be0cd(run). alvaroelpob's #10373 (sk_*) and #10376 (UI_create_method) add their sources and tests next to this PR's incore/libs/prx/libSceLibreSsl/CMakeLists.txtand their structs next to this PR'sLibreSslRsaMethodandLibreSslRsaininclude/Api.hpp; #10373's debt entry sits next to this PR's indocs/dev/debt/libSceLibreSsl.md, and the two lower the pending-export count to 321, on the line this PR sets. The merge keeps both sides in each and sets 313, theNotImplemented_nid_no_patchexports left in the mergedExport.cpp. This PR's other changed lines are the same. Theguest_libressltests with the tests for the files the merge changes pass 10 runs in a row. Linux: 92 run, 92 pass, 0 skip, 0 fail. Windows: 90 run, 90 pass, 0 skip, 0 fail. Suites: libc and libkernel pass on Linux (145 and 212) and on Windows (174 and 233). The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.7cf76af1d5, this PR's six commits onmain895ead67f7(run), after #10449 merged. The branch now holds only this PR's commits, moved ontomainwith a force-push. Each commit's changed lines are the same as before, and only their context moved: theadd_libraryline now listsmain's newer sources, andApi.hppand the debt file sit onmain's versions. The count commit sets 301, whatExport.cppleaves with this PR's six exports.guest_libressl_rsaandguest_libressl_runtimepass 10 runs in a row. Linux: 2 run, 2 pass, 0 skip, 0 fail. Windows: 2 run, 2 pass, 0 skip, 0 fail. Suites: libc and libkernel pass on Linux (166 and 264). On Windows libc passes (194), and libkernel passes 283 of 286:exec_arguments,guest_timed_join_import_libkernel_sysandguest_timed_join_import_libkernel_webfail at their setup in the verify's Windows build (FileNotFoundErrorstarting the title, or copying the libraries they load), and pass inmain's own Windows job at1829def9bf(job). The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.4ad9203124, a merge ofmain04fefebe90(run). The one conflict was the pending-exports count indocs/dev/debt/libSceLibreSsl.md:mainreads 300 after JaceTheBlu's #11105 (X509 lookups), and with this PR's implementations the mergedExport.cpphas 294 calls left that go throughNotImplemented_nid_no_patch, so the entry now says 294. This PR's other changed lines are the same.guest_libressl_rsaandguest_libressl_runtimeran 10 times with no failure. Linux: 2 run, 2 pass, 0 skip, 0 fail. Windows: 2 run, 2 pass, 0 skip, 0 fail. Suites: libc and libkernel pass on Linux (171 and 289). On Windows libc passes (199), and libkernel passes 309 of 312:exec_arguments,guest_timed_join_import_libkernel_sysandguest_timed_join_import_libkernel_webfail at their setup in the verify's Windows build (FileNotFoundErrorstarting the title, or copying the libraries they load), withmain's code too, and pass inmain's own Windows job at1829def9bf(job). The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.7be988fd70, a merge ofmain58b2753d74(run). The one conflict was the pending-exports count indocs/dev/debt/libSceLibreSsl.md:mainreads 299 after JaceTheBlu's #11189 (X509_VERIFY_PARAM_set1_host), and with this PR's implementations the mergedExport.cpphas 293 calls left that go throughNotImplemented_nid_no_patch, so the entry now says 293. This PR's other changed lines are the same.^guest_libresslandpublic_headersran 10 times with no failure. Linux: 33 run, 33 pass, 0 skip, 0 fail. Windows: 33 run, 33 pass, 0 skip, 0 fail. The libc and libkernel suites run 193 and 292 tests on Linux and 223 and 315 on Windows, with 0 failed. The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.77af176ffa, a merge ofmainc12e7e61a1(run), which brings JaceTheBlu's #13562 (OBJ_createandOBJ_cleanup). The one conflict was the pending-exports count indocs/dev/debt/libSceLibreSsl.md:mainreads 292 after #13562, and with this PR's implementations the mergedExport.cpphas 286 calls left that go throughNotImplemented_nid_no_patch, so the entry now says 286.CMakeLists.txt,Export.cppandApi.hppmerged without conflicts, and this PR's other changed lines are the same.^guest_libresslandpublic_headersran 10 times with no failure. Linux: 34 run, 34 pass, 0 skip, 0 fail. Windows: 34 run, 34 pass, 0 skip, 0 fail. The libc and libkernel suites run 199 and 308 tests on Linux and 226 and 330 on Windows, with 0 failed. The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.fa25361695, a merge ofmain0a148be963(run), which brings Ninot1Quyi's #13820 (SHA-512 initialization buffers) and hyvvs's #13760 (GENERAL_NAME_freeandGENERAL_NAMES_free).docs/dev/debt/libSceLibreSsl.md, next tomain's new and changed entries. The merge keeps those entries, and every other line comes from the side that changed it.Export.cpptotal, 284NotImplemented_nid_no_patchexports;main's line was 2 above its own total.^guest_libresslandpublic_headers. Linux: 38 run, 38 pass, 0 skip, 0 fail. Windows: 38 run, 38 pass, 0 skip, 0 fail. The libc and libkernel suites run 199 and 308 tests on Linux and 226 and 330 on Windows, with 0 failed. The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.67a8e941dd: merges ofmain88e804b0a7(e6b8a1727b) and3c3b3cda73(2eb2e4e3c0), each followed by a recount of the pending exports (39753d71a9,67a8e941dd) (run, on67a8e941dd).e6b8a1727bbrings Felipebmaitan's #9535 (error queues) and atharvjairath's #10078 (X509_EXTENSIONgetters). The one conflict was the pending-exports count line indocs/dev/debt/libSceLibreSsl.md.2eb2e4e3c0brings alvaroelpob's #10488 (EVP_CIPHER_CTX), without conflicts.NotImplemented_nid_no_patchcalls left in each mergedExport.cpp: 278 after the first merge (#9535 and #10078 implement three each) and 275 after the second (#10488 implements three).mainis otherwise unchanged. The^guest_libressltests, withguest_libressl_rsaandpublic_headers, pass 10 runs in a row. Linux: 44 run, 44 pass, 0 skip, 0 fail. Windows: 44 run, 44 pass, 0 skip, 0 fail. Suites: libc and libkernel pass on Linux (214 and 316) and on Windows (241 and 337). The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.55ff0cdc99, a merge ofmainb28bb77217(run), which brings HQasper's #9448 (the EVP message digest and HMAC functions).docs/dev/debt/libSceLibreSsl.md, where the merge keeps #9448's new entry with this PR's.NotImplemented_nid_no_patchcalls left in the mergedExport.cpp:main's 261, which its line now matches, less the 6 this PR implements.mainare the same, and it merges cleanly withmaina4eca2a056.^guest_libressltests, withguest_libressl_rsaandpublic_headers. Linux: 46 run, 46 pass, 0 skip, 0 fail. Windows: 46 run, 46 pass, 0 skip, 0 fail. Suites: libc and libkernel pass on Linux (217 and 319) and on Windows (244 and 340). The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.7482bd278c, a merge ofmain4f41f4c375(run), which brings Felipebmaitan's #9571 (CMAC with the AES-CBC ciphers).docs/dev/debt/libSceLibreSsl.md, which both sides changed. The mergedExport.cpphas 225NotImplementedexports, so the entry now says 225 (this PR said 255,main231). No function is in both PRs, and this PR's other lines are unchanged.^guest_libressltest. Linux: 51 run, 51 pass, 0 skip, 0 fail. Windows: 51 run, 51 pass, 0 skip, 0 fail. The libc and libkernel suites run 300 and 322 tests on Linux and 327 and 342 on Windows, with 0 failed. The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.main4f41f4c: AMD Radeon RX 6300 (RADV NAVI24, Mesa 25.2.8; report): 1,147 passed, 6 failed, none new (4 also fail onmain, 2 unstable onmain), 6 skipped, with no new validation IDs (551 tests on the GPU).13c396c3c4, the type 1 padding minimum and a debt sentence, for points 1 and 2 of XairRrR's review.TestPublicDecryptnow recovers two type 1 blocks throughRSA_public_decryptwith PKCS#1 padding. One has seven 0xFF bytes and must be refused (-1); the other has eight and must give its 245-byte payload.RSA_padding_check_PKCS1_type_1's minimum from 8 to 1 (index < 1).guest_libressl_rsathen fails at the seven-byte case, "LibreSSL RSA check failed at line 503", on GitHub's Linux and Windows runners (run).RSA_flags, RSA_sizeentry drops "No export of this module creates a key yet, so only keys the caller builds reach them", sinceRSA_newandd2i_RSA_PUBKEYnow do.^guest_libressltest. Linux: 51 run, 51 pass, 0 skip, 0 fail. Windows: 51 run, 51 pass, 0 skip, 0 fail. The libc and libkernel suites run 300 and 322 tests on Linux and 327 and 342 on Windows, with 0 failed. The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.7ecf157d95, a merge ofmain9ab6a281ea(run), which brings MatteoSid's #10395 (EC groups and keys).docs/dev/debt/libSceLibreSsl.md, which both sides changed. The mergedExport.cpphas 216NotImplementedexports, so the entry now says 216 (this PR said 225,main222). No function is in both PRs, and this PR's other lines are unchanged.^guest_libressltest, withpublic_headers. Linux: 54 run, 54 pass, 0 skip, 0 fail. Windows: 54 run, 54 pass, 0 skip, 0 fail. The libc and libkernel suites run 303 and 327 tests on Linux and 335 and 354 on Windows, with 0 failed. The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.354e5c8351, a merge ofmainb611e634f7(run), which brings LordVersA's #11662 (SSL_library_init).docs/dev/debt/libSceLibreSsl.md, which both sides changed. The mergedExport.cpphad 215NotImplementedexports, so the entry said 215 (this PR said 216,main221). No function is in both PRs, and this PR's other lines are unchanged.^guest_libressltest, withpublic_headers. Linux: 54 run, 54 pass, 0 skip, 0 fail. Windows: 54 run, 54 pass, 0 skip, 0 fail. The libc and libkernel suites run 303 and 329 tests on Linux and 335 and 360 on Windows, with 0 failed. The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.4c7c65a244, a merge ofmaind63781e9ce(run), which brings alvaroelpob's #10450 (EVP_CIPHER_block_size).docs/dev/debt/libSceLibreSsl.md: the mergedExport.cpphad 214NotImplementedexports, so the entry said 214 (this PR said 215,main220). No function is in both PRs, and this PR's other lines are unchanged.^guest_libressltest (now including #10450'sguest_libressl_evp_cipher) andpublic_headers. Linux: 55 run, 55 pass, 0 skip, 0 fail. Windows: 55 run, 55 pass, 0 skip, 0 fail. The libc and libkernel suites run 303 and 329 tests on Linux and 335 and 360 on Windows, with 0 failed. The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.05387ced6d, a merge ofmain9f9e420709(run), which brings alvaroelpob's #10448 (OCSP_response_status,OCSP_single_get0_status).docs/dev/debt/libSceLibreSsl.md. The mergedExport.cpphas 212NotImplementedexports, so the pending-exports entry now says 212 (this PR said 214,main218).^guest_libressltest (now including #10448'sguest_libressl_ocsp_response) andpublic_headers. Linux: 56 run, 56 pass, 0 skip, 0 fail. Windows: 56 run, 56 pass, 0 skip, 0 fail. The libc and libkernel suites run 303 and 329 tests on Linux and 335 and 360 on Windows, with 0 failed. The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.354e5c8351(report), withVK_LAYER_KHRONOS_validation: AMD Radeon RX 6300 (RADV NAVI24, Mesa 25.2.8), this head merged ontomainb611e63, 1,133 of 3,946 tests selected. 1,125 passed, 3 failed (none new: all 3 also fail onmain), 5 skipped. No new validation IDs over 575 GPU tests.guest_libressl_rsawasn't in the selection.984cae2063, a merge ofmaine772fb25cc(run), which brings our #10834 (the EVP cipher calls on the cipher context), StoneDC's #12774, #12775 and #14283 (tests of error-queue interleavings, DES ECB known answers, and SHA padding and digest extents) and rooklz's #14717 (the documented exception for faulting lookup and verify-parameter arguments).docs/dev/debt/libSceLibreSsl.md. The mergedExport.cpphas 190NotImplementedexports, so the pending-exports entry now says 190 (this PR said 212,main196).^guest_libressltest andpublic_headers. Linux: 58 run, 58 pass, 0 skip, 0 fail. Windows: 57 run, 57 pass, 0 skip, 0 fail;guest_libressl3_mixed_evpis registered only on Linux. The libc and libkernel suites run 322 and 331 tests on Linux and 353 and 362 on Windows, with 0 failed. The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.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)c8809e82e4). Our #10834, which set the same pending-exports count line indocs/dev/debt/libSceLibreSsl.md, has merged (5a273d9f3b), and this head's count includes it. Any order with our #10878, which sets that line too: whichever merges later recounts it in amainmerge. Any order with alvaroelpob's #10490 (libSceLibreSsl3): the overlap table'sRSA_newandd2i_RSA_PUBKEYare its placeholder entries there, and the two share no fileImported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T10:29:51Z.
Review: COMMENTED
I inspected the seven-commit diff and the RSA paths. The report in #8981 plus the cross-release layout evidence resolves my original version/structure concern. However, this PR is explicitly stacked on #10449, which is still open with
mergeStateStatus: DIRTY; its CI on #10915 currently consists of policy checks, with product test/build paths skipped. The full Linux RSA test results in the description are author-reported, not independently rerun by me.I am leaving this review as a comment rather than approving the dependent stack. Please coordinate the base PR's conflict resolution/landing and rerun the RSA target and conventions on the resulting exact head; then I can finish the review. This is an integration/test-status hold, not a finding that the reported crypto behavior is wrong.
Imported from boykopovar/AnyPS5. Originally posted by ahmadmuj on 2026-10-25T18:17:00Z.
Review: APPROVED
Reviewed head
5576345be456merged locally onto main7a25f87620a9(merge0fe667a97c45, not pushed). Linux x86-64, GCC 13.3, host only, no console.What I ran:
docs/dev/debt/libSceLibreSsl.mdconflicts. I kept main's file, added your 5 RSA lines after the ERR entry, and set the pending count to 337. Main is already at 345, and the merged Export.cpp has 337NotImplemented_nid_no_patchstubs. Everything else auto-merges, and the merged diff vs main matches this PR's own stat.guest_libressl_*targets, thenctest -R guest_libressl: 11/11 pass,guest_libressl_rsa4/4 runs.check_conventions.py --base origin/mainpasses. On plain main the new test doesn't compile (noLibreSslRsa), so it does guard the change.107a5b52..., matches OpenBSD's SHA256 file).rsa_st152,rsa_meth_st112,bignum_st24, and every field offset equalsLibreSslRsa,LibreSslRsaMethodandLibreSslBignum. The flag, padding, limit and NID constants and the 15 digest OIDs match too.Small things, none blocking:
DefaultPublicDecryptruns the mod-exp before the padding switch. With an 8193-16384-bit key and an unknown padding (say 0) it throws on the mbedtls limit, while 2.5.4 returns -1 whatever the mod-exp gives (thedefault:case inRSA_eay_public_decryptgoes toerr). Returning -1 for unknown paddings beforePublicOperationwould match.i < 8in rsa_pk1.c), a 3072-bit modulus with a 65-bit exponent (accepted), and exactly 16384 bits. The differential confirms the first two match 2.5.4, so this is only about catching a future off-by-one.Not checked: anything on a console; RSA_new, RSA_free and RSA_flags beyond layout and constants; d2i_RSA_PUBKEY with a non-null
out; the ERR queue (your debt says it stays empty).Approving on the above. The rebase only needs the 337 count.
Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T13:24:52Z.
Review: APPROVED
Reviewed — approved
RSA_new,RSA_free,d2i_RSA_PUBKEY,RSA_public_encrypt,RSA_public_decryptandRSA_verifybuild and pass their tests on the merged tree. I compared them with LibreSSL 2.5.4'srsa_lib.c,rsa_eay.c,rsa_pk1.c,rsa_oaep.c,rsa_none.c,rsa_sign.candx_bignum.cand found no behavioural mismatch. My findings are non-blocking.What I ran
Head
7482bd278c6decb380bf521396bd3295dd4f8d78, merged with--no-ffintomain4f41f4c375f5abb487dbd184fbc150f31994d762(merged treec24b6dba35db8d602e65e6376a2399a13d3d67c8). Debian 13 VM, Intel Xeon Gold 6136, GCC 14.2.0, Release, Ninja.Results
git diff --checkcheck_conventions.pylibsOKunwrap_self_UnwrapTest_test_new_output_inherits_the_destination_directory_group, also fails onmain.guest_libressl_rsapublic_headers(65 tests)guest_libressl_rsa, 66/66 passdocs/dev/debt/libSceLibreSsl.mdExport.cpp;mainhas 231git status --porcelainemptyNegative control
src/Rsa.cpp,include/Api.hppandExport.cpprestored frommain,guest_libressl_rsa_testsdoesn't compile. For example,GuestLibreSslRsa.cpp:158: unable to deduce 'auto*' from 'RSA_new_nid_postfix()'andtoo many arguments to function 'int d2i_RSA_PUBKEY_nid_postfix()'. So the test depends on the change.Rsa.cpp, one at a time:if (algorithm.parameter && !algorithm.nullParameter) return 0;): the test fails ("LibreSSL RSA check failed at line 688").index < 8toindex < 1(Rsa.cpp:433): the test still passes. See the first non-blocking finding.Findings
Blocking
None.
Non-blocking
RSA_padding_check_PKCS1_type_1is not tested at all. Atcore/libs/prx/libSceLibreSsl/src/Rsa.cpp:433,index < 8can be weakened toindex < 1andguest_libressl_rsastill passes. ahmadmuj's review noted that the exact 7-vs-8 boundary isn't pinned. The mutation above shows the check isn't exercised at all. It is a signature-validity check (fewer than 80xFFbytes must be refused), so a regression would go unnoticed.TestPublicDecryptorTestVerify, use the existingRecoverhelper to build two blocks:00 01+ 7×FF+00+ payload (expect -1 or 0) and00 01+ 8×FF+00+ payload (accepted).docs/dev/debt/libSceLibreSsl.md:24, in theRSA_flags, RSA_sizeentry, still says "No export of this module creates a key yet, so only keys the caller builds reach them."RSA_newandd2i_RSA_PUBKEYin this PR now create keys. CONTRIBUTING asks a PR that closes a gap to cut the entry to what is still open.DefaultPublicDecryptrunsPublicOperation(Rsa.cpp:514) before it rejects unknown paddings. With such a key and padding 0, it throws on the mbedtls 8192-bit limit, where 2.5.4 returns -1.Default*slot functions (Rsa.cpp:449-603) areAPS5_VABIfunctions in the anonymous namespace. The progress report listsDefaultInitas implemented and the seven otherDefault*slots as "declared as stubs", which inflates libSceLibreSsl's numbers (164/420 → 168/428). MeanwhileRSA_free,RSA_verifyandd2i_RSA_PUBKEYdon't appear as implemented at all._nid_no_patchsuffix. Renaming them (DefaultInit_nid_no_patch, …) would keep them out of the tools' export lists.What I checked against my reading of LibreSSL 2.5.4, with no difference found:
RSA_new_method: flagsmeth->flags & ~RSA_FLAG_NON_FIPS_ALLOW, thenRSA_eay_initsetsCACHE_PUBLIC | CACHE_PRIVATE.RSA_free: reference drop,finish,BN_clear_free.RSA_eay_public_encryptandRSA_eay_public_decrypt: modulus, exponent andflenchecks and output zero-fill.RSA_padding_add_PKCS1_type_2,RSA_padding_add_PKCS1_OAEP(emlen = tlen - 1, SHA-1 MGF1),RSA_padding_add_none,RSA_padding_check_none, and the type-1 scan.int_rsa_verify: signature length, the 36-byteNID_md5_sha1case, the trailing-data, parameter and NID checks.d2i_RSA_PUBKEY:*ppadvanced only on success, and the previous*afreed.bn_c2i/BN_bin2bnread the raw INTEGER content, so a 257-byte modulus givesdmax33, as the test expects.Not verified
RSA_flagsemulation, both from the discussion. I didn't reproduce either.int_rsa_verifyre-encodes theX509_SIGin DER and compares it with the decrypted block. If it does, the non-minimal NULL parameter that the test accepts (GuestLibreSslRsa.cpp:686,05 81 00) would be refused there. Both differentials report no mismatch, so I'm not raising it as a finding.RSA_freeon a shared key beyond reading thestd::atomic_refdecrement.Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T17:26:42Z.
Review: APPROVED
Re-checked — approved
Commit
13c396c3c4tests the 8-byte minimum of PKCS#1 type 1 padding and removes the outdatedRSA_flags, RSA_sizedebt sentence. That resolves my previous findings 1 and 2. The author kept findings 3 and 4 as they are, and neither blocks.What changed since my last review
13c396c3c4(test plus docs), adds the following:core/libs/tests/GuestLibreSslRsa.cpp:500-505:TestPublicDecryptsigns two type 1 blocks with the private exponent throughRecoverand decrypts them withRSA_public_decryptandRSA_PKCS1_PADDING:00 01+ 7×FF+00+ 246 bytes must return -1.00 01+ 8×FF+00+ 245 bytes must return 245, with the payload intact.docs/dev/debt/libSceLibreSsl.md:24drops "No export of this module creates a key yet, so only keys the caller builds reach them."13c396c3c4.What I ran
Head
13c396c3c4eb5ddad2502a269bcae1509b286245, merged with--no-ffintomain1e658521a0a599872612bb91949311e2956b5283(merged treedcdbf451761b013aa1f8cc791b51b4d2506b3de8). Debian 13 VM, Intel Xeon Gold 6136, GCC 14.2.0, Release, Ninja.git diff --checkcheck_conventions.pylibsOKunwrap_self_UnwrapTest_test_new_output_inherits_the_destination_directory_groupfails onmaintoo.guest_libressl_rsa+public_headersindex < 7)guest_libressl_rsafails: "LibreSSL RSA check failed at line 503"Export.cpp(225).mainhas 231.git status --porcelainemptyNegative control
The production code change is the same as in my last review. Restoring it from
mainalready made the test fail to compile. For the new test cases, I weakenedcore/libs/prx/libSceLibreSsl/src/Rsa.cpp:433fromindex < 8toindex < 7. That is a tighter mutation than theindex < 1from my previous review, and it shows the exact boundary is now pinned.guest_libressl_rsafails at the seven-byte case (GuestLibreSslRsa.cpp:503). After restoring the mergedRsa.cppand rebuilding, it passes and the worktree is clean.Previous findings
GuestLibreSslRsa.cpp:500-505cover both sides of the boundary, and theindex < 7mutation above now fails.docs/dev/debt/libSceLibreSsl.md:24on the merged tree.DefaultPublicDecryptstill runsPublicOperation(Rsa.cpp:514) before the padding switch. The author agreed and chose to leave it as it is. It throws rather than returning a wrong result, and theRSA_public_encrypt, RSA_public_decryptdebt entry already says the mbedtls 8192-bit limit makes a larger modulus throw. So it is covered by the debt file, and I don't block on it.Default*method slots (Rsa.cpp:449-603) areAPS5_VABIwithout_nid_no_patch, so the progress report counts them as exports. The author left the names as they are. This affects the tools' statistics, not behaviour.New findings
None.
Not verified
index < 1) is author-reported. My localindex < 7mutation is the evidence I'm relying on.