Skip to content

feat(libSceLibreSsl3): implement X509 field accessors - #13625

Closed
olegon85 wants to merge 1 commit into
boykopovar:mainfrom
olegon85:feat/libressl3-x509-accessors
Closed

olegon85 wants to merge 1 commit into
boykopovar:mainfrom
olegon85:feat/libressl3-x509-accessors

Conversation

@olegon85

Copy link
Copy Markdown
Contributor

What

Implements eight X509 field accessors in libSceLibreSsl3 that are currently stubs throwing NotImplemented_nid_no_patch: X509_get0_notBefore, X509_get0_notAfter, X509_getm_notBefore, X509_getm_notAfter, X509_get0_signature, X509_get_ext, X509_get_ext_count and X509_get0_extensions.

The 32-byte LibreSsl3X509 mirrors the v2 LibreSslX509 (certificate info at 0, signature algorithm at 8, signature at 16, valid at 24, references at 28). Its certInfo is an 80-byte LibreSsl3X509CertInfo holding version, serial number, signature, issuer, validity, subject, key, issuer UID, subject UID and extensions; notBefore and notAfter come from validity (two Asn1String* at offsets 0 and 8). X509_get0_signature exposes the stored signature and signature algorithm. Extension access uses the LibreSslStack num and data fields directly, since libSceLibreSsl3 does not implement sk_num or sk_value. Null certificates throw; missing validity or extension stack returns null or zero.

X509_up_ref and X509_get_version are already implemented by #12754 and are not touched here.

Tested

Ubuntu 24.04 x86-64: ctest -R guest_libressl3_x509_accessors — 1/1 pass. check_conventions.py --base origin/main clean. Windows syntax check via x86_64-w64-mingw32-g++ -fsyntax-only on Key.hpp, Api.hpp, X509Accessors.cpp and the test file: clean.

Checklist

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — changes requested

The Windows test setup still assigns properties to guest_libressl3_key_reference after the PR removes that CTest, so CMake configuration fails on Windows; the existing key-reference regression test is also no longer registered.

What I ran

Reviewed head ff6098bfcb916dfb16a2a7b15a963f5878896649 against PR base 5a75b4a119e2c92f8e0881944bd006c0b2bf9751. The stack check previewed this head cleanly against current main c0fb4a6aad1012b7e2abecaf2949e3d26c0e525d; declared dependency #12754's current head is not included, so its combined integration remains unverified. Environment: Linux x86-64, GCC 12.2.0, Python 3.11.2, CMake installed.

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13625
python3 tools/pr_abi_audit.py --base 5a75b4a119e2c92f8e0881944bd006c0b2bf9751 --head ff6098bfcb916dfb16a2a7b15a963f5878896649
python3 tools/pr_test_quality.py --root <isolated-head-checkout> --json core/libs/tests/GuestLibreSsl3X509Accessors.cpp
git diff --check 5a75b4a119e2c92f8e0881944bd006c0b2bf9751...ff6098bfcb916dfb16a2a7b15a963f5878896649
cmake --help-command set_tests_properties

Results

Check Result
Diff check Passed; no whitespace errors.
Repository conventions and PR template Passed.
Export declaration/definition audit Passed; no findings. This lexical check does not prove ABI or compilation.
Test quality heuristic One possible-unregistered-test warning; the new C++ executable is registered in CMake, so this is a heuristic false positive.
Dependency/merge preview This PR head merges cleanly with current main; the current head of declared dependency #12754 is not included.
Windows CMake test properties Blocking defect confirmed by source inspection: the WIN32 set_tests_properties list contains guest_libressl3_key_reference, but the PR removes its add_test. CMake documents that this command errors when a named test is not found.
Build and CTest Not run locally. The PR body reports Ubuntu CTest 1/1 and a Windows syntax check, but does not identify the tested SHA.
Relevant unedited output

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13625:

Head unchanged at completion: True
Base unchanged at completion: True
conventions_and_pr_template: passed

cmake --help-command set_tests_properties:

If the test is not found, CMake
will report an error.

python3 tools/pr_test_quality.py --root <isolated-head-checkout> --json core/libs/tests/GuestLibreSsl3X509Accessors.cpp:

{
  "findings": [
    {
      "path": "core/libs/tests/GuestLibreSsl3X509Accessors.cpp",
      "line": 1,
      "kind": "possible-unregistered-cpp-test",
      "message": "Changed C++ test source path was not found literally in CMake files; inspect registration, generated source lists, and workflow coverage."
    }
  ],
  "negative_control_candidates": []
}

Findings

Blocking

  • The PR replaces the guest_libressl3_key_reference test registration with guest_libressl3_x509_accessors, but the Windows-only set_tests_properties call still names guest_libressl3_key_reference. CMake errors when a named test does not exist, so Windows configuration fails. The replacement also stops running the existing key-reference regression coverage. Keep both test executables and CTest registrations, and include both registered test names in the Windows environment-property list. See the CMake changes at this head and the existing key-reference test source.

Non-blocking

None identified.

Sources

Not verified

No project configure, build, or CTest was run. The author-reported CTest and Windows syntax-check results are not tied to a stated SHA. Integration with the current head of dependency #12754 is also unverified.

To get this to a good state

Register and retain both the key-reference and X509-accessor tests, update the Windows environment-property list to name registered tests only, and provide exact-head test results. I’ll re-run the same no-build checks on the corrected head.

@JJenkx

JJenkx commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Windows run of head ff6098bfcb, merged onto current main (clean merge, local only): CMake configure fails on Windows.

CMake Error at core/libs/prx/libSceLibreSsl3/CMakeLists.txt:47 (set_tests_properties):
  set_tests_properties Can not find test to add properties to:
  guest_libressl3_key_reference

The diff replaces the existing guest_libressl3_key_reference block (add_test_executable(... GuestLibreSsl3KeyReference.cpp), its add_test and TIMEOUT) with the new guest_libressl3_x509_accessors block, instead of adding the new block alongside it. The if(WIN32) set_tests_properties(... guest_libressl3_key_reference guest_libressl3_x509_accessors ...) line still names the removed test, so configuration stops on Windows. Linux and macOS never run that block, so they configure, but guest_libressl3_key_reference silently stops being built and run there. core/libs/tests/GuestLibreSsl3KeyReference.cpp is still on main and in this branch.

Keeping the six key_reference lines and adding the new block after them should fix both. I haven't run the new test, because the configuration step fails first.

Windows 11 Enterprise 10.0.22621, WinLibs GCC 15.2.0 UCRT r7, CMake 4.3.1, Ninja, Release, BUILD_TESTING=ON.

AI-assisted: yes (Claude Code).

@oneandonlydean

Copy link
Copy Markdown
Collaborator

@olegon85 Thanks. The accessors read the same fields as LibreSSL 4.0.0 (x509_st, x509_cinf_st, X509v3_get_ext/X509v3_get_ext_count), and the offsets are asserted. A few points before this can land:

  1. Other open pull requests. feat(libSceLibreSsl3): implement the X509 notBefore, notAfter and signature getters #10491 (the notBefore/notAfter/signature getters) and feat(libSceLibreSsl3): implement X509_get0_extensions, X509_get_ext_count and X509_get_ext #10493 (X509_get0_extensions, X509_get_ext_count, X509_get_ext), both opened on 24 Oct, implement the same eight exports, and each conflicts with this one. The checklist says no other open PR does. Could you coordinate with that author on which set should land?
  2. CMake. In core/libs/prx/libSceLibreSsl3/CMakeLists.txt the new test replaces the guest_libressl3_key_reference registration instead of being added next to it. GuestLibreSsl3KeyReference.cpp is still in the tree but no longer runs, and the Windows set_tests_properties(...) line still names guest_libressl3_key_reference, so CMake fails there with "Can not find test to add properties to". Please keep the existing block and add yours after it.
  3. Headers. include/Key.hpp loses its #pragma once, and include/Api.hpp gains an extra blank line after extern "C" {. Please restore both.
  4. Debt (small). LibreSSL 4.0.0 reads x->cert_info->validity->notBefore and x->cert_info->extensions without checks, so a missing cert_info or validity faults there. Returning null or 0 is a choice made here, and the entry could say so.

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Progress report (7d9a2fc → bfaed17)

📈 System libraries: 26.74% (+0.03%, +8 implemented functions)

✅ 8 implemented
Library Name
libSceLibreSsl3 X509_get0_extensions_nid_postfix
libSceLibreSsl3 X509_get0_notAfter_nid_postfix
libSceLibreSsl3 X509_get0_notBefore_nid_postfix
libSceLibreSsl3 X509_get0_signature_nid_postfix
libSceLibreSsl3 X509_get_ext_count_nid_postfix
libSceLibreSsl3 X509_get_ext_nid_postfix
libSceLibreSsl3 X509_getm_notAfter_nid_postfix
libSceLibreSsl3 X509_getm_notBefore_nid_postfix

Changed libraries (implemented exports)

Library Before After Change
libSceLibreSsl3 9/270 (3.33%) 17/270 (6.30%) +2.96%

@MarcZX10

Copy link
Copy Markdown
Contributor

Re-checked — duplicate implementation found

The current head ff6098bfcb916dfb16a2a7b15a963f5878896649 implements the same eight X509 accessors already covered by the open #10491 (five getters) and #10493 (three extension accessors, depending on #10491); please reconcile the duplicate work before this PR proceeds.

@blawesom

Copy link
Copy Markdown
Contributor

Verified ff6098b on Linux x86-64 (GCC 16.2.1, CachyOS kernel 6.2.10, Release, BUILD_TESTING=ON, isolated worktree)

  • Built guest_libressl3_x509_accessors_tests and ran ctest -R '^guest_libressl3_x509_accessors$' -V: 1/1 passed (0.01s)
  • Ran the rest of the libSceLibreSsl3 family: ctest -R '^(guest_crypto_memcmp|guest_libressl3_digest|guest_libressl3_asn1|guest_libressl3_stack|guest_libressl3_x509_accessors)$' --parallel 8: 5/5 passed
  • tools/check_conventions.py --base origin/main: clean
  • Accessor semantics look right for the LibreSSL 4.0.0 layout cited in the debt entry (x509_st/x509_cinf_st); test covers happy paths, null validity, null extensions, out-of-range/negative X509_get_ext indices, null out-pointers for X509_get0_signature, and null-certificate throws. No code comments; debt count updated 80→72 with the functional entry added.

Still open (blocking, as oneandonlydean noted — none of these are addressed at the current head):

  1. Conflicting open PRs. feat(libSceLibreSsl3): implement the X509 notBefore, notAfter and signature getters #10491 and feat(libSceLibreSsl3): implement X509_get0_extensions, X509_get_ext_count and X509_get_ext #10493 (both open, author alvaroelpob) implement the same eight exports; the "no other open PR" checklist box is not truthful. This needs coordination before merge.
  2. CMake regression confirmed on Linux. The head replaces the guest_libressl3_key_reference block instead of adding the new test next to it: ninja -t targets shows no guest_libressl3_key_reference_tests, ctest -R key_reference has no test to run, and core/libs/tests/GuestLibreSsl3KeyReference.cpp is orphaned. On Windows the leftover set_tests_properties(... guest_libressl3_key_reference ...) line fails configure (per JJenkx). This silently drops an existing regression test.
  3. Headers. include/Key.hpp loses #pragma once, include/Api.hpp gains a stray blank line after extern "C" {.

Not run: Windows (no Windows environment here — configure failure there is reported by JJenkx, not reproduced by me), and console verification of the struct layouts, which the debt entry already flags.

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 10395 core/libs/prx/libSceLibreSsl3/CMakeLists.txt L42-43
PR 10452 core/libs/prx/libSceLibreSsl3/CMakeLists.txt L1
core/libs/prx/libSceLibreSsl3/include/Api.hpp L8-9
docs/dev/debt/libSceLibreSsl3.md L5
PR 10490 core/libs/prx/libSceLibreSsl3/CMakeLists.txt L1
docs/dev/debt/libSceLibreSsl3.md L5
PR 10491 core/libs/prx/libSceLibreSsl3/CMakeLists.txt L1
core/libs/prx/libSceLibreSsl3/Export.cpp L334-363, L369-378
core/libs/prx/libSceLibreSsl3/include/Api.hpp L76-81, L83-84
docs/dev/debt/libSceLibreSsl3.md L5
X509_get0_notAfter
X509_get0_notBefore
X509_get0_signature
X509_getm_notAfter
X509_getm_notBefore
PR 10493 core/libs/prx/libSceLibreSsl3/CMakeLists.txt L1
core/libs/prx/libSceLibreSsl3/Export.cpp L334-363
core/libs/prx/libSceLibreSsl3/include/Api.hpp L76-81
docs/dev/debt/libSceLibreSsl3.md L5
X509_get0_extensions
X509_get_ext
X509_get_ext_count
PR 11146 core/libs/prx/libSceLibreSsl3/CMakeLists.txt L42-43

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 9970 core/libs/prx/libSceLibreSsl3/CMakeLists.txt
core/libs/prx/libSceLibreSsl3/Export.cpp
docs/dev/debt/libSceLibreSsl3.md
PR 10461 core/libs/prx/libSceLibreSsl3/CMakeLists.txt
core/libs/prx/libSceLibreSsl3/Export.cpp
core/libs/prx/libSceLibreSsl3/include/Api.hpp
docs/dev/debt/libSceLibreSsl3.md
PR 10557 core/libs/prx/libSceLibreSsl3/CMakeLists.txt
core/libs/prx/libSceLibreSsl3/Export.cpp
core/libs/prx/libSceLibreSsl3/include/Api.hpp
docs/dev/debt/libSceLibreSsl3.md
PR 10631 core/libs/prx/libSceLibreSsl3/CMakeLists.txt
core/libs/prx/libSceLibreSsl3/Export.cpp
core/libs/prx/libSceLibreSsl3/include/Api.hpp
docs/dev/debt/libSceLibreSsl3.md
PR 10960 core/libs/prx/libSceLibreSsl3/CMakeLists.txt
core/libs/prx/libSceLibreSsl3/Export.cpp
core/libs/prx/libSceLibreSsl3/include/Api.hpp
docs/dev/debt/libSceLibreSsl3.md
PR 12315 core/libs/prx/libSceLibreSsl3/CMakeLists.txt
core/libs/prx/libSceLibreSsl3/Export.cpp
core/libs/prx/libSceLibreSsl3/include/Api.hpp
docs/dev/debt/libSceLibreSsl3.md
PR 12580 core/libs/prx/libSceLibreSsl3/Export.cpp
core/libs/prx/libSceLibreSsl3/include/Api.hpp
core/libs/prx/libSceLibreSsl3/include/Key.hpp
docs/dev/debt/libSceLibreSsl3.md
PR 12582 core/libs/prx/libSceLibreSsl3/Export.cpp
core/libs/prx/libSceLibreSsl3/include/Api.hpp
core/libs/prx/libSceLibreSsl3/include/Key.hpp
docs/dev/debt/libSceLibreSsl3.md
PR 12928 core/libs/prx/libSceLibreSsl3/Export.cpp
core/libs/prx/libSceLibreSsl3/include/Api.hpp
docs/dev/debt/libSceLibreSsl3.md
PR 12945 core/libs/prx/libSceLibreSsl3/CMakeLists.txt
core/libs/prx/libSceLibreSsl3/Export.cpp
core/libs/prx/libSceLibreSsl3/include/Api.hpp
core/libs/prx/libSceLibreSsl3/include/Key.hpp
docs/dev/debt/libSceLibreSsl3.md

@adriadam10

Copy link
Copy Markdown
Collaborator

Closing as a duplicate of open work.

Feel free to reopen if #10491/#10493 are abandoned, with those points addressed.

@adriadam10 adriadam10 closed this Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants