feat(libSceLibreSsl3): implement the X509 extension stack #17147
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/17147"
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 fishingpvalues on 2026-11-08T11:21:43Z.
What
Implements
X509_add_extand the non-null path ofX509_EXTENSION_freeinlibSceLibreSsl3.X509_add_extduplicates the 24-byte extension — its object with dynamic names and data, the critical flag and the octet value — creates the certificate-info extension stack when absent, appends the copy through the existing stack helper and moves it to the requested position. A null certificate or extension returns 0.X509_EXTENSION_freereleases a null or non-null extension through the object and octet-string destructors. Open PR #16689 only makes the null path a no-op; this adds the non-null release and will rebase if that lands first.src/X509ExtensionStack.cppholds both exports,tests/X509ExtensionStack.cppis registered asguest_libressl3_x509_extension_stack, and the stubs leaveAdditionalExports.cppwhile the declarations gain their real signatures ininclude/Api.hpp.docs/dev/debt/libSceLibreSsl3.mdloses two rows (125 to 123 callable exports, 116 to 114 named) and gains one Functional entry for the unverified PS5 layouts.Tested
Linux x86-64 (Debian 13, glibc 2.41, GCC 14.2.0), Release,
BUILD_TESTING=ON, basemainf9c2d92b91:cmake --build build --target guest_libressl3_x509_extension_stack_tests --parallel 8: passed.ctest --test-dir build -R '^guest_libressl3_x509_extension_stack$' --output-on-failure: 1/1 passed.python3 tools/check_conventions.py --base origin/main: all checks passed.mainf9c2d92b91and resolved the technical-debt inventory conflicts; rebuilt and reran the test.Checklist
main; #16689 also touchesX509_EXTENSION_freefor the null path only, so whichever merges second rebasesNotImplemented_nid_no_patch).mdfiles or images added to the repositoryX509_EXTENSION_free)Imported from boykopovar/AnyPS5. Originally posted by coptergui-ops on 2026-11-08T12:57:46Z.
Review: APPROVED
Reviewed at current head (
291de49). Implements X509_add_ext and the full (non-null) X509_EXTENSION_free: deep-copies the 24-byte extension (object with dynamic names/data, critical flag, octet value) through guest calloc/malloc with rollback on partial allocation failure, creates the cert-info extension stack when absent, appends via the existing stack helper and moves to the requested position; null x509 or extension returns 0; FreeExtension releases null and non-null through the object and octet-string destructors. Stubs removed from AdditionalExports.cpp, Api.hpp declarations gain real signatures (void X509_EXTENSION_free(void*), int X509_add_ext(void*, const void*, int)). New src/X509ExtensionStack.cpp + tests/X509ExtensionStack.cpp registered as guest_libressl3_x509_extension_stack; debt loses the two NotImplemented rows (138->136 callable, 128->126 named) and gains one Functional entry documenting the unverified PS5 layouts. Tests pin deep-copy independence, front insertion, null arguments and recorded full release. Overlap verdicts: (vs PR 16689, 'Same exports X509_EXTENSION_free') 16689 (open) only converts the stub to a null no-op (non-null still throws) - this PR implements the export completely and also covers the null path, so after 17147 lands, 16689's X509_EXTENSION_free declaration/stub-move work becomes redundant: 16689 must rebase keeping only AUTHORITY_KEYID_free/X509_CRL_free (merge-tree confirms textual conflict on the same Api.hpp L248 line and AdditionalExports stub). Not a duplicate of functionality - 17147 is strictly more complete. (vs PR 15770, debt md L70) 15770 edits the X509Validity/ASN1_TIME_diff entries around L53, this PR edits the NotImplemented/Functional tables at L217+ - different entries, no shared lines. Conventions checker: baseline warnings only, no new findings from this diff.Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-08T13:07:22Z.
Review: COMMENTED
Windows run of head
291de49ae5, merged ontomain57c0f6a48d. GitHub shows this branch as conflicting, and the local merge stops indocs/dev/debt/libSceLibreSsl3.md, so for the run I tookmain's version of that file. Setup: Windows 11, WinLibs GCC 15.2 (x86_64-ucrt-posix-seh), Release,BUILD_TESTING=ON.guest_libressl3_x509_extension_stackpasses as pushed.The copy drops the OID bytes of an object that isn't
DynamicData.DuplicateObject_nid_no_patchsetscopy->data = nullptrandcopy->length = 0, and copies the bytes only when the source has flag0x08. Objects from the static OID table (OBJ_nid2objand friends) haveflags == 0and point theirdataat static bytes. In LibreSSL,X509_add_ext→X509v3_add_ext→X509_EXTENSION_dupis anASN1_item_dup, an encode followed by a decode. The copy's object therefore always carries the OID bytes, and for a known OID it's the table object itself.The test builds every object with
0x01 | 0x04 | 0x08, so it never takes that path. I added a local, unpushed case to the test with a static keyUsage object:{"keyUsage", "X509v3 Key Usage", 83, 3, {55 1D 0F}, flags 0}. AfterX509_add_ext, the stored copy hasnid 83,length 0,data nulland flags0x1. This module's ownOBJ_cmp(copy, source)returns-3where LibreSSL gives 0. Anything that later matches the extension by its object, such asOBJ_cmpor a lookup by OID, or that encodes the certificate, sees an empty OID.A fix would be to always copy
lengthbytes ofdatawhensource->datais set, and setDynamicDataon the copy, whatever the source's flags are. The alternative is to reuse the source object when it isn'tObjectDynamic, as the decode path does for known OIDs. A test row with a static object would cover it.A smaller difference: when the certificate has no extension stack yet, this sets
certificate->extensionsbefore duplicating. If the duplicate fails, the certificate keeps an empty stack, where LibreSSL frees the new stack and leavesextensionsnull.