feat(libSceLibreSsl): implement EVP_CIPHER_block_size #10450

Merged
alvaroelpob merged 3 commits from upstream-pr/10450 into main 2026-11-04 22:30:33 +00:00
alvaroelpob commented 2026-10-24 01:03:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by alvaroelpob on 2026-10-24T01:03:03Z.


What

Implements EVP_CIPHER_block_size in libSceLibreSsl, which threw and was declared without parameters.

The module is LibreSSL 2.5.4 (firmware 13.40 measurements in #8981). The signature int EVP_CIPHER_block_size(const EVP_CIPHER*), the layout and the result follow that release's evp.h and evp_lib.c. It returns block_size as stored, with no range check.

The 2.5.4 EVP_CIPHER is 88 bytes on LP64 (nid, block_size at 4, key_len, iv_len, flags, init at 24, do_cipher, cleanup, ctx_size at 48, then the ASN.1, ctrl and app_data pointers), checked with static_asserts. This is the same layout #9571 uses for its EVP_aes_*_cbc objects, so this export reads those correctly once both are in. LibreSSL dereferences the cipher without checking it, so a null cipher throws.

The debt entry records the source and what is unverified, and the pending-export count drops from 357 to 356.

Tested

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

  • New guest_libressl_evp_cipher test: on an 88-byte buffer filled with 0xAA, the value at offset 4 is returned for 1, 8, 16, 0 and -1. On a zeroed cipher with nid and key_len set, it returns 16 and leaves the buffer unchanged. A null cipher throws. On main the first call throws.
  • Full ctest -j16: 2003/2004 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 ccf2527c39: 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 bd4796fe01, 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. bd4796fe01 (refactor(libSceLibreSsl): declare the EVP_CIPHER_block_size 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 18dc0f2f4e, 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.
  • Rebased on main 2dbe9b99f5 (after #9745, #9870 and #11111), head 21776a5c4b, 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 33427e8eb6) 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 6fe3d63343, 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, and guest_pthread_start timed out once at 20 s while another full suite shared the machine; run alone with --repeat until-fail:3 it passes 3/3 in about 2 s. check_conventions.py --base upstream/main passes.
  • Rebased on main cf79276fee (after #13820), head c235797955, to resolve the conflict on the pending-export count in the debt file. main still says 292 although #13820 removed two stubs, leaving 290, so the count is now set to the 289 stubs left in Export.cpp. Full build and ctest -j16: 3107/3107 pass (log_file failed once on #10486 and passed on five reruns and a second full run). check_conventions.py --base upstream/main passes.
  • Rebased on main 4939814d79 (after #9970, #10078 and #10488), head 099a300c60, to resolve the conflicts on the shared CMakeLists.txt, Export.cpp, Api.hpp and debt-file lines; both sides are kept. #10488 removed the three EVP_CIPHER_CTX_* stubs next to EVP_CIPHER_block_size, so all four are gone. The old docs(libSceLibreSsl): correct the pending export count commit became empty and is dropped. The count is set to the 260 stubs left in Export.cpp. Full build and ctest -j16: 3538/3538 pass. check_conventions.py --base upstream/main passes.
  • Rebased on main 4f41f4c375, head 336a167fce, to resolve the conflicts on the shared CMakeLists.txt, Export.cpp and debt-file lines; both sides are kept and the debt count is recomputed from Export.cpp. Full build and ctest -j16: 3796/3800 pass; guest_sce_net, guest_poll, guest_select_wait and guest_memory failed under that load, pass when run alone, and main 4f41f4c375 passes all 3799 with -j16 on the same machine. 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: #9446, #9571, #10395, #10418, #10448
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4991210566 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10450). Originally posted by [alvaroelpob](https://github.com/alvaroelpob) on 2026-10-24T01:03:03Z. --- ### What Implements `EVP_CIPHER_block_size` in libSceLibreSsl, which threw and was declared without parameters. The module is LibreSSL 2.5.4 ([firmware 13.40 measurements in #8981](https://github.com/boykopovar/AnyPS5/discussions/8981#discussioncomment-19111214)). The signature `int EVP_CIPHER_block_size(const EVP_CIPHER*)`, the layout and the result follow that release's [`evp.h` and `evp_lib.c`](https://github.com/libressl/openbsd/tree/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/evp). It returns `block_size` as stored, with no range check. The 2.5.4 `EVP_CIPHER` is 88 bytes on LP64 (`nid`, `block_size` at 4, `key_len`, `iv_len`, `flags`, `init` at 24, `do_cipher`, `cleanup`, `ctx_size` at 48, then the ASN.1, `ctrl` and `app_data` pointers), checked with `static_assert`s. This is the same layout #9571 uses for its `EVP_aes_*_cbc` objects, so this export reads those correctly once both are in. LibreSSL dereferences the cipher without checking it, so a null cipher throws. The debt entry records the source and what is unverified, and the pending-export count drops from 357 to 356. ### 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 26.04 (WSL2, kernel 6.18), GCC 15.2.0, Release, full build with `BUILD_TESTING=ON` on `main` e2b9700a9. - New `guest_libressl_evp_cipher` test: on an 88-byte buffer filled with 0xAA, the value at offset 4 is returned for 1, 8, 16, 0 and -1. On a zeroed cipher with `nid` and `key_len` set, it returns 16 and leaves the buffer unchanged. A null cipher throws. On `main` the first call throws. - Full `ctest -j16`: 2003/2004 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 ccf2527c39: 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 bd4796fe01, 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. bd4796fe01 (`refactor(libSceLibreSsl): declare the EVP_CIPHER_block_size 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 18dc0f2f4e, 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. - Rebased on `main` 2dbe9b99f5 (after #9745, #9870 and #11111), head 21776a5c4b, 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 33427e8eb6) 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 6fe3d63343, 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`, and `guest_pthread_start` timed out once at 20 s while another full suite shared the machine; run alone with `--repeat until-fail:3` it passes 3/3 in about 2 s. `check_conventions.py --base upstream/main` passes. - Rebased on `main` cf79276fee (after #13820), head c235797955, to resolve the conflict on the pending-export count in the debt file. `main` still says 292 although #13820 removed two stubs, leaving 290, so the count is now set to the 289 stubs left in `Export.cpp`. Full build and `ctest -j16`: 3107/3107 pass (`log_file` failed once on #10486 and passed on five reruns and a second full run). `check_conventions.py --base upstream/main` passes. - Rebased on `main` 4939814d79 (after #9970, #10078 and #10488), head 099a300c60, to resolve the conflicts on the shared `CMakeLists.txt`, `Export.cpp`, `Api.hpp` and debt-file lines; both sides are kept. #10488 removed the three `EVP_CIPHER_CTX_*` stubs next to `EVP_CIPHER_block_size`, so all four are gone. The old `docs(libSceLibreSsl): correct the pending export count` commit became empty and is dropped. The count is set to the 260 stubs left in `Export.cpp`. Full build and `ctest -j16`: 3538/3538 pass. `check_conventions.py --base upstream/main` passes. - Rebased on `main` 4f41f4c375, head 336a167fce, to resolve the conflicts on the shared `CMakeLists.txt`, `Export.cpp` and debt-file lines; both sides are kept and the debt count is recomputed from `Export.cpp`. Full build and `ctest -j16`: 3796/3800 pass; `guest_sce_net`, `guest_poll`, `guest_select_wait` and `guest_memory` failed under that load, pass when run alone, and `main` 4f41f4c375 passes all 3799 with `-j16` on the same machine. `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: #9446, #9571, #10395, #10418, #10448 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
copilot-pull-request-reviewer[bot] commented 2026-10-24 01:03:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-10-24T01:03:12Z.

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:5635980873 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10450#pullrequestreview-5635980873). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-10-24T01:03:12Z. **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-24 01:18:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T01:18:28Z.

Review: APPROVED


Reviewed the exact head f2a113665cdd845d61875a1b33822e4a13eec4da. The cited LibreSSL 2.5.4 public EVP_CIPHER layout places block_size at offset 4 and the 88-byte LP64 size/layout assertions are consistent with the type. The implementation returns the stored field without imposing an extra range check, and the focused test verifies representative positive, zero, negative, and null-pointer behavior without mutating the object. The PR's dependency list reflects its relationship to the existing cipher constructors and the stacked LibreSSL accessor work. Hosted eligibility, conventions, intake, labels, and report checks pass. The author reports a 2003/2004 full CTest run with one failure also present on base; I did not independently run the suite, and hosted product builds are skipped. No blocking issue found in the reviewed scope.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5636090994 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10450#pullrequestreview-5636090994). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T01:18:28Z. **Review:** APPROVED --- Reviewed the exact head f2a113665cdd845d61875a1b33822e4a13eec4da. The cited LibreSSL 2.5.4 public `EVP_CIPHER` layout places `block_size` at offset 4 and the 88-byte LP64 size/layout assertions are consistent with the type. The implementation returns the stored field without imposing an extra range check, and the focused test verifies representative positive, zero, negative, and null-pointer behavior without mutating the object. The PR's dependency list reflects its relationship to the existing cipher constructors and the stacked LibreSSL accessor work. Hosted eligibility, conventions, intake, labels, and report checks pass. The author reports a 2003/2004 full CTest run with one failure also present on base; I did not independently run the suite, and hosted product builds are skipped. No blocking issue found in the reviewed scope.
MarcZX10 commented 2026-10-29 08:59:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T08:59:40Z.

Review: CHANGES_REQUESTED


Re-check — changes requested\n\nThe new report is useful: it says the implementation functions were preserved through the merge and the full test suite has the same single known failure as its tested main, with conventions passing. However, the tested integration point is 4c7d275bef; current upstream main is aaccd0ba39, and this PR head is 44 commits behind it.\n\nPlease update onto current main, preserve the implementation and debt-count changes, recount the pending exports against the resulting Export.cpp, and rerun the relevant LibreSSL tests plus conventions on the exact updated head. The earlier approval was for the prior head and does not cover this stale integration point. I did not rerun these checks locally.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5695136065 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10450#pullrequestreview-5695136065). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-29T08:59:40Z. **Review:** CHANGES_REQUESTED --- ## Re-check — changes requested\n\nThe new report is useful: it says the implementation functions were preserved through the merge and the full test suite has the same single known failure as its tested main, with conventions passing. However, the tested integration point is 4c7d275bef; current upstream main is aaccd0ba39, and this PR head is 44 commits behind it.\n\nPlease update onto current main, preserve the implementation and debt-count changes, recount the pending exports against the resulting Export.cpp, and rerun the relevant LibreSSL tests plus conventions on the exact updated head. The earlier approval was for the prior head and does not cover this stale integration point. I did not rerun these checks locally.
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!10450
No description provided.