feat(libSceLibreSsl3): implement EVP_CIPHER_key_length and EVP_CIPHER_iv_length #13659

Merged
alvaroelpob merged 6 commits from upstream-pr/13659 into main 2026-10-31 12:57:07 +00:00
alvaroelpob commented 2026-10-30 22:04:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by alvaroelpob on 2026-10-30T22:04:03Z.


What

Implements EVP_CIPHER_key_length and EVP_CIPHER_iv_length in libSceLibreSsl3. Both are additional exports (13.60 table) that threw and were declared without parameters.

Signatures and results follow LibreSSL 4.0.0 evp_cipher.c: int EVP_CIPHER_key_length(const EVP_CIPHER*) returns key_len and int EVP_CIPHER_iv_length(const EVP_CIPHER*) returns iv_len, as stored. The 80-byte 4.0.0 EVP_CIPHER from evp_local.h (nid, block_size, key_len at 8, iv_len at 12, flags, init, do_cipher, cleanup, ctx_size at 48, the two ASN.1 pointers and ctrl) is LibreSsl3EvpCipher, checked with static_asserts. Its first four fields are at the same offsets as in the 2.5.4 layout of the ciphers that the forwarded libSceLibreSsl exports handle. LibreSSL dereferences the cipher without checking it, so a null cipher throws.

The debt entry records the source and what is unverified. The additional-export inventory loses both rows and its count drops from 180 to 178.

Tested

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

  • New guest_libressl3_cipher test: on a cipher filled with 0xA5, EVP_CIPHER_key_length and EVP_CIPHER_iv_length return the value stored in key_len and iv_len for 0, 1, 8, 12, 16, 24, 32, 64, -1, INT32_MAX and INT32_MIN and leave the cipher unchanged. An AES-256-CBC-shaped cipher returns 32 and 16. A null cipher throws std::invalid_argument.
  • Full ctest -j16 on head e08ec905d3: 3029/3029 pass. check_conventions.py --base upstream/main passes.
  • Not tested: Windows, a title.

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: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5091622801 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13659). Originally posted by [alvaroelpob](https://github.com/alvaroelpob) on 2026-10-30T22:04:03Z. --- ### What Implements `EVP_CIPHER_key_length` and `EVP_CIPHER_iv_length` in libSceLibreSsl3. Both are additional exports (13.60 table) that threw and were declared without parameters. Signatures and results follow [LibreSSL 4.0.0](https://github.com/libressl/openbsd/tree/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/evp) `evp_cipher.c`: `int EVP_CIPHER_key_length(const EVP_CIPHER*)` returns `key_len` and `int EVP_CIPHER_iv_length(const EVP_CIPHER*)` returns `iv_len`, as stored. The 80-byte 4.0.0 `EVP_CIPHER` from `evp_local.h` (`nid`, `block_size`, `key_len` at 8, `iv_len` at 12, `flags`, `init`, `do_cipher`, `cleanup`, `ctx_size` at 48, the two ASN.1 pointers and `ctrl`) is `LibreSsl3EvpCipher`, checked with `static_assert`s. Its first four fields are at the same offsets as in the [2.5.4 layout](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/evp/evp.h) of the ciphers that the forwarded libSceLibreSsl exports handle. LibreSSL dereferences the cipher without checking it, so a null cipher throws. The debt entry records the source and what is unverified. The additional-export inventory loses both rows and its count drops from 180 to 178. ### 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` d4de5943f6 (3028/3028 pass). - New `guest_libressl3_cipher` test: on a cipher filled with 0xA5, `EVP_CIPHER_key_length` and `EVP_CIPHER_iv_length` return the value stored in `key_len` and `iv_len` for 0, 1, 8, 12, 16, 24, 32, 64, -1, `INT32_MAX` and `INT32_MIN` and leave the cipher unchanged. An AES-256-CBC-shaped cipher returns 32 and 16. A null cipher throws `std::invalid_argument`. - Full `ctest -j16` on head e08ec905d3: 3029/3029 pass. `check_conventions.py --base upstream/main` passes. - Not tested: Windows, a title. ### 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: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-30 22:24:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-30T22:24:30Z.

Review: APPROVED


Reviewed — looks good

The two accessors read the matching key_len and iv_len fields, and the declarations, NIDs, layout assertions, and focused tests are consistent with the cited LibreSSL versions.

What I ran

Reviewed head e08ec905d34e0f8ab184333c53bf5cba82e4fffd against base 9605300f293b88295e223a27ff8cfecf24d7ab2a; the exact-head merge preview was clean. Environment: Debian Linux x86-64, Python 3.11.2; GCC 12.2.0 available but not invoked. No local build or C++ test was run.

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13659
python3 tools/pr_abi_audit.py --repo /marc/AnyPS5 --base 9605300f293b88295e223a27ff8cfecf24d7ab2a --head e08ec905d34e0f8ab184333c53bf5cba82e4fffd --json
python3 tools/pr_test_quality.py --root /tmp/anyps5-review-13659-exact --json core/libs/prx/libSceLibreSsl3/tests/Cipher.cpp
git worktree add --detach /tmp/anyps5-review-13659-exact e08ec905d34e0f8ab184333c53bf5cba82e4fffd
(cd /tmp/anyps5-review-13659-exact && python3 core/libs/tests/test_public_headers.py --audit-only)
git worktree remove --force /tmp/anyps5-review-13659-exact
gh pr checks 13659 --repo boykopovar/AnyPS5

I also read the pinned LibreSSL 4.0.0 and 2.5.4 source through the upstream repository API to verify the field behavior and layouts.

Results

Check Result
Diff, conventions, dependency/mergeability Passed; exact-head preview clean and no declared dependencies.
ABI audit Passed with no findings; declarations and definitions map to NIDs 4ryyfC3TknU and qAG7o03bkkM.
Layout and public-header audit LibreSsl3EvpCipher asserts 80 bytes, keyLength offset 8, ivLength offset 12; exact-head audit passed for 389 libraries and 24,477 exports.
Test registration and quality CMake registers the new guest_libressl3_cipher test. The heuristic warned that the source may be unregistered because it does not match the generated path literally; manual inspection confirmed registration.
Author-reported focused tests The PR reports ctest -j16 passed 3029/3029 on exact head e08ec905d34e0f8ab184333c53bf5cba82e4fffd. I did not independently reproduce that build or test run.
Hosted CI Windows was in progress at the final refresh. Conventions, eligibility, labels, library-portability, and report passed; Linux and specialized jobs were skipped.
Precheck wrapper Its isolated checkout lacked the workspace-only ABI and test-quality helpers. I ran the ABI audit and test-quality helper directly on the exact head.
Unedited outputs from checks
All conventions checks passed.
{
  "status": "passed",
  "symbols": [
    {
      "name": "EVP_CIPHER_iv_length_nid_postfix",
      "computed_nid": "4ryyfC3TknU",
      "declarations": [
        "core/libs/prx/libSceLibreSsl3/include/Api.hpp"
      ],
      "definitions": [
        "core/libs/prx/libSceLibreSsl3/src/Cipher.cpp"
      ],
      "explicit_aliases": [],
      "version": "not encoded by these source declarations; not verified"
    },
    {
      "name": "EVP_CIPHER_key_length_nid_postfix",
      "computed_nid": "qAG7o03bkkM",
      "declarations": [
        "core/libs/prx/libSceLibreSsl3/include/Api.hpp"
      ],
      "definitions": [
        "core/libs/prx/libSceLibreSsl3/src/Cipher.cpp"
      ],
      "explicit_aliases": [],
      "version": "not encoded by these source declarations; not verified"
    }
  ],
  "findings": []
}
389 libraries, 24477 exports: unique declarations and umbrella coverage verified
{
  "findings": [
    {
      "path": "core/libs/prx/libSceLibreSsl3/tests/Cipher.cpp",
      "line": 1,
      "kind": "possible-unregistered-cpp-test",
      "message": "Changed C++ test source path was not found literally in CMake files; inspect registration, generated source lists, and workflow coverage."
    }
  ],
  "negative_control_candidates": [],
  "limits": [
    "Heuristics can miss weak assertions and can flag valid tests; inspect every finding.",
    "A test that passes against base is not by itself proof that the PR test is inadequate.",
    "Negative controls are only candidates until the test actually runs against base and fails by assertion rather than import/setup error."
  ]
}
/usr/bin/python3: can't open file '/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13659-e08ec905d34e/head-e08ec905d34e-b62972f5/tools/pr_abi_audit.py': [Errno 2] No such file or directory
/usr/bin/python3: can't open file '/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13659-e08ec905d34e/head-e08ec905d34e-b62972f5/tools/pr_test_quality.py': [Errno 2] No such file or directory

git diff --check produced no output and exited 0.

Findings

Blocking

None found in the reviewed source, ABI audit, or test review.

Non-blocking

The bundled-console layout and runtime behavior remain unverified. The author reports an exact-head full test run; I did not reproduce it locally, and the hosted Windows job had not completed at the final check.

Sources

Not verified

No local compilation or C++ test was run. Windows hosted CI was still running; Linux and specialized jobs were skipped. No console or game behavior was tested.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5719324165 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13659#pullrequestreview-5719324165). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-30T22:24:30Z. **Review:** APPROVED --- # Reviewed — looks good The two accessors read the matching `key_len` and `iv_len` fields, and the declarations, NIDs, layout assertions, and focused tests are consistent with the cited LibreSSL versions. ## What I ran Reviewed head `e08ec905d34e0f8ab184333c53bf5cba82e4fffd` against base `9605300f293b88295e223a27ff8cfecf24d7ab2a`; the exact-head merge preview was clean. Environment: Debian Linux x86-64, Python 3.11.2; GCC 12.2.0 available but not invoked. No local build or C++ test was run. ```sh python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13659 python3 tools/pr_abi_audit.py --repo /marc/AnyPS5 --base 9605300f293b88295e223a27ff8cfecf24d7ab2a --head e08ec905d34e0f8ab184333c53bf5cba82e4fffd --json python3 tools/pr_test_quality.py --root /tmp/anyps5-review-13659-exact --json core/libs/prx/libSceLibreSsl3/tests/Cipher.cpp git worktree add --detach /tmp/anyps5-review-13659-exact e08ec905d34e0f8ab184333c53bf5cba82e4fffd (cd /tmp/anyps5-review-13659-exact && python3 core/libs/tests/test_public_headers.py --audit-only) git worktree remove --force /tmp/anyps5-review-13659-exact gh pr checks 13659 --repo boykopovar/AnyPS5 ``` I also read the pinned LibreSSL 4.0.0 and 2.5.4 source through the upstream repository API to verify the field behavior and layouts. ## Results | Check | Result | |---|---| | Diff, conventions, dependency/mergeability | Passed; exact-head preview clean and no declared dependencies. | | ABI audit | Passed with no findings; declarations and definitions map to NIDs `4ryyfC3TknU` and `qAG7o03bkkM`. | | Layout and public-header audit | `LibreSsl3EvpCipher` asserts 80 bytes, `keyLength` offset 8, `ivLength` offset 12; exact-head audit passed for 389 libraries and 24,477 exports. | | Test registration and quality | CMake registers the new `guest_libressl3_cipher` test. The heuristic warned that the source may be unregistered because it does not match the generated path literally; manual inspection confirmed registration. | | Author-reported focused tests | The PR reports `ctest -j16` passed 3029/3029 on exact head `e08ec905d34e0f8ab184333c53bf5cba82e4fffd`. I did not independently reproduce that build or test run. | | Hosted CI | Windows was in progress at the final refresh. Conventions, eligibility, labels, library-portability, and report passed; Linux and specialized jobs were skipped. | | Precheck wrapper | Its isolated checkout lacked the workspace-only ABI and test-quality helpers. I ran the ABI audit and test-quality helper directly on the exact head. | <details><summary>Unedited outputs from checks</summary> ```text All conventions checks passed. ``` ```json { "status": "passed", "symbols": [ { "name": "EVP_CIPHER_iv_length_nid_postfix", "computed_nid": "4ryyfC3TknU", "declarations": [ "core/libs/prx/libSceLibreSsl3/include/Api.hpp" ], "definitions": [ "core/libs/prx/libSceLibreSsl3/src/Cipher.cpp" ], "explicit_aliases": [], "version": "not encoded by these source declarations; not verified" }, { "name": "EVP_CIPHER_key_length_nid_postfix", "computed_nid": "qAG7o03bkkM", "declarations": [ "core/libs/prx/libSceLibreSsl3/include/Api.hpp" ], "definitions": [ "core/libs/prx/libSceLibreSsl3/src/Cipher.cpp" ], "explicit_aliases": [], "version": "not encoded by these source declarations; not verified" } ], "findings": [] } ``` ```text 389 libraries, 24477 exports: unique declarations and umbrella coverage verified ``` ```json { "findings": [ { "path": "core/libs/prx/libSceLibreSsl3/tests/Cipher.cpp", "line": 1, "kind": "possible-unregistered-cpp-test", "message": "Changed C++ test source path was not found literally in CMake files; inspect registration, generated source lists, and workflow coverage." } ], "negative_control_candidates": [], "limits": [ "Heuristics can miss weak assertions and can flag valid tests; inspect every finding.", "A test that passes against base is not by itself proof that the PR test is inadequate.", "Negative controls are only candidates until the test actually runs against base and fails by assertion rather than import/setup error." ] } ``` ```text /usr/bin/python3: can't open file '/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13659-e08ec905d34e/head-e08ec905d34e-b62972f5/tools/pr_abi_audit.py': [Errno 2] No such file or directory /usr/bin/python3: can't open file '/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13659-e08ec905d34e/head-e08ec905d34e-b62972f5/tools/pr_test_quality.py': [Errno 2] No such file or directory ``` `git diff --check` produced no output and exited 0. </details> ## Findings ### Blocking None found in the reviewed source, ABI audit, or test review. ### Non-blocking The bundled-console layout and runtime behavior remain unverified. The author reports an exact-head full test run; I did not reproduce it locally, and the hosted Windows job had not completed at the final check. ## Sources - [Accessor implementation at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/e08ec905d34e0f8ab184333c53bf5cba82e4fffd/core/libs/prx/libSceLibreSsl3/src/Cipher.cpp) - [Cipher layout and assertions at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/e08ec905d34e0f8ab184333c53bf5cba82e4fffd/core/libs/prx/libSceLibreSsl3/include/Cipher.hpp) - [Test at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/e08ec905d34e0f8ab184333c53bf5cba82e4fffd/core/libs/prx/libSceLibreSsl3/tests/Cipher.cpp) - [LibreSSL 4.0.0 accessor behavior](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/evp/evp_cipher.c#L1086-L1098) - [LibreSSL 4.0.0 cipher layout](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/evp/evp_local.h#L1284-L1308) - [LibreSSL 2.5.4 cipher layout](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/evp/evp.h#L297-L313) ## Not verified No local compilation or C++ test was run. Windows hosted CI was still running; Linux and specialized jobs were skipped. No console or game behavior was tested.
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!13659
No description provided.