feat(libSceLibreSsl3): implement EVP_CIPHER_nid, BN_is_negative and RSA_bits #14008

Closed
Appelschorle187 wants to merge 11 commits from upstream-pr/14008 into main
Appelschorle187 commented 2026-10-31 15:41:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Appelschorle187 on 2026-10-31T15:41:32Z.


What

Names and implements three libSceLibreSsl3 exports that were placeholders known only by NID. Each name was matched with compute_nid from tools/nid_names.py. The behaviour follows LibreSSL 4.0.0:

  • EVP_CIPHER_nid (aLdgrI2jAF0) returns nid at offset 0 of the 80-byte EVP_CIPHER.
  • BN_is_negative (AiNud8LR8B4) returns neg != 0 from the 24-byte BIGNUM. The new include/Bignum.hpp defines LibreSsl3Bignum.
  • RSA_bits (3KZ-L4y1gak) returns BN_num_bits(n), reading n at offset 24 of the module's existing 152-byte LibreSsl3Rsa layout.

A null argument throws, as do malformed bignums: negative top, null d, or a bit count above INT_MAX. The additional-export inventory goes from 177 entries (126 known only by NID) to 174 (123). Debt entries record that none of this is checked on the console. They also record that the console's RSA layout (offset 24 here, 32 in libSceLibreSsl's LibreSslRsa) is unverified.

Tested

Linux x86-64 (GCC). Built the libSceLibreSsl3 test targets and ran ctest -R "guest_libressl3|guest_crypto_memcmp": 9 of 9 passed, including the new guest_libressl3_bignum and guest_libressl3_rsa, and guest_libressl3_cipher, which now covers EVP_CIPHER_nid. tools/check_conventions.py --base origin/main and test_public_headers.py --audit-only pass. nm -D on the built libSceLibreSsl3.prx shows EVP_CIPHER_nid_nid_postfix, BN_is_negative_nid_postfix and RSA_bits_nid_postfix. No title, Windows or console testing.

The INT_MAX case in tests/Rsa.cpp computes a d pointer through uintptr_t so that d[top - 1] lands on one stack word instead of allocating 256 MiB. This is implementation-defined but holds on flat x86-64 address spaces.

tools/pr_overlap.py lists #10461, #10557, #10631, #10960, #12754, #12928, #12945 and #13662. They share files (Api.hpp, CMakeLists.txt, Key.hpp, AdditionalExports.cpp, the debt file) but none implements these exports.

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

🤖 Generated with Claude Code

https://claude.ai/code/session_013rhFWQL7oZRJSiGdkL5Gkn

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5099029570 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14008). Originally posted by [Appelschorle187](https://github.com/Appelschorle187) on 2026-10-31T15:41:32Z. --- ### What Names and implements three libSceLibreSsl3 exports that were placeholders known only by NID. Each name was matched with `compute_nid` from `tools/nid_names.py`. The behaviour follows LibreSSL 4.0.0: - `EVP_CIPHER_nid` (`aLdgrI2jAF0`) returns `nid` at offset 0 of the 80-byte `EVP_CIPHER`. - `BN_is_negative` (`AiNud8LR8B4`) returns `neg != 0` from the 24-byte `BIGNUM`. The new `include/Bignum.hpp` defines `LibreSsl3Bignum`. - `RSA_bits` (`3KZ-L4y1gak`) returns `BN_num_bits(n)`, reading `n` at offset 24 of the module's existing 152-byte `LibreSsl3Rsa` layout. A null argument throws, as do malformed bignums: negative `top`, null `d`, or a bit count above `INT_MAX`. The additional-export inventory goes from 177 entries (126 known only by NID) to 174 (123). Debt entries record that none of this is checked on the console. They also record that the console's RSA layout (offset 24 here, 32 in libSceLibreSsl's `LibreSslRsa`) is unverified. ### Tested Linux x86-64 (GCC). Built the libSceLibreSsl3 test targets and ran `ctest -R "guest_libressl3|guest_crypto_memcmp"`: 9 of 9 passed, including the new `guest_libressl3_bignum` and `guest_libressl3_rsa`, and `guest_libressl3_cipher`, which now covers `EVP_CIPHER_nid`. `tools/check_conventions.py --base origin/main` and `test_public_headers.py --audit-only` pass. `nm -D` on the built `libSceLibreSsl3.prx` shows `EVP_CIPHER_nid_nid_postfix`, `BN_is_negative_nid_postfix` and `RSA_bits_nid_postfix`. No title, Windows or console testing. The `INT_MAX` case in `tests/Rsa.cpp` computes a `d` pointer through `uintptr_t` so that `d[top - 1]` lands on one stack word instead of allocating 256 MiB. This is implementation-defined but holds on flat x86-64 address spaces. `tools/pr_overlap.py` lists #10461, #10557, #10631, #10960, #12754, #12928, #12945 and #13662. They share files (`Api.hpp`, `CMakeLists.txt`, `Key.hpp`, `AdditionalExports.cpp`, the debt file) but none implements these exports. ### 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 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_013rhFWQL7oZRJSiGdkL5Gkn
MarcZX10 commented 2026-10-31 15:49:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T15:49:03Z.

Review: COMMENTED


Tests run and reviewed — approval withheld pending PS5 RSA layout evidence

The implementations match the pinned LibreSSL source model, but the PR leaves the RSA.n layout unverified for the console module and RSA_bits dereferences that field.

What I ran

Reviewed head c6ee4cf150339432043d141947c859c3fd034099 against base 474030e58424fefdb65e5df9f3820810fbb4553c; the exact head has a clean individual merge preview. Environment: Debian Linux 6.1 x86_64, Python 3.11.2, GCC 12.2.0. No project build or C++ test run.

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14008
git diff --check 474030e58424fefdb65e5df9f3820810fbb4553c...c6ee4cf150339432043d141947c859c3fd034099
python3 tools/nid_names.py --name EVP_CIPHER_nid --name BN_is_negative --name RSA_bits
git worktree add --detach /tmp/anyps5-review-14008 c6ee4cf150339432043d141947c859c3fd034099
python3 tools/pr_test_quality.py --root /tmp/anyps5-review-14008 --json core/libs/prx/libSceLibreSsl3/tests/Bignum.cpp core/libs/prx/libSceLibreSsl3/tests/Cipher.cpp core/libs/prx/libSceLibreSsl3/tests/Rsa.cpp
git worktree remove /tmp/anyps5-review-14008
python3 tools/pr_abi_audit.py --repo . --base 474030e58424fefdb65e5df9f3820810fbb4553c --head c6ee4cf150339432043d141947c859c3fd034099 --json
curl -fsSL https://raw.githubusercontent.com/libressl/openbsd/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/rsa/rsa_eay.c | grep -n -A3 -B2 'RSA_bits'
curl -fsSL https://raw.githubusercontent.com/libressl/openbsd/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/rsa/rsa_lib.c | grep -n -A3 -B2 'RSA_bits'
gh pr checks 14008 --repo boykopovar/AnyPS5

I also inspected the exact CMake test registration and the pinned LibreSSL source files cited by the PR.

Results

Check Result
Diff check Passed; no output.
Conventions and PR template Passed on the exact head.
Name/NID mapping All three names match tools/nid_names.py.
Export/declaration audit The three new exports each have one header declaration and one definition. Warnings are the former Unknown_* placeholders removed as the same NIDs are renamed by this PR.
Test registration The heuristic flagged all three test paths as possibly unregistered. Manual inspection confirms they are registered by the library's CMake file; the heuristic does not resolve ${CMAKE_CURRENT_SOURCE_DIR} paths.
Precheck helper availability The exact PR tree predates pr_abi_audit.py and pr_test_quality.py, so the precheck could not invoke those helpers from that checkout. I ran the current local helpers against the exact PR commits instead.
Hosted CI Conventions, intake, and labels passed. No build or C++ test job was present in the check snapshot.
Author-reported tests The PR body reports 9/9 focused Linux tests passed, including the new cipher, bignum, and RSA tests. I did not independently run them.
Local build/tests Not run.
Unedited relevant output

NID mapping:

NAME                                     NID
EVP_CIPHER_nid                           aLdgrI2jAF0
BN_is_negative                           AiNud8LR8B4
RSA_bits                                 3KZ-L4y1gak

ABI audit, filtered to the three new symbols and its findings:

{
  "status": "passed_with_warnings",
  "symbols": [
    {
      "name": "BN_is_negative_nid_postfix",
      "computed_nid": "AiNud8LR8B4",
      "declarations": [
        "core/libs/prx/libSceLibreSsl3/include/Api.hpp"
      ],
      "definitions": [
        "core/libs/prx/libSceLibreSsl3/src/Bignum.cpp"
      ]
    },
    {
      "name": "EVP_CIPHER_nid_nid_postfix",
      "computed_nid": "aLdgrI2jAF0",
      "declarations": [
        "core/libs/prx/libSceLibreSsl3/include/Api.hpp"
      ],
      "definitions": [
        "core/libs/prx/libSceLibreSsl3/src/Cipher.cpp"
      ]
    },
    {
      "name": "RSA_bits_nid_postfix",
      "computed_nid": "3KZ-L4y1gak",
      "declarations": [
        "core/libs/prx/libSceLibreSsl3/include/Api.hpp"
      ],
      "definitions": [
        "core/libs/prx/libSceLibreSsl3/src/Rsa.cpp"
      ]
    }
  ],
  "findings": [
    {
      "symbol": "Unknown_3KZ_minus_L4y1gak_nid_no_patch",
      "kind": "export-removed",
      "message": "This APS5_VABI declaration, definition, or explicit alias appeared in the changed base files but not in the corresponding head files; verify that removing it is intentional."
    },
    {
      "symbol": "Unknown_AiNud8LR8B4_nid_no_patch",
      "kind": "export-removed",
      "message": "This APS5_VABI declaration, definition, or explicit alias appeared in the changed base files but not in the corresponding head files; verify that removing it is intentional."
    },
    {
      "symbol": "Unknown_aLdgrI2jAF0_nid_no_patch",
      "kind": "export-removed",
      "message": "This APS5_VABI declaration, definition, or explicit alias appeared in the changed base files but not in the corresponding head files; verify that removing it is intentional."
    }
  ]
}

Test-quality heuristic:

{
  "findings": [
    {"path":"core/libs/prx/libSceLibreSsl3/tests/Bignum.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."},
    {"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."},
    {"path":"core/libs/prx/libSceLibreSsl3/tests/Rsa.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."
  ]
}

LibreSSL source lookup:

rsa_eay.c
852-RSA_bits(const RSA *r)
853-{
854-    return BN_num_bits(r->n);
855-}
rsa_lib.c
223-RSA_security_bits(const RSA *rsa)
224-{
225-    return BN_security_bits(RSA_bits(rsa), -1);

Negative control

Assertion Change to code under test Did the test fail?
New tests check the reported cipher NID, bignum sign, and RSA modulus bit count. Restore the prior throwing placeholder exports. Not exercised; the exact-head C++ tests require a build, which I did not run.

Findings

Blocking

None confirmed from the inspected source and checks.

Non-blocking

  1. RSA_bits reads rsa->n at offset 24. The cited LibreSSL 4.0.0 rsa_local.h has that layout, but the PR's debt entry explicitly says the PS5 console layout is unverified; the other AnyPS5 LibreSslRsa model places n at offset 32 because it includes an engine field. This is a material ABI uncertainty, so I am withholding approval rather than treating the upstream layout as console evidence. Please provide evidence that the exact libSceLibreSsl3 RSA object uses offset 24, or keep RSA_bits throwing until that layout is established.
  2. The debt entry links the RSA_bits behavior to rsa_lib.c, but the function body is in the pinned LibreSSL rsa_eay.c; rsa_lib.c only calls RSA_bits from RSA_security_bits. Please correct the source link.

Sources

Not verified

I did not build the PR or run its C++ tests, Windows tests, a title, or console behavior. The 9/9 test result is author-reported. In particular, I could not verify that the console's libSceLibreSsl3 RSA object matches the upstream structure at offset 24.

To get this to a good state

Add evidence for the console RSA layout at offset 24 (or leave that export throwing), and correct the RSA_bits source link. I will reassess the same checks on the updated head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5723634075 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14008#pullrequestreview-5723634075). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-31T15:49:03Z. **Review:** COMMENTED --- # Tests run and reviewed — approval withheld pending PS5 RSA layout evidence The implementations match the pinned LibreSSL source model, but the PR leaves the `RSA.n` layout unverified for the console module and `RSA_bits` dereferences that field. ## What I ran Reviewed head `c6ee4cf150339432043d141947c859c3fd034099` against base `474030e58424fefdb65e5df9f3820810fbb4553c`; the exact head has a clean individual merge preview. Environment: Debian Linux 6.1 x86_64, Python 3.11.2, GCC 12.2.0. No project build or C++ test run. ```sh python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14008 git diff --check 474030e58424fefdb65e5df9f3820810fbb4553c...c6ee4cf150339432043d141947c859c3fd034099 python3 tools/nid_names.py --name EVP_CIPHER_nid --name BN_is_negative --name RSA_bits git worktree add --detach /tmp/anyps5-review-14008 c6ee4cf150339432043d141947c859c3fd034099 python3 tools/pr_test_quality.py --root /tmp/anyps5-review-14008 --json core/libs/prx/libSceLibreSsl3/tests/Bignum.cpp core/libs/prx/libSceLibreSsl3/tests/Cipher.cpp core/libs/prx/libSceLibreSsl3/tests/Rsa.cpp git worktree remove /tmp/anyps5-review-14008 python3 tools/pr_abi_audit.py --repo . --base 474030e58424fefdb65e5df9f3820810fbb4553c --head c6ee4cf150339432043d141947c859c3fd034099 --json curl -fsSL https://raw.githubusercontent.com/libressl/openbsd/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/rsa/rsa_eay.c | grep -n -A3 -B2 'RSA_bits' curl -fsSL https://raw.githubusercontent.com/libressl/openbsd/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/rsa/rsa_lib.c | grep -n -A3 -B2 'RSA_bits' gh pr checks 14008 --repo boykopovar/AnyPS5 ``` I also inspected the exact CMake test registration and the pinned LibreSSL source files cited by the PR. ## Results | Check | Result | |---|---| | Diff check | Passed; no output. | | Conventions and PR template | Passed on the exact head. | | Name/NID mapping | All three names match `tools/nid_names.py`. | | Export/declaration audit | The three new exports each have one header declaration and one definition. Warnings are the former `Unknown_*` placeholders removed as the same NIDs are renamed by this PR. | | Test registration | The heuristic flagged all three test paths as possibly unregistered. Manual inspection confirms they are registered by the library's CMake file; the heuristic does not resolve `${CMAKE_CURRENT_SOURCE_DIR}` paths. | | Precheck helper availability | The exact PR tree predates `pr_abi_audit.py` and `pr_test_quality.py`, so the precheck could not invoke those helpers from that checkout. I ran the current local helpers against the exact PR commits instead. | | Hosted CI | Conventions, intake, and labels passed. No build or C++ test job was present in the check snapshot. | | Author-reported tests | The PR body reports 9/9 focused Linux tests passed, including the new cipher, bignum, and RSA tests. I did not independently run them. | | Local build/tests | Not run. | <details><summary>Unedited relevant output</summary> NID mapping: ```text NAME NID EVP_CIPHER_nid aLdgrI2jAF0 BN_is_negative AiNud8LR8B4 RSA_bits 3KZ-L4y1gak ``` ABI audit, filtered to the three new symbols and its findings: ```json { "status": "passed_with_warnings", "symbols": [ { "name": "BN_is_negative_nid_postfix", "computed_nid": "AiNud8LR8B4", "declarations": [ "core/libs/prx/libSceLibreSsl3/include/Api.hpp" ], "definitions": [ "core/libs/prx/libSceLibreSsl3/src/Bignum.cpp" ] }, { "name": "EVP_CIPHER_nid_nid_postfix", "computed_nid": "aLdgrI2jAF0", "declarations": [ "core/libs/prx/libSceLibreSsl3/include/Api.hpp" ], "definitions": [ "core/libs/prx/libSceLibreSsl3/src/Cipher.cpp" ] }, { "name": "RSA_bits_nid_postfix", "computed_nid": "3KZ-L4y1gak", "declarations": [ "core/libs/prx/libSceLibreSsl3/include/Api.hpp" ], "definitions": [ "core/libs/prx/libSceLibreSsl3/src/Rsa.cpp" ] } ], "findings": [ { "symbol": "Unknown_3KZ_minus_L4y1gak_nid_no_patch", "kind": "export-removed", "message": "This APS5_VABI declaration, definition, or explicit alias appeared in the changed base files but not in the corresponding head files; verify that removing it is intentional." }, { "symbol": "Unknown_AiNud8LR8B4_nid_no_patch", "kind": "export-removed", "message": "This APS5_VABI declaration, definition, or explicit alias appeared in the changed base files but not in the corresponding head files; verify that removing it is intentional." }, { "symbol": "Unknown_aLdgrI2jAF0_nid_no_patch", "kind": "export-removed", "message": "This APS5_VABI declaration, definition, or explicit alias appeared in the changed base files but not in the corresponding head files; verify that removing it is intentional." } ] } ``` Test-quality heuristic: ```json { "findings": [ {"path":"core/libs/prx/libSceLibreSsl3/tests/Bignum.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."}, {"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."}, {"path":"core/libs/prx/libSceLibreSsl3/tests/Rsa.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." ] } ``` LibreSSL source lookup: ```text rsa_eay.c 852-RSA_bits(const RSA *r) 853-{ 854- return BN_num_bits(r->n); 855-} rsa_lib.c 223-RSA_security_bits(const RSA *rsa) 224-{ 225- return BN_security_bits(RSA_bits(rsa), -1); ``` </details> ## Negative control | Assertion | Change to code under test | Did the test fail? | |---|---|---| | New tests check the reported cipher NID, bignum sign, and RSA modulus bit count. | Restore the prior throwing placeholder exports. | Not exercised; the exact-head C++ tests require a build, which I did not run. | ## Findings ### Blocking None confirmed from the inspected source and checks. ### Non-blocking 1. `RSA_bits` reads `rsa->n` at offset 24. The cited LibreSSL 4.0.0 `rsa_local.h` has that layout, but the PR's debt entry explicitly says the PS5 console layout is unverified; the other AnyPS5 `LibreSslRsa` model places `n` at offset 32 because it includes an `engine` field. This is a material ABI uncertainty, so I am withholding approval rather than treating the upstream layout as console evidence. Please provide evidence that the exact `libSceLibreSsl3` RSA object uses offset 24, or keep `RSA_bits` throwing until that layout is established. 2. The debt entry links the `RSA_bits` behavior to `rsa_lib.c`, but the function body is in the pinned LibreSSL `rsa_eay.c`; `rsa_lib.c` only calls `RSA_bits` from `RSA_security_bits`. Please correct the source link. ## Sources - [The PR's note that the console RSA layout is unverified](https://github.com/boykopovar/AnyPS5/blob/c6ee4cf150339432043d141947c859c3fd034099/docs/dev/debt/libSceLibreSsl3.md#L19) - [The other AnyPS5 RSA layout, with `n` after `engine`](https://github.com/boykopovar/AnyPS5/blob/c6ee4cf150339432043d141947c859c3fd034099/core/libs/prx/libSceLibreSsl/include/Api.hpp#L192-L213) - [The `libSceLibreSsl3` model places `n` at offset 24](https://github.com/boykopovar/AnyPS5/blob/c6ee4cf150339432043d141947c859c3fd034099/core/libs/prx/libSceLibreSsl3/include/Key.hpp#L27-L55) - [Pinned LibreSSL 4.0.0 RSA structure](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/rsa/rsa_local.h#L690-L744) - [Pinned LibreSSL `RSA_bits` implementation](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/rsa/rsa_eay.c#L852-L856) - [Pinned LibreSSL `BN_is_negative` implementation](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/bn/bn_lib.c#L668-L672) - [Pinned LibreSSL `EVP_CIPHER_nid` implementation](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/evp/evp_cipher.c#L1073-L1077) - [CMake registrations for the three tests](https://github.com/boykopovar/AnyPS5/blob/c6ee4cf150339432043d141947c859c3fd034099/core/libs/prx/libSceLibreSsl3/CMakeLists.txt#L54-L78) ## Not verified I did not build the PR or run its C++ tests, Windows tests, a title, or console behavior. The 9/9 test result is author-reported. In particular, I could not verify that the console's `libSceLibreSsl3` RSA object matches the upstream structure at offset 24. ## To get this to a good state Add evidence for the console RSA layout at offset 24 (or leave that export throwing), and correct the `RSA_bits` source link. I will reassess the same checks on the updated head.
MarcZX10 commented 2026-10-31 15:49:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T15:49:16Z.

Review: COMMENTED


Tests run and reviewed — approval withheld pending PS5 RSA layout evidence

The implementations match the pinned LibreSSL source model, but the PR leaves the RSA.n layout unverified for the console module and RSA_bits dereferences that field.

What I ran

Reviewed head c6ee4cf150339432043d141947c859c3fd034099 against base 474030e58424fefdb65e5df9f3820810fbb4553c; the exact head has a clean individual merge preview. Environment: Debian Linux 6.1 x86_64, Python 3.11.2, GCC 12.2.0. No project build or C++ test run.

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14008
git diff --check 474030e58424fefdb65e5df9f3820810fbb4553c...c6ee4cf150339432043d141947c859c3fd034099
python3 tools/nid_names.py --name EVP_CIPHER_nid --name BN_is_negative --name RSA_bits
git worktree add --detach /tmp/anyps5-review-14008 c6ee4cf150339432043d141947c859c3fd034099
python3 tools/pr_test_quality.py --root /tmp/anyps5-review-14008 --json core/libs/prx/libSceLibreSsl3/tests/Bignum.cpp core/libs/prx/libSceLibreSsl3/tests/Cipher.cpp core/libs/prx/libSceLibreSsl3/tests/Rsa.cpp
git worktree remove /tmp/anyps5-review-14008
python3 tools/pr_abi_audit.py --repo . --base 474030e58424fefdb65e5df9f3820810fbb4553c --head c6ee4cf150339432043d141947c859c3fd034099 --json
curl -fsSL https://raw.githubusercontent.com/libressl/openbsd/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/rsa/rsa_eay.c | grep -n -A3 -B2 'RSA_bits'
curl -fsSL https://raw.githubusercontent.com/libressl/openbsd/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/rsa/rsa_lib.c | grep -n -A3 -B2 'RSA_bits'
gh pr checks 14008 --repo boykopovar/AnyPS5

I also inspected the exact CMake test registration and the pinned LibreSSL source files cited by the PR.

Results

Check Result
Diff check Passed; no output.
Conventions and PR template Passed on the exact head.
Name/NID mapping All three names match tools/nid_names.py.
Export/declaration audit The three new exports each have one header declaration and one definition. Warnings are the former Unknown_* placeholders removed as the same NIDs are renamed by this PR.
Test registration The heuristic flagged all three test paths as possibly unregistered. Manual inspection confirms they are registered by the library's CMake file; the heuristic does not resolve ${CMAKE_CURRENT_SOURCE_DIR} paths.
Precheck helper availability The exact PR tree predates pr_abi_audit.py and pr_test_quality.py, so the precheck could not invoke those helpers from that checkout. I ran the current local helpers against the exact PR commits instead.
Hosted CI Conventions, intake, and labels passed. No build or C++ test job was present in the check snapshot.
Author-reported tests The PR body reports 9/9 focused Linux tests passed, including the new cipher, bignum, and RSA tests. I did not independently run them.
Local build/tests Not run.
Unedited relevant output

NID mapping:

NAME                                     NID
EVP_CIPHER_nid                           aLdgrI2jAF0
BN_is_negative                           AiNud8LR8B4
RSA_bits                                 3KZ-L4y1gak

ABI audit, filtered to the three new symbols and its findings:

{
  "status": "passed_with_warnings",
  "symbols": [
    {
      "name": "BN_is_negative_nid_postfix",
      "computed_nid": "AiNud8LR8B4",
      "declarations": [
        "core/libs/prx/libSceLibreSsl3/include/Api.hpp"
      ],
      "definitions": [
        "core/libs/prx/libSceLibreSsl3/src/Bignum.cpp"
      ]
    },
    {
      "name": "EVP_CIPHER_nid_nid_postfix",
      "computed_nid": "aLdgrI2jAF0",
      "declarations": [
        "core/libs/prx/libSceLibreSsl3/include/Api.hpp"
      ],
      "definitions": [
        "core/libs/prx/libSceLibreSsl3/src/Cipher.cpp"
      ]
    },
    {
      "name": "RSA_bits_nid_postfix",
      "computed_nid": "3KZ-L4y1gak",
      "declarations": [
        "core/libs/prx/libSceLibreSsl3/include/Api.hpp"
      ],
      "definitions": [
        "core/libs/prx/libSceLibreSsl3/src/Rsa.cpp"
      ]
    }
  ],
  "findings": [
    {
      "symbol": "Unknown_3KZ_minus_L4y1gak_nid_no_patch",
      "kind": "export-removed",
      "message": "This APS5_VABI declaration, definition, or explicit alias appeared in the changed base files but not in the corresponding head files; verify that removing it is intentional."
    },
    {
      "symbol": "Unknown_AiNud8LR8B4_nid_no_patch",
      "kind": "export-removed",
      "message": "This APS5_VABI declaration, definition, or explicit alias appeared in the changed base files but not in the corresponding head files; verify that removing it is intentional."
    },
    {
      "symbol": "Unknown_aLdgrI2jAF0_nid_no_patch",
      "kind": "export-removed",
      "message": "This APS5_VABI declaration, definition, or explicit alias appeared in the changed base files but not in the corresponding head files; verify that removing it is intentional."
    }
  ]
}

Test-quality heuristic:

{
  "findings": [
    {"path":"core/libs/prx/libSceLibreSsl3/tests/Bignum.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."},
    {"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."},
    {"path":"core/libs/prx/libSceLibreSsl3/tests/Rsa.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."
  ]
}

LibreSSL source lookup:

rsa_eay.c
852-RSA_bits(const RSA *r)
853-{
854-    return BN_num_bits(r->n);
855-}
rsa_lib.c
223-RSA_security_bits(const RSA *rsa)
224-{
225-    return BN_security_bits(RSA_bits(rsa), -1);

Negative control

Assertion Change to code under test Did the test fail?
New tests check the reported cipher NID, bignum sign, and RSA modulus bit count. Restore the prior throwing placeholder exports. Not exercised; the exact-head C++ tests require a build, which I did not run.

Findings

Blocking

None confirmed from the inspected source and checks.

Non-blocking

  1. RSA_bits reads rsa->n at offset 24. The cited LibreSSL 4.0.0 rsa_local.h has that layout, but the PR's debt entry explicitly says the PS5 console layout is unverified; the other AnyPS5 LibreSslRsa model places n at offset 32 because it includes an engine field. This is a material ABI uncertainty, so I am withholding approval rather than treating the upstream layout as console evidence. Please provide evidence that the exact libSceLibreSsl3 RSA object uses offset 24, or keep RSA_bits throwing until that layout is established.
  2. The debt entry links the RSA_bits behavior to rsa_lib.c, but the function body is in the pinned LibreSSL rsa_eay.c; rsa_lib.c only calls RSA_bits from RSA_security_bits. Please correct the source link.

Sources

Not verified

I did not build the PR or run its C++ tests, Windows tests, a title, or console behavior. The 9/9 test result is author-reported. In particular, I could not verify that the console's libSceLibreSsl3 RSA object matches the upstream structure at offset 24.

To get this to a good state

Add evidence for the console RSA layout at offset 24 (or leave that export throwing), and correct the RSA_bits source link. I will reassess the same checks on the updated head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5723635149 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14008#pullrequestreview-5723635149). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-31T15:49:16Z. **Review:** COMMENTED --- # Tests run and reviewed — approval withheld pending PS5 RSA layout evidence The implementations match the pinned LibreSSL source model, but the PR leaves the `RSA.n` layout unverified for the console module and `RSA_bits` dereferences that field. ## What I ran Reviewed head `c6ee4cf150339432043d141947c859c3fd034099` against base `474030e58424fefdb65e5df9f3820810fbb4553c`; the exact head has a clean individual merge preview. Environment: Debian Linux 6.1 x86_64, Python 3.11.2, GCC 12.2.0. No project build or C++ test run. ```sh python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14008 git diff --check 474030e58424fefdb65e5df9f3820810fbb4553c...c6ee4cf150339432043d141947c859c3fd034099 python3 tools/nid_names.py --name EVP_CIPHER_nid --name BN_is_negative --name RSA_bits git worktree add --detach /tmp/anyps5-review-14008 c6ee4cf150339432043d141947c859c3fd034099 python3 tools/pr_test_quality.py --root /tmp/anyps5-review-14008 --json core/libs/prx/libSceLibreSsl3/tests/Bignum.cpp core/libs/prx/libSceLibreSsl3/tests/Cipher.cpp core/libs/prx/libSceLibreSsl3/tests/Rsa.cpp git worktree remove /tmp/anyps5-review-14008 python3 tools/pr_abi_audit.py --repo . --base 474030e58424fefdb65e5df9f3820810fbb4553c --head c6ee4cf150339432043d141947c859c3fd034099 --json curl -fsSL https://raw.githubusercontent.com/libressl/openbsd/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/rsa/rsa_eay.c | grep -n -A3 -B2 'RSA_bits' curl -fsSL https://raw.githubusercontent.com/libressl/openbsd/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/rsa/rsa_lib.c | grep -n -A3 -B2 'RSA_bits' gh pr checks 14008 --repo boykopovar/AnyPS5 ``` I also inspected the exact CMake test registration and the pinned LibreSSL source files cited by the PR. ## Results | Check | Result | |---|---| | Diff check | Passed; no output. | | Conventions and PR template | Passed on the exact head. | | Name/NID mapping | All three names match `tools/nid_names.py`. | | Export/declaration audit | The three new exports each have one header declaration and one definition. Warnings are the former `Unknown_*` placeholders removed as the same NIDs are renamed by this PR. | | Test registration | The heuristic flagged all three test paths as possibly unregistered. Manual inspection confirms they are registered by the library's CMake file; the heuristic does not resolve `${CMAKE_CURRENT_SOURCE_DIR}` paths. | | Precheck helper availability | The exact PR tree predates `pr_abi_audit.py` and `pr_test_quality.py`, so the precheck could not invoke those helpers from that checkout. I ran the current local helpers against the exact PR commits instead. | | Hosted CI | Conventions, intake, and labels passed. No build or C++ test job was present in the check snapshot. | | Author-reported tests | The PR body reports 9/9 focused Linux tests passed, including the new cipher, bignum, and RSA tests. I did not independently run them. | | Local build/tests | Not run. | <details><summary>Unedited relevant output</summary> NID mapping: ```text NAME NID EVP_CIPHER_nid aLdgrI2jAF0 BN_is_negative AiNud8LR8B4 RSA_bits 3KZ-L4y1gak ``` ABI audit, filtered to the three new symbols and its findings: ```json { "status": "passed_with_warnings", "symbols": [ { "name": "BN_is_negative_nid_postfix", "computed_nid": "AiNud8LR8B4", "declarations": [ "core/libs/prx/libSceLibreSsl3/include/Api.hpp" ], "definitions": [ "core/libs/prx/libSceLibreSsl3/src/Bignum.cpp" ] }, { "name": "EVP_CIPHER_nid_nid_postfix", "computed_nid": "aLdgrI2jAF0", "declarations": [ "core/libs/prx/libSceLibreSsl3/include/Api.hpp" ], "definitions": [ "core/libs/prx/libSceLibreSsl3/src/Cipher.cpp" ] }, { "name": "RSA_bits_nid_postfix", "computed_nid": "3KZ-L4y1gak", "declarations": [ "core/libs/prx/libSceLibreSsl3/include/Api.hpp" ], "definitions": [ "core/libs/prx/libSceLibreSsl3/src/Rsa.cpp" ] } ], "findings": [ { "symbol": "Unknown_3KZ_minus_L4y1gak_nid_no_patch", "kind": "export-removed", "message": "This APS5_VABI declaration, definition, or explicit alias appeared in the changed base files but not in the corresponding head files; verify that removing it is intentional." }, { "symbol": "Unknown_AiNud8LR8B4_nid_no_patch", "kind": "export-removed", "message": "This APS5_VABI declaration, definition, or explicit alias appeared in the changed base files but not in the corresponding head files; verify that removing it is intentional." }, { "symbol": "Unknown_aLdgrI2jAF0_nid_no_patch", "kind": "export-removed", "message": "This APS5_VABI declaration, definition, or explicit alias appeared in the changed base files but not in the corresponding head files; verify that removing it is intentional." } ] } ``` Test-quality heuristic: ```json { "findings": [ {"path":"core/libs/prx/libSceLibreSsl3/tests/Bignum.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."}, {"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."}, {"path":"core/libs/prx/libSceLibreSsl3/tests/Rsa.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." ] } ``` LibreSSL source lookup: ```text rsa_eay.c 852-RSA_bits(const RSA *r) 853-{ 854- return BN_num_bits(r->n); 855-} rsa_lib.c 223-RSA_security_bits(const RSA *rsa) 224-{ 225- return BN_security_bits(RSA_bits(rsa), -1); ``` </details> ## Negative control | Assertion | Change to code under test | Did the test fail? | |---|---|---| | New tests check the reported cipher NID, bignum sign, and RSA modulus bit count. | Restore the prior throwing placeholder exports. | Not exercised; the exact-head C++ tests require a build, which I did not run. | ## Findings ### Blocking None confirmed from the inspected source and checks. ### Non-blocking 1. `RSA_bits` reads `rsa->n` at offset 24. The cited LibreSSL 4.0.0 `rsa_local.h` has that layout, but the PR's debt entry explicitly says the PS5 console layout is unverified; the other AnyPS5 `LibreSslRsa` model places `n` at offset 32 because it includes an `engine` field. This is a material ABI uncertainty, so I am withholding approval rather than treating the upstream layout as console evidence. Please provide evidence that the exact `libSceLibreSsl3` RSA object uses offset 24, or keep `RSA_bits` throwing until that layout is established. 2. The debt entry links the `RSA_bits` behavior to `rsa_lib.c`, but the function body is in the pinned LibreSSL `rsa_eay.c`; `rsa_lib.c` only calls `RSA_bits` from `RSA_security_bits`. Please correct the source link. ## Sources - [The PR's note that the console RSA layout is unverified](https://github.com/boykopovar/AnyPS5/blob/c6ee4cf150339432043d141947c859c3fd034099/docs/dev/debt/libSceLibreSsl3.md#L19) - [The other AnyPS5 RSA layout, with `n` after `engine`](https://github.com/boykopovar/AnyPS5/blob/c6ee4cf150339432043d141947c859c3fd034099/core/libs/prx/libSceLibreSsl/include/Api.hpp#L192-L213) - [The `libSceLibreSsl3` model places `n` at offset 24](https://github.com/boykopovar/AnyPS5/blob/c6ee4cf150339432043d141947c859c3fd034099/core/libs/prx/libSceLibreSsl3/include/Key.hpp#L27-L55) - [Pinned LibreSSL 4.0.0 RSA structure](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/rsa/rsa_local.h#L690-L744) - [Pinned LibreSSL `RSA_bits` implementation](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/rsa/rsa_eay.c#L852-L856) - [Pinned LibreSSL `BN_is_negative` implementation](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/bn/bn_lib.c#L668-L672) - [Pinned LibreSSL `EVP_CIPHER_nid` implementation](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/evp/evp_cipher.c#L1073-L1077) - [CMake registrations for the three tests](https://github.com/boykopovar/AnyPS5/blob/c6ee4cf150339432043d141947c859c3fd034099/core/libs/prx/libSceLibreSsl3/CMakeLists.txt#L54-L78) ## Not verified I did not build the PR or run its C++ tests, Windows tests, a title, or console behavior. The 9/9 test result is author-reported. In particular, I could not verify that the console's `libSceLibreSsl3` RSA object matches the upstream structure at offset 24. ## To get this to a good state Add evidence for the console RSA layout at offset 24 (or leave that export throwing), and correct the `RSA_bits` source link. I will reassess the same checks on the updated head.

Pull request closed

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!14008
No description provided.