Skip to content

feat(libSceLibreSsl): implement X509_NAME_get_entry and X509_NAME_ENTRY_get_data - #10477

Closed
alvaroelpob wants to merge 5 commits into
boykopovar:mainfrom
alvaroelpob:feat/libscelibressl-x509-names
Closed

alvaroelpob wants to merge 5 commits into
boykopovar:mainfrom
alvaroelpob:feat/libscelibressl-x509-names

Conversation

@alvaroelpob

@alvaroelpob alvaroelpob commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

What

Implements X509_NAME_get_entry and X509_NAME_ENTRY_get_data in libSceLibreSsl, which threw and were declared without parameters.

The module is LibreSSL 2.5.4 (firmware 13.40 measurements in #8981). Signatures, layouts and results follow that release's x509.h, x509name.c and stack.c:

Export Behaviour
X509_NAME_ENTRY* X509_NAME_get_entry(X509_NAME*, int loc) null for a null name, a negative loc, a null entry stack (sk_num is -1) or loc >= num; otherwise entries->data[loc]
ASN1_STRING* X509_NAME_ENTRY_get_data(X509_NAME_ENTRY*) null for a null entry, otherwise value

The layouts are 40 bytes for X509_NAME (entries at 0), 24 for X509_NAME_ENTRY (object, value, set, size) and 32 for _STACK (num, data, sorted, num_alloc, comp). They were checked with static_asserts and against offsetof from the 2.5.4 headers compiled on x86-64. A positive entry count with a null entry array, which LibreSSL dereferences, throws. No export of this module creates a name yet, so for now only names built by the caller reach these functions.

The 2.5.4 _STACK layout is main's LibreSslStack from #10373. This PR reads it through that struct and changes none of the sk_* exports.

The debt entry records the source and what is unverified, and the pending-export count drops from 357 to 355.

Tested

Ubuntu 26.04 (WSL2, kernel 6.18), GCC 15.2.0, Release, full build with BUILD_TESTING=ON on main db6af9e. There is one commit per function, and each adds that function with its test block and debt update. Each was built and its guest_libressl_x509_name test and check_conventions.py run on its own.

Checklist

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Progress report (d23df92 → 6bf0609)

📈 System libraries: 26.7% (+0.01%, +2 implemented functions)

✅ 2 implemented
Library Name
libSceLibreSsl X509_NAME_ENTRY_get_data_nid_postfix
libSceLibreSsl X509_NAME_get_entry_nid_postfix

Changed libraries (implemented exports)

Library Before After Change
libSceLibreSsl 202/427 (47.31%) 204/427 (47.78%) +0.47%

@alvaroelpob
alvaroelpob marked this pull request as ready for review October 24, 2026 02:44
Copilot AI balanced review requested due to automatic review settings October 24, 2026 02:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@github-actions

github-actions Bot commented Oct 24, 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 11359 X509_NAME_ENTRY_get_data
X509_NAME_get_entry
core/libs/prx/libSceLibreSsl/src/X509Name.cpp
core/libs/tests/GuestLibreSslX509Name.cpp
PR 13266 X509_NAME_ENTRY_get_data
X509_NAME_get_entry
core/libs/prx/libSceLibreSsl/src/X509Name.cpp
core/libs/tests/GuestLibreSslX509Name.cpp
PR 13285 X509_NAME_ENTRY_get_data
X509_NAME_get_entry
core/libs/prx/libSceLibreSsl/src/X509Name.cpp
core/libs/tests/GuestLibreSslX509Name.cpp
PR 13546 X509_NAME_ENTRY_get_data
X509_NAME_get_entry
core/libs/prx/libSceLibreSsl/src/X509Name.cpp
core/libs/tests/GuestLibreSslX509Name.cpp
PR 13547 X509_NAME_ENTRY_get_data
X509_NAME_get_entry
core/libs/prx/libSceLibreSsl/src/X509Name.cpp
core/libs/tests/GuestLibreSslX509Name.cpp
PR 13877 X509_NAME_ENTRY_get_data
X509_NAME_get_entry
core/libs/prx/libSceLibreSsl/src/X509Name.cpp
core/libs/tests/GuestLibreSslX509Name.cpp

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 10508 core/libs/prx/libSceLibreSsl/CMakeLists.txt
core/libs/prx/libSceLibreSsl/Export.cpp
core/libs/prx/libSceLibreSsl/include/Api.hpp
docs/dev/debt/libSceLibreSsl.md
PR 10570 core/libs/prx/libSceLibreSsl/CMakeLists.txt
core/libs/prx/libSceLibreSsl/Export.cpp
core/libs/prx/libSceLibreSsl/include/Api.hpp
docs/dev/debt/libSceLibreSsl.md
PR 10878 core/libs/prx/libSceLibreSsl/CMakeLists.txt
core/libs/prx/libSceLibreSsl/Export.cpp
core/libs/prx/libSceLibreSsl/include/Api.hpp
docs/dev/debt/libSceLibreSsl.md
PR 10915 core/libs/prx/libSceLibreSsl/CMakeLists.txt
core/libs/prx/libSceLibreSsl/Export.cpp
core/libs/prx/libSceLibreSsl/include/Api.hpp
docs/dev/debt/libSceLibreSsl.md
PR 11003 core/libs/prx/libSceLibreSsl/CMakeLists.txt
core/libs/prx/libSceLibreSsl/Export.cpp
core/libs/prx/libSceLibreSsl/include/Api.hpp
docs/dev/debt/libSceLibreSsl.md
PR 11128 core/libs/prx/libSceLibreSsl/CMakeLists.txt
core/libs/prx/libSceLibreSsl/Export.cpp
core/libs/prx/libSceLibreSsl/include/Api.hpp
docs/dev/debt/libSceLibreSsl.md
PR 11146 core/libs/prx/libSceLibreSsl/CMakeLists.txt
core/libs/prx/libSceLibreSsl/Export.cpp
core/libs/prx/libSceLibreSsl/include/Api.hpp
docs/dev/debt/libSceLibreSsl.md
PR 11151 core/libs/prx/libSceLibreSsl/CMakeLists.txt
core/libs/prx/libSceLibreSsl/Export.cpp
core/libs/prx/libSceLibreSsl/include/Api.hpp
docs/dev/debt/libSceLibreSsl.md
PR 11175 core/libs/prx/libSceLibreSsl/CMakeLists.txt
core/libs/prx/libSceLibreSsl/Export.cpp
core/libs/prx/libSceLibreSsl/include/Api.hpp
docs/dev/debt/libSceLibreSsl.md
PR 11176 core/libs/prx/libSceLibreSsl/CMakeLists.txt
core/libs/prx/libSceLibreSsl/Export.cpp
core/libs/prx/libSceLibreSsl/include/Api.hpp
docs/dev/debt/libSceLibreSsl.md
PR 11359 core/libs/prx/libSceLibreSsl/CMakeLists.txt
core/libs/prx/libSceLibreSsl/Export.cpp
core/libs/prx/libSceLibreSsl/include/Api.hpp
core/libs/prx/libSceLibreSsl/src/X509Name.cpp
core/libs/tests/GuestLibreSslX509Name.cpp
docs/dev/debt/libSceLibreSsl.md
PR 11466 core/libs/prx/libSceLibreSsl/CMakeLists.txt
core/libs/prx/libSceLibreSsl/Export.cpp
core/libs/prx/libSceLibreSsl/include/Api.hpp
docs/dev/debt/libSceLibreSsl.md
PR 11553 docs/dev/debt/libSceLibreSsl.md
PR 12928 core/libs/prx/libSceLibreSsl/Export.cpp
core/libs/prx/libSceLibreSsl/include/Api.hpp
docs/dev/debt/libSceLibreSsl.md
PR 13266 core/libs/prx/libSceLibreSsl/CMakeLists.txt
core/libs/prx/libSceLibreSsl/Export.cpp
core/libs/prx/libSceLibreSsl/include/Api.hpp
core/libs/prx/libSceLibreSsl/src/X509Name.cpp
core/libs/tests/GuestLibreSslX509Name.cpp
docs/dev/debt/libSceLibreSsl.md
PR 13285 core/libs/prx/libSceLibreSsl/CMakeLists.txt
core/libs/prx/libSceLibreSsl/Export.cpp
core/libs/prx/libSceLibreSsl/include/Api.hpp
core/libs/prx/libSceLibreSsl/src/X509Name.cpp
core/libs/tests/GuestLibreSslX509Name.cpp
docs/dev/debt/libSceLibreSsl.md
PR 13486 core/libs/prx/libSceLibreSsl/CMakeLists.txt
core/libs/prx/libSceLibreSsl/Export.cpp
core/libs/prx/libSceLibreSsl/include/Api.hpp
docs/dev/debt/libSceLibreSsl.md
PR 13546 core/libs/prx/libSceLibreSsl/CMakeLists.txt
core/libs/prx/libSceLibreSsl/Export.cpp
core/libs/prx/libSceLibreSsl/include/Api.hpp
core/libs/prx/libSceLibreSsl/src/X509Name.cpp
core/libs/tests/GuestLibreSslX509Name.cpp
docs/dev/debt/libSceLibreSsl.md
PR 13547 core/libs/prx/libSceLibreSsl/CMakeLists.txt
core/libs/prx/libSceLibreSsl/Export.cpp
core/libs/prx/libSceLibreSsl/include/Api.hpp
core/libs/prx/libSceLibreSsl/src/X509Name.cpp
core/libs/tests/GuestLibreSslX509Name.cpp
docs/dev/debt/libSceLibreSsl.md
PR 13860 core/libs/prx/libSceLibreSsl/Export.cpp
core/libs/prx/libSceLibreSsl/include/Api.hpp
docs/dev/debt/libSceLibreSsl.md
PR 13877 core/libs/prx/libSceLibreSsl/CMakeLists.txt
core/libs/prx/libSceLibreSsl/Export.cpp
core/libs/prx/libSceLibreSsl/include/Api.hpp
core/libs/prx/libSceLibreSsl/src/X509Name.cpp
core/libs/tests/GuestLibreSslX509Name.cpp
docs/dev/debt/libSceLibreSsl.md
PR 14115 core/libs/prx/libSceLibreSsl/Export.cpp
core/libs/prx/libSceLibreSsl/include/Api.hpp
docs/dev/debt/libSceLibreSsl.md
PR 14179 docs/dev/debt/libSceLibreSsl.md
PR 14193 docs/dev/debt/libSceLibreSsl.md
PR 14212 docs/dev/debt/libSceLibreSsl.md
PR 15480 core/libs/prx/libSceLibreSsl/Export.cpp
core/libs/prx/libSceLibreSsl/include/Api.hpp
docs/dev/debt/libSceLibreSsl.md
PR 15481 core/libs/prx/libSceLibreSsl/Export.cpp
core/libs/prx/libSceLibreSsl/include/Api.hpp
docs/dev/debt/libSceLibreSsl.md
PR 15482 core/libs/prx/libSceLibreSsl/Export.cpp
core/libs/prx/libSceLibreSsl/include/Api.hpp
docs/dev/debt/libSceLibreSsl.md
PR 15483 core/libs/prx/libSceLibreSsl/Export.cpp
core/libs/prx/libSceLibreSsl/include/Api.hpp
docs/dev/debt/libSceLibreSsl.md
PR 15586 docs/dev/debt/libSceLibreSsl.md
PR 15737 docs/dev/debt/libSceLibreSsl.md
PR 15827 core/libs/prx/libSceLibreSsl/CMakeLists.txt
core/libs/prx/libSceLibreSsl/Export.cpp
core/libs/prx/libSceLibreSsl/include/Api.hpp
docs/dev/debt/libSceLibreSsl.md
PR 15994 core/libs/prx/libSceLibreSsl/CMakeLists.txt
core/libs/prx/libSceLibreSsl/Export.cpp
core/libs/prx/libSceLibreSsl/include/Api.hpp
docs/dev/debt/libSceLibreSsl.md
PR 16079 docs/dev/debt/libSceLibreSsl.md

@alvaroelpob

Copy link
Copy Markdown
Contributor Author

Rebased on main 1e740a2 (head 448392a) to resolve the conflict from #9033 on the shared CMakeLists.txt and debt-file lines. Full suite 2043/2044, with the same failure on main. Depends on drops #9033 and adds #9949.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 24, 2026

@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 both X509_NAME accessors against the cited LibreSSL 2.5.4 layouts and stack behavior. The entry-count/data-array checks preserve the null/out-of-range behavior described, and the data getter returns only the entry's value field; the focused tests cover boundary and null-slot cases. The current head merges cleanly with upstream main; conventions and diff checks pass. I compiled and ran GuestLibreSslX509Name.cpp with X509Name.cpp directly using GCC 12.2.0; it passed. The broader Linux suite is author-reported; hosted product jobs are skipped.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 25, 2026
@oneandonlydean oneandonlydean self-assigned this Oct 25, 2026
@alvaroelpob
alvaroelpob force-pushed the feat/libscelibressl-x509-names branch from 448392a to 73b11e7 Compare October 25, 2026 05:32
@alvaroelpob

Copy link
Copy Markdown
Contributor Author

Rebased on main e7e3e9c, head 73b11e7, to resolve the conflict from #9529 on the shared CMakeLists.txt and debt-file lines; both sides are kept and the count is 353 minus this PR's exports. #10706 now requires each export to be declared once in include/Api.hpp, so 73b11e7 moves these signatures and their structs there and drops the test's redeclarations. Full suite 2202/2203, with the same failure on main. Depends on drops the merged #9529.

@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Oct 25, 2026

@ahmadmuj ahmadmuj 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 head d63afe313c, merged locally onto main 7a25f87620. Linux, GCC 13.3, Release.

What I ran:

  • guest_libressl_x509_name on the merged tree: pass.
  • Mutation controls, one at a time on X509Name.cpp: main's stub bodies, num < loc instead of num <= loc, no loc < 0 check, and entry->object instead of entry->value. The test fails on each.
  • Layout probe against LibreSSL 2.5.4 built from the release tarball (sha256 107a5b52..., matches the published SHA256): every field of X509_NAME, X509_NAME_ENTRY and _STACK has the same offset and size as LibreSslX509Name, LibreSslX509NameEntry and LibreSslStack (40/24/32 bytes). OPENSSL_NO_BUFFER only switches bytes between two pointer types.
  • Differential: I dlopened the merged libSceLibreSsl.prx and passed real 2.5.4 X509_NAME* values straight to both exports. I compared them with 2.5.4's own calls for loc in INT_MIN, -2, -1, 0..count+1, INT_MAX, and get_data on every entry. The names were a null name, an empty name, API-built names (multi-valued RDNs, 40 entries, 38 after deletes) and subjects/issuers parsed from DER certs with 1, 3, 6 (multi-valued) and 11 entries. 363 comparisons, 0 mismatches.
  • num > 0 with a null data array: 2.5.4 segfaults for loc 0..num-1 and returns NULL outside that range. This PR throws for the same loc values and returns NULL for the rest. That matches the debt entry.

Sources: 2.5.4 x509name.c X509_NAME_get_entry / X509_NAME_ENTRY_get_data, stack.c sk_num / sk_value, x509.h, stack.h.

LGTM. One heads-up: the branch now conflicts with main in docs/dev/debt/libSceLibreSsl.md only. Main reworded the MD4..SHA512 entry next to your count line, so CI needs a merge first.

Not checked: the console, and whether the module really is 2.5.4. I relied on the #8981 measurement for that, as the debt entry does.

@alvaroelpob
alvaroelpob force-pushed the feat/libscelibressl-x509-names branch from d63afe3 to b976726 Compare October 25, 2026 18:51
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Oct 31, 2026
@alvaroelpob
alvaroelpob force-pushed the feat/libscelibressl-x509-names branch from 63a6ee7 to 1fe82b5 Compare November 1, 2026 03:06
@alvaroelpob

Copy link
Copy Markdown
Contributor Author

Rebased onto main after #13820 merged (new head 1fe82b5); the pending-export count is now 288, the stubs actually left in Export.cpp. Also restores the PS5 3.20 export table commit link, which my previous rebase had broken. Full suite 3107/3107.

@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Nov 1, 2026
@alvaroelpob
alvaroelpob force-pushed the feat/libscelibressl-x509-names branch from 1fe82b5 to 856f9fd Compare November 2, 2026 16:12
@alvaroelpob

alvaroelpob commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Rebased onto main after #9970, #10078 and #10488 merged (new head 886b309); the pending count is now 259, the stubs left in Export.cpp. Full suite 3538/3538. Merged #9448 and #10078 are dropped from Depends on.

@alvaroelpob
alvaroelpob force-pushed the feat/libscelibressl-x509-names branch from 856f9fd to 886b309 Compare November 2, 2026 16:54
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Nov 2, 2026
@alvaroelpob
alvaroelpob force-pushed the feat/libscelibressl-x509-names branch from 886b309 to 2417a2f Compare November 3, 2026 18:26
@alvaroelpob

Copy link
Copy Markdown
Contributor Author

Rebased onto main 4f41f4c and recomputed the debt counter. Build, check_conventions and the full ctest pass.

@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Nov 3, 2026
@alvaroelpob

Copy link
Copy Markdown
Contributor Author

Rebased on main 9ab6a28 to resolve the conflicts with #10395 on the shared CMakeLists.txt, Api.hpp and debt lines; the pending-export count is recomputed from Export.cpp. Head d0ebffd. Full Linux suite: 3898/3898; check_conventions.py passes.

@alvaroelpob
alvaroelpob force-pushed the feat/libscelibressl-x509-names branch from 2417a2f to d0ebffd Compare November 4, 2026 19:43
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Nov 4, 2026
@alvaroelpob
alvaroelpob force-pushed the feat/libscelibressl-x509-names branch from d0ebffd to 4da8e01 Compare November 5, 2026 12:28
@alvaroelpob

Copy link
Copy Markdown
Contributor Author

@MarcZX10 Rebased on main d63781e to resolve the conflicts on the shared CMakeLists.txt, Api.hpp and debt lines (#10395 and #11662); the pending-export count is recomputed from Export.cpp. Head 4da8e01. Full Linux suite on that head: 3936/3936; check_conventions.py passes. The implementation and debt changes are unchanged apart from the count.

@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Nov 5, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

Hi @alvaroelpob, thanks for this. Your three commits (9f7896f2ba, 1b7914cf30, 4da8e01907) are now on main with your authorship: #11129 was built on top of them and merged as a0a8b1b173. Merging current main into this branch leaves no remaining change, so I'm closing this as already landed. Thanks again for the X509_NAME work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build docs needs rebase Conflicts with main, rebase needed prx

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants