feat(libSceLibreSsl): implement X509_NAME_oneline #11359

Merged
JaceTheBlu merged 1 commit from upstream-pr/11359 into main 2026-11-06 12:26:08 +00:00
JaceTheBlu commented 2026-10-26 08:16:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JaceTheBlu on 2026-10-26T08:16:29Z.


What

Implements X509_NAME_oneline in libSceLibreSsl, which threw and was declared without parameters. It is the second step towards d2i_X509, whose decode callback stores X509_NAME_oneline(subject, NULL, 0) in x509_st.name.

This branch is stacked on two open PRs and merges both, together with current main:

  • #11129 (X509_NAME_get_entry, X509_NAME_ENTRY_get_data, X509_NAME_get_index_by_NID, X509_NAME_get_text_by_NID, on #10477's name structures), merged at its current head e0af928fe;
  • #11261 (object table and i2t_ASN1_OBJECT), now merged into main.

Merge #11129 first; this PR's own diff is then only X509_NAME_oneline, its test and its debt entry. X509_NAME_oneline is added at the end of #11129's src/X509Name.cpp, uses the LibreSslStack, LibreSslX509NameEntry and LibreSslX509Name types from Api.hpp, and reads each entry through #11129's X509_NAME_get_entry. Its tests are guest_libressl_x509_name_oneline and guest_libressl_x509_name_oneline_allocator (tests/X509NameOneline.cpp), so they do not collide with #11129's guest_libressl_x509_name.

char* X509_NAME_oneline(X509_NAME* a, char* buf, int len) follows LibreSSL 2.5.4 x509_obj.c:

  • each entry is written as /SN=value: the short name comes from the object table (OBJ_obj2nid then OBJ_nid2sn), and an unknown or unassigned NID falls back to i2t_ASN1_OBJECT into an 80-byte scratch buffer, so an unassigned NID reports OBJ_R_UNKNOWN_NID from each lookup as in LibreSSL;
  • value bytes outside ' '..'~' are written as \xHH; a GeneralString whose length is a multiple of four and whose non-zero bytes all sit at offset 3 of each group keeps only those bytes, any other value keeps every byte;
  • with a caller buffer, the entries that fit in len - 1 bytes are kept and the first that does not fit ends the text; a null name gives "NO X509_NAME" truncated as strlcpy does, and no entry gives "" (even for len 0);
  • without a caller buffer, the text grows in a guest-heap BUF_MEM exactly as 2.5.4 buffer.c ((len + 3) / 3 * 4) and recallocarray do, starting at 200 bytes; the returned block is the guest's to free. A failed allocation returns null after the BUF and then the X509 malloc errors, and frees what it allocated.

A null entry, an entry without a value, and a value without data behind a positive length throw where LibreSSL faults. The debt entry records this, and the pending-export count is recounted from Export.cpp.

Tested

Debian trixie container, GCC 14.2, full Release build of head 157f00e75 (current main 801d5b9bc, #11129 and #11261 merged). ctest -R 'libressl|crypto_memcmp': 28 of 28 pass, including #11129's guest_libressl_x509_name, #11261's guest_libressl_object_text and guest_libressl_object_allocation, and this PR's guest_libressl_x509_name_oneline (null names, empty and missing entry stacks, short names, every truncation point of a caller buffer, len 0, escapes, the GeneralString filter and its non-cases, unknown and unassigned OIDs with their error-queue entries, a null object, text past the first 200 bytes, the throwing cases) and guest_libressl_x509_name_oneline_allocator (the 24-byte header, 268 bytes for the first 200 and 612 for the grown text, the frees, and each of the three allocations failing). tools/check_test_registration.py build and python3 tools/check_conventions.py --base upstream/main pass. Not tested on Windows by me (see the Windows run in the comments for the earlier head), on a title or on a console.

Outside the repository, this function was compared with 2.5.4's own X509_NAME_oneline, BUF_MEM_new/grow/free and recallocarray, compiled next to it with 2.5.4's object functions: 300,000 random names (0 to 6 entries; table, random, unassigned, null and empty objects; eight string types; zero, high and printable bytes up to 120 long; missing entry stacks and null names; caller buffers of -3 to 316 bytes or none), comparing the returned pointer, every byte of the caller buffer or the allocated text, and the number of errors reported. No difference, rerun on this head.

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: #11129
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5014210041 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11359). Originally posted by [JaceTheBlu](https://github.com/JaceTheBlu) on 2026-10-26T08:16:29Z. --- ### What Implements `X509_NAME_oneline` in libSceLibreSsl, which threw and was declared without parameters. It is the second step towards `d2i_X509`, whose decode callback stores `X509_NAME_oneline(subject, NULL, 0)` in `x509_st.name`. This branch is stacked on two open PRs and merges both, together with current `main`: - #11129 (`X509_NAME_get_entry`, `X509_NAME_ENTRY_get_data`, `X509_NAME_get_index_by_NID`, `X509_NAME_get_text_by_NID`, on #10477's name structures), merged at its current head `e0af928fe`; - #11261 (object table and `i2t_ASN1_OBJECT`), now merged into `main`. Merge #11129 first; this PR's own diff is then only `X509_NAME_oneline`, its test and its debt entry. `X509_NAME_oneline` is added at the end of #11129's `src/X509Name.cpp`, uses the `LibreSslStack`, `LibreSslX509NameEntry` and `LibreSslX509Name` types from `Api.hpp`, and reads each entry through #11129's `X509_NAME_get_entry`. Its tests are `guest_libressl_x509_name_oneline` and `guest_libressl_x509_name_oneline_allocator` (`tests/X509NameOneline.cpp`), so they do not collide with #11129's `guest_libressl_x509_name`. `char* X509_NAME_oneline(X509_NAME* a, char* buf, int len)` follows LibreSSL 2.5.4 [`x509_obj.c`](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/x509/x509_obj.c): - each entry is written as `/SN=value`: the short name comes from the object table (`OBJ_obj2nid` then `OBJ_nid2sn`), and an unknown or unassigned NID falls back to `i2t_ASN1_OBJECT` into an 80-byte scratch buffer, so an unassigned NID reports `OBJ_R_UNKNOWN_NID` from each lookup as in LibreSSL; - value bytes outside `' '`..`'~'` are written as `\xHH`; a `GeneralString` whose length is a multiple of four and whose non-zero bytes all sit at offset 3 of each group keeps only those bytes, any other value keeps every byte; - with a caller buffer, the entries that fit in `len - 1` bytes are kept and the first that does not fit ends the text; a null name gives `"NO X509_NAME"` truncated as `strlcpy` does, and no entry gives `""` (even for `len` 0); - without a caller buffer, the text grows in a guest-heap `BUF_MEM` exactly as 2.5.4 `buffer.c` (`(len + 3) / 3 * 4`) and `recallocarray` do, starting at 200 bytes; the returned block is the guest's to free. A failed allocation returns null after the `BUF` and then the `X509` malloc errors, and frees what it allocated. A null entry, an entry without a value, and a value without data behind a positive length throw where LibreSSL faults. The debt entry records this, and the pending-export count is recounted from `Export.cpp`. ### Tested Debian trixie container, GCC 14.2, full Release build of head `157f00e75` (current `main` `801d5b9bc`, #11129 and #11261 merged). `ctest -R 'libressl|crypto_memcmp'`: 28 of 28 pass, including #11129's `guest_libressl_x509_name`, #11261's `guest_libressl_object_text` and `guest_libressl_object_allocation`, and this PR's `guest_libressl_x509_name_oneline` (null names, empty and missing entry stacks, short names, every truncation point of a caller buffer, `len` 0, escapes, the `GeneralString` filter and its non-cases, unknown and unassigned OIDs with their error-queue entries, a null object, text past the first 200 bytes, the throwing cases) and `guest_libressl_x509_name_oneline_allocator` (the 24-byte header, 268 bytes for the first 200 and 612 for the grown text, the frees, and each of the three allocations failing). `tools/check_test_registration.py build` and `python3 tools/check_conventions.py --base upstream/main` pass. Not tested on Windows by me (see the Windows run in the comments for the earlier head), on a title or on a console. Outside the repository, this function was compared with 2.5.4's own `X509_NAME_oneline`, `BUF_MEM_new`/`grow`/`free` and `recallocarray`, compiled next to it with 2.5.4's object functions: 300,000 random names (0 to 6 entries; table, random, unassigned, null and empty objects; eight string types; zero, high and printable bytes up to 120 long; missing entry stacks and null names; caller buffers of -3 to 316 bytes or none), comparing the returned pointer, every byte of the caller buffer or the allocated text, and the number of errors reported. No difference, rerun on this head. `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: #11129 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-10-26 08:43:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T08:43:17Z.

Review: CHANGES_REQUESTED


I reviewed exact head 0cffc3c5a049b1eebadf32235364d3de05e4ca08. The implementation and test report are substantial, but the current overlap state needs an explicit integration plan before this can be approved.

#11129 is open and implements the sibling X509_NAME_* operations in the same newly added src/X509Name.cpp, with shared changes to Export.cpp, Api.hpp, CMake and the LibreSSL debt file. A pairwise git merge-tree of the current #11129 and #11359 heads conflicts in Export.cpp, Api.hpp, src/X509Name.cpp (add/add), and docs/dev/debt/libSceLibreSsl.md. #11359's checklist currently says no other open PR implements the same functions and lists only #11261 as a dependency; that does not capture this shared-file integration requirement. Please coordinate an order with #11129's author, update the dependency/overlap details, and rebase or split the oneline implementation so both implementations and tests are retained. #11261 is still open and is the stated dependency; #11261 and #11129 merge-preview clean in code, with only a debt-file conflict.

The current head is 4 commits ahead and 302 behind main 204c6747d0a1cbaf932def3dea0778810cc3935e. After the agreed stack is assembled on current main, rerun the LibreSSL X509 name and allocation tests, conventions, and overlap checks on the resulting exact head. Existing hosted policy checks pass; product/build jobs are path-skipped. I have not independently run the reported 300,000-case LibreSSL differential harness.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5649380837 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11359#pullrequestreview-5649380837). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-26T08:43:17Z. **Review:** CHANGES_REQUESTED --- I reviewed exact head `0cffc3c5a049b1eebadf32235364d3de05e4ca08`. The implementation and test report are substantial, but the current overlap state needs an explicit integration plan before this can be approved. #11129 is open and implements the sibling `X509_NAME_*` operations in the same newly added `src/X509Name.cpp`, with shared changes to `Export.cpp`, `Api.hpp`, CMake and the LibreSSL debt file. A pairwise `git merge-tree` of the current #11129 and #11359 heads conflicts in `Export.cpp`, `Api.hpp`, `src/X509Name.cpp` (add/add), and `docs/dev/debt/libSceLibreSsl.md`. #11359's checklist currently says no other open PR implements the same functions and lists only #11261 as a dependency; that does not capture this shared-file integration requirement. Please coordinate an order with #11129's author, update the dependency/overlap details, and rebase or split the oneline implementation so both implementations and tests are retained. #11261 is still open and is the stated dependency; #11261 and #11129 merge-preview clean in code, with only a debt-file conflict. The current head is 4 commits ahead and 302 behind `main` `204c6747d0a1cbaf932def3dea0778810cc3935e`. After the agreed stack is assembled on current main, rerun the LibreSSL X509 name and allocation tests, conventions, and overlap checks on the resulting exact head. Existing hosted policy checks pass; product/build jobs are path-skipped. I have not independently run the reported 300,000-case LibreSSL differential harness.
MarcZX10 commented 2026-10-31 10:04:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T10:04:12Z.

Review: CHANGES_REQUESTED


Re-checked — new head, changes requested

The earlier integration fix uses an older #11129 head; merging the two current PR heads still conflicts in four shared files.

What I ran

Re-checked #11359 at head 35f4b078afdcbb2b68d3f33f8ab22e01877c0ab4, against its recorded base c3c45d73abd34dca81da6bad87cb6d36ea437a66. Current main was 45f4f82449a72e31aa9fd3120bd82820211dea41; both PRs preview cleanly against it individually. The current #11129 dependency head is e0af928fe934ca43d5b35aa8ac548e7e67eab4d1, and #11359 does not include that head. Environment: Linux, Python 3.11.2; no C/C++ compiler or build was run.

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 11359
python3 tools/pr_stack_check.py 11359 --repo boykopovar/AnyPS5 --output-dir /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-11359-35f4b078afdc/stack
git merge-tree --write-tree refs/codex/reviews/11129 refs/codex/reviews/11359

Results

Check Result
Diff check and conventions Passed against the PR's recorded base.
Individual current-main merge previews #11129 and #11359 each merge cleanly against 45f4f82449a72e31aa9fd3120bd82820211dea41.
Dependency head inclusion Current #11129 head e0af928fe934ca43d5b35aa8ac548e7e67eab4d1 is not included in #11359 head 35f4b078afdcbb2b68d3f33f8ab22e01877c0ab4; #11261 is already merged.
Pairwise merge preview Conflicts in core/libs/prx/libSceLibreSsl/CMakeLists.txt, Export.cpp, include/Api.hpp, and docs/dev/debt/libSceLibreSsl.md.
Hosted CI Eligibility, conventions, library-portability, labels and report passed. Windows was in progress at the last refresh; Linux and specialized jobs were skipped.
Precheck helper limitations ABI and test-quality helper scripts are absent from the isolated PR checkout, so those checks did not run.
Relevant raw output
All conventions checks passed.
- PR #11129: **clean** against current base; head `e0af928fe934ca43d5b35aa8ac548e7e67eab4d1`; changed paths: none reported
- PR #11359: **clean** against current base; head `35f4b078afdcbb2b68d3f33f8ab22e01877c0ab4`; changed paths: none reported
- #11129 → #11359: **current_dependency_head_not_included**; overlapping changed paths: `core/libs/prx/libSceLibreSsl/CMakeLists.txt`, `core/libs/prx/libSceLibreSsl/Export.cpp`, `core/libs/prx/libSceLibreSsl/include/Api.hpp`, `core/libs/prx/libSceLibreSsl/src/X509Name.cpp`, `core/libs/tests/GuestLibreSslX509Name.cpp`, `docs/dev/debt/libSceLibreSsl.md`
Auto-merging core/libs/prx/libSceLibreSsl/CMakeLists.txt
CONFLICT (content): Merge conflict in core/libs/prx/libSceLibreSsl/CMakeLists.txt
Auto-merging core/libs/prx/libSceLibreSsl/Export.cpp
CONFLICT (content): Merge conflict in core/libs/prx/libSceLibreSsl/Export.cpp
Auto-merging core/libs/prx/libSceLibreSsl/include/Api.hpp
CONFLICT (content): Merge conflict in core/libs/prx/libSceLibreSsl/include/Api.hpp
Auto-merging docs/dev/debt/libSceLibreSsl.md
CONFLICT (content): Merge conflict in docs/dev/debt/libSceLibreSsl.md

Findings

Blocking

The branch includes #11129's earlier head 6fb16fdc1, but the live #11129 head has since added X509 name accessors and changed the same build, export, public-header and debt files. A merge preview of the exact current heads reports content conflicts in four files, so the declared integration order is not currently usable as posted. Please merge the live #11129 head e0af928fe934ca43d5b35aa8ac548e7e67eab4d1 into this branch and resolve the shared files while retaining both PRs' implementations and tests. Since #11261 is merged, update the dependency checklist to reflect the remaining open dependency. I will rerun the same checks on the resulting head.

Non-blocking

The author reports a full Release build, 28/28 selected CTest cases, registration and convention checks, and a 300,000-case LibreSSL differential comparison on this head; I did not independently run those checks.

Sources

Not verified

No local build or CTest was run. Windows CI was still in progress at the final refresh; Linux and specialized CI jobs were skipped. The author's reported differential and test results were read from the PR discussion, not independently reproduced.

To get this to a good state

Integrate the current #11129 head, resolve the four shared-file conflicts while preserving both changes, and update the dependency line because #11261 is merged. I will rerun these checks on the updated head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5722278822 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11359#pullrequestreview-5722278822). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-31T10:04:12Z. **Review:** CHANGES_REQUESTED --- # Re-checked — new head, changes requested The earlier integration fix uses an older #11129 head; merging the two current PR heads still conflicts in four shared files. ## What I ran Re-checked #11359 at head `35f4b078afdcbb2b68d3f33f8ab22e01877c0ab4`, against its recorded base `c3c45d73abd34dca81da6bad87cb6d36ea437a66`. Current `main` was `45f4f82449a72e31aa9fd3120bd82820211dea41`; both PRs preview cleanly against it individually. The current #11129 dependency head is `e0af928fe934ca43d5b35aa8ac548e7e67eab4d1`, and #11359 does not include that head. Environment: Linux, Python 3.11.2; no C/C++ compiler or build was run. ```sh python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 11359 python3 tools/pr_stack_check.py 11359 --repo boykopovar/AnyPS5 --output-dir /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-11359-35f4b078afdc/stack git merge-tree --write-tree refs/codex/reviews/11129 refs/codex/reviews/11359 ``` ## Results | Check | Result | |---|---| | Diff check and conventions | Passed against the PR's recorded base. | | Individual current-main merge previews | #11129 and #11359 each merge cleanly against `45f4f82449a72e31aa9fd3120bd82820211dea41`. | | Dependency head inclusion | Current #11129 head `e0af928fe934ca43d5b35aa8ac548e7e67eab4d1` is not included in #11359 head `35f4b078afdcbb2b68d3f33f8ab22e01877c0ab4`; #11261 is already merged. | | Pairwise merge preview | Conflicts in `core/libs/prx/libSceLibreSsl/CMakeLists.txt`, `Export.cpp`, `include/Api.hpp`, and `docs/dev/debt/libSceLibreSsl.md`. | | Hosted CI | Eligibility, conventions, library-portability, labels and report passed. Windows was in progress at the last refresh; Linux and specialized jobs were skipped. | | Precheck helper limitations | ABI and test-quality helper scripts are absent from the isolated PR checkout, so those checks did not run. | <details> <summary>Relevant raw output</summary> ```text All conventions checks passed. ``` ```text - PR #11129: **clean** against current base; head `e0af928fe934ca43d5b35aa8ac548e7e67eab4d1`; changed paths: none reported - PR #11359: **clean** against current base; head `35f4b078afdcbb2b68d3f33f8ab22e01877c0ab4`; changed paths: none reported - #11129 → #11359: **current_dependency_head_not_included**; overlapping changed paths: `core/libs/prx/libSceLibreSsl/CMakeLists.txt`, `core/libs/prx/libSceLibreSsl/Export.cpp`, `core/libs/prx/libSceLibreSsl/include/Api.hpp`, `core/libs/prx/libSceLibreSsl/src/X509Name.cpp`, `core/libs/tests/GuestLibreSslX509Name.cpp`, `docs/dev/debt/libSceLibreSsl.md` ``` ```text Auto-merging core/libs/prx/libSceLibreSsl/CMakeLists.txt CONFLICT (content): Merge conflict in core/libs/prx/libSceLibreSsl/CMakeLists.txt Auto-merging core/libs/prx/libSceLibreSsl/Export.cpp CONFLICT (content): Merge conflict in core/libs/prx/libSceLibreSsl/Export.cpp Auto-merging core/libs/prx/libSceLibreSsl/include/Api.hpp CONFLICT (content): Merge conflict in core/libs/prx/libSceLibreSsl/include/Api.hpp Auto-merging docs/dev/debt/libSceLibreSsl.md CONFLICT (content): Merge conflict in docs/dev/debt/libSceLibreSsl.md ``` </details> ## Findings ### Blocking The branch includes #11129's earlier head `6fb16fdc1`, but the live #11129 head has since added X509 name accessors and changed the same build, export, public-header and debt files. A merge preview of the exact current heads reports content conflicts in four files, so the declared integration order is not currently usable as posted. Please merge the live #11129 head `e0af928fe934ca43d5b35aa8ac548e7e67eab4d1` into this branch and resolve the shared files while retaining both PRs' implementations and tests. Since #11261 is merged, update the dependency checklist to reflect the remaining open dependency. I will rerun the same checks on the resulting head. ### Non-blocking The author reports a full Release build, 28/28 selected CTest cases, registration and convention checks, and a 300,000-case LibreSSL differential comparison on this head; I did not independently run those checks. ## Sources - [Current #11129 X509 name implementation at its exact head](https://github.com/boykopovar/AnyPS5/blob/e0af928fe934ca43d5b35aa8ac548e7e67eab4d1/core/libs/prx/libSceLibreSsl/src/X509Name.cpp) - [Reviewed #11359 X509 name implementation at its exact head](https://github.com/boykopovar/AnyPS5/blob/35f4b078afdcbb2b68d3f33f8ab22e01877c0ab4/core/libs/prx/libSceLibreSsl/src/X509Name.cpp) ## Not verified No local build or CTest was run. Windows CI was still in progress at the final refresh; Linux and specialized CI jobs were skipped. The author's reported differential and test results were read from the PR discussion, not independently reproduced. ## To get this to a good state Integrate the current #11129 head, resolve the four shared-file conflicts while preserving both changes, and update the dependency line because #11261 is merged. I will rerun these checks on the updated 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!11359
No description provided.