feat(libSceLibreSsl3): implement X509V3_set_ctx #15629

Merged
alvaroelpob merged 3 commits from upstream-pr/15629 into main 2026-11-10 11:01:30 +00:00
alvaroelpob commented 2026-11-03 22:27:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by alvaroelpob on 2026-11-03T22:27:20Z.


What

Implements X509V3_set_ctx in libSceLibreSsl3. As in LibreSSL 4.0.0 x509_conf.c, it stores the issuer, subject, request, CRL and flags in the caller's 48-byte X509V3_CTX from the public 4.0.0 x509v3.h and leaves db alone.

Tested

Linux x86-64 (WSL2), Release: the full build passes and ctest --test-dir build -j16 passes 3829 of 3829 tests, including the new guest_libressl3_x509v3_context. python3 tools/check_conventions.py --base upstream/main passes. Not run on a console or in a title.

Checklist

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5145475985 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15629). Originally posted by [alvaroelpob](https://github.com/alvaroelpob) on 2026-11-03T22:27:20Z. --- ### What Implements `X509V3_set_ctx` in libSceLibreSsl3. As in LibreSSL 4.0.0 [`x509_conf.c`](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/x509/x509_conf.c#L430-L440), it stores the issuer, subject, request, CRL and flags in the caller's 48-byte `X509V3_CTX` from the public 4.0.0 `x509v3.h` and leaves `db` alone. ### 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. --> Linux x86-64 (WSL2), Release: the full build passes and `ctest --test-dir build -j16` passes 3829 of 3829 tests, including the new `guest_libressl3_x509v3_context`. `python3 tools/check_conventions.py --base upstream/main` passes. Not run on a console or in a title. ### 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: #12945, #14366, #14889, #14890, #14992, #15031, #15045, #15119, #15289, #15303, #15472, #15514, #15544, #15591, #15599, #15616, #15618, #15620, #15622, #15623, #15624, #15625, #15627, #15628 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
XairRrR commented 2026-11-03 23:09:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T23:09:20Z.

Review: APPROVED


Reviewed — approved

X509V3_set_ctx matches the LibreSSL 4.0.0 code the PR cites, and the new test passes on the merged tree. The test also fails when the export is reverted to main's throwing stub. I found no issues.

What I ran

Head 197ead80f3e9cfad89eec9a637c0d4267c4c7e3e, main 1c8c0efc8c41314402e6966da5bef6ea3d639d10, merged with --no-ff into tree a8c7d326a531b6deed1b20325d83a029bc47e166. Debian 13 VM, GCC 14.2.0, Release, Ninja.

git diff --check 1c8c0efc8c41314402e6966da5bef6ea3d639d10...197ead80f3e9cfad89eec9a637c0d4267c4c7e3e
python3 tools/check_conventions.py --base 1c8c0efc8c41314402e6966da5bef6ea3d639d10
# negative control: src/X509V3Context.cpp body replaced by NotImplemented_nid_no_patch(__func__)
ninja -C build -j32 -l32 guest_libressl3_x509v3_context_tests
ctest --test-dir build -R "^guest_libressl3_x509v3_context$" --output-on-failure
# merged file restored from a8c7d326a531b6deed1b20325d83a029bc47e166
ninja -C build -j32 -l32 guest_libressl3_x509v3_context_tests
ctest --test-dir build -R "^guest_libressl3_x509v3_context$" --output-on-failure
git status --porcelain
# cited reference, read from the libressl-openbsd submodule's object store
git show ce488b78e0bd994780569df718596b9776ff681a:src/lib/libcrypto/x509/x509_conf.c | sed -n 428,442p
git show ce488b78e0bd994780569df718596b9776ff681a:src/lib/libcrypto/x509/x509v3.h | sed -n 121,132p

Results

Check Result
git diff --check clean
check_conventions.py All conventions checks passed
Configure / build / libs (script) ok
Selected tests (script) 835 ran, 831 passed, 3 expected skips, 0 new failures, 0 timeouts
Known failure unwrap_self_UnwrapTest_test_new_output_inherits_the_destination_directory_group: fails on main too, unrelated to this PR
guest_libressl3_x509v3_context passed (about 0.01 s)
public_headers passed: "406 libraries, 28302 exports: unique declarations and umbrella coverage verified"
Vulkan validation comparison skipped by the script: the PR changes no AGC driver, shader recompiler or VideoOut files
Cited LibreSSL 4.0.0 source x509_conf.c L430–L440 is X509V3_set_ctx and sets issuer, subject, CRL, request and flags. It does not touch db. x509v3.h L123–L131 is struct v3_ext_ctx { int flags; X509 *issuer_cert; X509 *subject_cert; X509_REQ *subject_req; X509_CRL *crl; void *db; }. This matches the new struct and its static_asserts.

Negative control

I replaced the body of core/libs/prx/libSceLibreSsl3/src/X509V3Context.cpp with NotImplemented_nid_no_patch(__func__), which is what main does for this export. After a rebuild the test failed as expected:

Output
terminate called after throwing an instance of 'std::runtime_error'
  what():  X509V3_set_ctx_nid_postfix not implemented
0% tests passed, 1 tests failed out of 1
	2874 - guest_libressl3_x509v3_context (Subprocess aborted)

I then restored the merged file and rebuilt; the test passed again, and git status --porcelain was empty.

Findings

Blocking

None.

Non-blocking

None.

Notes from reading the code:

  • The repository's pinned libressl-openbsd submodule is an older LibreSSL whose context still has db_meth before db. This does not affect the implementation:
    • The fields it writes are at the same offsets (0–32) in both layouts.
    • It never touches db or db_meth.
    • Only the 48-byte size assertion depends on the version, and the debt entry records that.
  • The null-context throw (core/libs/prx/libSceLibreSsl3/src/X509V3Context.cpp:7) follows the library's existing rule that inputs on which LibreSSL would fault throw instead.
  • The new debt entry and the updated inventory count (174 exports: 164 named, 10 known only by NID) match the export removed from AdditionalExports.cpp.

Not verified

  • Behaviour on a PS5 console, and which LibreSSL version Sony's libSceLibreSsl3 is built from. The debt entry already lists this as open.
  • Windows/MinGW build and the WIN32 PATH setting for the new test.
  • The full test suite: only the tests the script selected and the new test were run.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5760786922 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15629#pullrequestreview-5760786922). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-11-03T23:09:20Z. **Review:** APPROVED --- # Reviewed — approved `X509V3_set_ctx` matches the LibreSSL 4.0.0 code the PR cites, and the new test passes on the merged tree. The test also fails when the export is reverted to `main`'s throwing stub. I found no issues. ## What I ran Head `197ead80f3e9cfad89eec9a637c0d4267c4c7e3e`, `main` `1c8c0efc8c41314402e6966da5bef6ea3d639d10`, merged with `--no-ff` into tree `a8c7d326a531b6deed1b20325d83a029bc47e166`. Debian 13 VM, GCC 14.2.0, Release, Ninja. ``` git diff --check 1c8c0efc8c41314402e6966da5bef6ea3d639d10...197ead80f3e9cfad89eec9a637c0d4267c4c7e3e python3 tools/check_conventions.py --base 1c8c0efc8c41314402e6966da5bef6ea3d639d10 # negative control: src/X509V3Context.cpp body replaced by NotImplemented_nid_no_patch(__func__) ninja -C build -j32 -l32 guest_libressl3_x509v3_context_tests ctest --test-dir build -R "^guest_libressl3_x509v3_context$" --output-on-failure # merged file restored from a8c7d326a531b6deed1b20325d83a029bc47e166 ninja -C build -j32 -l32 guest_libressl3_x509v3_context_tests ctest --test-dir build -R "^guest_libressl3_x509v3_context$" --output-on-failure git status --porcelain # cited reference, read from the libressl-openbsd submodule's object store git show ce488b78e0bd994780569df718596b9776ff681a:src/lib/libcrypto/x509/x509_conf.c | sed -n 428,442p git show ce488b78e0bd994780569df718596b9776ff681a:src/lib/libcrypto/x509/x509v3.h | sed -n 121,132p ``` ## Results | Check | Result | |---|---| | `git diff --check` | clean | | `check_conventions.py` | All conventions checks passed | | Configure / build / `libs` (script) | ok | | Selected tests (script) | 835 ran, 831 passed, 3 expected skips, 0 new failures, 0 timeouts | | Known failure | `unwrap_self_UnwrapTest_test_new_output_inherits_the_destination_directory_group`: fails on `main` too, unrelated to this PR | | `guest_libressl3_x509v3_context` | passed (about 0.01 s) | | `public_headers` | passed: "406 libraries, 28302 exports: unique declarations and umbrella coverage verified" | | Vulkan validation comparison | skipped by the script: the PR changes no AGC driver, shader recompiler or VideoOut files | | Cited LibreSSL 4.0.0 source | `x509_conf.c` L430–L440 is `X509V3_set_ctx` and sets issuer, subject, CRL, request and flags. It does not touch `db`. `x509v3.h` L123–L131 is `struct v3_ext_ctx { int flags; X509 *issuer_cert; X509 *subject_cert; X509_REQ *subject_req; X509_CRL *crl; void *db; }`. This matches the new struct and its `static_assert`s. | ## Negative control I replaced the body of `core/libs/prx/libSceLibreSsl3/src/X509V3Context.cpp` with `NotImplemented_nid_no_patch(__func__)`, which is what `main` does for this export. After a rebuild the test failed as expected: <details><summary>Output</summary> ``` terminate called after throwing an instance of 'std::runtime_error' what(): X509V3_set_ctx_nid_postfix not implemented 0% tests passed, 1 tests failed out of 1 2874 - guest_libressl3_x509v3_context (Subprocess aborted) ``` </details> I then restored the merged file and rebuilt; the test passed again, and `git status --porcelain` was empty. ## Findings ### Blocking None. ### Non-blocking None. Notes from reading the code: - The repository's pinned `libressl-openbsd` submodule is an older LibreSSL whose context still has `db_meth` before `db`. This does not affect the implementation: - The fields it writes are at the same offsets (0–32) in both layouts. - It never touches `db` or `db_meth`. - Only the 48-byte size assertion depends on the version, and the debt entry records that. - The null-context `throw` (`core/libs/prx/libSceLibreSsl3/src/X509V3Context.cpp:7`) follows the library's existing rule that inputs on which LibreSSL would fault throw instead. - The new debt entry and the updated inventory count (174 exports: 164 named, 10 known only by NID) match the export removed from `AdditionalExports.cpp`. ## Not verified - Behaviour on a PS5 console, and which LibreSSL version Sony's libSceLibreSsl3 is built from. The debt entry already lists this as open. - Windows/MinGW build and the `WIN32` `PATH` setting for the new test. - The full test suite: only the tests the script selected and the new test were run. <!-- anyps5-bots job=3695 head=197ead80f3e9cfad89eec9a637c0d4267c4c7e3e -->
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!15629
No description provided.