feat(libSceLibreSsl): implement OCSP_response_status and OCSP_single_get0_status #10448

Merged
alvaroelpob merged 6 commits from upstream-pr/10448 into main 2026-11-04 23:10:05 +00:00
alvaroelpob commented 2026-10-24 00:56:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by alvaroelpob on 2026-10-24T00:56:17Z.


What

Implements OCSP_response_status and OCSP_single_get0_status in libSceLibreSsl, which threw and were declared without parameters.

The module is LibreSSL 2.5.4 (firmware 13.40 measurements in #8981). Signatures, layouts and results follow that release's ocsp.h, ocsp_cl.c and a_enum.c:

Export Behaviour
int OCSP_response_status(OCSP_RESPONSE*) ASN1_ENUMERATED_get(responseStatus), truncated to int
int OCSP_single_get0_status(OCSP_SINGLERESP*, int* reason, ASN1_GENERALIZEDTIME** revtime, ASN1_GENERALIZEDTIME** thisupd, ASN1_GENERALIZEDTIME** nextupd) -1 for a null single response; otherwise returns certStatus->type. For a revoked status it stores revocationTime and the enumerated reason, or -1 when there is no reason. It then stores thisUpdate and nextUpdate, writing only the outputs that aren't null

ASN1_ENUMERATED_get, which this module doesn't export, is reproduced for both: 0 for a null value or null data, -1 for a type other than V_ASN1_ENUMERATED (10) and V_ASN1_NEG_ENUMERATED (0x10A) or a length above 8 bytes, otherwise the big-endian bytes, negated for the negative type.

The layouts (ASN1_STRING 24 bytes, OCSP_RESPONSE 16, OCSP_CERTSTATUS 16 with the union at 8, OCSP_REVOKEDINFO 16, OCSP_SINGLERESP 40) are checked with static_asserts. LibreSSL dereferences a null response, a null certStatus, and a null revoked record when the time or reason is requested without checking them, so those throw. No export of this module decodes a response yet, so for now only structures built by the caller reach these functions.

The debt entry records the source and what is unverified, and the pending-export count drops by 2 (342 to 340 on current main). The OCSP string functions in #9949 live in src/Ocsp.cpp. This PR uses src/OcspResponse.cpp, so the two don't add the same file.

Tested

Ubuntu 26.04 (WSL2, kernel 6.18), GCC 15.2.0, Release, full build with BUILD_TESTING=ON on main e2b9700a9. There is one commit per function, and each adds that function with its test block and debt update. Each was built and its guest_libressl_ocsp_response test and check_conventions.py run on its own.

  • New guest_libressl_ocsp_response test. OCSP_response_status is checked with one- and two-byte values, a negative enumerated value, a 5-byte value truncated to int, an 8-byte value with the top bit set, a 9-byte value (-1), zero length, null data, the wrong type (-1), and a null status (0); a null response throws. OCSP_single_get0_status returns -1 without writing for a null single response. For good and unknown it fills only thisupd and nextupd, leaving reason and revtime alone. For revoked it covers a reason, no reason (-1), a wrongly typed reason (-1) and null outputs. A revoked status with a null record throws only when the reason or time is requested, and a null certStatus throws. On main the first call throws.
  • Full ctest -j16 at the last commit: 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 ac9661e493: 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 f28584b07d, 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. f28584b07d (refactor(libSceLibreSsl): declare the OCSP status 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 2db12797e2, to resolve the conflicts with main on the shared CMakeLists.txt and debt-file lines; both sides are kept and the count is 342 minus this PR's exports. Full build and ctest -j16: 2275/2276 pass; agc_driver_multisample_retirement fails the same way on that main. check_conventions.py --base upstream/main passes.
  • Review fix 5ab224da00 drops LibreSslAsn1String and uses main's Asn1String (same 24-byte layout, asserted in Asn1.cpp) in the OCSP structs, signatures and test; guest_libressl_ocsp_response and public_headers pass. Full build and ctest -j16 on main ae7d59258e: 2275/2276 pass; agc_driver_multisample_retirement fails the same way on that main. check_conventions.py --base upstream/main passes.
  • Rebased on main 88795ed448 (after #10248; head 5b7598547f) 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 f000377fe2, 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 474030e584 (after #13562), head 742ed7a7c6, to resolve the conflict on the pending-export count in the debt file; the count is 292 minus this PR's exports. Full build and ctest -j16: 3062/3062 pass. check_conventions.py --base upstream/main passes.
  • Rebased on main cf79276fee (after #13820), head 7e59cbf222, 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 288 stubs left in Export.cpp. It also restores the PS5 3.20 export table link, b2a77c09cd71c01f34c790cfbe98c751a13262ad, which the previous rebase had written without its zeros. 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 81f030e81d, to resolve the conflicts on the shared CMakeLists.txt, Export.cpp, Api.hpp and debt-file lines; both sides are kept. This replaces the merge of main pushed to the branch as d05afe006c, which only changed the pending count. The count is set to the 259 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 3013ef2759, 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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4991161255 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10448). Originally posted by [alvaroelpob](https://github.com/alvaroelpob) on 2026-10-24T00:56:17Z. --- ### What Implements `OCSP_response_status` and `OCSP_single_get0_status` in libSceLibreSsl, which threw and were 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)). Signatures, layouts and results follow that release's [`ocsp.h`, `ocsp_cl.c`](https://github.com/libressl/openbsd/tree/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/ocsp) and [`a_enum.c`](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/asn1/a_enum.c): | Export | Behaviour | |---|---| | `int OCSP_response_status(OCSP_RESPONSE*)` | `ASN1_ENUMERATED_get(responseStatus)`, truncated to `int` | | `int OCSP_single_get0_status(OCSP_SINGLERESP*, int* reason, ASN1_GENERALIZEDTIME** revtime, ASN1_GENERALIZEDTIME** thisupd, ASN1_GENERALIZEDTIME** nextupd)` | -1 for a null single response; otherwise returns `certStatus->type`. For a revoked status it stores `revocationTime` and the enumerated reason, or -1 when there is no reason. It then stores `thisUpdate` and `nextUpdate`, writing only the outputs that aren't null | `ASN1_ENUMERATED_get`, which this module doesn't export, is reproduced for both: 0 for a null value or null data, -1 for a type other than `V_ASN1_ENUMERATED` (10) and `V_ASN1_NEG_ENUMERATED` (0x10A) or a length above 8 bytes, otherwise the big-endian bytes, negated for the negative type. The layouts (`ASN1_STRING` 24 bytes, `OCSP_RESPONSE` 16, `OCSP_CERTSTATUS` 16 with the union at 8, `OCSP_REVOKEDINFO` 16, `OCSP_SINGLERESP` 40) are checked with `static_assert`s. LibreSSL dereferences a null response, a null `certStatus`, and a null revoked record when the time or reason is requested without checking them, so those throw. No export of this module decodes a response yet, so for now only structures built by the caller reach these functions. The debt entry records the source and what is unverified, and the pending-export count drops by 2 (342 to 340 on current `main`). The OCSP string functions in #9949 live in `src/Ocsp.cpp`. This PR uses `src/OcspResponse.cpp`, so the two don't add the same file. ### 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. There is one commit per function, and each adds that function with its test block and debt update. Each was built and its `guest_libressl_ocsp_response` test and `check_conventions.py` run on its own. - New `guest_libressl_ocsp_response` test. `OCSP_response_status` is checked with one- and two-byte values, a negative enumerated value, a 5-byte value truncated to `int`, an 8-byte value with the top bit set, a 9-byte value (-1), zero length, null data, the wrong type (-1), and a null status (0); a null response throws. `OCSP_single_get0_status` returns -1 without writing for a null single response. For good and unknown it fills only `thisupd` and `nextupd`, leaving `reason` and `revtime` alone. For revoked it covers a reason, no reason (-1), a wrongly typed reason (-1) and null outputs. A revoked status with a null record throws only when the reason or time is requested, and a null `certStatus` throws. On `main` the first call throws. - Full `ctest -j16` at the last commit: 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 ac9661e493: 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 f28584b07d, 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. f28584b07d (`refactor(libSceLibreSsl): declare the OCSP status 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 2db12797e2, to resolve the conflicts with `main` on the shared `CMakeLists.txt` and debt-file lines; both sides are kept and the count is 342 minus this PR's exports. Full build and `ctest -j16`: 2275/2276 pass; `agc_driver_multisample_retirement` fails the same way on that `main`. `check_conventions.py --base upstream/main` passes. - Review fix 5ab224da00 drops `LibreSslAsn1String` and uses `main`'s `Asn1String` (same 24-byte layout, asserted in `Asn1.cpp`) in the OCSP structs, signatures and test; `guest_libressl_ocsp_response` and `public_headers` pass. Full build and `ctest -j16` on `main` ae7d59258e: 2275/2276 pass; `agc_driver_multisample_retirement` fails the same way on that `main`. `check_conventions.py --base upstream/main` passes. - Rebased on `main` 88795ed448 (after #10248; head 5b7598547f) 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 f000377fe2, 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` 474030e584 (after #13562), head 742ed7a7c6, to resolve the conflict on the pending-export count in the debt file; the count is 292 minus this PR's exports. Full build and `ctest -j16`: 3062/3062 pass. `check_conventions.py --base upstream/main` passes. - Rebased on `main` cf79276fee (after #13820), head 7e59cbf222, 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 288 stubs left in `Export.cpp`. It also restores the PS5 3.20 export table link, `b2a77c09cd71c01f34c790cfbe98c751a13262ad`, which the previous rebase had written without its zeros. 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 81f030e81d, to resolve the conflicts on the shared `CMakeLists.txt`, `Export.cpp`, `Api.hpp` and debt-file lines; both sides are kept. This replaces the merge of `main` pushed to the branch as d05afe006c, which only changed the pending count. The count is set to the 259 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 3013ef2759, 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 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
copilot-pull-request-reviewer[bot] commented 2026-10-24 00:56:26 +00:00 (Migrated from github.com)

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

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:5635939629 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10448#pullrequestreview-5635939629). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-10-24T00:56:26Z. **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:36:27 +00:00 (Migrated from github.com)

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

Review: APPROVED


Reviewed exact head 9f5e341f96cee180fc349f4c4be1ecbb0e2da29a. I compared both implementations and the 24/16/40-byte guest layouts with the pinned LibreSSL 2.5.4 ocsp_cl.c, ocsp.h, and a_enum.c. The null-single return, raw certificate status, optional output writes, revoked reason handling, ASN.1 enum limits and values, and null-dereference cases match those sources. The only related open PR I found is #9949, which implements status/reason text conversion rather than these two functions.\n\nI compiled the exact changed implementation and supplied test with GCC 12.2, C++20, -Wall -Wextra -Werror; libSceLibreSsl OCSP response tests passed. This focused direct build used a temporary NotImplemented_nid_no_patch shim, so it does not validate full project linkage or exception integration. The exact-head conventions check passed. Hosted eligibility, conventions, intake, labels and report checks pass; full Linux/Windows product jobs are skipped under repository policy. The PR declares its LibreSSL dependency ordering. I found no blocking behavior issue.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5636203514 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10448#pullrequestreview-5636203514). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T01:36:27Z. **Review:** APPROVED --- Reviewed exact head 9f5e341f96cee180fc349f4c4be1ecbb0e2da29a. I compared both implementations and the 24/16/40-byte guest layouts with the pinned LibreSSL 2.5.4 ocsp_cl.c, ocsp.h, and a_enum.c. The null-single return, raw certificate status, optional output writes, revoked reason handling, ASN.1 enum limits and values, and null-dereference cases match those sources. The only related open PR I found is #9949, which implements status/reason text conversion rather than these two functions.\n\nI compiled the exact changed implementation and supplied test with GCC 12.2, C++20, -Wall -Wextra -Werror; libSceLibreSsl OCSP response tests passed. This focused direct build used a temporary NotImplemented_nid_no_patch shim, so it does not validate full project linkage or exception integration. The exact-head conventions check passed. Hosted eligibility, conventions, intake, labels and report checks pass; full Linux/Windows product jobs are skipped under repository policy. The PR declares its LibreSSL dependency ordering. I found no blocking behavior issue.
MarcZX10 commented 2026-10-29 08:59:41 +00:00 (Migrated from github.com)

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

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:5695136346 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10448#pullrequestreview-5695136346). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-29T08:59:41Z. **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!10448
No description provided.