feat(libSceLibreSsl): implement i2d_X509_PUBKEY #13546
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/13546"
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-30T18:00:45Z.
What
Implements
i2d_X509_PUBKEYin libSceLibreSsl, on top of theX509decoder from #13266. This is stacked on #13266, and through it #11359 and #11129. Merge those first; this PR's own diff is then only the encoder, its tests and its debt entry.src/X509.cppports the LibreSSL 2.5.4 template encoder (tasn_enc.c) for the items anX509_PUBKEYholds. It reuses the item tables of the decoder.ASN1_TYPEparameters of every type are encoded, including high tag numbers, and SEQUENCE, SET and OTHER values written as they are.i2c_ASN1_INTEGERhandles padding and negative values, as LibreSSL does.i2c_ASN1_BIT_STRINGcounts unused bits whenASN1_STRING_FLAG_BITS_LEFTis not set, and clears them otherwise.outreturns the length;*outgets a buffer from the guest heap;*outand the pointer advances.PutHeader, which the canonical name encoding already used, now also takes a tag class.There is a new entry in
docs/dev/debt/libSceLibreSsl.md, and the pending count goes from 286 to 285.These cases throw instead of being encoded, because nothing reachable from an
X509_PUBKEYneeds them:These cases throw where LibreSSL reads before the data or faults:
BITS_LEFT, and a negative zero INTEGER;ASN1_TYPE;Tested
Debian container, GCC 14.2, full Release build of head
16388cabad:ctest -R 'libressl|crypto_memcmp'passes 38 of 38.tools/check_test_registration.pyandpython3 tools/check_conventions.py --base upstream/mainpass.guest_libressl_x509checks that a decoded key encodes back to its DER in all three output forms, and that nothing is written outside the encoding. It also checks:BITS_LEFT;guest_libressl_oracle(ANYPS5_LIBRESSL_ORACLE) now also decodes random certificates with both implementations and encodes their public keys. In 60% of runs it first applies the same change to both keys:It compares the return value, the bytes, the pointer advance and the error queue for each output form. The 11,646 cases show no difference. The only differences the oracle reports are the 6
AES_set_*_keycases already described in the debt file.Not tested on Windows, on a title or on a console.
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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-11-01T19:50:18Z.
Review: COMMENTED
Correction (2026-11-01): this review's claim that maintainers close PRs without a title ID is wrong. CONTRIBUTING allows
Unblocks: none; a title is only required when the PR fixes a title. The technical points below are unaffected.Two process points; I have not reviewed the encoder itself.
Stacked on open PRs. This branch carries about 50 commits and 11 files because it sits on #13266 (still open), through it #11359 and #11129. The "own diff is then only the encoder" statement cannot be checked from the PR as submitted: GitHub shows +3915 lines, including the merges of
pr10477. Please retarget or rebase once the base lands, otherwise this cannot be reviewed or merged independently, and CI results here do not isolate this change. #13547 and #13877 carry the same 50-odd commits.No title reaches it. "Unblocks: none" and "Not tested on Windows, on a title or on a console."
i2d_X509_PUBKEYis a leaf of the X509 decoder that itself has no consumer on main (PEM_X509_INFO_read_biostill throws, per the sibling PR). Maintainers close export PRs that do not name a title ID and a log line showing the title reaching the function on main. Which title callsi2d_X509_PUBKEY, and which earlier export in that title's trace currently throws first?Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T06:45:23Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the points below are optional.
What I ran
Reviewed head
8057ade57bd671539090517c8d17fb765098b812using the prepared diff and the pinned repository reader. No commands or tests were run; the build, test, and oracle results in the description are author-reported.Read all changed lines in
CMakeLists.txt,Api.hpp,src/X509.cpp,tests/Oracle.cpp,tests/OracleReference.cpp,tests/X509.cpp, anddocs/dev/debt/libSceLibreSsl.md, plus the relevantExport.cppdiff. All changed files were included; no files were excluded.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The full build, registered tests, oracle comparisons, Windows behavior, title behavior, and console behavior were not independently verified. The description reports a Debian/GCC 14.2 build and passing tests at a different head (
16388cabad); those are author-reported results, not runs on this reviewed head.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T14:01:22Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change based on the source inspected; the reported tests were not run in this review.
What I ran
Reviewed head
b97fded6b7be929b146fe207b402938ae96db3d7usingrepo_read.pyto inspect the prepared diff, manifest, and changed source and test files. No build or tests were run.Results
Findings
Blocking
None found in the inspected code.
Non-blocking
None.
Not verified
The full text of
core/libs/prx/libSceLibreSsl/tests/Oracle.cppandcore/libs/prx/libSceLibreSsl/tests/OracleReference.cppwas not read; those files were included in the review bundle but excluded from detailed inspection. Build, automated tests, Windows behavior, title behavior, and console behavior were not verified. The description reports a Debian Release build and 38 passing tests, plus 11,646 oracle cases; these are author-reported results.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T13:08:22Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: fix
d2i_X509so decode failures do not leave a freed certificate pointer in the caller’s output.What I ran
Reviewed head
08100a4b9d7ad08f135b037f1e393a38b01f70c5using the prepared diff and pinned reader. No build or tests were run. The author reports a Debian/GCC 14.2 build, 38 passing tests, and 11,646 oracle cases; those results were not independently verified.Results
Findings
Blocking
core/libs/prx/libSceLibreSsl/src/X509.cpp:2051:ItemDecodefrees the reused certificate on failure (SequenceDecode’s failure path callsItemFree), but this wrapper returns null without clearing*certificate. The existing reuse test expects the output pointer to be null after a failed decode, but its call passes the now-freed pointer back in and does not check the pointer’s value. Clear the caller’s output pointer when decoding fails, and ensure the failed decode path does not leave a dangling pointer.Non-blocking
None.
Not verified
No commands, build, tests, or console execution were performed. All changed files were included and read:
core/libs/prx/libSceLibreSsl/CMakeLists.txt,core/libs/prx/libSceLibreSsl/Export.cpp,core/libs/prx/libSceLibreSsl/include/Api.hpp,core/libs/prx/libSceLibreSsl/src/X509.cpp,core/libs/prx/libSceLibreSsl/tests/Oracle.cpp,core/libs/prx/libSceLibreSsl/tests/OracleReference.cpp,core/libs/prx/libSceLibreSsl/tests/X509.cpp, anddocs/dev/debt/libSceLibreSsl.md.To get this to a good state
Fix the dangling output pointer on decode failure, then rerun the X.509 tests and allocator test on the new head.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T16:00:55Z.
Review: COMMENTED
On Linux, CTest passed
guest_libressl_x509_derandguest_libressl_x509_der_allocatorwith this revision integrated. The default cases cover DER algorithm identifiers, omitted fields, and bit-string padding. The allocator variant passed separately.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.