feat(libSceLibreSsl): implement OBJ_obj2nid for objects with a known NID #10571

Closed
MarcZX10 wants to merge 14 commits from upstream-pr/10571 into main
MarcZX10 commented 2026-10-24 10:23:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T10:23:51Z.


What

Implements OBJ_obj2nid in libSceLibreSsl for the cases that need no object identifier table, following LibreSSL 2.5.4's obj_dat.c: a null object returns NID_undef, an object whose nid is set returns it, and an object with nid == NID_undef and no encoded bytes follows the 2.5.4 table search to NID_ccitt (404). An object known only by its encoded bytes throws through NotImplemented_nid_no_patch, since the table is not present.

The 40-byte LP64 ASN1_OBJECT layout is the one used by #10461. PS5 behavior has not been independently measured.

Commits: implementation, test, debt entry.

Tested

Linux x86-64, GCC. Full CMake configuration is blocked in this isolated checkout because the SDL2 submodule is not populated and XRandR is unavailable. Compiled ObjNid.cpp and GuestLibreSslObjNid.cpp directly with -std=c++20 -Wall -Wextra -Werror, linked a small shim for NotImplemented_nid_no_patch, and ran the test successfully. The test checks the 404 empty-object result, stored-NID and null cases, and the unsupported encoded-byte path. The CTest registration was not run through CMake. tools/check_conventions.py and git diff --check pass. The overlap check script could not parse the current GitHub PR response; existing overlap reports identify shared LibreSSL build/debt files, and this PR now declares its order after #10570.

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: #10570
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4994585136 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10571). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T10:23:51Z. --- ### What Implements `OBJ_obj2nid` in libSceLibreSsl for the cases that need no object identifier table, following LibreSSL 2.5.4's [obj_dat.c](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/objects/obj_dat.c): a null object returns `NID_undef`, an object whose `nid` is set returns it, and an object with `nid == NID_undef` and no encoded bytes follows the 2.5.4 table search to `NID_ccitt` (404). An object known only by its encoded bytes throws through `NotImplemented_nid_no_patch`, since the table is not present. The 40-byte LP64 `ASN1_OBJECT` layout is the one used by #10461. PS5 behavior has not been independently measured. Commits: implementation, test, debt entry. ### Tested Linux x86-64, GCC. Full CMake configuration is blocked in this isolated checkout because the SDL2 submodule is not populated and XRandR is unavailable. Compiled `ObjNid.cpp` and `GuestLibreSslObjNid.cpp` directly with `-std=c++20 -Wall -Wextra -Werror`, linked a small shim for `NotImplemented_nid_no_patch`, and ran the test successfully. The test checks the 404 empty-object result, stored-NID and null cases, and the unsupported encoded-byte path. The CTest registration was not run through CMake. `tools/check_conventions.py` and `git diff --check` pass. The overlap check script could not parse the current GitHub PR response; existing overlap reports identify shared LibreSSL build/debt files, and this PR now declares its order after #10570. ### Checklist - [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: #10570 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
harisibrar1 commented 2026-10-24 12:29:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-24T12:29:26Z.

Review: COMMENTED


Checked against main 87666fc5d6 and LibreSSL 2.5.4 (obj_dat.c / obj_dat.pl at 2e2c612, and the generated crypto/objects/obj_dat.h and include/openssl/obj_mac.h from the libressl-2.5.4 release tarball):

  • The null and nid != 0 paths and the 40-byte layout match 2.5.4, and throwing for objects that only have encoded bytes looks right to me.
  • I don't think the length == 0 → NID_undef branch (ObjNid.cpp:168) matches 2.5.4. With nid == 0, OBJ_obj2nid falls through to OBJ_bsearch_obj, and obj_cmp compares length first. obj_dat.pl gives single-arc OIDs length 0, so the generated obj_objs starts with six length-0 entries (0, 181, 393, 404, 645, 646), and NUM_OBJ is 890. The bisection probes 445, 222, 111, 55, 27, 13, 6 and then 3, so an empty object (e.g. a fresh ASN1_OBJECT_new()) matches obj_objs[3] and returns 404 (NID_ccitt), not NID_undef. I couldn't run this on a console; it comes from reading the source and the generated table (the zero-length memcmp on NULL pointers is formally UB but returns 0 in practice). Could this case throw like the encoded-bytes case, or return 404 with that source cited? The test at GuestLibreSslObjNid.cpp:206-207 and the debt sentence would need updating to match.
  • Small heads-up: this PR and #10570 both rewrite line 1 of libSceLibreSsl/CMakeLists.txt, insert their test blocks at the same place, and edit the same debt count line, so whichever merges second will need a rebase, and the count should end at 354.

Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5638238584 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10571#pullrequestreview-5638238584). Originally posted by [harisibrar1](https://github.com/harisibrar1) on 2026-10-24T12:29:26Z. **Review:** COMMENTED --- Checked against main 87666fc5d6 and LibreSSL 2.5.4 (obj_dat.c / obj_dat.pl at 2e2c612, and the generated crypto/objects/obj_dat.h and include/openssl/obj_mac.h from the libressl-2.5.4 release tarball): - The null and `nid != 0` paths and the 40-byte layout match 2.5.4, and throwing for objects that only have encoded bytes looks right to me. - I don't think the `length == 0 → NID_undef` branch (ObjNid.cpp:168) matches 2.5.4. With `nid == 0`, `OBJ_obj2nid` falls through to `OBJ_bsearch_obj`, and `obj_cmp` compares `length` first. obj_dat.pl gives single-arc OIDs length 0, so the generated `obj_objs` starts with six length-0 entries (0, 181, 393, 404, 645, 646), and `NUM_OBJ` is 890. The bisection probes 445, 222, 111, 55, 27, 13, 6 and then 3, so an empty object (e.g. a fresh `ASN1_OBJECT_new()`) matches `obj_objs[3]` and returns 404 (`NID_ccitt`), not `NID_undef`. I couldn't run this on a console; it comes from reading the source and the generated table (the zero-length `memcmp` on NULL pointers is formally UB but returns 0 in practice). Could this case throw like the encoded-bytes case, or return 404 with that source cited? The test at GuestLibreSslObjNid.cpp:206-207 and the debt sentence would need updating to match. - Small heads-up: this PR and #10570 both rewrite line 1 of `libSceLibreSsl/CMakeLists.txt`, insert their test blocks at the same place, and edit the same debt count line, so whichever merges second will need a rebase, and the count should end at 354. Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.

Pull request closed

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!10571
No description provided.