feat(libSceLibreSsl3): implement ECDSA_do_sign #17626
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/17626"
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 GalaxyGamingFR on 2026-11-09T04:34:46Z.
What
Implement
ECDSA_do_signinlibSceLibreSsl3, replacing its parameterless throwing placeholder inAdditionalExports.cpp.ce488b78, the revision the library's debt file already uses. Inecdsa.cECDSA_do_signdispatches toecdsa_sign_sig, which returns a newECDSA_SIGholdingrands, or NULL when the key has no group or no private key.ECDSA_signis the same signature run throughi2d_ECDSA_SIG. A NULL key is dereferenced (key->meth).src/EcdsaSig.cpp, next toECDSA_SIG_new/ECDSA_SIG_set0/ECDSA_SIG_free. It does not touch the layout ofEcKeyand does not includeEc.hpp. It only calls libSceLibreSsl's exportedECDSA_size,ECDSA_sign,BN_bin2bnandBN_free. It signs into a buffer ofECDSA_sizebytes, decodes the DERSEQUENCE { INTEGER r, INTEGER s }(short or one/two-byte long lengths, so P-521 is covered), and stores the twoBIGNUMs withECDSA_SIG_set0.ECDSA_sizereturns 0 for a key without a group andECDSA_signreturns 0 for a key without a private key, so both return NULL like upstream. A malformed encoding fromECDSA_signcannot happen and throws (NotImplemented_nid_no_patch).Api.hppnow declares it asECDSA_SIG* ECDSA_do_sign(const unsigned char* digest, int digestLength, EC_KEY* key).EC_KEYis libSceLibreSsl'sEcKey, as theEC_KEY_*,ECDSA_signandECDSA_verifyexports are forwarded to the parent.ECDSA_SIGis the existing 16-byteLibreSsl3EcdsaSig.Gaps, recorded in
docs/dev/debt/libSceLibreSsl3.md:std::invalid_argument). A negative digest length, or a NULL digest with a nonzero length, throws through libSceLibreSsl'sECDSA_sign.EC_KEY_METHODdispatch is not modelled; the signature always comes from libSceLibreSsl's mbedtls-backedECDSA_sign.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/EcdsaDoSign.cppinto one executable withsrc/EcdsaSig.cpp, libSceLibreSsl'sEc.cppandBignum.cpp, and the3rdparty/mbedtlslibrary sources.APS5_VABIwas defined empty, and I added a stand-in shim:NotImplementedAt_nid_no_patchthrows,HostEntropy_nid_no_patchis seeded for key generation and signing,LibreSslPutError_nid_no_patchis a no-op, andApplicationHeapRegister_nid_no_patch/malloc_nid_postfix/calloc_nid_postfix/free_nid_postfixroute to the registered allocator and abort if none is registered. No title or homebrew, and not built on Linux or macOS.The test passes. Since
ECDSA_SIG_newandBN_bin2bnallocate from the application heap, it registers a counting heap astests/BignumDivide.cppdoes. It checks the following:ECDSA_verifyagainst a separate key holding only its public keyrandsare positive, no wider than the degree, their DER re-encoding fits inECDSA_sizeand verifies withECDSA_verify, a different digest does not verify, and a second signature of the same digest differs and also verifiesEvery block allocated on the heap is freed at the end.
A deliberate bug makes the test fail: swapping
randsin theECDSA_SIG_set0call fails at line 152 (the verification).-Wall -Wextrais clean for the touched files, andg++ -fsyntax-onlypasses onsrc/EcdsaSig.cpp,AdditionalExports.cppand the test.python tools/check_conventions.py --base origin/mainandgit diff --checkpass.Just before opening this, I searched open pull requests for
ECDSA_do_signand found none (the two closed/merged hits, #10407 and #15827, are the libSceLibreSsl EC work this builds on). This PR is independent of #17621 and #17622: it uses another source file and its CMake lines go in another place. It changes the export inventory count line in the debt file, as do #17621, #17622, #16586, #16588, #16589, #16848 and #16918, so whichever lands later needs a one-line rebase.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
Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-18T07:23:38Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this review; the review folder and repository source were not accessible through the available tools.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T08:51:51Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the implementation and included coverage support merging, with console behavior still unverified.
What I ran
Reviewed head
7a9dd284b8835ca5db44ab4f56f5843b6b7a7f62and its prepared diff. No commands or tests were run in this review; the test results in the PR description are author-reported.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
PS5 behavior, Linux and macOS builds, and the author-reported Windows test execution were not independently verified. The changed files read were
core/libs/prx/libSceLibreSsl3/AdditionalExports.cpp,core/libs/prx/libSceLibreSsl3/CMakeLists.txt,core/libs/prx/libSceLibreSsl3/include/Api.hpp,core/libs/prx/libSceLibreSsl3/src/EcdsaSig.cpp,core/libs/prx/libSceLibreSsl3/tests/EcdsaDoSign.cpp, anddocs/dev/debt/changes/feat-libressl3-ecdsa-do-sign.md. The manifest lists six changed files, all included; none were excluded.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-30T08:54:15Z.
Review: COMMENTED
Actionable comments posted: 1
Architecture findings (1)
Advisory architecture findings (1)
ee8a757b-110c-4825-a224-1833ba9d5c2fReviewing files that changed from the base of the PR and between
1b8f79a5b5and7a9dd284b8.core/libs/prx/libSceLibreSsl3/AdditionalExports.cppcore/libs/prx/libSceLibreSsl3/CMakeLists.txtcore/libs/prx/libSceLibreSsl3/include/Api.hppcore/libs/prx/libSceLibreSsl3/src/EcdsaSig.cppcore/libs/prx/libSceLibreSsl3/tests/EcdsaDoSign.cppdocs/dev/debt/changes/feat-libressl3-ecdsa-do-sign.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T10:18:24Z.
Review: COMMENTED
Reviewed — no blocking findings
The implementation is consistent with the stated DER conversion approach; no blocking defect was verified, but the submitted test and build claims could not be run in this review.
What I ran
Reviewed head
6286f3cbd2b32abdf2c96309b9144cbeac035f3dusing the prepared review bundle andrepo_read.pyreader. No commands or tests were executed; no merged-preview check was performed.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The implementation was not compiled or executed in this review. Windows build/test claims and behavior on Linux, macOS, and a PS5 remain unverified. No file was excluded: all six files marked
changedin the manifest were read, including every added line.AdditionalExports.cpphas no added lines.To get this to a good state
Nothing is required.