feat(libSceLibreSsl3): implement EVP_PKEY assignment and reference accessors #17138

Merged
fishingpvalues merged 2 commits from upstream-pr/17138 into main 2026-11-12 11:22:42 +00:00
fishingpvalues commented 2026-11-08 10:59:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fishingpvalues on 2026-11-08T10:59:43Z.


What

Implements three libSceLibreSsl3 key-accessor exports that threw NotImplemented_nid_no_patch:

  • EVP_PKEY_assign (gp5dGS14-pI) stores the type and native key pointer in the 24-byte EVP_PKEY. A null key returns 0, and replacing a non-null native key or method throws through NotImplemented_nid_no_patch because the type-specific destructor is not modelled.
  • EVP_PKEY_set1_EC_KEY assigns the EC key and takes a reference through EC_KEY_up_ref; a null key returns 0.
  • EVP_PKEY_get1_RSA returns the RSA key with a reference through RSA_up_ref, queues EVP_R_EXPECTING_AN_RSA_KEY and returns null for another key type, and throws for a null key or a null RSA where LibreSSL dereferences it.

src/PkeyAccessors.cpp holds all three, tests/PkeyAccessors.cpp is registered as guest_libressl3_pkey_accessors, and the stubs leave Export.cpp/AdditionalExports.cpp while the declarations gain their real signatures in include/Api.hpp. docs/dev/debt/libSceLibreSsl3.md loses the EVP_PKEY_assign row (125 to 124 callable exports, 116 to 115 named) and gains one Functional entry for the unverified PS5 ABI, the reference semantics and the replacement gap.

Tested

Linux x86-64 (CachyOS, GCC 16.2.1), Release, BUILD_TESTING=ON, base main 828e44310e:

  • guest_libressl3_pkey_accessors covers assignment, repeated get1_RSA references, the wrong-type error code 0x06fff07f, EC assignment and reference counting, the null-key return, replacement and null-argument throws, and an empty error queue.
  • ctest --test-dir build -R '^guest_libressl3_pkey_accessors$' --output-on-failure: 1/1 passed.
  • python3 tools/check_conventions.py --base origin/main: passed; tools/check_test_registration.py build: passed.
  • Not run: Windows, a console, or a title.

Checklist

  • Based on current main; no other open PR implements these exports
  • 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); the replacement gap is in the debt entry
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5210749883 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17138). Originally posted by [fishingpvalues](https://github.com/fishingpvalues) on 2026-11-08T10:59:43Z. --- ### What Implements three `libSceLibreSsl3` key-accessor exports that threw `NotImplemented_nid_no_patch`: - `EVP_PKEY_assign` (`gp5dGS14-pI`) stores the type and native key pointer in the 24-byte `EVP_PKEY`. A null key returns 0, and replacing a non-null native key or method throws through `NotImplemented_nid_no_patch` because the type-specific destructor is not modelled. - `EVP_PKEY_set1_EC_KEY` assigns the EC key and takes a reference through `EC_KEY_up_ref`; a null key returns 0. - `EVP_PKEY_get1_RSA` returns the RSA key with a reference through `RSA_up_ref`, queues `EVP_R_EXPECTING_AN_RSA_KEY` and returns null for another key type, and throws for a null key or a null RSA where LibreSSL dereferences it. `src/PkeyAccessors.cpp` holds all three, `tests/PkeyAccessors.cpp` is registered as `guest_libressl3_pkey_accessors`, and the stubs leave `Export.cpp`/`AdditionalExports.cpp` while the declarations gain their real signatures in `include/Api.hpp`. `docs/dev/debt/libSceLibreSsl3.md` loses the `EVP_PKEY_assign` row (125 to 124 callable exports, 116 to 115 named) and gains one Functional entry for the unverified PS5 ABI, the reference semantics and the replacement gap. ### Tested Linux x86-64 (CachyOS, GCC 16.2.1), Release, `BUILD_TESTING=ON`, base `main` `828e44310e`: - `guest_libressl3_pkey_accessors` covers assignment, repeated `get1_RSA` references, the wrong-type error code `0x06fff07f`, EC assignment and reference counting, the null-key return, replacement and null-argument throws, and an empty error queue. - `ctest --test-dir build -R '^guest_libressl3_pkey_accessors$' --output-on-failure`: 1/1 passed. - `python3 tools/check_conventions.py --base origin/main`: passed; `tools/check_test_registration.py build`: passed. - Not run: Windows, a console, or a title. ### Checklist - [x] Based on current `main`; no other open PR implements these exports - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); the replacement gap is in the debt entry - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
coptergui-ops commented 2026-11-08 12:30:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by coptergui-ops on 2026-11-08T12:30:08Z.

Review: APPROVED


Reviewed at current head (rebased; per-file diffs verified byte-identical to GitHub's patches). Implements EVP_PKEY_assign (gp5dGS14-pI), set1_EC_KEY and get1_RSA in src/PkeyAccessors.cpp with the 24-byte EVP_PKEY layout, up_ref reference semantics and the documented NotImplemented throw on key replacement; stubs removed from Export.cpp, Api.hpp declarations gain real signatures, PkeyQueries test block registered. Tests pin type codes, up_ref counters, queued LibreSSL errors (EVP_R_EXPECTING_AN_RSA_KEY) and null-key returns. Overlap verdicts (39 bot-flagged old PRs, compared changed lines not file names): no old PR touches the assign/get1_RSA/set1_EC lines; PR 14499 edits the neighboring get0_EC_KEY declaration, a different function, no collision. Intra-wave: PR 17142 and this PR both insert a debt bullet at the same anchor in docs/dev/debt/libSceLibreSsl3.md - git merge-tree shows that debt bullet insertion is the ONLY conflict (Export.cpp, Api.hpp and CMakeLists auto-merge); whoever merges second should rebase its bullet. Not a duplication. Conventions checker: no new findings from this diff (debt-length warnings pre-exist on main).

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5817877590 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17138#pullrequestreview-5817877590). Originally posted by [coptergui-ops](https://github.com/coptergui-ops) on 2026-11-08T12:30:08Z. **Review:** APPROVED --- Reviewed at current head (rebased; per-file diffs verified byte-identical to GitHub's patches). Implements EVP_PKEY_assign (gp5dGS14-pI), set1_EC_KEY and get1_RSA in src/PkeyAccessors.cpp with the 24-byte EVP_PKEY layout, up_ref reference semantics and the documented NotImplemented throw on key replacement; stubs removed from Export.cpp, Api.hpp declarations gain real signatures, PkeyQueries test block registered. Tests pin type codes, up_ref counters, queued LibreSSL errors (EVP_R_EXPECTING_AN_RSA_KEY) and null-key returns. Overlap verdicts (39 bot-flagged old PRs, compared changed lines not file names): no old PR touches the assign/get1_RSA/set1_EC lines; PR 14499 edits the neighboring get0_EC_KEY declaration, a different function, no collision. Intra-wave: PR 17142 and this PR both insert a debt bullet at the same anchor in docs/dev/debt/libSceLibreSsl3.md - git merge-tree shows that debt bullet insertion is the ONLY conflict (Export.cpp, Api.hpp and CMakeLists auto-merge); whoever merges second should rebase its bullet. Not a duplication. Conventions checker: no new findings from this diff (debt-length warnings pre-exist on main).
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!17138
No description provided.