feat(libSceLibreSsl): implement EVP_PKEY_type #10398

Merged
alvaroelpob merged 3 commits from upstream-pr/10398 into main 2026-10-27 07:52:32 +00:00
alvaroelpob commented 2026-10-23 21:26:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by alvaroelpob on 2026-10-23T21:26:46Z.


What

Implements EVP_PKEY_type(int) in libSceLibreSsl, which threw and was declared without parameters. It is a pure lookup of a key type's base type, in one commit.

The module is LibreSSL 2.5.4 (firmware 13.40 measurements in #8981). In that release EVP_PKEY_type returns the pkey_id that EVP_PKEY_asn1_find finds in standard_methods, following alias entries to their base type, or NID_undef (0). The engine branch can't apply: every ENGINE_ export of this module throws, so no engine is ever registered. EVP_PKEY_asn1_add0, the only way to add application methods, isn't exported.

Type (NID from obj_mac.num) Result
RSA 6, its alias 19 6
EC 408, HMAC 855, CMAC 894 the same type
DH 28 28
DSA 66, 67, 70, 113, 116 116
anything else, GOST 811, 815, 946 and 947 included 0

Which method families the console's build compiles in comes from BunnyFl's run of firmware 13.42's module on a PC, over every type from -1000 to 5000 and the int extremes: DH and DSA are compiled in and GOST is not (OPENSSL_NO_GOST), and every other type matches this table. The debt entry records this.

Tested

Ubuntu (WSL2, kernel 6.18), GCC 15.2.0, Release, full build with BUILD_TESTING=ON on main a0e858ff7.

  • New guest_libressl_pkey_type test checks:

    • the five implemented types and the RSA alias;
    • DH 28 and the five DSA types;
    • 0 for neighbouring and unrelated types (0, -1, 1, 5, 7, 64, 65, 117, 407, 409, 672, 854, 856, 893, 895, 948, INT_MIN, INT_MAX).

    On main the first call throws.

  • Full ctest -j16: 1992/1993 pass. agc_driver_multisample_retirement fails the same way on main on this machine.

  • Not tested: Windows, a title.

  • Rebased on main 1e740a23a3 (after #9033), head d7412d888a: the conflicts were only the add_library source list, the end of the test block, the pending-export count and the last debt entry; both sides are kept and the count is 357 minus this PR's exports. Full build and ctest -j16: 2043/2044 pass; agc_driver_multisample_retirement fails the same way on that main. check_conventions.py --base upstream/main passes.

  • Rebased on main e7e3e9c198, head e400befc61, to resolve the conflict from #9529 on the shared CMakeLists.txt and debt-file lines; both sides are kept and the count is 353 minus this PR's exports. e400befc61 (refactor(libSceLibreSsl): declare the EVP_PKEY_type exports in the public header) puts the real signatures and their structs in libSceLibreSsl/include/Api.hpp and drops the test's redeclarations, which public_headers requires since #10706. Full build and ctest -j16: 2202/2203 pass; agc_driver_multisample_retirement fails the same way on that main. check_conventions.py --base upstream/main passes.

  • Rebased on main ae7d59258e (after #9949), head de9de5ebcd, to resolve the conflicts with main on the shared CMakeLists.txt and debt-file lines; both sides are kept and the count is 342 minus this PR's exports. Full build and ctest -j16: 2275/2276 pass; agc_driver_multisample_retirement fails the same way on that main. check_conventions.py --base upstream/main passes.

  • Review fix 64680a6faa returns 28 for DH, 116 for the DSA types and 0 for GOST, as firmware 13.42's module does, drops the throw checks, tests the DH and DSA results with the GOST types among the 0 cases, and updates the debt entry; guest_libressl_pkey_type passes, and returning the type itself for the DSA aliases fails it. Full build and ctest -j16 on main ae7d59258e: 2275/2276 pass; agc_driver_multisample_retirement fails the same way on that main. check_conventions.py --base upstream/main passes.

  • Rebased on main 2dbe9b99f5 (after #9745, #9870 and #11111), head c9ffcc7cfb, to resolve the conflicts with main on the shared CMakeLists.txt and debt-file lines; both sides are kept and the count is 340 minus this PR's exports. Full build and ctest -j16: 2370/2371 pass; agc_driver_multisample_retirement fails the same way on that main. check_conventions.py --base upstream/main passes.

  • Rebased on main 88795ed448 (after #10248; head 15044f970e) to resolve the conflicts on the shared debt-file lines; both sides are kept and the count is 335 minus this PR's exports. Full build and ctest -j16: 2383/2384 pass; agc_driver_multisample_retirement fails the same way on that main. check_conventions.py --base upstream/main passes.

  • Rebased on main c7b4878fa8 (after #10373, #10376 and #10449), head 1e88908181, to resolve the conflicts with main on the shared CMakeLists.txt, Api.hpp and debt-file lines; both sides are kept and the count is 319 minus this PR's exports. Full build and ctest -j16: 2394/2395 pass; agc_driver_multisample_retirement fails the same way on that main. check_conventions.py --base upstream/main passes.

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: #9448, #9571, #10078, #10395
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4989459396 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10398). Originally posted by [alvaroelpob](https://github.com/alvaroelpob) on 2026-10-23T21:26:46Z. --- ### What Implements `EVP_PKEY_type(int)` in libSceLibreSsl, which threw and was declared without parameters. It is a pure lookup of a key type's base type, in one commit. The module is LibreSSL 2.5.4 ([firmware 13.40 measurements in #8981](https://github.com/boykopovar/AnyPS5/discussions/8981#discussioncomment-19111214)). In that release [`EVP_PKEY_type`](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/evp/p_lib.c#L372-L388) returns the `pkey_id` that `EVP_PKEY_asn1_find` finds in [`standard_methods`](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/asn1/ameth_lib.c#L83-L111), following alias entries to their base type, or `NID_undef` (0). The engine branch can't apply: every `ENGINE_` export of this module throws, so no engine is ever registered. `EVP_PKEY_asn1_add0`, the only way to add application methods, isn't exported. | Type (NID from `obj_mac.num`) | Result | |---|---| | RSA 6, its alias 19 | 6 | | EC 408, HMAC 855, CMAC 894 | the same type | | DH 28 | 28 | | DSA 66, 67, 70, 113, 116 | 116 | | anything else, GOST 811, 815, 946 and 947 included | 0 | Which method families the console's build compiles in comes from [BunnyFl's run of firmware 13.42's module](https://github.com/boykopovar/AnyPS5/pull/10398#issuecomment-6406072913) on a PC, over every type from -1000 to 5000 and the `int` extremes: DH and DSA are compiled in and GOST is not (`OPENSSL_NO_GOST`), and every other type matches this table. The debt entry records this. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Ubuntu (WSL2, kernel 6.18), GCC 15.2.0, Release, full build with `BUILD_TESTING=ON` on `main` a0e858ff7. - New `guest_libressl_pkey_type` test checks: - the five implemented types and the RSA alias; - DH 28 and the five DSA types; - 0 for neighbouring and unrelated types (0, -1, 1, 5, 7, 64, 65, 117, 407, 409, 672, 854, 856, 893, 895, 948, `INT_MIN`, `INT_MAX`). On `main` the first call throws. - Full `ctest -j16`: 1992/1993 pass. `agc_driver_multisample_retirement` fails the same way on `main` on this machine. - Not tested: Windows, a title. - Rebased on `main` 1e740a23a3 (after #9033), head d7412d888a: the conflicts were only the `add_library` source list, the end of the test block, the pending-export count and the last debt entry; both sides are kept and the count is 357 minus this PR's exports. Full build and `ctest -j16`: 2043/2044 pass; `agc_driver_multisample_retirement` fails the same way on that `main`. `check_conventions.py --base upstream/main` passes. - Rebased on `main` e7e3e9c198, head e400befc61, to resolve the conflict from #9529 on the shared `CMakeLists.txt` and debt-file lines; both sides are kept and the count is 353 minus this PR's exports. e400befc61 (`refactor(libSceLibreSsl): declare the EVP_PKEY_type exports in the public header`) puts the real signatures and their structs in `libSceLibreSsl/include/Api.hpp` and drops the test's redeclarations, which `public_headers` requires since #10706. Full build and `ctest -j16`: 2202/2203 pass; `agc_driver_multisample_retirement` fails the same way on that `main`. `check_conventions.py --base upstream/main` passes. - Rebased on `main` ae7d59258e (after #9949), head de9de5ebcd, to resolve the conflicts with `main` on the shared `CMakeLists.txt` and debt-file lines; both sides are kept and the count is 342 minus this PR's exports. Full build and `ctest -j16`: 2275/2276 pass; `agc_driver_multisample_retirement` fails the same way on that `main`. `check_conventions.py --base upstream/main` passes. - Review fix 64680a6faa returns 28 for DH, 116 for the DSA types and 0 for GOST, as firmware 13.42's module does, drops the throw checks, tests the DH and DSA results with the GOST types among the 0 cases, and updates the debt entry; `guest_libressl_pkey_type` passes, and returning the type itself for the DSA aliases fails it. Full build and `ctest -j16` on `main` ae7d59258e: 2275/2276 pass; `agc_driver_multisample_retirement` fails the same way on that `main`. `check_conventions.py --base upstream/main` passes. - Rebased on `main` 2dbe9b99f5 (after #9745, #9870 and #11111), head c9ffcc7cfb, to resolve the conflicts with `main` on the shared `CMakeLists.txt` and debt-file lines; both sides are kept and the count is 340 minus this PR's exports. Full build and `ctest -j16`: 2370/2371 pass; `agc_driver_multisample_retirement` fails the same way on that `main`. `check_conventions.py --base upstream/main` passes. - Rebased on `main` 88795ed448 (after #10248; head 15044f970e) to resolve the conflicts on the shared debt-file lines; both sides are kept and the count is 335 minus this PR's exports. Full build and `ctest -j16`: 2383/2384 pass; `agc_driver_multisample_retirement` fails the same way on that `main`. `check_conventions.py --base upstream/main` passes. - Rebased on `main` c7b4878fa8 (after #10373, #10376 and #10449), head 1e88908181, to resolve the conflicts with `main` on the shared `CMakeLists.txt`, `Api.hpp` and debt-file lines; both sides are kept and the count is 319 minus this PR's exports. Full build and `ctest -j16`: 2394/2395 pass; `agc_driver_multisample_retirement` fails the same way on that `main`. `check_conventions.py --base upstream/main` passes. ### 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: #9448, #9571, #10078, #10395 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
copilot-pull-request-reviewer[bot] commented 2026-10-23 21:26:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-10-23T21:26:56Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5634620484 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10398#pullrequestreview-5634620484). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-10-23T21:26:56Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
MarcZX10 commented 2026-10-23 23:10:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T23:10:14Z.

Review: APPROVED


Reviewed the exact head 9b9dd413ec91f72a6d326179ee9321c31ba36746. The mapping matches LibreSSL 2.5.4: EVP_PKEY_type returns the unaliased method pkey_id, or NID_undef, and the pinned ASN.1 method lookup follows alias base IDs. The explicit throws for DH/DSA/GOST preserve the repository's rule not to guess whether those optional families were compiled into the console module.

I independently compiled and ran GuestLibreSslPkeyType.cpp with Pkey.cpp under GCC C++20 with -Wall -Wextra -Werror; it passed. The exact-head conventions check and git diff --check also passed. I did not run the full project build or a title. The four declared dependencies are still open, and this branch is 141 commits behind current main; please rebase after the dependency stack settles, then rerun the project checks on that head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5635379751 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10398#pullrequestreview-5635379751). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-23T23:10:14Z. **Review:** APPROVED --- Reviewed the exact head `9b9dd413ec91f72a6d326179ee9321c31ba36746`. The mapping matches LibreSSL 2.5.4: `EVP_PKEY_type` returns the unaliased method `pkey_id`, or `NID_undef`, and the pinned ASN.1 method lookup follows alias base IDs. The explicit throws for DH/DSA/GOST preserve the repository's rule not to guess whether those optional families were compiled into the console module. I independently compiled and ran `GuestLibreSslPkeyType.cpp` with `Pkey.cpp` under GCC C++20 with `-Wall -Wextra -Werror`; it passed. The exact-head conventions check and `git diff --check` also passed. I did not run the full project build or a title. The four declared dependencies are still open, and this branch is 141 commits behind current `main`; please rebase after the dependency stack settles, then rerun the project checks on that head.
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!10398
No description provided.