feat(libSceLibreSsl3): implement X509_STORE_CTX_new, free, get0_param and X509_STORE_up_ref #15544

Merged
ashwin280802 merged 1 commit from upstream-pr/15544 into main 2026-11-10 04:45:40 +00:00
ashwin280802 commented 2026-11-03 18:29:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ashwin280802 on 2026-11-03T18:29:44Z.


What

Implements four libSceLibreSsl3 exports that threw NotImplemented_nid_no_patch: X509_STORE_CTX_new, X509_STORE_CTX_free, X509_STORE_CTX_get0_param and X509_STORE_up_ref. The module forwards X509_STORE_new, X509_STORE_free and the X509_STORE_CTX_* getters and setters to libSceLibreSsl, so the new code uses that library's layouts: the 136-byte store with references at offset 128 and the 240-byte context.

Source: LibreSSL x509_vfy.c (X509_STORE_CTX_new, X509_STORE_CTX_free, X509_STORE_CTX_cleanup, X509_STORE_CTX_get0_param) and x509_lu.c (X509_STORE_up_ref) at 078b3d1d.

  • X509_STORE_CTX_new returns a zeroed guest-heap context; X509_STORE_CTX_get0_param returns param.
  • X509_STORE_up_ref increments references atomically and returns 1 when the new count is above 1, otherwise 0.
  • X509_STORE_CTX_free ignores null and frees the context. Its cleanup also releases a cleanup callback, an owned verify parameter, the policy tree, the chain and the extra data; those paths throw without changing the context, because the code that releases them is not available here.

Deliberate divergences, recorded in docs/dev/debt/libSceLibreSsl3.md: X509_STORE_CTX_new does not queue ERR_R_MALLOC_FAILURE (the error queue is not modelled), null arguments to get0_param and up_ref throw where LibreSSL dereferences them, and up_ref throws at INT32_MAX.

Open PRs: none implements these four functions; I searched the diffs of the open PRs that touch these files, including the 18 the overlap tool could not compare (#12315, #14465, #14499, #14612, #15163, #15514, #15627, #15629, #15631, #15737, #15758, #15760, #15761, #15765, #15770, #15826, #15831, #15854); git log -G for the four exported names over those PR heads finds no commits. Several touch the same debt file and the test list in CMakeLists.txt, which will need a trivial rebase.

Tested

Windows 11, at 8600542dc5.

ctest --test-dir build-full -R "guest_libressl3_(x509_store_context|x509_verify_param|stack)":

1/3 Test #3273: guest_libressl3_x509_verify_param ....   Passed    0.04 sec
2/3 Test #3274: guest_libressl3_stack ................   Passed    0.02 sec
3/3 Test #3275: guest_libressl3_x509_store_context ...   Passed    0.11 sec
100% tests passed out of 3

The new test covers all four functions, the throwing free paths, leaks and 8 threads x 20000 up_ref calls. tools/check_conventions.py --base origin/main passes.

I changed 17 conditions and statements in the new code one at a time and the test failed on each.

Not covered by a test: allocation failure of X509_STORE_CTX_new.

Not verified: I also ran all the repository's tests on Windows and Linux, and every libSceLibreSsl3 test passed; the only failures were select_tests_MissingCommandTests, vulkan_validation_gate_commands and guest_mmap_executable, which fail on main on this machine too. Nothing was run on a console, and the 240-byte context and 136-byte store layouts of the console's libSceLibreSsl3 are not checked against it.

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:5142497321 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15544). Originally posted by [ashwin280802](https://github.com/ashwin280802) on 2026-11-03T18:29:44Z. --- ### What Implements four `libSceLibreSsl3` exports that threw `NotImplemented_nid_no_patch`: `X509_STORE_CTX_new`, `X509_STORE_CTX_free`, `X509_STORE_CTX_get0_param` and `X509_STORE_up_ref`. The module forwards `X509_STORE_new`, `X509_STORE_free` and the `X509_STORE_CTX_*` getters and setters to libSceLibreSsl, so the new code uses that library's layouts: the 136-byte store with `references` at offset 128 and the 240-byte context. Source: LibreSSL [`x509_vfy.c`](https://github.com/libressl/openbsd/blob/078b3d1d/src/lib/libcrypto/x509/x509_vfy.c) (`X509_STORE_CTX_new`, `X509_STORE_CTX_free`, `X509_STORE_CTX_cleanup`, `X509_STORE_CTX_get0_param`) and [`x509_lu.c`](https://github.com/libressl/openbsd/blob/078b3d1d/src/lib/libcrypto/x509/x509_lu.c) (`X509_STORE_up_ref`) at 078b3d1d. - `X509_STORE_CTX_new` returns a zeroed guest-heap context; `X509_STORE_CTX_get0_param` returns `param`. - `X509_STORE_up_ref` increments `references` atomically and returns 1 when the new count is above 1, otherwise 0. - `X509_STORE_CTX_free` ignores null and frees the context. Its cleanup also releases a cleanup callback, an owned verify parameter, the policy tree, the chain and the extra data; those paths throw without changing the context, because the code that releases them is not available here. Deliberate divergences, recorded in `docs/dev/debt/libSceLibreSsl3.md`: `X509_STORE_CTX_new` does not queue `ERR_R_MALLOC_FAILURE` (the error queue is not modelled), null arguments to `get0_param` and `up_ref` throw where LibreSSL dereferences them, and `up_ref` throws at `INT32_MAX`. Open PRs: none implements these four functions; I searched the diffs of the open PRs that touch these files, including the 18 the overlap tool could not compare (#12315, #14465, #14499, #14612, #15163, #15514, #15627, #15629, #15631, #15737, #15758, #15760, #15761, #15765, #15770, #15826, #15831, #15854); `git log -G` for the four exported names over those PR heads finds no commits. Several touch the same debt file and the test list in `CMakeLists.txt`, which will need a trivial rebase. ### 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. --> Windows 11, at 8600542dc5. `ctest --test-dir build-full -R "guest_libressl3_(x509_store_context|x509_verify_param|stack)"`: ``` 1/3 Test #3273: guest_libressl3_x509_verify_param .... Passed 0.04 sec 2/3 Test #3274: guest_libressl3_stack ................ Passed 0.02 sec 3/3 Test #3275: guest_libressl3_x509_store_context ... Passed 0.11 sec 100% tests passed out of 3 ``` The new test covers all four functions, the throwing free paths, leaks and 8 threads x 20000 `up_ref` calls. `tools/check_conventions.py --base origin/main` passes. I changed 17 conditions and statements in the new code one at a time and the test failed on each. Not covered by a test: allocation failure of `X509_STORE_CTX_new`. Not verified: I also ran all the repository's tests on Windows and Linux, and every libSceLibreSsl3 test passed; the only failures were select_tests_MissingCommandTests, vulkan_validation_gate_commands and guest_mmap_executable, which fail on main on this machine too. Nothing was run on a console, and the 240-byte context and 136-byte store layouts of the console's libSceLibreSsl3 are not checked against it. ### 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
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!15544
No description provided.