feat(libSceLibreSsl3): implement EC_POINT_dup #17621

Merged
GalaxyGamingFR merged 2 commits from upstream-pr/17621 into main 2026-12-03 06:46:24 +00:00
GalaxyGamingFR commented 2026-11-09 03:26:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by GalaxyGamingFR on 2026-11-09T03:26:42Z.


What

Implement EC_POINT_dup in libSceLibreSsl3, replacing its parameterless throwing placeholder in AdditionalExports.cpp.

  • Source: LibreSSL 4.0.0 at ce488b78 ec_lib.c, the revision the library's debt file already uses. Upstream returns NULL for a NULL source, makes a new point with EC_POINT_new(group) (NULL for a NULL group), copies the source into it with EC_POINT_copy, and frees it and returns NULL if the copy fails.
  • EcPoint and EcGroup belong to libSceLibreSsl's mbedtls wrappers. The new src/EcPoint.cpp does not touch their layout and does not include Ec.hpp. It only calls libSceLibreSsl's exported EC_POINT_new, EC_POINT_point2oct, EC_POINT_oct2point and EC_POINT_free: it queries the uncompressed size of the source, encodes it, and decodes the bytes into a new point of the group. The point at infinity goes through the same path as its one-byte encoding. If any step returns 0, the new point is freed and the export returns null.
  • Api.hpp now declares it as EcPoint* EC_POINT_dup(const EcPoint* source, const EcGroup* group).
  • A source on another curve than the group throws (NotImplemented_nid_no_patch) through libSceLibreSsl's same-curve check, like the other point functions. LibreSSL would copy it, since prime curves share one method. The size is queried before the new point is made, and the new point is held by a unique_ptr, so nothing leaks when that throws.

The gaps are recorded in docs/dev/debt/libSceLibreSsl3.md: the throw on another curve, and no ERR_R_PASSED_NULL_PARAMETER queued for a null group. The export inventory is updated (113 exports, 104 named).

No title's trace or disassembly was used, and the export was not measured on a PS5.

Tested

Windows 11, WinLibs GCC 15.2.0 UCRT. This is not a full CMake build. I compiled the new tests/EcPoint.cpp with src/EcPoint.cpp, libSceLibreSsl's Ec.cpp and the 3rdparty/mbedtls library sources into one executable, with APS5_VABI defined empty, a one-line NotImplementedAt_nid_no_patch that throws, and a seeded HostEntropy_nid_no_patch for key generation. No title or homebrew, and not built on Linux or macOS.

  • The test passes. It checks that a null source (with and without a group) and a null group return null. It decodes the P-256 generator (NID 415) from its known uncompressed encoding, duplicates it, frees the source and checks that the copy still encodes to the same 65 bytes. For each of the eleven curves (409, 415, 711 to 716, 928, 932, 934) it duplicates the point at infinity and a generated public key. The copy is a different pointer, has the same uncompressed and compressed encodings, keeps them after the source and its key are freed, and can itself be duplicated.
  • Two deliberate bugs both make the test fail: skipping the decode into the new point fails at line 64, and dropping the null-source check throws from EC_POINT_point2oct.
  • -Wall -Wextra is clean for the new files, and python tools/check_conventions.py --base origin/main passes.

I searched open and merged pull requests for EC_POINT_dup just before opening this one, and none implements it. #16586, #16588, #16589, #16848 and #16918 change the same export inventory count, so whichever lands later needs a one-line rebase.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added support for duplicating elliptic-curve points into a specified group. Successful duplication creates an independent copy; invalid inputs or duplication failures return no point.
    • Added automated coverage for point duplication across supported curves, including null inputs, points at infinity, and repeated copies.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5218230626 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17621). Originally posted by [GalaxyGamingFR](https://github.com/GalaxyGamingFR) on 2026-11-09T03:26:42Z. --- ### What Implement `EC_POINT_dup` in `libSceLibreSsl3`, replacing its parameterless throwing placeholder in `AdditionalExports.cpp`. - Source: LibreSSL 4.0.0 at [`ce488b78` `ec_lib.c`](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/ec/ec_lib.c#L735-L753), the revision the library's debt file already uses. Upstream returns NULL for a NULL source, makes a new point with `EC_POINT_new(group)` (NULL for a NULL group), copies the source into it with `EC_POINT_copy`, and frees it and returns NULL if the copy fails. - `EcPoint` and `EcGroup` belong to libSceLibreSsl's mbedtls wrappers. The new `src/EcPoint.cpp` does not touch their layout and does not include `Ec.hpp`. It only calls libSceLibreSsl's exported `EC_POINT_new`, `EC_POINT_point2oct`, `EC_POINT_oct2point` and `EC_POINT_free`: it queries the uncompressed size of the source, encodes it, and decodes the bytes into a new point of the group. The point at infinity goes through the same path as its one-byte encoding. If any step returns 0, the new point is freed and the export returns null. - `Api.hpp` now declares it as `EcPoint* EC_POINT_dup(const EcPoint* source, const EcGroup* group)`. - A source on another curve than the group throws (`NotImplemented_nid_no_patch`) through libSceLibreSsl's same-curve check, like the other point functions. LibreSSL would copy it, since prime curves share one method. The size is queried before the new point is made, and the new point is held by a `unique_ptr`, so nothing leaks when that throws. The gaps are recorded in `docs/dev/debt/libSceLibreSsl3.md`: the throw on another curve, and no `ERR_R_PASSED_NULL_PARAMETER` queued for a null group. The export inventory is updated (113 exports, 104 named). No title's trace or disassembly was used, and the export was not measured on a PS5. ### Tested Windows 11, WinLibs GCC 15.2.0 UCRT. This is not a full CMake build. I compiled the new `tests/EcPoint.cpp` with `src/EcPoint.cpp`, libSceLibreSsl's `Ec.cpp` and the `3rdparty/mbedtls` library sources into one executable, with `APS5_VABI` defined empty, a one-line `NotImplementedAt_nid_no_patch` that throws, and a seeded `HostEntropy_nid_no_patch` for key generation. No title or homebrew, and not built on Linux or macOS. - The test passes. It checks that a null source (with and without a group) and a null group return null. It decodes the P-256 generator (NID 415) from its known uncompressed encoding, duplicates it, frees the source and checks that the copy still encodes to the same 65 bytes. For each of the eleven curves (409, 415, 711 to 716, 928, 932, 934) it duplicates the point at infinity and a generated public key. The copy is a different pointer, has the same uncompressed and compressed encodings, keeps them after the source and its key are freed, and can itself be duplicated. - Two deliberate bugs both make the test fail: skipping the decode into the new point fails at line 64, and dropping the null-source check throws from `EC_POINT_point2oct`. - `-Wall -Wextra` is clean for the new files, and `python tools/check_conventions.py --base origin/main` passes. I searched open and merged pull requests for `EC_POINT_dup` just before opening this one, and none implements it. #16586, #16588, #16589, #16848 and #16918 change the same export inventory count, so whichever lands later needs a one-line rebase. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Added support for duplicating elliptic-curve points into a specified group. Successful duplication creates an independent copy; invalid inputs or duplication failures return no point. * Added automated coverage for point duplication across supported curves, including null inputs, points at infinity, and repeated copies. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
MarcZX10 commented 2026-11-20 15:25:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T15:25:47Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the implementation and the reviewed tests support the described duplication behavior.

What I ran

Reviewed head 140e74c548224e2d9c09ec6798753ec0d981a7b9 using the prepared diff and pinned repo_read.py source context. I did not run commands or tests; the test results in the description are author-reported.

Results

Check Result Note
Diff and targeted source review passed Implementation and callers inspected
Automated checks not run No tests run during this review

Findings

Blocking

None.

Non-blocking

None.

Not verified

The full build, CI results, Linux/macOS behavior, and PS5 behavior were not verified. I read all changed files listed as included in manifest.json: AdditionalExports.cpp, CMakeLists.txt, include/Api.hpp, src/EcPoint.cpp, tests/EcPoint.cpp, and docs/dev/debt/libSceLibreSsl3.md. No changed files were excluded in the manifest. files.json was not available through the reader.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5995091004 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17621#pullrequestreview-5995091004). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T15:25:47Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the implementation and the reviewed tests support the described duplication behavior. ## What I ran Reviewed head `140e74c548224e2d9c09ec6798753ec0d981a7b9` using the prepared diff and pinned `repo_read.py` source context. I did not run commands or tests; the test results in the description are author-reported. ## Results | Check | Result | Note | | --- | --- | --- | | Diff and targeted source review | passed | Implementation and callers inspected | | Automated checks | not run | No tests run during this review | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The full build, CI results, Linux/macOS behavior, and PS5 behavior were not verified. I read all changed files listed as included in `manifest.json`: `AdditionalExports.cpp`, `CMakeLists.txt`, `include/Api.hpp`, `src/EcPoint.cpp`, `tests/EcPoint.cpp`, and `docs/dev/debt/libSceLibreSsl3.md`. No changed files were excluded in the manifest. `files.json` was not available through the reader. ## To get this to a good state Nothing is required.
MarcZX10 commented 2026-11-30 08:47:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T08:47:20Z.

Review: COMMENTED


Reviewed — no blocking findings

The reviewed implementation and focused tests show no verified blocking defect; I did not run the tests or build.

What I ran

Reviewed head ba697eff0714fd1762739da816faf182b500a710 using the prepared diff and repo_read.py to inspect the changed code and relevant callers. No build, test command, or merged-preview check was run by me.

Results

Check Result Note
Diff and implementation review passed Six changed files considered
Build and tests not run Author reports a Windows test run
Console behavior not run No console measurement reported

Negative control

Not run by me. The description reports two deliberate mutations that failed the test; I did not independently verify them.

Findings

Blocking

None.

Non-blocking

None.

Sources

Not verified

I read the changed implementation, its tests, the debt note, and the relevant CMake and API diff ranges; AdditionalExports.cpp was reviewed through its diff hunk only. I did not read the full CMake or API files. No tests or build were run by me, and Linux, macOS, and PS5 behavior remain unverified. The Windows test and convention-check results are author-reported.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6109120137 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17621#pullrequestreview-6109120137). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-30T08:47:20Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The reviewed implementation and focused tests show no verified blocking defect; I did not run the tests or build. ## What I ran Reviewed head `ba697eff0714fd1762739da816faf182b500a710` using the prepared diff and `repo_read.py` to inspect the changed code and relevant callers. No build, test command, or merged-preview check was run by me. ## Results | Check | Result | Note | |---|---|---| | Diff and implementation review | passed | Six changed files considered | | Build and tests | not run | Author reports a Windows test run | | Console behavior | not run | No console measurement reported | ## Negative control Not run by me. The description reports two deliberate mutations that failed the test; I did not independently verify them. ## Findings ### Blocking None. ### Non-blocking None. ## Sources - [EC_POINT_dup implementation at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/ba697eff0714fd1762739da816faf182b500a710/core/libs/prx/libSceLibreSsl3/src/EcPoint.cpp) - [EC_POINT_dup tests at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/ba697eff0714fd1762739da816faf182b500a710/core/libs/prx/libSceLibreSsl3/tests/EcPoint.cpp) - [Underlying EC point conversion helpers at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/ba697eff0714fd1762739da816faf182b500a710/core/libs/prx/libSceLibreSsl/src/Ec.cpp) ## Not verified I read the changed implementation, its tests, the debt note, and the relevant CMake and API diff ranges; `AdditionalExports.cpp` was reviewed through its diff hunk only. I did not read the full CMake or API files. No tests or build were run by me, and Linux, macOS, and PS5 behavior remain unverified. The Windows test and convention-check results are author-reported. ## To get this to a good state Nothing is required.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!17621
No description provided.