feat(libSceLibreSsl): implement X509_VERIFY_PARAM_set_hostflags and X509_VERIFY_PARAM_set1_ip_asc #11100

Merged
JaceTheBlu merged 11 commits from upstream-pr/11100 into main 2026-10-28 14:35:25 +00:00
JaceTheBlu commented 2026-10-25 17:33:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JaceTheBlu on 2026-10-25T17:33:10Z.


What

Implements X509_VERIFY_PARAM_set_hostflags and X509_VERIFY_PARAM_set1_ip_asc in libSceLibreSsl, which threw and were declared without parameters. Builds on the verify parameter layout from #11089, whose commit is the first one on this branch.

Export Behaviour
void X509_VERIFY_PARAM_set_hostflags(X509_VERIFY_PARAM*, unsigned int) stores the flags in the parameter identity's hostflags, replacing the previous value
int X509_VERIFY_PARAM_set1_ip_asc(X509_VERIFY_PARAM*, const char*) parses the text as a2i_ipadd does: IPv6 when it holds a :, with :: compression and a trailing dotted IPv4 part, otherwise IPv4 through sscanf("%d.%d.%d.%d") with each part 0-255; copies the 4 or 16 bytes into a malloc block that replaces the previous address and its length, returns 1; returns 0 and keeps the previous address for text the parser rejects or a failed allocation

Both follow LibreSSL 2.5.4 x509_vpm.c and the a2i_ipadd, ipv4_from_asc, ipv6_from_asc, ipv6_cb and ipv6_hex of v3_utl.c with CONF_parse_list from conf_mod.c. These functions and the parameter layouts are unchanged in LibreSSL 2.7 (OPENBSD_6_3), the first release whose symbols include X509_VERIFY_PARAM_set1_host and SSL_get0_param, which the module also exports (as #9448 notes). 2.8 appends a poisoned field to the parameter identity; the debt entry records it. IPv4 parts are read with the guest sscanf, as the module would through libc, so its whitespace, sign and trailing-text handling carries over (" 1. 2.3.4" and "+1.2.3.4x" are accepted, as in LibreSSL).

A null address text, and null verify parameters or identity once an address is accepted, throw where LibreSSL faults; a rejected address returns 0 before reading the parameters, as LibreSSL does. The pending-export count in docs/dev/debt/libSceLibreSsl.md drops from 342 to 340.

Tested

Debian trixie container, GCC 14.2, full Release build. ctest -R 'libressl|crypto_memcmp': 15 of 15 pass, including the new guest_libressl_x509_verify_param (host flags replaced, not ORed; IPv4 and IPv6 forms accepted and rejected with their exact bytes; a rejected address keeps the previous one; the throwing cases) and guest_libressl_x509_verify_param_allocator (one malloc per address, the previous one freed, a failed malloc returning 0 and keeping the old address). tools/check_test_registration.py build and python3 tools/check_conventions.py --base upstream/main pass. Not tested on Windows, on a title or on a console.

Outside the repository, the address parser was compared with LibreSSL 2.5.4's own C code compiled next to it, both using the same sscanf: 4,000,026 inputs (random strings over hex digits, :, ., signs and spaces, generated IPv6 and IPv4 forms, and the edge cases above), 87,444 of them accepted, with no difference in result or bytes.

tools/pr_overlap.py was not run (no authenticated gh).

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: #11089
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5007020975 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11100). Originally posted by [JaceTheBlu](https://github.com/JaceTheBlu) on 2026-10-25T17:33:10Z. --- ### What Implements `X509_VERIFY_PARAM_set_hostflags` and `X509_VERIFY_PARAM_set1_ip_asc` in libSceLibreSsl, which threw and were declared without parameters. Builds on the verify parameter layout from #11089, whose commit is the first one on this branch. | Export | Behaviour | |---|---| | `void X509_VERIFY_PARAM_set_hostflags(X509_VERIFY_PARAM*, unsigned int)` | stores the flags in the parameter identity's `hostflags`, replacing the previous value | | `int X509_VERIFY_PARAM_set1_ip_asc(X509_VERIFY_PARAM*, const char*)` | parses the text as `a2i_ipadd` does: IPv6 when it holds a `:`, with `::` compression and a trailing dotted IPv4 part, otherwise IPv4 through `sscanf("%d.%d.%d.%d")` with each part 0-255; copies the 4 or 16 bytes into a `malloc` block that replaces the previous address and its length, returns 1; returns 0 and keeps the previous address for text the parser rejects or a failed allocation | Both follow LibreSSL 2.5.4 [`x509_vpm.c`](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/x509/x509_vpm.c) and the `a2i_ipadd`, `ipv4_from_asc`, `ipv6_from_asc`, `ipv6_cb` and `ipv6_hex` of [`v3_utl.c`](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/x509v3/v3_utl.c) with `CONF_parse_list` from `conf_mod.c`. These functions and the parameter layouts are unchanged in LibreSSL 2.7 (`OPENBSD_6_3`), the first release whose symbols include `X509_VERIFY_PARAM_set1_host` and `SSL_get0_param`, which the module also exports (as #9448 notes). 2.8 appends a `poisoned` field to the parameter identity; the debt entry records it. IPv4 parts are read with the guest `sscanf`, as the module would through libc, so its whitespace, sign and trailing-text handling carries over (`" 1. 2.3.4"` and `"+1.2.3.4x"` are accepted, as in LibreSSL). A null address text, and null verify parameters or identity once an address is accepted, throw where LibreSSL faults; a rejected address returns 0 before reading the parameters, as LibreSSL does. The pending-export count in `docs/dev/debt/libSceLibreSsl.md` drops from 342 to 340. ### Tested Debian trixie container, GCC 14.2, full Release build. `ctest -R 'libressl|crypto_memcmp'`: 15 of 15 pass, including the new `guest_libressl_x509_verify_param` (host flags replaced, not ORed; IPv4 and IPv6 forms accepted and rejected with their exact bytes; a rejected address keeps the previous one; the throwing cases) and `guest_libressl_x509_verify_param_allocator` (one `malloc` per address, the previous one freed, a failed `malloc` returning 0 and keeping the old address). `tools/check_test_registration.py build` and `python3 tools/check_conventions.py --base upstream/main` pass. Not tested on Windows, on a title or on a console. Outside the repository, the address parser was compared with LibreSSL 2.5.4's own C code compiled next to it, both using the same `sscanf`: 4,000,026 inputs (random strings over hex digits, `:`, `.`, signs and spaces, generated IPv6 and IPv4 forms, and the edge cases above), 87,444 of them accepted, with no difference in result or bytes. `tools/pr_overlap.py` was not run (no authenticated `gh`). ### 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: #11089 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-25 17:36:06 +00:00 (Migrated from github.com)

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

Review: APPROVED


Reviewed exact head 887c9b6d5182b618a4d93a2c550c4f36b858deac. The new parameter/store layouts, flag propagation, and IPv4/IPv6 parsing follow the cited LibreSSL 2.5.4 sources; the address update allocates before replacing the previous value, and the reported allocator tests cover that failure path. The PR reports 15/15 focused CTests and a 4,000,026-input comparison against the pinned parser. git diff --check upstream/main is clean. I could not independently configure the full local build because SDL2 development configuration (SDL2Config.cmake) is unavailable here; hosted product jobs are path-skipped, so the functional results are the author-reported focused run. The declared dependency on #11089 is appropriate.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5644372700 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11100#pullrequestreview-5644372700). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T17:36:06Z. **Review:** APPROVED --- Reviewed exact head `887c9b6d5182b618a4d93a2c550c4f36b858deac`. The new parameter/store layouts, flag propagation, and IPv4/IPv6 parsing follow the cited LibreSSL 2.5.4 sources; the address update allocates before replacing the previous value, and the reported allocator tests cover that failure path. The PR reports 15/15 focused CTests and a 4,000,026-input comparison against the pinned parser. `git diff --check upstream/main` is clean. I could not independently configure the full local build because SDL2 development configuration (`SDL2Config.cmake`) is unavailable here; hosted product jobs are path-skipped, so the functional results are the author-reported focused run. The declared dependency on #11089 is appropriate.
MarcZX10 commented 2026-10-25 17:44:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T17:44:46Z.

Review: APPROVED


Re-reviewed exact head 2bafc417cc2630e51ffc89a7469a22f4505331a7. Compared with my prior reviewed head 887c9b6d5182b618a4d93a2c550c4f36b858deac, all four changed source/test files have identical contents; the only delta is normalization of their executable file mode to regular files. The previously reviewed implementation and evidence therefore still apply. Current eligibility, conventions, labels, and report checks pass; product jobs are path-skipped. Approved at this exact head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5644417698 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11100#pullrequestreview-5644417698). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T17:44:46Z. **Review:** APPROVED --- Re-reviewed exact head `2bafc417cc2630e51ffc89a7469a22f4505331a7`. Compared with my prior reviewed head `887c9b6d5182b618a4d93a2c550c4f36b858deac`, all four changed source/test files have identical contents; the only delta is normalization of their executable file mode to regular files. The previously reviewed implementation and evidence therefore still apply. Current eligibility, conventions, labels, and report checks pass; product jobs are path-skipped. Approved at this exact head.
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!11100
No description provided.