feat(libSceLibreSsl): implement EVP_PKEY_new and EVP_PKEY_free #10570
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10570"
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 MarcZX10 on 2026-10-24T10:22:50Z.
What
Implements
EVP_PKEY_newandEVP_PKEY_freein libSceLibreSsl. The 56-byte key follows the LP64 layout of LibreSSL 2.5.4'sEVP_PKEY(type, save_type, references, ameth, engine, key, save_parameters, attributes); a new key has type and save_typeEVP_PKEY_NONE, one reference andsave_parametersset.EVP_PKEY_freeaccepts null, drops one reference atomically and releases the key on the last one. A key that holds an engine, method, algorithm data or attributes throws throughNotImplemented_nid_no_patch, because no export can attach them yet.Sources are linked in the technical debt file. PS5 behavior has not been independently measured.
Commits: for each function in turn (
EVP_PKEY_new, thenEVP_PKEY_free), the implementation, its test and its debt entry.The first field is the key type, so this layout matches the one
EVP_PKEY_idreads in #10418. Both PRs edit adjacent lines ofExport.cppandCMakeLists.txt, so expect a textual conflict, with no code dependency.Tested
On the rebased head, compiled
PkeyLifecycle.cppandGuestLibreSslPkeyLifecycle.cppwith GCC C++20,-Wall -Wextra -Werror, and a local shim for the guest allocator and throw path; the focused lifecycle test exited 0.git diff --checkandpython3 tools/check_conventions.py --base upstream/main --head HEADpass. A full CMake configure could not be repeated from this isolated checkout because its SDL2 submodule is not populated and XRandR is unavailable; Windows was not run.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 harisibrar1 on 2026-10-24T12:29:19Z.
Review: COMMENTED
Checked against main
87666fc5d6and LibreSSL 2.5.4 (evp/p_lib.c and evp/evp.h at 2e2c612):EVP_PKEY_new, andEVP_PKEY_free's decrement /<= 0release match p_lib.c:186-205 and 402-418. Usingmalloc_nid_postfix/free_nid_postfixpairs correctly with main'sCRYPTO_free, and throwing (with the reference restored) for keys that carry ameth/engine/key/attributes seems right while nothing can attach them.evp_local.hlink in the debt entry is 404 at 2e2c612; that header was added in later LibreSSL releases. In 2.5.4,struct evp_pkey_stis insrc/lib/libcrypto/evp/evp.h(lines 124-149). Could the link point there?libSceLibreSsl/CMakeLists.txt, insert test blocks at the same spot, and edit the same debt count line, so whichever merges second will need a rebase, and the count should end at 354.Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
Imported from boykopovar/AnyPS5. Originally posted by ahmadmuj on 2026-10-25T18:06:50Z.
Review: APPROVED
Checked head
48b67ca8merged onto main7a25f876, Linux, GCC 13, Release. Only the debt file conflicts (I kept main's side locally), so that part still needs the rebase.What I ran:
guest_libressl_pkey_lifecycle_testson the merge.ctest -R guest_libressl_pkey_lifecyclepasses. WithEVP_PKEY_newswapped back to aNotImplemented_nid_no_patchstub it aborts, so the test really goes red to green.sizeof(EVP_PKEY)56, offsets 0/4/8/16/24/32/40/48, andEVP_PKEY_newgives type 0, save_type 0, references 1, null pointers, save_parameters 1. The PR's object has the same values at the same offsets, with the padding zeroed.check_conventions.pypasses. Export.cpp goes from 345 to 343NotImplemented_nid_no_patch(__func__)stubs, which matches the debt count.Two non-blocking test notes:
pkey->saveParameters = 1;still passes (I tried it). One more read at offset 40 would pin it, e.g.int saveParameters; std::memcpy(&saveParameters, static_cast<std::byte*>(pkey) + 40, sizeof(saveParameters)); Require(saveParameters == 1, "a new key saves parameters");references.fetch_add(1, ...)restore also passes. Main's LibreSSL tests do pin throw paths (RequireThrowsincore/libs/prx/libSceLibreSsl/tests/Asn1.cpp), so the old block that set offset 32, caught the throw and checked references == 1 would fit there.Approving on the evidence above.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-02T04:57:33Z.
Review: COMMENTED
Reviewed — debt count and conflict requests checked, count not confirmed against main
The head is now mergeable and the debt count matches this head's Export.cpp, but the reviewer's 298 was computed on an older base and is not confirmed here.
What I ran
a644edf30c).Results
Findings
Sources
github.com/boykopovar/AnyPS5@463b949628/docs/dev/debt/libSceLibreSsl.md (L12)github.com/boykopovar/AnyPS5@463b949628/core/libs/prx/libSceLibreSsl/Export.cpp (L705-L725)Not verified