feat(libSceLibreSsl): implement X509_get_ext_d2i #13877
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/13877"
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-31T10:45:29Z.
What
Implements
X509_get_ext_d2iin libSceLibreSsl, ported from LibreSSL 2.5.4 (X509V3_get_d2iinv3_lib.c).idxreports a duplicate extension withcrit = -2, a non-nullidxresumes after the given position, and a missing extension sets both to -1.ext_dat.h: basicConstraints, keyUsage, the GENERAL_NAMES extensions, authorityKeyIdentifier, extendedKeyUsage, CRL distribution points, issuingDistributionPoint, authority/subject info access, name and policy constraints, policy mappings, proxyCertInfo, Sxnet, the Netscape strings and the OCSP extensions (40 methods).CHOICEkind, whichGENERAL_NAMEandDIST_POINT_NAMEneed.GENERAL_NAMEuses the 16-byte{type, value}layout, the same as #13760.certificatePoliciesthrows throughNotImplemented_nid_no_patch: its qualifiers need ANY DEFINED BY decoding, which the engine does not have yet.Depends on: #13266 (the d2i_X509 template engine). This branch is stacked on it, so the diff includes #13266 until that one merges.
Tested
guest_libressl_x509: new cases for every GENERAL_NAME choice, the constraint extensions, thecrit/idxsearch positions, duplicates, decoding errors (ASN1_R_NO_MATCHING_CHOICE_TYPE) and the throwing paths.libressl|crypto_memcmptests pass.guest_libressl_oracle(ANYPS5_LIBRESSL_ORACLE): 30,000 rounds of generated and mutated certificates with 1 to 5 extensions. 16,148 lookups comparecrit,idx, error codes and the value re-encoded through LibreSSL's own i2d, with 0 differences; the 13,852 rejected certificates also match. The only differences in the whole run are the 6AES_set_*_keyones already present on main.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 MarcZX10 on 2026-10-31T10:59:51Z.
Review: COMMENTED
Tests run and reviewed — approval deferred
The reviewed implementation has no blocking source finding, but CI did not execute the PR’s new X509 tests.
What I ran
Reviewed head
926bce0d3214312c50575aa0f9bd9e108939f210against basefd31320e83fe417fa9c7fef792613653d9eb4f02; the incremental stack includes #13266’s current head and its merge preview against the PR base was clean. Local environment: Debian Linux x86_64, Python 3.11.2.Results
tests/X509.cppis registered asguest_libressl_x509andguest_libressl_x509_allocator.Relevant unedited output
Findings
Blocking
None found in the reviewed source.
Non-blocking
The new X509 test target is registered in CMake but was not selected by this Windows workflow. The implementation’s test assertions therefore remain unverified by CI on this head.
Sources
2e2c612066aa993717528a0249c15c51128d61cband its OCSP extension decoder.Not verified
To get this to a good state
Please provide a CI run that executes
guest_libressl_x509andguest_libressl_x509_allocator, or update the workflow so these targets are selected. I will re-check both tests on the new head before approving.Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-11-01T19:50:21Z.
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.Process points first; I have not gone through the 40-method decode tables.
Stacked on open PRs. About 50 commits and 11 files (+4358) because this sits on #13266 (still open), #11359 and #11129, and the template decoder gains a
CHOICEkind in this same PR. The part that is actually new here cannot be separated from the carried commits in the GitHub diff, and the same chain is carried by #13546 and #13547. Please retarget or rebase once the base lands."Unblocks: none". No title ID and no log line showing a title reaching
X509_get_ext_d2ion main. A 4k-line export for 40 extension types with no consumer is the shape that gets closed; please name the title and the extension it asks for, and consider limiting the PR to the methods that title uses if the others are not covered by the oracle tests.A change to the shared template decoder (new
CHOICEkind) deserves its own negative test: what happens to a malformedGENERAL_NAMEwith an unknown tag, and with a truncated value? Does it throw or return null with an error queued, as LibreSSL does?Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-16T11:07:22Z.
Review: CHANGES_REQUESTED
Reviewed — comments
Changes are required before merge: resolve the extension lookup behavior when a non-null index starts beyond the end of the extension list.
What I ran
Reviewed head
f7182b9afd760ef6c76750020be427a88368c108using the prepared diff and repository reader. No tests or build commands were run.Results
Findings
Blocking
core/libs/prx/libSceLibreSsl/src/X509.cpp:2285: Whenindexis non-null, the function resumes at*index + 1. If that position is at or beyondextensions->num, the loop finds nothing and resets*indexto-1. LibreSSL's indexed lookup leaves the supplied index unchanged when no later matching extension exists; callers iterating duplicate extensions can therefore lose their stopping position. Preserve the starting index on this no-match path (while retaining-1for an initial search).Non-blocking
None.
Not verified
No tests, build, or runtime checks were performed. The source files listed as changed in the manifest were included; no changed files were excluded by the provided file listing.
To get this to a good state
Preserve LibreSSL's index value when a resumed search finds no extension, and rerun the extension lookup tests.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-17T09:32:52Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
da3e5d0a3479, basemain. I read the description, the commit list, the manifest and the whole diff (3,666 lines).repo_read.pyto check declarations, file paths and struct definitions.libressl|crypto_memcmptests and the oracle run (30,000 rounds) are author-reported. I did not run them.files.jsonunderreviewed. Excluded by rule: none.Results
guest_libressl_x509testsguest_libressl_oracleruncertificatePoliciesthrows, no notes addedFindings
Blocking
None.
Non-blocking
docs/dev/debt/libSceLibreSsl.md:130: thed2i_X509 and X509_freeentry is added twice, at lines 128 and 130. The copies differ: line 130 adds "on hosts whoselongis 8 bytes as in the guest". Keep line 130 and delete line 128. The description says the pending count drops from 285 to 284, so recheck that count after the change.Not verified
dpnamefor a relative-name CRL distribution point at decode time.X509.cpp:2119(DistPointNameCallback) handles onlyNewPostandFreePost, anddpnamematches nothing in the module. The LibreSSL source is not in the repository view, so I could not check. If LibreSSL fills it,X509_get_ext_d2ireturns a different struct for relative names. The oracle would not catch this if its re-encoding does not use that field.ExtensionDecode(X509.cpp:2240) falls through fromNotImplemented_nid_no_patchinto the next case. That is only safe if the call never returns. I did not check its declaration.X509.cpp. I did not judge the rule against them.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T13:59:20Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this; the points below are optional.
What I ran
Reviewed head
6dbfd27abb7124ca3aa7cf1000db97c5e854d69fand the prepared diff; no tests or builds were run. The author reports passing tests and an oracle comparison, which I did not independently run.Results
Findings
Blocking
None.
Non-blocking
certificatePoliciesdeliberately throws because its qualifiers require unsupportedANY DEFINED BYdecoding. This is documented in the description and technical debt entry; callers that need this extension will need a follow-up implementation. (core/libs/prx/libSceLibreSsl/src/X509.cpp:2240)Not verified
No build, unit test, oracle run, or console behavior was verified. The reviewed files were
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. All eight changed files were listed as included in the manifest; the excluded file list was not available in the review folder.To get this to a good state
Nothing is required. Optional: implement
certificatePoliciesdecoding when qualifier support is available.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T13:05:28Z.
Review: COMMENTED
Reviewed — comments
The review of head
628d78b87b2ac7d5c86fcb77d032a5b31e07cc64found no verified blocking defects, but the newly added behavior has not been run in this session and the reference implementation path needs correction before a formal approval is justified.What I ran
Results
Findings
Blocking
None verified.
Non-blocking
certificatePoliciespath throws afterX509_get_ext_d2ihas already written the matching extension index and critical flag. If callers catch the exception, those outputs remain modified, unlike the C API’s normal error return contract. Consider returning a failure through the decoder’s existing error path, or documenting and testing the throw semantics. Seecore/libs/prx/libSceLibreSsl/src/X509.cpp:2239-2240andcore/libs/prx/libSceLibreSsl/src/X509.cpp:2291-2308.Not verified
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. No changed files were excluded by the review manifest.To get this to a good state
Nothing is required. The exception-path output mutation is optional feedback.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T12:56:03Z.
Review: COMMENTED
Reviewed — no blocking findings
The pinned change implements the extension lookup and decoding paths described; the review was limited to targeted source ranges, so a formal approval is not justified.
What I ran
9b8115038524dfc43a28670a122a5d485eeb0f39; no tests or build commands were run.Results
Findings
Blocking
None identified in the inspected implementation.
Non-blocking
None.
Not verified
The full changed-file contents were not read. Targeted review covered the implementation around extension method lookup, decoding, and
X509_get_ext_d2i; full contents ofX509.cpp,tests/X509.cpp,tests/Oracle.cpp,tests/OracleReference.cpp,include/Api.hpp,CMakeLists.txt,Export.cpp, anddocs/dev/debt/libSceLibreSsl.mdwere not reviewed. Test and build claims in the PR description were not independently verified. No repository files were excluded according to the prepared file listing.To get this to a good state
Complete a full review of all changed files and run the relevant checks before making a formal decision.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T13:16:52Z.
Review: COMMENTED
Checked the branch sources and built the focused tests against the existing Linux runtime.
X509passed. The separate reference-oracle executables did not build in this standalone setup.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.