feat(libSceLibreSsl): implement EVP_PKEY_set1_RSA, EVP_PKEY_get1_RSA and EVP_PKEY_copy_parameters #11128

Merged
ahmadmuj merged 107 commits from upstream-pr/11128 into main 2026-11-06 07:57:15 +00:00
ahmadmuj commented 2026-10-25 19:00:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ahmadmuj on 2026-10-25T19:00:40Z.


What

Implements legacy EVP_PKEY_set1_RSA, EVP_PKEY_get1_RSA and EVP_PKEY_copy_parameters, including RSA payload release. Native LibreSSL3 new/free use its separate 32-byte layout; legacy PKEY stays 56 bytes.

Head b14b01250ec10f46ce6344302e38c67e7f1e3cbd merges main 3ba9ab08cc6decca2307a69b77c4efbac06badc7 and preserves maintainer commit f1cbf7c835269eefd9d73906d0ad7b0adbb27542. SSL_get_privatekey forwards to the parent library and can return its legacy PKEY. This is a documented native forwarding gap. Objects from the two modules must not be mixed. The native constructor/free correction and local set1/copy refusals remain intact. The maintainer's main merge resolves the debt-only conflict. It keeps both PKEY gap entries, main's new debt entries, and the count of 387 forwards. The prior PKEY code and tests remain unchanged.

Native payload destruction remains unsupported. Final release with a method or payload restores the reference and throws. Allocation failure returns null without queuing the native allocation error. The tests do not pin unsupported throws. Native RSA producer/get1 stubs remain unchanged.

Legacy behavior follows LibreSSL 2.5.4 p_lib.c. Native layout and empty-object lifecycle follow LibreSSL 4.0.0 evp_local.h and p_lib.c.

Tested

The maintainer head passes a Linux Release rebuild (21 incremental steps), after the equivalent SSL integration passes its 408-step build. All ten focused tests pass: legacy PKEY lifecycle/RSA/SSL session; native PKEY lifecycle/getters/queries, key references, RSA setters, SSL and TLS protocols. The inherited actual-NID binding check and all 65 public headers pass. Conventions and whitespace pass. These checks run again on the maintainer head because its linked libc/NetCtl code and public-header inputs differ. Its SSL source, tests and debt match the locally verified integration exactly.

The native lifecycle test checks allocation size and fields, supported reference changes, empty-object release, zeroization and allocation failure. The maintainer removes the private-key refusal check and the method/payload throw assertions. No cross-layout safety claim follows from the passing tests.

Prior constructor regression evidence remains: the old native constructor allocates 56 bytes instead of 32, before any retain/free. Earlier differential and mutation evidence applies only to unchanged legacy code. Those runs are not repeated. No new Windows/macOS, console, game-dump, full-product or full-ctest run is claimed.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: #11151 (#10570, #10490 and #10915 are merged)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5007716951 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11128). Originally posted by [ahmadmuj](https://github.com/ahmadmuj) on 2026-10-25T19:00:40Z. --- ### What Implements legacy `EVP_PKEY_set1_RSA`, `EVP_PKEY_get1_RSA` and `EVP_PKEY_copy_parameters`, including RSA payload release. Native LibreSSL3 new/free use its separate 32-byte layout; legacy PKEY stays 56 bytes. Head `b14b01250ec10f46ce6344302e38c67e7f1e3cbd` merges main `3ba9ab08cc6decca2307a69b77c4efbac06badc7` and preserves maintainer commit `f1cbf7c835269eefd9d73906d0ad7b0adbb27542`. `SSL_get_privatekey` forwards to the parent library and can return its legacy PKEY. This is a documented native forwarding gap. Objects from the two modules must not be mixed. The native constructor/free correction and local set1/copy refusals remain intact. The maintainer's main merge resolves the debt-only conflict. It keeps both PKEY gap entries, main's new debt entries, and the count of 387 forwards. The prior PKEY code and tests remain unchanged. Native payload destruction remains unsupported. Final release with a method or payload restores the reference and throws. Allocation failure returns null without queuing the native allocation error. The tests do not pin unsupported throws. Native RSA producer/get1 stubs remain unchanged. Legacy behavior follows LibreSSL 2.5.4 [p_lib.c](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/evp/p_lib.c). Native layout and empty-object lifecycle follow LibreSSL 4.0.0 [evp_local.h](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/evp/evp_local.h) and [p_lib.c](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/evp/p_lib.c). ### Tested The maintainer head passes a Linux Release rebuild (21 incremental steps), after the equivalent SSL integration passes its 408-step build. All ten focused tests pass: legacy PKEY lifecycle/RSA/SSL session; native PKEY lifecycle/getters/queries, key references, RSA setters, SSL and TLS protocols. The inherited actual-NID binding check and all 65 public headers pass. Conventions and whitespace pass. These checks run again on the maintainer head because its linked libc/NetCtl code and public-header inputs differ. Its SSL source, tests and debt match the locally verified integration exactly. The native lifecycle test checks allocation size and fields, supported reference changes, empty-object release, zeroization and allocation failure. The maintainer removes the private-key refusal check and the method/payload throw assertions. No cross-layout safety claim follows from the passing tests. Prior constructor regression evidence remains: the old native constructor allocates 56 bytes instead of 32, before any retain/free. Earlier differential and mutation evidence applies only to unchanged legacy code. Those runs are not repeated. No new Windows/macOS, console, game-dump, full-product or full-ctest run is claimed. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: #11151 (#10570, #10490 and #10915 are merged) - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-25 19:04:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T19:04:10Z.

Review: APPROVED


Reviewed the new EVP_PKEY_set1_RSA, EVP_PKEY_get1_RSA and EVP_PKEY_copy_parameters behavior in commit c7928085 against LibreSSL 2.5.4 p_lib.c. The set/get reference-count changes and the RSA type mismatch error align with the source; RSA has no parameter-copy method, so same-type copies return 0 without changing the target, and differing types queue EVP_R_DIFFERENT_KEY_TYPES. The implementation preserves the documented unsupported cases for non-RSA methods and engines, and the focused tests cover replacement, same-pointer refcounts, null input, error queue values and final RSA release. The PR reports 14 LibreSSL guest tests, ASan differential testing, and 12 mutation checks; eligibility, conventions, intake, labels and report pass. Hosted product build jobs are skipped, and Windows/macOS plus console behavior are not reported as tested. This is stacked on #10570 and #10915, so those dependencies still need to land first.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5644780455 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11128#pullrequestreview-5644780455). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T19:04:10Z. **Review:** APPROVED --- Reviewed the new `EVP_PKEY_set1_RSA`, `EVP_PKEY_get1_RSA` and `EVP_PKEY_copy_parameters` behavior in commit `c7928085` against LibreSSL 2.5.4 `p_lib.c`. The set/get reference-count changes and the RSA type mismatch error align with the source; RSA has no parameter-copy method, so same-type copies return 0 without changing the target, and differing types queue `EVP_R_DIFFERENT_KEY_TYPES`. The implementation preserves the documented unsupported cases for non-RSA methods and engines, and the focused tests cover replacement, same-pointer refcounts, null input, error queue values and final RSA release. The PR reports 14 LibreSSL guest tests, ASan differential testing, and 12 mutation checks; eligibility, conventions, intake, labels and report pass. Hosted product build jobs are skipped, and Windows/macOS plus console behavior are not reported as tested. This is stacked on #10570 and #10915, so those dependencies still need to land first.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!11128
No description provided.