feat(libSceLibreSsl): implement X509_NAME_print_ex #17961

Merged
Noxy-HNR merged 10 commits from upstream-pr/17961 into main 2026-11-16 08:08:59 +00:00
Noxy-HNR commented 2026-11-10 01:08:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Noxy-HNR on 2026-11-10T01:08:42Z.


What

Implements X509_NAME_print_ex for libSceLibreSsl, replacing the NotImplemented stub. The export is a typed adapter over the real X509_NAME_print_ex from the pinned 3rdparty/libressl-openbsd submodule: LibreSslCrypto.cmake builds a curated libcrypto subset (asn1/a_strex.c, the ASN.1 item codecs, object tables, BIO, stack, lhash, BIGNUM and the error tables) into a static libressl_crypto library. X509_NAME_print and ASN1_tag2str are copied from t_x509.c and asn1_par.c into libressl/x509_name_print.c with the upstream notice, so the rest of those files is not pulled in. The OpenBSD strlcpy, strlcat, reallocarray, recallocarray and freezero come from the submodule's src/lib/libc with their notices, and libressl/libressl_port.c holds the remaining shims, which are our own code. The library is needed on every configuration, not only tests, because libSceLibreSsl itself links it for this export; the build stops with a message naming the submodule when 3rdparty/libressl-openbsd is not initialised. The guest name, entry, object, string and stack layouts match the submodule's (checked by static_assert), so the adapter passes the guest name straight through, prints into a memory BIO and copies the result to the guest BIO.

  • The object tables (obj_mac.h, obj_dat.h) are generated at build time by GenerateObjects.py, a Python port of LibreSSL's objects.pl and obj_dat.pl. Its output matches the Perl scripts apart from the "generated by" line, and both the script and the generated headers carry the upstream notice, so the build needs no Perl.
  • The pinned do_buf reads past a BMPString or UniversalString whose length is not a whole number of characters. The adapter makes such a value fail before it prints, as newer LibreSSL does, unless the value would be hex-dumped instead.
  • Output follows the submodule revision rather than the 2.5.4 sources the rest of the module tracks; this and the BOOLEAN union-reuse byte are recorded in the library debt file.

Tested

Linux (Ubuntu 24.04, GCC 13.3, Release), head 133003b34c: all 91 guest_libressl*/guest_libre_ssl* tests, including guest_libressl_x509_name_print_ex, pass 3 of 3 runs, and nm -D shows none of the internal LibreSSL symbols exported from libSceLibreSsl.prx. The print test was clean under valgrind on the previous head. Before the partial-character guard, the print test crashed on Linux in do_buf (odd-length BMPString case).

Windows (MinGW GCC 15.2.0), head 133003b34c: guest_libressl_x509_name_print_ex and the two guest_libressl_x509_name_oneline tests pass 3 of 3 runs. The test covers separators, ordering, field modes, alignment, escaping, UTF-8 edge cases (surrogates, odd BMPString, truncated UniversalString, >U+10FFFF, invalid UTF-8), unknown/DER dumps, write-failure accounting and compatibility mode. Not tested on a console or in a title.

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:5233920898 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17961). Originally posted by [Noxy-HNR](https://github.com/Noxy-HNR) on 2026-11-10T01:08:42Z. --- ### What Implements `X509_NAME_print_ex` for libSceLibreSsl, replacing the `NotImplemented` stub. The export is a typed adapter over the real `X509_NAME_print_ex` from the pinned `3rdparty/libressl-openbsd` submodule: `LibreSslCrypto.cmake` builds a curated libcrypto subset (`asn1/a_strex.c`, the ASN.1 item codecs, object tables, BIO, stack, lhash, BIGNUM and the error tables) into a static `libressl_crypto` library. `X509_NAME_print` and `ASN1_tag2str` are copied from `t_x509.c` and `asn1_par.c` into `libressl/x509_name_print.c` with the upstream notice, so the rest of those files is not pulled in. The OpenBSD `strlcpy`, `strlcat`, `reallocarray`, `recallocarray` and `freezero` come from the submodule's `src/lib/libc` with their notices, and `libressl/libressl_port.c` holds the remaining shims, which are our own code. The library is needed on every configuration, not only tests, because libSceLibreSsl itself links it for this export; the build stops with a message naming the submodule when `3rdparty/libressl-openbsd` is not initialised. The guest name, entry, object, string and stack layouts match the submodule's (checked by `static_assert`), so the adapter passes the guest name straight through, prints into a memory BIO and copies the result to the guest BIO. - The object tables (`obj_mac.h`, `obj_dat.h`) are generated at build time by `GenerateObjects.py`, a Python port of LibreSSL's `objects.pl` and `obj_dat.pl`. Its output matches the Perl scripts apart from the "generated by" line, and both the script and the generated headers carry the upstream notice, so the build needs no Perl. - The pinned `do_buf` reads past a BMPString or UniversalString whose length is not a whole number of characters. The adapter makes such a value fail before it prints, as newer LibreSSL does, unless the value would be hex-dumped instead. - Output follows the submodule revision rather than the 2.5.4 sources the rest of the module tracks; this and the BOOLEAN union-reuse byte are recorded in the library debt 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. --> Linux (Ubuntu 24.04, GCC 13.3, Release), head 133003b34c: all 91 `guest_libressl*`/`guest_libre_ssl*` tests, including `guest_libressl_x509_name_print_ex`, pass 3 of 3 runs, and `nm -D` shows none of the internal LibreSSL symbols exported from `libSceLibreSsl.prx`. The print test was clean under valgrind on the previous head. Before the partial-character guard, the print test crashed on Linux in `do_buf` (odd-length BMPString case). Windows (MinGW GCC 15.2.0), head 133003b34c: `guest_libressl_x509_name_print_ex` and the two `guest_libressl_x509_name_oneline` tests pass 3 of 3 runs. The test covers separators, ordering, field modes, alignment, escaping, UTF-8 edge cases (surrogates, odd BMPString, truncated UniversalString, >U+10FFFF, invalid UTF-8), unknown/DER dumps, write-failure accounting and compatibility mode. Not tested 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: 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!17961
No description provided.