feat(libSceLibreSsl): implement OCSP_check_validity #11174

Merged
ahmadmuj merged 8 commits from upstream-pr/11174 into main 2026-11-05 15:44:38 +00:00
ahmadmuj commented 2026-10-25 20:35:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ahmadmuj on 2026-10-25T20:35:38Z.


What

Implements OCSP_check_validity, following LibreSSL 2.5.4 ocsp_cl.c and the time parser and compare in a_time_tm.c.

  • Only the 15-char YYYYMMDDHHMMSSZ form parses (no fractions, no UTCTime, same digit and range checks). The ASN.1 type field is ignored, like 2.5.4, which only reads data and length.
  • Same check order and errors: thisUpdate field, not yet valid, too old (when maxsec >= 0), then nextUpdate field, expired, nextUpdate before thisUpdate. Each failure queues one ERR_PACK(39, 0xfff, reason) through the existing error queue.
  • Times compare field by field like ASN1_time_tm_cmp, not as epoch seconds, so 20000231000000Z sorts before March 1 just like 2.5.4.
  • Now comes from guest time, and the offsets go through guest gmtime_r. When gmtime_r fails, the call returns 0 with no error, as in 2.5.4.
  • t_now + nsec is signed overflow in C. The reference build is -O1 -fno-strict-overflow, and the add compiles to a plain add, so I wrap it too. A wrapped value is always outside the gmtime range, so huge nsec/maxsec values return 0 without an error, same as 2.5.4. A null thisupd throws (2.5.4 dereferences it).

Heads-up: no export builds an ASN1_GENERALIZEDTIME yet (d2i_OCSP_RESPONSE is still a stub), same as the other OCSP getters in flight.

Tested

Ubuntu 24.04 on WSL2, GCC 13.3, Release. Head bcb832214c8d merges main 080dbd08c6f8 without rewriting published history.

  • The OCSP source and regression test are byte-identical to the previous head 70530ea4b847.
  • Fresh build passes. The focused OCSP test passes (1/1), ordinary LibreSSL tests pass (57/57), and public headers pass (65/65). Patched and oracle targets are excluded. Conventions and whitespace checks pass.
  • These runtime checks ran on the merge of main 4180951e90e6. The final main update changes only unrelated dialog, JXR, signaling and video files; no build files or LibreSSL dependencies change.
  • The pending-export count is 195, counted from the remaining stubs in Export.cpp.
  • Earlier differential and mutation checks below are historical evidence and were not repeated.

Earlier checks

Ubuntu 24.04 on WSL2, GCC 13.3, Release, on main 5a2744c5. Latest run: merged with main e4501451.

  • Differential against real LibreSSL 2.5.4 static libcrypto.a: a host probe (not committed) ran about 45 cases: valid windows, each error, every bad-string shape (13-char UTCTime, fraction, no Z, out-of-range fields, sign chars, null data, negative and zero length), type 23 and 4, Feb 31, year 0000, and nsec/maxsec at LONG_MAX, LONG_MIN, 6e16 and 7e16. The guest test asserts the same return value and error codes, and that each call queues at most one error.
  • The test uses far-past and far-future times (2000 and 9999, with a 100-year nsec where both ends matter), so it doesn't depend on the clock.
  • Red: with a throwing stub body, guest_libressl_ocsp aborts with OCSP_check_validity_nid_postfix not implemented. Mutations that each fail it: accept second 60, accept a 16-char string, reject equal thisUpdate/nextUpdate, run the age check for negative maxsec, check nextUpdate-before-thisUpdate ahead of expiry.
  • ctest -R "guest_libressl|public_headers": 103/103 pass. check_conventions.py --base origin/main passes.
  • The merge also sets the pending export count to 289, the number of NotImplemented_nid_no_patch stubs left in Export.cpp (main says 292 but has 290).
  • Not tested by me: no console or game dump. Windows (ycbuzi) and macOS (Gonic0) runs of earlier heads pass; the OCSP code and test are unchanged since.

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:5008451709 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11174). Originally posted by [ahmadmuj](https://github.com/ahmadmuj) on 2026-10-25T20:35:38Z. --- ### What Implements `OCSP_check_validity`, following LibreSSL 2.5.4 [ocsp_cl.c](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/ocsp/ocsp_cl.c#L323-L392) and the time parser and compare in [a_time_tm.c](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/asn1/a_time_tm.c#L32-L209). - Only the 15-char `YYYYMMDDHHMMSSZ` form parses (no fractions, no UTCTime, same digit and range checks). The ASN.1 type field is ignored, like 2.5.4, which only reads `data` and `length`. - Same check order and errors: thisUpdate field, not yet valid, too old (when `maxsec >= 0`), then nextUpdate field, expired, nextUpdate before thisUpdate. Each failure queues one `ERR_PACK(39, 0xfff, reason)` through the existing error queue. - Times compare field by field like `ASN1_time_tm_cmp`, not as epoch seconds, so `20000231000000Z` sorts before March 1 just like 2.5.4. - Now comes from guest `time`, and the offsets go through guest `gmtime_r`. When `gmtime_r` fails, the call returns 0 with no error, as in 2.5.4. - `t_now + nsec` is signed overflow in C. The reference build is `-O1 -fno-strict-overflow`, and the add compiles to a plain `add`, so I wrap it too. A wrapped value is always outside the gmtime range, so huge `nsec`/`maxsec` values return 0 without an error, same as 2.5.4. A null `thisupd` throws (2.5.4 dereferences it). Heads-up: no export builds an `ASN1_GENERALIZEDTIME` yet (`d2i_OCSP_RESPONSE` is still a stub), same as the other OCSP getters in flight. ### Tested Ubuntu 24.04 on WSL2, GCC 13.3, Release. Head `bcb832214c8d` merges main `080dbd08c6f8` without rewriting published history. - The OCSP source and regression test are byte-identical to the previous head `70530ea4b847`. - Fresh build passes. The focused OCSP test passes (1/1), ordinary LibreSSL tests pass (57/57), and public headers pass (65/65). Patched and oracle targets are excluded. Conventions and whitespace checks pass. - These runtime checks ran on the merge of main `4180951e90e6`. The final main update changes only unrelated dialog, JXR, signaling and video files; no build files or LibreSSL dependencies change. - The pending-export count is 195, counted from the remaining stubs in `Export.cpp`. - Earlier differential and mutation checks below are historical evidence and were not repeated. #### Earlier checks Ubuntu 24.04 on WSL2, GCC 13.3, Release, on `main` 5a2744c5. Latest run: merged with `main` e4501451. - Differential against real LibreSSL 2.5.4 static `libcrypto.a`: a host probe (not committed) ran about 45 cases: valid windows, each error, every bad-string shape (13-char UTCTime, fraction, no `Z`, out-of-range fields, sign chars, null data, negative and zero length), type 23 and 4, Feb 31, year 0000, and `nsec`/`maxsec` at `LONG_MAX`, `LONG_MIN`, 6e16 and 7e16. The guest test asserts the same return value and error codes, and that each call queues at most one error. - The test uses far-past and far-future times (2000 and 9999, with a 100-year `nsec` where both ends matter), so it doesn't depend on the clock. - Red: with a throwing stub body, `guest_libressl_ocsp` aborts with `OCSP_check_validity_nid_postfix not implemented`. Mutations that each fail it: accept second 60, accept a 16-char string, reject equal thisUpdate/nextUpdate, run the age check for negative `maxsec`, check nextUpdate-before-thisUpdate ahead of expiry. - `ctest -R "guest_libressl|public_headers"`: 103/103 pass. `check_conventions.py --base origin/main` passes. - The merge also sets the pending export count to 289, the number of `NotImplemented_nid_no_patch` stubs left in `Export.cpp` (main says 292 but has 290). - Not tested by me: no console or game dump. Windows ([ycbuzi](https://github.com/boykopovar/AnyPS5/pull/11174#issuecomment-6405612828)) and macOS ([Gonic0](https://github.com/boykopovar/AnyPS5/pull/11174#issuecomment-6445040770)) runs of earlier heads pass; the OCSP code and test are unchanged since. ### 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-25 20:40:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T20:40:06Z.

Review: COMMENTED


I reviewed the implementation at head 19e3b8cf55c9986443058424e921bb60410871bf against LibreSSL 2.5.4's OCSP_check_validity flow: validation order, generalized-time field parsing/comparison, slack/max-age boundaries, and error-queue behavior. I did not find a concrete mismatch in the reviewed logic. The added guest cases cover the precedence and malformed-time boundaries called out in the PR description.

Independent checks here: conventions, git diff --check, and C++20 syntax compilation of Ocsp.cpp and GuestLibreSslOcsp.cpp passed. I could not execute the guest test binary in this worktree. Hosted eligibility, conventions, intake, labels, and report checks passed; product build jobs were skipped. I’m leaving a comment-only review because I do not have an independent runtime result for this implementation.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5645153350 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11174#pullrequestreview-5645153350). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T20:40:06Z. **Review:** COMMENTED --- I reviewed the implementation at head `19e3b8cf55c9986443058424e921bb60410871bf` against LibreSSL 2.5.4's `OCSP_check_validity` flow: validation order, generalized-time field parsing/comparison, slack/max-age boundaries, and error-queue behavior. I did not find a concrete mismatch in the reviewed logic. The added guest cases cover the precedence and malformed-time boundaries called out in the PR description. Independent checks here: conventions, `git diff --check`, and C++20 syntax compilation of `Ocsp.cpp` and `GuestLibreSslOcsp.cpp` passed. I could not execute the guest test binary in this worktree. Hosted eligibility, conventions, intake, labels, and report checks passed; product build jobs were skipped. I’m leaving a comment-only review because I do not have an independent runtime result for this implementation.
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!11174
No description provided.