feat(libSceLibreSsl): implement X509_get_issuer_name, X509_get_subject_name and X509_get_serialNumber #10478

Merged
alvaroelpob merged 10 commits from upstream-pr/10478 into main 2026-11-06 04:11:15 +00:00
alvaroelpob commented 2026-10-24 02:46:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by alvaroelpob on 2026-10-24T02:46:13Z.


What

Implements X509_get_issuer_name, X509_get_subject_name and X509_get_serialNumber 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 x509.h and x509_cmp.c:

Export Behaviour
X509_NAME* X509_get_issuer_name(X509*) cert_info->issuer
X509_NAME* X509_get_subject_name(X509*) cert_info->subject
ASN1_INTEGER* X509_get_serialNumber(X509*) cert_info->serialNumber

The layouts are 176 bytes for X509 (cert_info at 0) and 104 for X509_CINF (serialNumber at 8, issuer at 24, subject at 40). They were checked with static_asserts and against offsetof from the 2.5.4 headers compiled on x86-64. LibreSSL dereferences the certificate and its info without checking them, so a null for either throws. No export of this module creates a certificate yet, so for now only certificates built by the caller reach these functions.

The debt entry records the source and what is unverified, and the pending-export count drops from 357 to 354.

Tested

Ubuntu 26.04 (WSL2, kernel 6.18), GCC 15.2.0, Release, full build with BUILD_TESTING=ON on main 379b1dca3. 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_x509 test and check_conventions.py run on its own.

  • New guest_libressl_x509 test. Each getter returns null while its field is null and then returns its own field, not a neighbour: issuer versus subject, serial number versus version. A null certificate and a null certificate info throw in all three.
  • Full ctest -j16 at the last commit: 2005/2006 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 6d3755d4d7: 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 190f012bc5, 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. 190f012bc5 (refactor(libSceLibreSsl): declare the X509 name and serial 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 6a3402ef61, 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.
  • Rebased on main 2dbe9b99f5 (after #9745, #9870 and #11111), head 5458e6f643, to resolve the conflicts with main on the shared CMakeLists.txt and debt-file lines; both sides are kept and the count is 340 minus this PR's exports. Full build and ctest -j16: 2370/2371 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 4fa2d55578) 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 0c05e03eab, 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. check_conventions.py --base upstream/main passes.
  • Rebased on main 474030e584 (after #13562), head 3462b50cc5, 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 a30919457a, 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 287 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 c9ce4296b7, to resolve the conflicts on the shared CMakeLists.txt, Export.cpp, Api.hpp and debt-file lines; both sides are kept. The count is set to the 258 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 4002ce1244, 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, #10448, #10450, #10477
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4991880139 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10478). Originally posted by [alvaroelpob](https://github.com/alvaroelpob) on 2026-10-24T02:46:13Z. --- ### What Implements `X509_get_issuer_name`, `X509_get_subject_name` and `X509_get_serialNumber` 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 [`x509.h` and `x509_cmp.c`](https://github.com/libressl/openbsd/tree/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/x509): | Export | Behaviour | |---|---| | `X509_NAME* X509_get_issuer_name(X509*)` | `cert_info->issuer` | | `X509_NAME* X509_get_subject_name(X509*)` | `cert_info->subject` | | `ASN1_INTEGER* X509_get_serialNumber(X509*)` | `cert_info->serialNumber` | The layouts are 176 bytes for `X509` (`cert_info` at 0) and 104 for `X509_CINF` (`serialNumber` at 8, `issuer` at 24, `subject` at 40). They were checked with `static_assert`s and against `offsetof` from the 2.5.4 headers compiled on x86-64. LibreSSL dereferences the certificate and its info without checking them, so a null for either throws. No export of this module creates a certificate yet, so for now only certificates built by the caller reach these functions. The debt entry records the source and what is unverified, and the pending-export count drops from 357 to 354. ### 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` 379b1dca3. 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_x509` test and `check_conventions.py` run on its own. - New `guest_libressl_x509` test. Each getter returns null while its field is null and then returns its own field, not a neighbour: issuer versus subject, serial number versus version. A null certificate and a null certificate info throw in all three. - Full `ctest -j16` at the last commit: 2005/2006 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 6d3755d4d7: 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 190f012bc5, 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. 190f012bc5 (`refactor(libSceLibreSsl): declare the X509 name and serial 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 6a3402ef61, 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. - Rebased on `main` 2dbe9b99f5 (after #9745, #9870 and #11111), head 5458e6f643, to resolve the conflicts with `main` on the shared `CMakeLists.txt` and debt-file lines; both sides are kept and the count is 340 minus this PR's exports. Full build and `ctest -j16`: 2370/2371 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 4fa2d55578) 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 0c05e03eab, 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`. `check_conventions.py --base upstream/main` passes. - Rebased on `main` 474030e584 (after #13562), head 3462b50cc5, 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 a30919457a, 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 287 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 c9ce4296b7, to resolve the conflicts on the shared `CMakeLists.txt`, `Export.cpp`, `Api.hpp` and debt-file lines; both sides are kept. The count is set to the 258 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 4002ce1244, 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, #10448, #10450, #10477 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
copilot-pull-request-reviewer[bot] commented 2026-10-24 02:50:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-10-24T02:50: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:5636483477 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10478#pullrequestreview-5636483477). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-10-24T02:50: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 15:59:36 +00:00 (Migrated from github.com)

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

Review: APPROVED


Reviewed the three X509 accessors against the cited LibreSSL 2.5.4 layouts. The certificate-info member offsets match the static assertions, including the 64-bit ASN1_ENCODING length needed to keep those offsets, and the null certificate/info paths are covered. The current head merges cleanly with upstream main; convention and diff checks pass. I compiled and ran GuestLibreSslX509.cpp with X509.cpp directly using GCC 12.2.0; it passed. The broader Linux test results are author-reported; hosted product jobs are skipped.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5638872805 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10478#pullrequestreview-5638872805). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T15:59:36Z. **Review:** APPROVED --- Reviewed the three X509 accessors against the cited LibreSSL 2.5.4 layouts. The certificate-info member offsets match the static assertions, including the 64-bit ASN1_ENCODING length needed to keep those offsets, and the null certificate/info paths are covered. The current head merges cleanly with upstream main; convention and diff checks pass. I compiled and ran `GuestLibreSslX509.cpp` with `X509.cpp` directly using GCC 12.2.0; it passed. The broader Linux test results are author-reported; hosted product jobs are skipped.
ahmadmuj commented 2026-10-25 18:08:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ahmadmuj on 2026-10-25T18:08:23Z.

Review: APPROVED


Reviewed head 79c3000fa8 merged onto main 7a25f87620. Only the debt file conflicts (the usual pending-count line); taking main's side with the count at 342 matches the 342 stubs left in Export.cpp. Linux x86_64, GCC 13.3, Release.

What I ran:

  • guest_libressl_x509 and the other guest_libressl_* tests on the merged tree: all pass.
  • Mutations: issuer returning .subject, serial returning .version, and dropping the null certInfo check each make guest_libressl_x509 fail.
  • tools/check_conventions.py --base origin/main: pass.
  • Layout probe compiled against the official 2.5.4 tarball headers (sha256 107a5b52...336efa, matches ftp.openbsd.org): sizeof(X509) 176, sizeof(X509_CINF) 104, sizeof(ASN1_ENCODING) 24, cert_info 0, serialNumber 8, issuer 24, subject 40, enc 80. Same as the static_asserts. The only #ifdef in x509_st is OPENSSL_NO_SHA around sha1_hash, which 2.5.4 doesn't define, and it sits after every field read here anyway.
  • Differential: parsed 5 real certs with a built 2.5.4 d2i_X509 (RSA and EC, v1 and v3, serials 0, 1, 0xFF and a 20-byte one, plus a leaf whose issuer differs from its subject) and called the PR's exports on the same X509*. All three pointers equal 2.5.4's X509_get_* for every cert, and names and serial bytes read back correctly through them.

Source: 2.5.4 x509_cmp.c L148-177 return a->cert_info->issuer/subject/serialNumber with no null check, so throwing on a null cert or cert info fits the rules. The struct fields match x509.h L251-264 and asn1.h L246-250 (long len, so int64_t is right).

Not checked: a console, or the console's build options (they could only change what's in rest).

Two small optional things:

  1. The PR body still says the count drops from 357 to 354; the diff and tree say 345 to 342.
  2. X509_get_serialNumber could return Asn1String* instead of void*. ASN1_INTEGER is asn1_string_st in 2.5.4, and ASN1_INTEGER_get_nid_postfix already takes const Asn1String*, so a caller could pass the result straight in.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5644562879 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10478#pullrequestreview-5644562879). Originally posted by [ahmadmuj](https://github.com/ahmadmuj) on 2026-10-25T18:08:23Z. **Review:** APPROVED --- Reviewed head `79c3000fa8` merged onto main `7a25f87620`. Only the debt file conflicts (the usual pending-count line); taking main's side with the count at 342 matches the 342 stubs left in `Export.cpp`. Linux x86_64, GCC 13.3, Release. What I ran: - `guest_libressl_x509` and the other `guest_libressl_*` tests on the merged tree: all pass. - Mutations: issuer returning `.subject`, serial returning `.version`, and dropping the null `certInfo` check each make `guest_libressl_x509` fail. - `tools/check_conventions.py --base origin/main`: pass. - Layout probe compiled against the official 2.5.4 tarball headers (sha256 `107a5b52...336efa`, matches ftp.openbsd.org): `sizeof(X509)` 176, `sizeof(X509_CINF)` 104, `sizeof(ASN1_ENCODING)` 24, `cert_info` 0, `serialNumber` 8, `issuer` 24, `subject` 40, `enc` 80. Same as the static_asserts. The only `#ifdef` in `x509_st` is `OPENSSL_NO_SHA` around `sha1_hash`, which 2.5.4 doesn't define, and it sits after every field read here anyway. - Differential: parsed 5 real certs with a built 2.5.4 `d2i_X509` (RSA and EC, v1 and v3, serials 0, 1, 0xFF and a 20-byte one, plus a leaf whose issuer differs from its subject) and called the PR's exports on the same `X509*`. All three pointers equal 2.5.4's `X509_get_*` for every cert, and names and serial bytes read back correctly through them. Source: 2.5.4 `x509_cmp.c` L148-177 return `a->cert_info->issuer/subject/serialNumber` with no null check, so throwing on a null cert or cert info fits the rules. The struct fields match `x509.h` L251-264 and `asn1.h` L246-250 (`long len`, so `int64_t` is right). Not checked: a console, or the console's build options (they could only change what's in `rest`). Two small optional things: 1. The PR body still says the count drops from 357 to 354; the diff and tree say 345 to 342. 2. `X509_get_serialNumber` could return `Asn1String*` instead of `void*`. `ASN1_INTEGER` is `asn1_string_st` in 2.5.4, and `ASN1_INTEGER_get_nid_postfix` already takes `const Asn1String*`, so a caller could pass the result straight in.
MarcZX10 commented 2026-10-29 08:59:36 +00:00 (Migrated from github.com)

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

Review: DISMISSED


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