feat(libSceLibreSsl): add the LibreSSL object table and implement i2t_ASN1_OBJECT #11261
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11261"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by JaceTheBlu on 2026-10-25T22:57:28Z.
What
Adds LibreSSL's object table to libSceLibreSsl and implements
i2t_ASN1_OBJECT, which threw and was declared without parameters. This is the first step towardsd2i_X509: when LibreSSL decodes an OID it knows, it hands out the static object from this table rather than a new one, so decoded certificates need the same objects.The table (
src/ObjectTable.cpp, generated) holds the 956 objects of LibreSSL 2.5.4 (short name, long name, NID, OID bytes, in the 40-byte LP64ASN1_OBJECTlayout also used by #10461, #10571 and #11129) and the 890-entryobj_objssearch order. It is not typed:perl objects.pl objects.txt obj_mac.num obj_mac.handperl obj_dat.pl obj_mac.h obj_dat.hat 2e2c612066, then a small C program that includes the generatedobj_dat.hand printsnid_objsandobj_objs, from which the C++ file is written. 2.5.4 is the version string the module holds (#9745). LibreSSL 2.7 adds NIDs 956-967; of those only the threejurisdiction*names have OIDs, which would print by name in 2.7 and numerically here; the debt entry records it.int i2t_ASN1_OBJECT(char* buf, int buf_len, const ASN1_OBJECT* a)is 2.5.4'sOBJ_obj2txt(buf, buf_len, a, 0)(obj_dat.c):OBJ_bsearch_loop andobj_cmpover the same order, so duplicate encodings resolve as in LibreSSL (1.3 toORG, a non-null empty encoding toNID_ccitt);strlcpydoes and its length returned; an unassigned NID makes each name lookup reportOBJ_R_UNKNOWN_NID(ERR_LIB_OBJ, function0xfff) through the error queue, then falls back to the dotted form, as does a NID past the table, without an error;snprintfsemantics: a short buffer keeps whole leading parts and the return value counts every character; a truncated subidentifier returns 0 and leaves the parts already written; arcs past 64 bits, which LibreSSL computes withBIGNUM, are printed exactly with a small arbitrary-precision helper.A negative buffer length, and a null buffer with a positive length, throw instead of reaching
strlcpy/snprintfas asize_t. Objects added at run time are left out because no export of this module adds one. The pending-export count drops by one.Relation to other open PRs: #10508 carries the short names and
sn_objsorder generated from the same inputs, and #10571 throws for the table search inOBJ_obj2nid. This table can back both (long names, encodings andobj_objsare what they lack); whichever lands later can switch to the shared table. The new functions here are internal (_nid_no_patch), so no export overlaps.Tested
Debian trixie container, GCC 14.2, full Release build.
ctest -R 'libressl|crypto_memcmp': 13 of 13 pass, including the newguest_libressl_object_text(table entries, the unassigned NIDs, search results including duplicates, names, truncation, dotted forms, the first arc rules, 64-bit and larger arcs, a truncated subidentifier, the error-queue entries, and the throwing cases).tools/check_test_registration.py buildandpython3 tools/check_conventions.py --base upstream/mainpass. Not tested on Windows, on a title or on a console.Outside the repository, this
i2t_ASN1_OBJECTwas compared with 2.5.4's ownOBJ_obj2txt,OBJ_obj2nid,OBJ_nid2ln,OBJ_nid2snand bsearch, compiled next to it on the generatedobj_dat.hwith OpenSSL'sBIGNUM: 423,424 cases (every table object with and without its NID set, at 12 buffer sizes; 400,000 random encodings including invalid ones, random and out-of-table NIDs and null data; 1- to 40-byte arcs), comparing the return value, every byte of the buffer and the number of errors reported. No difference.tools/pr_overlap.pywas not run (no authenticatedgh).git merge-treeagainst the open LibreSSL pull requests shows only the usual shared-file conflicts (end ofCMakeLists.txt, the debt file).Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T23:01:32Z.
Review: APPROVED
Reviewed exact head
8e4e770b349cb41f9835ed926f9819a3443ae8a9against LibreSSL 2.5.4obj_dat.c, including OBJ_obj2txt name fallback, unassigned/out-of-range NIDs, short-buffer termination, truncated arcs, and large first/subsequent subidentifiers. The object-order lookup and emitted data are consistent with the pinned source.git diff --check upstream/main...upstream/pr/11261and the local conventions check pass. Hosted eligibility, conventions, intake, labels, and report checks pass; product build jobs were skipped by path policy. I did not rerun the author’s full Release/13-test suite or 423,424-case native comparison locally; those remain author-reported evidence. No concrete blocking defect found.Imported from boykopovar/AnyPS5. Originally posted by thepoppfish on 2026-10-25T23:59:41Z.
Review: DISMISSED
Found an allocation-failure contract issue on exact head
8e4e770b349cb41f9835ed926f9819a3443ae8a9.Even the ordinary unknown OID
1.2.3.4constructs a heap-backedBigNumber(0)for each arc. Failing the first hostoperator newletsstd::bad_allocescape fromi2t_ASN1_OBJECTinstead of returning an integer failure. Large-arc scratch allocations also escape without a BN error queued.The pinned OBJ_obj2txt source creates a BIGNUM only when a subidentifier exceeds an LP64 word. Its error path returns 0. BN_new/expansion report allocation failures with BNerror; err.h fixes that to library 3/function 0xfff/reason 65.
Tested repair: 20f51c5e63d1, branch codex/review-object-text-allocation. It:
to_chars;bad_allocto 0 plus the BN allocation error, preserving already-written output and earlier error-queue entries;The support commit changes three files (production code, regression, CMake). Its parent is a clean local merge
3d00e4699d1547ae459e68a5f4ccb0c980b3b5d9of this PR and main snapshot2b5225605bd58c91fff82a7dafcb8c6e9a33d569. The LibreSSL subtree was unchanged by that main merge before the repair. This is a cherry-pick aid, not another PR or a choice of landing order.Independent native Windows / GCC 16.2.0-6 UCRT, C++20,
-O1 -g -fno-inline -fno-lto, static C++ runtime:The allocation-point counts differ because the repair makes fewer temporary allocations; they are not 192 identical points matched against 144. All tracked scratch allocations are released on both versions. The oracle corpus has 128 inputs at 12 buffer sizes, including nonminimal/truncated encodings, 64-bit boundaries and arcs up to 280 bits; numeric-only cases force an out-of-table NID to isolate formatting. The failure regression uses ordinary unknown objects with NID 0.
tests/ObjectText.cpppasses against both versions. The four-test standalone CTest fixture passes on the repair in 0.23 s, zero skips.guest_libressl_object_allocation_teststarget through the module's real CMake and original test/unwind helpers: 1/1 pass. This module fixture supplies only a narrow libc support boundary and an unused mbedcrypto interface; it is not the full product. Its registration audit finds all 11 configured test executables registered (only the focused target was built/run).The new full-build target can be replayed with
cmake --build build --target guest_libressl_object_allocation_testsandctest --test-dir build -R '^guest_libressl_object_allocation$' --output-on-failureafter configuring the support checkout with testing enabled. The standalone replay below requires no crypto dependency build.I did not run the full libc/LibreSSL product build or 13-test suite, the author's 423424-case native LibreSSL comparison, Linux/macOS, a console/title, or a canonical PR-overlap scan. The object table and lookup data are unchanged. AI-assisted implementation/replay: Codex.
Standalone regression replay against the head and repair
Save this as
replay.pyoutside the checkouts, set the two paths, and run with GCC/MinGW and objcopy on PATH. The only support definition is the throwing NotImplemented boundary; valid numeric/fault cases do not call it. It compiles the complete production object text/table/error files and the linked commit's actual regression source. Head must exit 1 and the repair 0; exact allocation counts can vary with the host C++ library.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T00:07:38Z.
Review: DISMISSED
I need to supersede my earlier approval after a new allocation-failure case was identified. I independently compiled the exact-head
ObjectText.cpp,ObjectTable.cppandError.cppwith a one-shot failing globaloperator new, then calledi2t_ASN1_OBJECT_nid_postfixon the ordinary unknown OID1.2.3.4.std::bad_allocescaped the C ABI function on its firstBigNumberconstruction.BigNumberinitializes a heap-backed two-limb vector for every encoded arc, including word-sized values that need no arbitrary precision; the decimal conversion also allocates for large arcs.Please avoid allocating for ordinary word-sized subidentifiers and handle allocation failure in the large-arc path using the LibreSSL 2.5.4 failure contract (return 0 and queue the BN allocation error), preserving any already-written output and earlier errors. Add a registered fault-injection regression for both an ordinary OID and an arc that requires arbitrary precision. The current
ObjectText.cpptests do not exercise allocation failure. My exact-head reproduction printedstd::bad_alloc escaped i2t_ASN1_OBJECT.The table/search and normal formatting checks I reviewed earlier remain sound; this is a distinct blocking failure-path issue. Hosted conventions, eligibility, intake, labels and report checks pass; product jobs are skipped by path policy. I did not rerun the author's full build or 423,424-case comparison.