feat(libSceLibreSsl3): implement ECDSA_do_verify #19033

Open
fishingpvalues wants to merge 23 commits from upstream-pr/19033 into main
fishingpvalues commented 2026-11-12 16:46:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fishingpvalues on 2026-11-12T16:46:38Z.


What

ECDSA_do_verify leaves the throwing AdditionalExports.cpp stub and follows LibreSSL 4.0.0 ecdsa.c/ecs_lib.c: it returns 1 for a valid signature, 0 for an invalid one, and -1 for an internal error or a key without a group or public key. A null key, which LibreSSL dereferences, throws std::invalid_argument; a missing signature component throws; an empty or negative component, or one outside [1, order-1], returns 0; a negative digest length returns -1 and a null digest with a positive length throws. The signature components are read from the module's guest Bignums as little-endian 64-bit limbs and verified with mbedtls against the key's public point. Error-queue entries for internal failures are not modelled, which the debt entry records.

The test signs through the parent ECDSA_sign and decodes the DER SEQUENCE { r, s }, then checks the valid case, a different digest, a flipped component byte, empty and negative components, the missing-component throw, and the null, no-group and no-public-key contracts.

Tested

Linux x86-64 (Debian 13, glibc 2.41, GCC 14.2.0), Release, BUILD_TESTING=ON, base main f9c2d92b91:

  • cmake --build build --target guest_libressl3_ecdsa_do_verify_tests --parallel 8: passed.
  • ctest --test-dir build -R '^guest_libressl3_ecdsa_do_verify$' --output-on-failure: 1/1 passed.
  • python3 tools/check_conventions.py --base origin/main: all checks passed.
  • Not run: Windows, a console or a title.

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
  • 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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5281465722 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19033). Originally posted by [fishingpvalues](https://github.com/fishingpvalues) on 2026-11-12T16:46:38Z. --- ### What `ECDSA_do_verify` leaves the throwing `AdditionalExports.cpp` stub and follows LibreSSL 4.0.0 `ecdsa.c`/`ecs_lib.c`: it returns 1 for a valid signature, 0 for an invalid one, and -1 for an internal error or a key without a group or public key. A null key, which LibreSSL dereferences, throws `std::invalid_argument`; a missing signature component throws; an empty or negative component, or one outside [1, order-1], returns 0; a negative digest length returns -1 and a null digest with a positive length throws. The signature components are read from the module's guest Bignums as little-endian 64-bit limbs and verified with mbedtls against the key's public point. Error-queue entries for internal failures are not modelled, which the debt entry records. The test signs through the parent `ECDSA_sign` and decodes the DER `SEQUENCE { r, s }`, then checks the valid case, a different digest, a flipped component byte, empty and negative components, the missing-component throw, and the null, no-group and no-public-key contracts. ### Tested Linux x86-64 (Debian 13, glibc 2.41, GCC 14.2.0), Release, `BUILD_TESTING=ON`, base `main` `f9c2d92b91`: - `cmake --build build --target guest_libressl3_ecdsa_do_verify_tests --parallel 8`: passed. - `ctest --test-dir build -R '^guest_libressl3_ecdsa_do_verify$' --output-on-failure`: 1/1 passed. - `python3 tools/check_conventions.py --base origin/main`: all checks passed. - Not run: Windows, a console or a title. ### 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 - [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
MarcZX10 commented 2026-11-20 13:31:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T13:31:05Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the implementation and its focused test are consistent with the stated contract, and the author-reported Linux checks passed.

What I ran

Reviewed head d4596f306f2c2e6a0022c21933ddd94f193b405f against main. I inspected the prepared diff and changed code through repo_read.py; I did not run commands or tests. The author reports a successful test build, focused CTest run, and conventions check on Linux x86-64.

Results

Check Result Note
Code review passed Changed implementation and test inspected
Focused test not run Linux pass reported by author
Windows and console not run Not covered

Findings

Blocking

None.

Non-blocking

None.

Not verified

I read all seven changed files listed in the manifest: core/libs/prx/libSceLibreSsl3/AdditionalExports.cpp, core/libs/prx/libSceLibreSsl3/CMakeLists.txt, core/libs/prx/libSceLibreSsl3/include/Api.hpp, core/libs/prx/libSceLibreSsl3/src/EcdsaDoVerify.cpp, core/libs/prx/libSceLibreSsl3/tests/EcdsaDoVerify.cpp, docs/dev/debt/changes/feat-libressl3-ecdsa-do-verify.md, and docs/dev/debt/changes/libressl3-20171-inventory.md. I also read the relevant BIGNUM, EC key and signature type definitions and the existing LibreSSL debt entry. Windows behavior, console behavior, and title compatibility were not verified. No precheck, negative control, or tests were run by me.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5993455072 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19033#pullrequestreview-5993455072). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T13:31:05Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the implementation and its focused test are consistent with the stated contract, and the author-reported Linux checks passed. ## What I ran Reviewed head `d4596f306f2c2e6a0022c21933ddd94f193b405f` against `main`. I inspected the prepared diff and changed code through `repo_read.py`; I did not run commands or tests. The author reports a successful test build, focused CTest run, and conventions check on Linux x86-64. ## Results | Check | Result | Note | |---|---|---| | Code review | passed | Changed implementation and test inspected | | Focused test | not run | Linux pass reported by author | | Windows and console | not run | Not covered | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified I read all seven changed files listed in the manifest: `core/libs/prx/libSceLibreSsl3/AdditionalExports.cpp`, `core/libs/prx/libSceLibreSsl3/CMakeLists.txt`, `core/libs/prx/libSceLibreSsl3/include/Api.hpp`, `core/libs/prx/libSceLibreSsl3/src/EcdsaDoVerify.cpp`, `core/libs/prx/libSceLibreSsl3/tests/EcdsaDoVerify.cpp`, `docs/dev/debt/changes/feat-libressl3-ecdsa-do-verify.md`, and `docs/dev/debt/changes/libressl3-20171-inventory.md`. I also read the relevant BIGNUM, EC key and signature type definitions and the existing LibreSSL debt entry. Windows behavior, console behavior, and title compatibility were not verified. No precheck, negative control, or tests were run by me. ## To get this to a good state Nothing is required.
ligmaSec commented 2026-12-03 11:54:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T11:54:16Z.

Review: COMMENTED


Compiled the changed ECDSA wrapper with the new EcdsaDoVerify fixture against the existing Linux PRXs. It passed valid signature, mismatch, and missing-argument cases and checked the three expected result classes.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6169234273 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19033#pullrequestreview-6169234273). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T11:54:16Z. **Review:** COMMENTED --- Compiled the changed ECDSA wrapper with the new `EcdsaDoVerify` fixture against the existing Linux PRXs. It passed valid signature, mismatch, and missing-argument cases and checked the three expected result classes. AI-assisted: yes.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/19033:upstream-pr/19033'
git switch 'upstream-pr/19033'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/19033'
git switch 'upstream-pr/19033'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/19033'
git switch 'upstream-pr/19033'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/19033'
git switch 'main'
git merge --squash 'upstream-pr/19033'
git switch 'main'
git merge --ff-only 'upstream-pr/19033'
git switch 'main'
git merge 'upstream-pr/19033'
git push origin 'main'
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!19033
No description provided.