fix(libSceLibreSsl): decode compressed 224-bit EC points and report errors #11466
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11466"
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 christopear on 2026-10-26T15:12:36Z.
What
Fixes two gaps in the existing EC point decoder carried by #11146 from #10407: compressed secp224k1/P-224 points currently throw, and decoding does not update the LibreSSL error queue. This follow-up implements modular square roots for every supported prime curve and matches LibreSSL 2.5.4's decoding errors, error-queue clearing and point state after failed decoding.
EC_POINT_newalso queues the reference null-group/allocation errors.The existing EC point types, public signatures and point/key APIs are retained. The decoder is moved from
Ec.cppintoEcPoint.cppto keep the arithmetic and validation together. Caller BN_CTX storage remains unused; scratch storage is host-owned. Cross-curve point reuse and backend arithmetic/allocation failures remain documented throwing gaps.Source: public LibreSSL 2.5.4
ec_lib.c,ec_oct.candecp_oct.c, OpenBSD revision2e2c612066aa993717528a0249c15c51128d61cb; this is the version identified in published firmware 13.40 measurements. No PS5 module, title or console execution was tested.Stacked on #11146, which carries #10395, the EC implementation from closed #10407, and #10915. Their original commits/authorship are retained. This PR's own change is commit 5de6263705 (replayed from fb6b35dc7b); the intended merge order is #10395 and #10915, then #11146, then this follow-up. After the dependencies merge, remove the inherited commits from the diff. Shared-file overlaps with unrelated PRs may still require rebasing; no independent implementation of the prerequisite exports is proposed here.
Tested
Current update includes parent main
a61d5edf9855e9bb6965695ecd247614861dd5e3and the current prerequisite heads: #1114629cfe068b0, #109157be988fd70, #10395c1e28b6338. Their original history/authorship is retained. Shared CMake/API/debt conflicts are resolved while retaining newer upstream functionality.The October 28 review is addressed: removed the single cross-curve decoding
RequireThrowsand its unused alternate-group fixture; retained all three null-argument assertions. The RSA fixture cleanup remains identical to current #10915. EC production code is unchanged from the previously reviewed implementation. Cross-curve runtime behavior remains an explicitly documented unknown; no new behavior is asserted.Ubuntu 26.04 x86-64, GCC 15.2.0, Release with bundled dependencies:
92e45814d8: full build succeeded, 37 LibreSSL tests passed, and full suite 2,961 passed, 32 skipped, zero failures, 2,993 registered tests in 271.10 seconds.6a5b78ccbf811f3f2eefe76ef9e594ffd31da7a7additionally integrates unrelated upstream inventory, scheduler, NGS2 and tooling changes; LibreSSL source/tests are unchanged from the candidate. Full build and full suite rerun on this exact head: 2,961 passed, 32 skipped, zero failures, 2,993 registered tests in 253.32 seconds.cmake --build build --parallel 8;ctest --test-dir build -R libressl --output-on-failure --parallel 4;ctest --test-dir build --output-on-failure --parallel 4. Full suite runs use normal host permissions.git diff --checkpasses. The required old-forkorigin/maincomparison reports inherited NID/commit-subject findings: the candidate and upstream-only checks produced byte-for-byte identical output (51 findings, 15 errors). These are outside this contribution.codex/libressl-ec-review-oct30; shared files and incomplete comparisons against conflicting PRs remain. No claim of a globally conflict-free dependency stack.Reference evidence from original code commit
fb6b35dc7b: the regression test failed against the prerequisite decoder and passed with this fix. The committed test covers 33 reference points across 11 curves plus decoding errors, field bounds, parity, infinity and state/error-queue effects. A separate real-LibreSSL 2.5.4 differential matched 22,110 cases, including complete error queues and final point state, with null and supplied BN_CTX. That standalone differential was not rerun for this refresh; reproduction remains below.Independent Windows validation applies to earlier head
9e6abd40ab: contributor-reported Windows 11 / WinLibs GCC 15.2.0 success for five EC/RSA tests. No fresh Windows, PS5 or title execution was performed for this head. No performance claim.Reproduce the independent LibreSSL 2.5.4 comparison (Linux)
Save the C++ harness below as
differential.cppin a temporary directory outside the checkout. Save the shell block asreproduce.sh, then runbash reproduce.sh /absolute/path/to/that/directoryfrom the AnyPS5 checkout. The reference archive is built outside the repository and is not a runtime dependency.Seed 12345; 1,005 encodings per curve, each tested with two context modes, across 11 curves. Inputs include empty/infinity encodings, all 256 prefixes, small compressed X values with both parities, random encodings, and random generator multiples in compressed/uncompressed/hybrid forms. Each case starts with the generator and a pre-existing error.
Expected output:
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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T15:23:01Z.
Review: CHANGES_REQUESTED
I reviewed the incremental change
fb6b35dc7b26fb9455c9eb337c99d34eb3e24efband the inherited EC decoder context. I did not find a concrete correctness defect in the compressed-point arithmetic or the added vectors. The PR reports a 2,346-pass full suite and a 22,110-case LibreSSL differential; I did not independently rerun those tests.I am requesting one repository-rule update before approval: this branch’s parent main is
716cb74e0871, while currentmainisb0f1183ca12b.CONTRIBUTING.mdrequires each PR branch to stay up to date with main. The intervening commits touchScanningWide.cpp,GuestWideConversion.cpp, and unrelated debt documents, and the merge-tree preview is clean, so I found no new code conflict. Please sync this branch to current main and let the required checks rerun; the dependency chain can remain as described.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T15:51:31Z.
Review: APPROVED
Re-reviewed exact head
9e6abd40ab93. This synchronization includes the parentmainrequested in my earlier review and leaves the EC implementation unchanged. The declared dependency chain (#11146, #10395 and #10915) is explicit; the author reports 28/28 focused tests after syncing, alongside the earlier 2,346-pass full suite and 22,110-case LibreSSL differential. I did not independently rerun those crypto tests. Current-main conventions andgit diff --checkpass, and the merge preview is clean. The only latermaincommit changes an unrelated IME debt note. I found no unresolved correctness or dependency-order issue in this update. Approved.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-18T15:45:55Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: fix the hybrid point decoding validation/state behavior described below.
What I ran
Reviewed head
ed8624f22c90b2cf26388a7022e9383f0756a532. No build or tests were run in this review. I read the prepared description, commit list, diff and manifest, and inspected all 12 changed files listed in the manifest; all were marked included. No files were excluded by rule. No repository files outside that set were read for context.Results
Findings
Blocking
core/libs/prx/libSceLibreSsl/src/EcPoint.cpp:133: Hybrid encodings with an incorrect parity bit are rejected before the decoded coordinates are copied into the caller’s point, but hybrid encodings whose parity matches and whose coordinates are off-curve are swapped into the caller’s point at lines 136–138 beforembedtls_ecp_check_pubkeyrejects them at line 140. This means a failed hybrid decode changes point state. Keep validation on the temporary decoded point and copy it only after validation, while preserving the reference behavior for failures that occur after point assignment. Add a test for a hybrid encoding with correct parity but off-curve coordinates and assert both the return/error and final point state.Non-blocking
Not verified
To get this to a good state
Fix the hybrid decoding validation ordering and add a regression test for the rejected off-curve hybrid case. Rerun the EC point tests and relevant build checks on the updated head.
Pull request closed