feat(libSceLibreSsl): implement RSA_private_encrypt, RSA_private_decrypt and RSA_sign #11151
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11151"
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 ahmadmuj on 2026-10-25T19:42:36Z.
What
Implements
RSA_private_encrypt,RSA_private_decryptandRSA_signon theRSAobject from #10915, following LibreSSL 2.5.4 rsa_eay.c, the padding files next to it, rsa_sign.c and bn_blind.c.#10915 and #10449 are merged. The original implementation is
823aab9and6aa3fd5(test-only). Current-main integration also guards RSA verification against registered OIDs and makes signing throw for unsupported dynamic identifiers. It does not add dynamic digest support.RSA_eay_*: blinding (unlessRSA_FLAG_NO_BLINDING), the CRT path with itseverify anddfallback, and plaindwhen CRT fields are missing. Same order as 2.5.4, mbedtls for the math (reuses #10915'sModExp).RSA_signbuilds the DERDigestInfofrom #10915's 15-entry digest table, or signs the raw 36 bytes forNID_md5_sha1. A guest method'srsa_signslot gets called whenRSA_FLAG_SIGN_VERis set.rsa->blinding) and the Montgomery contexts. Outputs are the same for a consistent key. The differences are in the debt entry.rsa_mod_exp/bn_mod_exp, numbers over the 8192-bit mbedtls limit, non-normalised BIGNUMs, n == 1 with blinding, and anRSA_signNID that's in range but not a digest. The full list is in the debt file.BN_newandBN_bin2bnare now implemented on main.RSA_generate_key_exstays outside this PR. The PSS pair is in #11175.Current alignment
Head
944b114d0ea56a8868473c81165ffa86ff598f4fmerges main08e73174f230de4f475c04299170d8c14d6e3425, including #10915. Published history is preserved. The merged count-free debt wording is preserved.The registered-OID guards remain in RSA verification and public-key decoding. Their tests accept the correct result or an unsupported-path refusal. The unsupported custom-method and non-digest signing throw assertions are removed. The other private RSA checks remain.
The final main merge changes only debt wording. Fresh checks: focused RSA, private RSA and error tests pass (3/3). Public headers pass (65/65). Conventions and whitespace pass. Prior differential and mutation results below were not repeated. Windows CI remains external. The final test-only correction also passes the focused private-RSA test on #11151; dependent branches inherit that exact test.
Tested
The following feature checks predate this alignment. Fresh checks appear above.
Ubuntu 24.04 on WSL2, GCC 13.3, Release, on
main+ #10915.libcrypto.a: a host generator recorded 2124 cases on 6 keys (512 to 4096 bits, e = 3 and 65537) in about 20 shapes each: missingd,e, CRT fields, a baddmp1, evenn, n = 1, the flag combos. Output buffers are prefilled and compared in full, so extra writes count. A guest harness (not committed) got 1904/1904 byte-exact, 54/54 matches on the return value only (cases where the output bytes aren't comparable), and 166/166 deliberate throws.guest_libressl_rsa_private: exact 2.5.4 vectors on a 512-bit key for each padding, the key shapes,RSA_signwith SHA-256 and MD5-SHA1, empty and longest digests, and the refused types, and method-slot dispatch with recording callbacks.RSA_eay_private_encrypt not implemented(and the decrypt/sign variants). Mutations that each fail the test: skip blinding, drop the CRT fallback, always outputretfor X9.31, writesiglenon a failed sign, wrongDigestInfoNULL parameter.ctest -R libressl: 15/15 pass onmain9857eee+ #10915939a194, including #10915'sguest_libressl_rsa.check_conventions.py --base origin/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 MarcZX10 on 2026-10-25T19:47:37Z.
Review: APPROVED
Reviewed exact head
9343653603, focusing on private RSA padding, blinding, CRT fallback, method-slot dispatch, DigestInfo construction, and the associated tests and debt notes. Local checks passed: check_conventions.py --base upstream/main, git diff --check upstream/main...HEAD, the public-header audit (368 libraries / 12,196 exports), and a C++20 syntax compile of Rsa.cpp against the pinned Mbed TLS headers. The PR reports a LibreSSL 2.5.4 differential run and 13/13 libressl CTest cases; I could not independently rerun those runtime tests here because this checkout has no configured project build. Product CI jobs are skipped under the repository PR policy. I found no blocking issue in the source review.Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-11-01T20:02:10Z.
Review: COMMENTED
Correction (2026-11-01): this review's claim that maintainers close PRs without a title ID is wrong. CONTRIBUTING allows
Unblocks: none; a title is only required when the PR fixes a title. The technical points below are unaffected.No title ID and no log line. The description says
Unblocks: noneand states the exports "matter once #9446 or a PEM reader lands", because guests cannot build a private key through this module whileBN_newandBN_bin2bnare stubs. So no title can reachRSA_private_encrypt,RSA_private_decryptorRSA_signonmaintoday, and the 2,400-line diff (Rsa.cpp plus two test files) is unreachable code until another PR lands.mainshowing the import being hit. Without it this is export-only work, which is what maintainers have been closing.rsa->blinding, and that this differs from 2.5.4. Please state in the debt entry what a guest that readsrsa->blindingafterwards observes.