feat(libSceLibreSsl): implement OBJ_create and free added objects in OBJ_cleanup #13562

Merged
JaceTheBlu merged 2 commits from upstream-pr/13562 into main 2026-10-31 01:59:51 +00:00
JaceTheBlu commented 2026-10-30 18:22:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JaceTheBlu on 2026-10-30T18:22:23Z.


What

Implements OBJ_create in libSceLibreSsl and makes OBJ_cleanup, until now an empty stub, free what it adds. OBJ_obj2txt (behind i2t_ASN1_OBJECT) now names added objects.

The new src/ObjectCreate.cpp follows LibreSSL 2.5.4 obj_dat.c:

  • OBJ_create parses the dotted text with a port of a2d_ASN1_OBJECT (a_object.c):
    • spaces and dots as separators, empty arcs read as zero, and arcs past 64 bits;
    • the same ASN.1 error codes for each bad input, including an empty text, which LibreSSL reads as a bad first arc;
    • a text with no second arc value, such as 1., adds nothing and queues nothing.
  • Each object takes the next NID from 956 (NUM_NID).
  • The added table is keyed by encoding and by NID, as in OBJ_add_object. The latest object with a given encoding wins.
  • The lookups in ObjectText.cpp follow OBJ_obj2nid and OBJ_nid2ln/OBJ_nid2sn:
    • Added encodings are searched before the built-in table, so an added copy of a built-in OID changes its name.
    • Once the table exists, an unknown NID past the table queues OBJ_R_UNKNOWN_NID; before that, and after OBJ_cleanup, it queues nothing.
  • OBJ_cleanup drops every added object and the table, but keeps the NID counter.

The OBJ_cleanup part of the silent-stub entry and the i2t_ASN1_OBJECT entry are updated, and there is a new entry in docs/dev/debt/libSceLibreSsl.md. The pending count goes from 293 to 292.

Remaining differences from LibreSSL:

  • Added objects live in host memory, so an allocation failure throws instead of queuing ERR_R_MALLOC_FAILURE.
  • OBJ_cleanup is never deferred. check_defer only fires for ciphers or digests with an added NID, and no export registers one.
  • Name lookups of added objects (OBJ_sn2nid, OBJ_ln2nid) are not kept, since no export reads them yet.
  • A null OID text throws where LibreSSL faults.

Tested

Debian container, GCC 14.2, full Release build of head 50527ff1d6: ctest -R 'libressl|crypto_memcmp' passes 34 of 34. tools/check_test_registration.py and python3 tools/check_conventions.py --base upstream/main pass.

  • guest_libressl_object_text checks:

    • each parse error code, an empty text and a text without a second arc value;
    • NID numbering, including after OBJ_cleanup;
    • long-name, short-name and dotted fallback;
    • an added copy of commonName overriding the table;
    • an arc past 64 bits, and empty arcs;
    • the OBJ_R_UNKNOWN_NID queue before and after OBJ_cleanup;
    • that OBJ_cleanup restores built-in names.
  • guest_libressl_oracle (ANYPS5_LIBRESSL_ORACLE) now also runs 20,000 rounds of OBJ_create on both implementations, with an occasional OBJ_cleanup on both. Each round uses:

    • random dotted or spaced texts, some with huge arcs or a damaged character;
    • random or null names.

    After each call it compares the result and the error queue. It then compares i2t_ASN1_OBJECT, with random buffer sizes, on four objects drawn from built-in and created encodings, some with a preset NID around the end of the table. The 20,000 rounds show no difference. The only differences the oracle reports are the 6 AES_set_*_key cases already described in the debt file.

Not tested on Windows, on a title or on a console.

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

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5089124853 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13562). Originally posted by [JaceTheBlu](https://github.com/JaceTheBlu) on 2026-10-30T18:22:23Z. --- ### What Implements `OBJ_create` in libSceLibreSsl and makes `OBJ_cleanup`, until now an empty stub, free what it adds. `OBJ_obj2txt` (behind `i2t_ASN1_OBJECT`) now names added objects. The new `src/ObjectCreate.cpp` follows LibreSSL 2.5.4 `obj_dat.c`: - **`OBJ_create`** parses the dotted text with a port of `a2d_ASN1_OBJECT` (`a_object.c`): - spaces and dots as separators, empty arcs read as zero, and arcs past 64 bits; - the same ASN.1 error codes for each bad input, including an empty text, which LibreSSL reads as a bad first arc; - a text with no second arc value, such as `1.`, adds nothing and queues nothing. - **Each object** takes the next NID from 956 (`NUM_NID`). - **The added table** is keyed by encoding and by NID, as in `OBJ_add_object`. The latest object with a given encoding wins. - **The lookups** in `ObjectText.cpp` follow `OBJ_obj2nid` and `OBJ_nid2ln`/`OBJ_nid2sn`: - Added encodings are searched before the built-in table, so an added copy of a built-in OID changes its name. - Once the table exists, an unknown NID past the table queues `OBJ_R_UNKNOWN_NID`; before that, and after `OBJ_cleanup`, it queues nothing. - **`OBJ_cleanup`** drops every added object and the table, but keeps the NID counter. The `OBJ_cleanup` part of the silent-stub entry and the `i2t_ASN1_OBJECT` entry are updated, and there is a new entry in `docs/dev/debt/libSceLibreSsl.md`. The pending count goes from 293 to 292. Remaining differences from LibreSSL: - Added objects live in host memory, so an allocation failure throws instead of queuing `ERR_R_MALLOC_FAILURE`. - `OBJ_cleanup` is never deferred. `check_defer` only fires for ciphers or digests with an added NID, and no export registers one. - Name lookups of added objects (`OBJ_sn2nid`, `OBJ_ln2nid`) are not kept, since no export reads them yet. - A null OID text throws where LibreSSL faults. ### Tested Debian container, GCC 14.2, full Release build of head `50527ff1d6`: `ctest -R 'libressl|crypto_memcmp'` passes 34 of 34. `tools/check_test_registration.py` and `python3 tools/check_conventions.py --base upstream/main` pass. - **`guest_libressl_object_text`** checks: - each parse error code, an empty text and a text without a second arc value; - NID numbering, including after `OBJ_cleanup`; - long-name, short-name and dotted fallback; - an added copy of `commonName` overriding the table; - an arc past 64 bits, and empty arcs; - the `OBJ_R_UNKNOWN_NID` queue before and after `OBJ_cleanup`; - that `OBJ_cleanup` restores built-in names. - **`guest_libressl_oracle`** (`ANYPS5_LIBRESSL_ORACLE`) now also runs 20,000 rounds of `OBJ_create` on both implementations, with an occasional `OBJ_cleanup` on both. Each round uses: - random dotted or spaced texts, some with huge arcs or a damaged character; - random or null names. After each call it compares the result and the error queue. It then compares `i2t_ASN1_OBJECT`, with random buffer sizes, on four objects drawn from built-in and created encodings, some with a preset NID around the end of the table. The 20,000 rounds show no difference. The only differences the oracle reports are the 6 `AES_set_*_key` cases already described in the debt file. Not tested on Windows, on a title or on a console. ### 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 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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!13562
No description provided.