feat(libSceLibreSsl): implement OCSP_resp_count and OCSP_resp_get0 #11003

Merged
lopdan merged 22 commits from upstream-pr/11003 into main 2026-11-05 18:23:36 +00:00
lopdan commented 2026-10-25 14:03:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by lopdan on 2026-10-25T14:03:22Z.


What

Implement OCSP_resp_count and OCSP_resp_get0 in libSceLibreSsl: the number of single responses in an OCSP_BASICRESP and the response at an index, read from the guest objects.

The signatures, the LP64 layouts (tbsResponseData at offset 0 of OCSP_BASICRESP, responses at offset 24 of OCSP_RESPDATA, and the 32-byte _STACK with its int size at 0 and entry array at 8) and the results follow LibreSSL 2.5.4: ocsp.h, ocsp_cl.c, stack.h and stack.c. That is the version the published firmware 13.40 measurements identify and the existing libSceLibreSsl debt entries use. Nothing is verified on a console; the debt entry says so.

  • A null OCSP_BASICRESP gives -1 and null; a null responses stack gives -1 and null.
  • The stack size is returned as stored, negative values included, as sk_num does. An index below 0 or not below the size gives null without reading the entry array; null entries are returned as stored.
  • Where 2.5.4 dereferences a null pointer, the call throws through NotImplemented_nid_no_patch: a null tbsResponseData (both functions, any index) and a null entry array with an index in range.

Like the cipher getters of #10071, these read objects that no export of this library creates yet (d2i_OCSP_RESPONSE and OCSP_response_get1_basic still throw). The progress scanner still counts 46/399 for libSceLibreSsl because it marks exports with a throwing path as incomplete, as with the merged ASN.1 getters.

No open or closed PR names these exports (GitHub search for each name), and tools/pr_overlap.py finds no open PR with the same exports or new files. Its line conflicts are #9949, whose OCSP stub and declaration changes sit next to the removed ones, and #10078, #10248, #10395 and #10484, which change the same lines of the debt file or the end of the CMakeLists, as every LibreSSL PR does; whichever lands second needs a trivial rebase. The 30 open PRs it could not compare because they conflict with main do not touch these exports either. The new files do not collide with #9949's src/Ocsp.cpp or #10448's src/OcspResponse.cpp.

Tested

  • CachyOS Linux x86-64 (kernel 7.2.9), GCC 16.2.1, Ninja, Release, configured with -DBUILD_TESTING=ON; only the LibreSSL test targets were built. Rebased on main at e05ba6feeb and everything below rerun after the rebase.
  • ctest --test-dir build -R guest_libressl_ocsp_basic_response --output-on-failure: passed. The test lays out the guest objects as raw bytes at the 2.5.4 offsets, points every field the functions must not read at decoys with other values, and covers null inputs, a null stack, sizes 3, 0, -2 and INT_MAX, indices 0 to 3, -1, INT_MIN and INT_MAX, a null entry, that no byte is written, and the throwing paths.
  • The test fails, and passes again once restored, with each of: an off-by-one upper bound, 0 instead of -1 for a null response or a null stack, reading the stack at offset 32, and no throw for a null entry array.
  • ctest --test-dir build -R guest_libressl --output-on-failure: 11/11 passed (libSceLibreSsl and libSceLibreSsl3).
  • ctest --test-dir build -R public_headers -j 12: 65/65 passed.
  • ctest --test-dir build -R '^(conventions_|debt_|stubgen|nid_database|pr_overlap|check_compile)' -j 12: 82/82 passed.
  • python3 tools/check_conventions.py --base upstream/main: all checks passed.
  • python3 tools/progress.py --module libSceLibreSsl: libraries 46/399 (11.53%) before and after.
  • python3 tools/pr_overlap.py --branch feat/libSceLibreSsl-OCSP_resp_count: no open PR with the same exports or new files; its line conflicts are listed under What.
  • Not tested: Windows, the whole project, titles, a PS5 console.

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:5005426797 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11003). Originally posted by [lopdan](https://github.com/lopdan) on 2026-10-25T14:03:22Z. --- ### What Implement `OCSP_resp_count` and `OCSP_resp_get0` in libSceLibreSsl: the number of single responses in an `OCSP_BASICRESP` and the response at an index, read from the guest objects. The signatures, the LP64 layouts (`tbsResponseData` at offset 0 of `OCSP_BASICRESP`, `responses` at offset 24 of `OCSP_RESPDATA`, and the 32-byte `_STACK` with its `int` size at 0 and entry array at 8) and the results follow LibreSSL 2.5.4: [ocsp.h](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/ocsp/ocsp.h#L263-L298), [ocsp_cl.c](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/ocsp/ocsp_cl.c#L218-L233), [stack.h](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/stack/stack.h#L66-L73) and [stack.c](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/stack/stack.c#L294-L308). That is the version the [published firmware 13.40 measurements](https://github.com/boykopovar/AnyPS5/discussions/8981#discussioncomment-19111214) identify and the existing libSceLibreSsl debt entries use. Nothing is verified on a console; the debt entry says so. - A null `OCSP_BASICRESP` gives -1 and null; a null responses stack gives -1 and null. - The stack size is returned as stored, negative values included, as `sk_num` does. An index below 0 or not below the size gives null without reading the entry array; null entries are returned as stored. - Where 2.5.4 dereferences a null pointer, the call throws through `NotImplemented_nid_no_patch`: a null `tbsResponseData` (both functions, any index) and a null entry array with an index in range. Like the cipher getters of #10071, these read objects that no export of this library creates yet (`d2i_OCSP_RESPONSE` and `OCSP_response_get1_basic` still throw). The progress scanner still counts 46/399 for libSceLibreSsl because it marks exports with a throwing path as incomplete, as with the merged ASN.1 getters. No open or closed PR names these exports (GitHub search for each name), and `tools/pr_overlap.py` finds no open PR with the same exports or new files. Its line conflicts are #9949, whose OCSP stub and declaration changes sit next to the removed ones, and #10078, #10248, #10395 and #10484, which change the same lines of the debt file or the end of the CMakeLists, as every LibreSSL PR does; whichever lands second needs a trivial rebase. The 30 open PRs it could not compare because they conflict with `main` do not touch these exports either. The new files do not collide with #9949's `src/Ocsp.cpp` or #10448's `src/OcspResponse.cpp`. ### 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. --> - CachyOS Linux x86-64 (kernel 7.2.9), GCC 16.2.1, Ninja, Release, configured with `-DBUILD_TESTING=ON`; only the LibreSSL test targets were built. Rebased on `main` at e05ba6feeb and everything below rerun after the rebase. - `ctest --test-dir build -R guest_libressl_ocsp_basic_response --output-on-failure`: passed. The test lays out the guest objects as raw bytes at the 2.5.4 offsets, points every field the functions must not read at decoys with other values, and covers null inputs, a null stack, sizes 3, 0, -2 and `INT_MAX`, indices 0 to 3, -1, `INT_MIN` and `INT_MAX`, a null entry, that no byte is written, and the throwing paths. - The test fails, and passes again once restored, with each of: an off-by-one upper bound, 0 instead of -1 for a null response or a null stack, reading the stack at offset 32, and no throw for a null entry array. - `ctest --test-dir build -R guest_libressl --output-on-failure`: 11/11 passed (libSceLibreSsl and libSceLibreSsl3). - `ctest --test-dir build -R public_headers -j 12`: 65/65 passed. - `ctest --test-dir build -R '^(conventions_|debt_|stubgen|nid_database|pr_overlap|check_compile)' -j 12`: 82/82 passed. - `python3 tools/check_conventions.py --base upstream/main`: all checks passed. - `python3 tools/progress.py --module libSceLibreSsl`: `libraries 46/399 (11.53%)` before and after. - `python3 tools/pr_overlap.py --branch feat/libSceLibreSsl-OCSP_resp_count`: no open PR with the same exports or new files; its line conflicts are listed under What. - Not tested: Windows, the whole project, titles, a PS5 console. ### 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 <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
MarcZX10 commented 2026-10-25 14:10:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T14:10:05Z.

Review: APPROVED


Reviewed the LibreSSL 2.5.4 layouts and bounds behavior against the cited source. The implementation returns the stored stack count (including negative values), rejects out-of-range indexes before touching the entry array, preserves null entries, and throws only on the documented dereference cases. The raw-byte regression test uses decoy fields to check the offsets and covers the boundary/null cases described. I verified conventions and diff cleanliness, and both changed C++ translation units pass local C++20 syntax checks. The author reports the focused OCSP test and 11 LibreSSL tests passing; product tests are not run by the current hosted checks, and Windows/console behavior remains unverified as stated.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5643607601 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11003#pullrequestreview-5643607601). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T14:10:05Z. **Review:** APPROVED --- Reviewed the LibreSSL 2.5.4 layouts and bounds behavior against the cited source. The implementation returns the stored stack count (including negative values), rejects out-of-range indexes before touching the entry array, preserves null entries, and throws only on the documented dereference cases. The raw-byte regression test uses decoy fields to check the offsets and covers the boundary/null cases described. I verified conventions and diff cleanliness, and both changed C++ translation units pass local C++20 syntax checks. The author reports the focused OCSP test and 11 LibreSSL tests passing; product tests are not run by the current hosted checks, and Windows/console behavior remains unverified as stated.
MarcZX10 commented 2026-10-29 09:05:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T09:05:37Z.

Review: APPROVED


The implementation and raw-byte regression test were previously reviewed, and the current head now includes current main. The debt count is 297, matching the resulting Export.cpp after this PR removes the two OCSP exports from the 299-entry base. The author reports the OCSP test and full LibreSSL suite; I did not rerun them. The current conventions and labels checks are still pending, so this review covers source correctness and does not claim those checks passed.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5695206022 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11003#pullrequestreview-5695206022). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-29T09:05:37Z. **Review:** APPROVED --- The implementation and raw-byte regression test were previously reviewed, and the current head now includes current main. The debt count is 297, matching the resulting Export.cpp after this PR removes the two OCSP exports from the 299-entry base. The author reports the OCSP test and full LibreSSL suite; I did not rerun them. The current conventions and labels checks are still pending, so this review covers source correctness and does not claim those checks passed.
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!11003
No description provided.