feat(libSceLibreSsl): implement EC groups and keys for named curves #10395
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10395"
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 MatteoSid on 2026-10-23T21:06:37Z.
What
Implements nine libSceLibreSsl exports that were throwing
NotImplemented:EC_GROUP_new_by_curve_name,EC_GROUP_free,EC_GROUP_get_degree,EC_KEY_new,EC_KEY_new_by_curve_name,EC_KEY_free,EC_KEY_set_group,EC_KEY_get0_groupandECDSA_size.ec/ec_curve.c,ec/ec_lib.c,ec/ec_key.candecdsa/ecs_lib.cat 2e2c612.EC_GROUPandEC_KEYare opaque in LibreSSL (defined inec_lcl.h), so they are host objects. A group holds anmbedtls_ecp_groupfrom the mbedtls submodule (3.6.7, already linked asmbedcrypto), which the remainingEC_KEY,EC_POINTandECDSAexports can build on.Api.hppdeclares them as opaqueEcGroupandEcKeywith the exports' signatures; their layout is in the internalinclude/Ec.hpp, which onlyEc.cppand tests include, so the umbrella header does not pull in mbedtls.curve_list: NIDs 409 (prime192v1), 415 (prime256v1), 711 to 716 (secp192k1, secp224k1, secp224r1, secp256k1, secp384r1, secp521r1) and LibreSSL's brainpoolP256r1, P384r1 and P512r1 (928, 932, 934, not OpenSSL's 927, 931, 933). The other 79 members of the list (binary, WTLS, GOST, twisted brainpool and small prime curves; 2.5.4'sopensslfeatures.hkeeps EC2M and GOST enabled) throw. Any other NID returns null, asEC_GROUP_new_by_curve_namedoes.EC_GROUP_get_degreereturns the field size in bits (mbedtlspbits), which isBN_num_bits(p)in LibreSSL's GFp method.ECDSA_sizerepeats LibreSSL's computation: a DER INTEGER as long as the order with its top bit assumed set, twice, inside a SEQUENCE. That is 72 for P-256 and 141 for P-521 (2.5.4's bound, not the 139 later OpenSSL versions return).EC_KEY_set_groupstores a copy; a null group drops the previous one and returns 0, asEC_GROUP_dup(NULL)makes it do.EC_KEY_new,EC_KEY_new_by_curve_nameandEC_KEY_freeto this library, while itsEC_KEY_up_ref(LibreSsl3EcKey*)increments the counter at offset 48 of LibreSSL 4.0.0's 64-byteEC_KEY(ec/ec_local.h, the source main's libSceLibreSsl3 debt entry cites). On the 8-byte key the first commit adds, that write lands past its end. The second commit, co-authored by ahmadmuj fromb499692115a2in #11146, givesEcKeythat layout instead, with 2.5.4EC_KEY_new's defaults (version 1,POINT_CONVERSION_UNCOMPRESSED): the group in itsgroupslot and an atomic reference count at offset 48, starting at one;Ec.hppasserts standard layout, size 64 and offset 48.EC_KEY_freedecrements that count and frees the key at zero or below, as 2.5.4'sec_key.cdoes. libSceLibreSsl3's interface,LibreSsl3EcKeyand code are unchanged; only its key-reference test changes.Gaps, in the debt entry: no
EC_R_UNKNOWN_GROUPis queued, a key holds no keys and no export reads its conversion form or flags until the otherEC_KEYandEC_POINTexports exist, the lifetime shared with libSceLibreSsl3 is not checked on the console (maskym ran both tests on Windows on head85f2f2b514), and null groups and keys throw where LibreSSL dereferences them. The pending-exports count goes from 231 to 222.Tested
Linux (Ubuntu 24.04 container, GCC 13.3), full configure with
-DBUILD_TESTING=ON, Release: builtlibSceLibreSsl,libSceLibreSsl3, their patched.prxfiles and the fifty-three LibreSSL tests;ctest -R 'libressl|crypto_memcmp|public_headers'passes 118 of 118 (the fifty-three LibreSSL tests,public_headersand its 64 compile checks) on head9327713d3a, based onmain4f41f4c375. The newguest_libressl_ecchecks the degree andECDSA_sizeof all 11 curves through both constructors, null for 10 unknown NIDs,EC_KEY_set_groupwith a copy, a replacement, the key's own group and null, and null arguments. It fails when secp224k1 is mapped to mbedtls's secp224r1.guest_libressl3_key_referencekeeps main's caller-owned layout checks, asserts thatEcKeyandLibreSsl3EcKeyhave the same size and counter offset, checks that keys from both constructors start with version 1, conversion form 4 and the method, keys, encoding flags, flags and extra data cleared (it fails when both defaults are zero), and retains them through libSceLibreSsl3'sEC_KEY_up_ref, frees one reference and balances 4,000 concurrent retain and free pairs; built with AddressSanitizer and leak detection it is clean, and it reports the 64-byte keys as leaked whenEC_KEY_freeskips thedelete.nm -Don the patchedlibSceLibreSsl.prxlists the nine NIDs.tools/check_conventions.py --base origin/mainpasses;tools/pr_overlap.py --branch feat/libressl-ec-groups-keyson9327713d3a: the only open PRs with the same exports or new files are #11146 and #11466, which contain this PR's earlier commits and depend on it; #11146 carries the earlier lifetime fix inb499692115a2. The line overlaps are, in libSceLibreSsl, theadd_librarysource list, the test block and the pending count, which every libSceLibreSsl PR edits; in libSceLibreSsl3, the retain debt entry, which #12754 also edits, and the end ofGuestLibreSsl3KeyReference.cpp, where #14499 adds itsEVP_PKEY_get0_EC_KEYtest. #9448 landed first, as agreed, and #9571 since; this head keeps their sources and debt entries next to this PR's and recounts the stubs. With the others, whichever is merged later only rebases those lines. No title tested.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-23T23:52:38Z.
Review: APPROVED
Reviewed the full diff at
0ea7483291f4699d77ed683409da182df4f9d096against the pinned LibreSSL 2.5.4 EC and ECDSA sources cited in the PR. The curve mappings, copy semantics forEC_KEY_set_group, field-degree result, and DER size calculation match the reference for the implemented subset. The behavior is explicit for curves not supplied by mbedtls versus unrecognized NIDs, and the tests cover known, unsupported, and unknown values plus null/group replacement cases.I independently built the PR's mbedtls submodule's
mbedcrypto, compiled the exactEc.cppandGuestLibreSslEc.cppwith a throwingNotImplemented_nid_no_patchtest stub, and ran the harness successfully. This checks the implementation and its direct test harness, not the packaged.prx/NID path or full AnyPS5 build. Current hosted checks pass conventions, intake and labels; the PR reports its full Linux build and seven focused tests. I found no blocking issue.Imported from boykopovar/AnyPS5. Originally posted by ahmadmuj on 2026-10-25T18:08:38Z.
Review: APPROVED
Reviewed head
fdf6acfc47cec37ab48c7cb10aede877c5e13c41merged onto main7a25f87620a9b862dc194dd0f659686b0f6cc8b0(clean merge). Linux, GCC 13.3, Release.What I ran:
ctest -R 'libressl|crypto_memcmp|public_headers'on the merged tree: 77/77 pass.guest_libressl_ec3/3 with--repeat until-fail:3.MBEDTLS_ECP_DP_SECP224R1, or dropping the top-bit pad byte inECDSA_size, makesguest_libressl_ecfail onECDSA_size.tools/check_conventions.py --base origin/mainpasses. The 9 symbols come fromEc.cpp.o, and only those 9 stubs leftExport.cpp.SHA256file). It callsEC_GROUP_new_by_curve_name,EC_KEY_new_by_curve_name,EC_GROUP_get_degreeandECDSA_sizefor NIDs -1, 0 to 1200 and 100000.EC_get_builtin_curves. Your 11 mapped NIDs plus theCurvesMissingFromMbedtlsranges equal that set exactly. No curve NID falls through to null, and no NID outside the list throws.ECDSA_sizematch your test table for all 11 curves (712 gives 66, 716 gives 141, 934 gives 137). The brainpool r1 NIDs are 928, 932 and 934 (OBJ_sn2nid).UnknownNidsreturn null in 2.5.4.EC_KEY_newhas no group andECDSA_size0.EC_KEY_set_groupcopies, replaces, and with null returns 0 and leaves no group.ECDSA_size(NULL)is 0. All match.The
CurvesMissingFromMbedtlstest loop oneandonlydean asked about is gone on this head. The production throw and its debt entry stay.One non-blocking suggestion, fine as a follow-up: main now has the error queue (
LibreSslPutError_nid_no_patchininclude/Error.hpp). So theEC_R_UNKNOWN_GROUPgap in the debt entry can be closed with one call. In 2.5.4,EC_GROUP_new_by_curve_name(406)followed byERR_get_error()gives0x10fff081(ECerror(EC_R_UNKNOWN_GROUP), library 16, function 0xfff, reason 129). NIDs <= 0 queue nothing. With this PR the queue stays empty. Something likeif (nid > 0) LibreSslPutError_nid_no_patch(16, 0xfff, 129);beforereturn nullptr;inNewGroupwould match. Then the debt line and the "no export of this library adds an error yet" line in the ERR entry would need updating.LGTM. Not checked on a console.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T22:13:08Z.
Review: CHANGES_REQUESTED
Reviewing exact head
b2e992430900f6812e6d7ef48321cf9af3227a88.What I ran
3a40945e62with current main319621ba2e; main has since changed this PR'sCMakeLists.txt,Export.cpp,Api.hpp, and debt file.Results
Findings
Blocking
Export.cppalter the count, and the PR's current description reports the earlier count.Non-blocking
Sources
Not verified
To get this to a good state
Merge current main, update the pending-export count, rerun the focused LibreSSL tests on the resulting head, and request a re-review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T23:57:00Z.
Review: CHANGES_REQUESTED
Re-checked — changes requested for current-main base
The prior export-count and integration findings are addressed, and the reported LibreSSL tests are strong; this branch still needs the current base required by the contribution guide.
What I ran
d450bbcc78de2c560c0a62a0f8bf80d5520c0581; currentmainis3a2b91981651569163768854a1fcdc7193b6667b.git merge-tree --write-tree upstream/main upstream/pr-10395— clean preview, treeff6c2a2b1d2b53d16739ae606adbb7d395d4159f.git diff --check upstream/main...upstream/pr-10395— passed.python3 tools/check_conventions.py --base upstream/main --head upstream/pr-10395— passed.libSceLibreSsl,libSceLibreSsl3, patched PRX builds and 99 focused tests passing on this head's earlier base319621ba2e.Results
319621ba2e578bd053b0baba2877fe70520e0737; currentmainis newerFindings
The earlier integration and count issues are resolved. Current
mainhas not changed any of the seven files touched by this PR since319621ba2e, and I found no new code issue in the current merge preview.CONTRIBUTING.mdrequires branches to stay up to date withmain. Please rebase onto3a2b91981651569163768854a1fcdc7193b6667band rerun the focusedctest -R 'libressl|crypto_memcmp|public_headers'checks on the resulting tree. The preview is clean, but the branch and test run are not yet on the required current base.Sources
Not verified
I did not locally build LibreSSL, run CTest, or verify console behavior. The test results above are attributed to the author.
To get this to a good state
Rebase onto current
main, rerun the focused test command above, and request a re-review with the exact head and output.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T10:39:47Z.
Review: CHANGES_REQUESTED
Review of the requested head
I checked exact head
6819348ad03549f37292a3cc5ef87ce458d615aaagainst livemain1db077e876. The PR's current-main merge preview is clean andgit diff --checkpasses. The author reports 99/99 focused LibreSSL, crypto and public-header tests on this exact head, plus a negative control for the curve mapping. I did not run a local build or test.Blocking: overlap order with #9448 is not declared
The PR body notes shared
CMakeLists.txt, test-registration and debt-count sections with #9448 and says whichever lands later will rebase, but its checklist still saysDepends on: none. I fetched both current heads and ran a pairwise merge preview; it has content conflicts in:core/libs/prx/libSceLibreSsl/CMakeLists.txtcore/libs/prx/libSceLibreSsl/include/Api.hppdocs/dev/debt/libSceLibreSsl.mdCONTRIBUTING.mdrequires authors to agree on the order for shared-line overlaps and declare the dependency on the PR that must land second. Please coordinate with #9448's author and record the agreed order in the checklist. If this PR lands first, #9448 should depend on it; if #9448 lands first, this PR should depend on #9448 and be rebased after it. Preserve both implementations, tests, and the correct pending-export count.The reported exact-head tests support the implementation, but they do not resolve this merge-order requirement. No title/console behavior is claimed by this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T23:09:58Z.
Review: APPROVED
Re-checked — new head, looks good
The earlier review’s dependency-order concern is resolved in the PR description: #9448 lands first and this PR depends on it; the implementation and focused-test evidence otherwise remain unchanged on head
6819348ad03549f37292a3cc5ef87ce458d615aa.What I ran
Reviewed head
6819348ad03549f37292a3cc5ef87ce458d615aaagainst PR base2960e9a6e7e1fc99c4ed180c71495b5eb83464c7. The branch is explicitly dependent on open #9448; I did not request an early rebase. Checks ran in the Linux workspace; no compiler or build was invoked.Results
Depends on: #9448; #9448 remains openUnedited local command output
Findings
Blocking
None found in the re-check. The dependency order is now agreed and recorded, and the author’s combined test report covers the shared LibreSSL registration, declarations, tests and debt-count lines.
Non-blocking
The test runs are author-reported, not local runs. This approval does not remove the declared dependency: #9448 should land first, then this branch should be rebased and revalidated as the author describes.
Sources
Not verified
I did not run a local LibreSSL build or tests, a console test, or the post-#9448 rebase. The combined 36-test run and exact-head 99/99 run are author-reported.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T02:12:18Z.
Review: APPROVED
Reviewed — looks good
The current implementation and focused tests show no blocker; the author reports a Linux build and 100/100 focused tests passing on this exact head.
What I ran
f7c37da4d7de31dccb6400b5d39cf64bc327a796against PR basec12e7e61a185261d837b6fb2ff1c92a07a00e5ff; currentmainmatches the base, and the merge preview is clean.The diff, conventions, current-main merge preview, and independent ABI audit passed. The precheck's test-quality helper was unavailable in its isolated checkout; manual inspection confirmed the new C++ test is registered in CMake. The author's report says Linux/Ubuntu 24.04, GCC 13.3, Release,
BUILD_TESTING=ON;ctest -j8 -R 'libressl|crypto_memcmp|public_headers'passed 100/100, includingguest_libressl_ec.Sources
Not verified
I did not run a local build or tests; the Linux build and tests above are author-reported. Windows/macOS product tests and console behavior were not verified here. The declared #9448 dependency remains open, so the stated landing order still applies.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T00:18:38Z.
Review: APPROVED
Re-checked — new head, looks good
The second commit now makes
EC_KEY_up_refandEC_KEY_freeshare the same reference count, and I found no blocker in the updated implementation or test report.What I ran
Reviewed exact head
7836a888cf93078eb993b862ba78c7018ea528baagainst PR base8a4fc62318a4b73b6895bf20a024c625efeb7c3b. The PR's merge preview against that base is clean. The declared dependency #9448 is still open, its head is not included here, and its own preview conflicts with currentmain; the PR description specifies that #9448 lands first. Environment: Debian Linux x86-64, Python 3.11.2; no local C++ compiler or build was run.Results
Findings
Blocking
None found in the reviewed update.
Non-blocking
The declared #9448 dependency remains in effect. This approval covers the current diff; it does not change the stated order that #9448 lands first and #10395 is then rebased and revalidated. Windows and console lifetime interoperability remain unverified, as the PR records.
Sources
Not verified
I did not run a local build or CTest, Windows tests, or console behavior. The Linux build, 104-test result, ASan run, and negative control above are author-reported rather than independently reproduced.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T02:32:04Z.
Review: APPROVED
Re-checked — new head, looks good
The new head changes only the LibreSSL debt documentation relative to the previously approved implementation, and I found no blocker in that update.
What I ran
Reviewed head
85d8cff7e0df7705269099d8ddf1726e85fe1247against PR base0a148be96367e8c0aec0d0144f9d136ec7314f58; its merge preview against currentmaincf79276fee2f042feb6a7c71d0d6a27e9cfe2592is clean. Relative to previously reviewed head7836a888cf93078eb993b862ba78c7018ea528ba, the only changed file isdocs/dev/debt/libSceLibreSsl.md. Environment: Debian Linux x86-64, Python 3.11.2; I did not build locally.Results
tools/pr_abi_audit.pyortools/pr_test_quality.py; those two optional checks could not run there.Findings
Blocking
None found in this documentation-only update.
Non-blocking
#9448 remains the declared prerequisite and is still open. This approval covers the current head; after #9448 lands, rebase and rerun the checks as planned.
Sources
Not verified
I did not run a local build or CTest, Windows tests, or console behavior. The 104-test result is author-reported.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T14:31:37Z.
Review: COMMENTED
Reviewed — no blocking findings
The nine EC exports are implemented with ownership that holds up on every path I traced (copy-on-
EC_KEY_set_groupincluding self-assignment, a refcount that frees only at the last reference, and a null group that drops the previous one), and theEcKeylayout matches LibreSSL 4.0.0'sec_key_st; the layout is the 4.0.0 one on purpose, which the PR body discloses, and it differs from the 2.5.4 header the signatures cite.What I ran
67708e8ceb858f5071d0716441c456fe5b52f918, basea043b048db(the precheck base)./usr/bin/python33.11.2, no build.python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 10395 --output-dir /dev/shm/reviewer-run/precheck/10395python3 tools/pr_abi_audit.py --repo /marc/AnyPS5 --base a043b048db --head 67708e8ceb858f5071d0716441c456fe5b52f918 --json(exit 0;passed; 0 findings; 399 symbols).core/libs/tests/GuestLibreSslEc.cppfrom a head extract: one literal-path registration heuristic.gh api:src/lib/libcrypto/ec/ec_local.hatce488b78e0bd994780569df718596b9776ff681a(4.0.0), whereec_key_stismeth0,version8,group16,pub_key24,priv_key32,enc_flag40,conv_form44,references48,flags52,ex_data56 (64 bytes); andsrc/lib/libcrypto/ec/ec_lcl.hat2e2c612066aa993717528a0249c15c51128d61cb(2.5.4), whereversionis 0,group8,references40,method_data48 (56 bytes). The PR'sEcKeymatches 4.0.0 field for field.ECDSA_sizearithmetic checked by hand: P-256 gives 72 and P-384 gives 104, the values the test pins.Results
Precheck report, checks table, unedited (
/dev/shm/reviewer-run/precheck/10395/report.md):The precheck deliberately does not configure, build, or compile AnyPS5.git diff --check a043b048db8b33ab42ba5b70c94f852b9bd5866b...67708e8ceb858f5071d0716441c456fe5b52f918/usr/bin/python3 tools/check_conventions.py --base a043b048db8b33ab42ba5b70c94f852b9bd5866b --head 67708e8ceb858f5071d0716441c456fe5b52f918 --title feat(libSceLibreSsl): implement EC groups and keys for named curves --body /dev/shm/reviewer-run/precheck/10395/pr-body.md/usr/bin/python3 tools/pr_abi_audit.py --base a043b048db8b33ab42ba5b70c94f852b9bd5866b --head 67708e8ceb858f5071d0716441c456fe5b52f918 --jsonNo changed Python implementation files.No changed tools/ module has an existing sibling tools/tests/test_<module>.py suite.No changed test_*.py files./usr/bin/python3 /marc/AnyPS5/tools/pr_stack_check.py 10395 --repo boykopovar/AnyPS5 --output-dir /dev/shm/reviewer-run/precheck/10395/stackNot run: C++ tests need exact-head binaries, which require a build; the precheck does not build./usr/bin/python3 /dev/shm/reviewer-run/precheck/10395/head-67708e8ceb85-e021d4e9/tools/pr_test_quality.py --root /dev/shm/reviewer-run/precheck/10395/head-67708e8ceb85-e021d4e9 --json core/libs/prx/libSceLibreSsl/CMakeLists.txt core/libs/prx/libSceLibreSsl/Export.cpp core/libs/prx/libSceLibreSsl/include/Api.hpp core/libs/prx/libSceLibreSsl/include/Ec.hpp core/libs/prx/libSceLibreSsl/src/Ec.cpp core/libs/prx/libSceLibreSsl3/CMakeLists.txt core/libs/tests/GuestLibreSsl3KeyReference.cpp core/libs/tests/GuestLibreSslEc.cpp docs/dev/debt/libSceLibreSsl.md docs/dev/debt/libSceLibreSsl3.mdNo changed Python test module in tools/ can be run as a no-build base-source control.Negative control
Not run here. The C++ test needs a build.
Findings
Blocking: none.
Non-blocking:
EcKey. The PR body explains that the layout follows 4.0.0 so that keys shared withlibSceLibreSsl3keepreferencesat offset 48. If a title readsEC_KEYfields directly with the 2.5.4 header, the offsets are wrong (for examplegroupis at 8 in 2.5.4 and at 16 here). The PR describes these objects as opaque, so this is a risk to confirm, not a defect in the code.EC_KEY_set_groupbuilds a newEcGroupfrom the curve identity rather than copying the group'smbedtls_ecp_group. That is correct because the group is determined by the curve, but a group whose parameters were changed by other code would not be copied.Sources
github.com/boykopovar/AnyPS5@67708e8ceb/core/libs/prx/libSceLibreSsl/src/Ec.cppgithub.com/boykopovar/AnyPS5@67708e8ceb/core/libs/prx/libSceLibreSsl/include/Ec.hppec_key_st(commit-pinned):github.com/libressl/openbsd@ce488b78e0/src/lib/libcrypto/ec/ec_local.h (L224-L241)ec_key_st(commit-pinned):github.com/libressl/openbsd@2e2c612066/src/lib/libcrypto/ec/ec_lcl.h (L244-L259)Not verified
guest_libressl_ecandguest_libressl3_key_referencewere not built or run; the PR's run (Linux, 105 of 105 tests on an earlier head) is the author's report.libSceLibreSsl(2.5.4) layout ofEC_KEYwas not verified.conventions(one run cancelled, one succeeded) andlabelshad reported at review time.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-02T11:08:03Z.
Review: APPROVED
Re-checked — new head, approved
The rebased head has no blocking source finding; the author reports 110/110 focused tests on this exact SHA, and both live hosted checks pass.
What I ran
Reviewed all 10 changed files at head
c9c4535844610a61f02c7a15b4fc1e49ff9fe5f7against base3c3b3cda739f9eb00a07fae50d94a3af5f6fb8f2. Environment: Debian 12, Linux x86_64, Python 3.11.2, Git 2.39.5, GCC 12.2.0. I did not build or run CTest locally. The author reports a Release build and 110 focused tests passing on this exact head in the latest test report.The precheck's isolated checkout lacks the ABI and test-quality helper scripts, so I reran those checks from the workspace. I also confirmed the tests are registered in CMake; the heuristic does not recognize the registration helper's generated source list.
Results
Precheck summary table (unedited)
The precheck deliberately does not configure, build, or compile AnyPS5.git diff --check 3c3b3cda739f9eb00a07fae50d94a3af5f6fb8f2...c9c4535844610a61f02c7a15b4fc1e49ff9fe5f7/usr/bin/python3 tools/check_conventions.py --base 3c3b3cda739f9eb00a07fae50d94a3af5f6fb8f2 --head c9c4535844610a61f02c7a15b4fc1e49ff9fe5f7 --title feat(libSceLibreSsl): implement EC groups and keys for named curves --body /tmp/review-10395/pr-body.md/usr/bin/python3 tools/pr_abi_audit.py --base 3c3b3cda739f9eb00a07fae50d94a3af5f6fb8f2 --head c9c4535844610a61f02c7a15b4fc1e49ff9fe5f7 --jsonNo changed Python implementation files.No changed tools/ module has an existing sibling tools/tests/test_<module>.py suite.No changed test_*.py files./usr/bin/python3 /marc/AnyPS5/tools/pr_stack_check.py 10395 --repo boykopovar/AnyPS5 --output-dir /tmp/review-10395/stackNot run: C++ tests need exact-head binaries, which require a build; the precheck does not build./usr/bin/python3 /tmp/review-10395/head-c9c453584461-a0f8f34b/tools/pr_test_quality.py --root /tmp/review-10395/head-c9c453584461-a0f8f34b --json core/libs/prx/libSceLibreSsl/CMakeLists.txt core/libs/prx/libSceLibreSsl/Export.cpp core/libs/prx/libSceLibreSsl/include/Api.hpp core/libs/prx/libSceLibreSsl/include/Ec.hpp core/libs/prx/libSceLibreSsl/src/Ec.cpp core/libs/prx/libSceLibreSsl3/CMakeLists.txt core/libs/tests/GuestLibreSsl3KeyReference.cpp core/libs/tests/GuestLibreSslEc.cpp docs/dev/debt/libSceLibreSsl.md docs/dev/debt/libSceLibreSsl3.mdNo changed Python test module in tools/ can be run as a no-build base-source control.Manual audit output (unedited)
ABI audit summary:
Test-quality output:
Hosted check output (unedited)
Negative control
Findings
Blocking
None found in the reviewed code or tests.
Non-blocking
Depends on: #9448. The stack report confirms #9448 is still open, its head conflicts with current main, and its changes are not included in this head. #10395 itself previews cleanly against its current base; preserve the declared landing order and rebase/update the pending-export count after #9448 lands.Sources
EC_KEY_set_groupNot verified
I did not independently build or run CTest. The 110-test result is author-reported, not my run. No PS5 console behavior was tested. The current hosted checks contain only conventions and labels; no hosted build job ran for this head.
To get this to a good state
No code change is requested on this reviewed head. Keep #9448 as the declared prerequisite; after it lands, rebase this PR, recalculate the pending-export count, and rerun the focused LibreSSL tests on the new head. I will recheck any changed head.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-02T18:46:12Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Both EC key constructors leave
versionandconversionFormat zero, although the referenced LibreSSL 2.5.4 constructor initializes them to version 1 and uncompressed form.What I ran
Reviewed all ten changed files at head
241d083a37256e9fef0325b5e435295b933cf96eagainst PR baseb28bb772177768f99874ca38f6252cd0139acf2a. The stack check previewed it cleanly against currentmaina4eca2a056bf3bbbec98ab42e9d28163e4ea9cb8; no dependency was declared. Environment: Debian Linux x86_64, Python 3.11.2, GCC 12.2.0. I did not configure or build AnyPS5.The PR reports 112 passing tests on this head, but its stated base is
8723ebf113, not the current PR base. That report is author-provided; I did not run those tests.Results
main; no declared dependency.main.Full precheck table and raw output
The precheck deliberately does not configure, build, or compile AnyPS5.git diff --check b28bb772177768f99874ca38f6252cd0139acf2a...241d083a37256e9fef0325b5e435295b933cf96e/usr/bin/python3 tools/check_conventions.py --base b28bb772177768f99874ca38f6252cd0139acf2a --head 241d083a37256e9fef0325b5e435295b933cf96e --title feat(libSceLibreSsl): implement EC groups and keys for named curves --body /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-10395-241d083a3725/pr-body.md/usr/bin/python3 tools/pr_abi_audit.py --base b28bb772177768f99874ca38f6252cd0139acf2a --head 241d083a37256e9fef0325b5e435295b933cf96e --jsonNo changed Python implementation files.No changed tools/ module has an existing sibling tools/tests/test_<module>.py suite.No changed test_*.py files./usr/bin/python3 /marc/AnyPS5/tools/pr_stack_check.py 10395 --repo boykopovar/AnyPS5 --output-dir /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-10395-241d083a3725/stackNot run: C++ tests need exact-head binaries, which require a build; the precheck does not build./usr/bin/python3 /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-10395-241d083a3725/head-241d083a3725-482d5640/tools/pr_test_quality.py --root /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-10395-241d083a3725/head-241d083a3725-482d5640 --json core/libs/prx/libSceLibreSsl/CMakeLists.txt core/libs/prx/libSceLibreSsl/Export.cpp core/libs/prx/libSceLibreSsl/include/Api.hpp core/libs/prx/libSceLibreSsl/include/Ec.hpp core/libs/prx/libSceLibreSsl/src/Ec.cpp core/libs/prx/libSceLibreSsl3/CMakeLists.txt core/libs/tests/GuestLibreSsl3KeyReference.cpp core/libs/tests/GuestLibreSslEc.cpp docs/dev/debt/libSceLibreSsl.md docs/dev/debt/libSceLibreSsl3.mdNo changed Python test module in tools/ can be run as a no-build base-source control.The two precheck helper errors were:
Standalone audit output:
The standalone test-quality heuristic flagged both C++ tests as possibly unregistered because the CMake source path is expressed through
${LIBS_INCLUDE_DIR}. The manual CMake inspection found both registrations. Hosted checks on the reviewed head:Negative control
Findings
Blocking
EC_KEY_newandEC_KEY_new_by_curve_nameconstructEcKeywithversion == 0andconversionForm == 0. The pinned LibreSSL 2.5.4EC_KEY_newinitializes the version to1and the point conversion form toPOINT_CONVERSION_UNCOMPRESSED(4); the current object therefore has different initial state from the implementation this PR says it follows. Please initialize both fields to those defaults and add assertions for both constructors.Non-blocking
Sources
Not verified
I did not build or run CTest, the AddressSanitizer test, Windows tests, or console behavior. The author reports 112 passing tests and an AddressSanitizer lifetime test on this head, but those runs were against
main8723ebf113; the current PR base isb28bb772177768f99874ca38f6252cd0139acf2a. Hosted checks on the exact head ran conventions and labels only.To get this to a good state
Initialize
versionto1andconversionFormtoPOINT_CONVERSION_UNCOMPRESSED, and add checks for bothEC_KEY_newandEC_KEY_new_by_curve_name. On the new head, rerunpython3 tools/check_conventions.py --base origin/mainandctest --test-dir build -R 'libressl|crypto_memcmp|public_headers'; I will re-check the defaults, exact head, and test results.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-03T08:31:05Z.
Review: COMMENTED
Re-checked — new head, no blocking findings
The rebased change still matches the reviewed curve list and key layout; the current conventions and labels checks are pending, so this is a COMMENTED result.
What I ran
Reviewed all ten changed files at head
9327713d3a0e7cd23b652f6bf5b7d52bb8e7aaedagainst base4f41f4c375f5abb487dbd184fbc150f31994d762. The current-base merge preview is clean. Environment: Debian 12 x86_64, Python 3.11.2, Git 2.39.5. I did not build or run CTest. The author reports an exact-head Linux build and 118/118 selected tests; I did not reproduce these.Results
Precheck table and relevant raw output
Direct ABI audit summary:
Test-quality helper warnings:
Both sources are registered by
add_test_executablein their library CMake files. Hosted status at refresh:Negative control
Not run by me. The author reports that the new EC test fails when secp224k1 is mapped to secp224r1; I did not independently reproduce this control.
Findings
Blocking
None found in the ten changed files.
Non-blocking
The current conventions and labels checks have not completed. The test-quality heuristic flags both C++ tests because it does not resolve the CMake helper's generated source path; direct inspection confirms that both tests are registered.
Sources
Not verified
I did not run a local build, CTest, AddressSanitizer, console behavior, or the author's reported negative control. The current conventions and labels checks remain pending. The author-reported Linux results are not independently reproduced here.
To get this to a good state
Let the current conventions and labels checks finish. I will refresh the head and checks before deciding whether to approve.
Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T15:35:42Z.
Review: APPROVED
Reviewed — approved
The nine EC exports and the 64-byte
EcKeylayout shared with libSceLibreSsl3 build and pass their tests on the merged tree. Both mutation controls make the tests fail, and I found nothing blocking.What I ran
Head
9327713d3a0e7cd23b652f6bf5b7d52bb8e7aaed,main4f41f4c375f5abb487dbd184fbc150f31994d762, merged with--no-ff(tree719ba88157c01461ebf0ac44227e3aca2d34d879). Debian 13 VM (32 vCPU, Xeon Gold 6136), GCC 14.2.0, Release, Ninja,BUILD_TESTING=ON.Results
git diff --checkcheck_conventions.pylibs(script)mainfailures:guest_interfaces,guest_socket_options_multicast,unwrap_self_..._group,vector_constant_factor_tininess. Unexpected skipguest_net_ctlalso happens onmain.guest_libressl_ecguest_libressl3_key_referencepublic_headersmain's baseline is 57.2 s, so this comes frommain, not the PRgit status --porcelainis emptyFocused ctest output
Negative control
Restoring all production files from
mainremovesinclude/Ec.hpp, which both tests include, so the tests would not compile. That says nothing useful, so I tested with targeted mutations of the production code instead:MBEDTLS_ECP_DP_SECP224R1makesguest_libressl_ecabort withfailed: ECDSA_size(exit 134). This confirms the author's control.EcKey::versionandconversionFormto 0 makesguest_libressl3_key_reference_tests ecabort withnew EC key version or conversion form(exit 134). This confirms the control the author reported for MarcZX10's change request.After restoring both files from the merged tree and rebuilding, both tests pass three times and the worktree is clean.
Findings
Blocking
None.
Non-blocking
core/libs/prx/libSceLibreSsl/src/Ec.cpp:43usesstd::pairbut does not include<utility>. It builds now only because another header pulls it in. Add#include <utility>.core/libs/tests/GuestLibreSsl3KeyReference.cpp:87callsEC_KEY_up_refon anEcKeythroughreinterpret_cast<LibreSsl3EcKey*>. This stands in for what a guest does across the ABI, and thestatic_asserts on size and counter offset guard the layout. Strictly, though, it reachesreferencesthrough an unrelated type, so the test depends on the two structs keeping the same layout, not on a shared type. It is fine for a test, but a shared header type for the counter prefix would make the contract explicit if more code relies on it.On the code, I checked against the logic of the cited LibreSSL 2.5.4 sources:
ECDSA_size(DER integer with the top-bit pad, doubled, inside a SEQUENCE) gives 72 for P-256, 66 for secp224k1 (225-bit order) and 141 for P-521.EC_KEY_freefrees at a new count ≤ 0, the same asCRYPTO_add(..., -1) > 0.EC_KEY_set_groupmakes the copy before deleting the old group, so self-assignment is safe; the debt entry records this difference.I agree with the earlier non-blocking points from MarcZX10 and ahmadmuj (the 4.0.0 layout versus the 2.5.4 header, and the missing
EC_R_UNKNOWN_GROUP). Both are disclosed in the debt entry, and I have nothing new to add on them.Not verified
EC_KEYlayout and lifetime interoperability, which the debt entry records.Ec.cpp:52-53).