feat(libSceLibreSsl3): implement EVP digest contexts and SHA methods #10960
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10960"
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 AZLisme on 2026-10-25T11:21:36Z.
What
Implement
EVP_MD_CTX_new,EVP_MD_CTX_free,EVP_DigestInit,EVP_sha1andEVP_sha224with guest-heap ownership and SysV callbacks. The opaque SSL3 types share the legacy provider's 120-byte method / 48-byte context representation so its ordinary digest operations can consume these records. Engine and owned-key-context handling remains explicit throwing debt; the documented host representation differs from native firmware layouts.Current head
176068deee632b72a753f1495852b8e8e8a3df56incorporates B-Howell's preserving mergeb81773f7and frozen main1e24993fa3a7da25e8fc27152af654687ba64552. The CMake/debt resolutions retain both sides, including current main's X509, error and initialization work. The five EVP implementations and their fixtures are unchanged. All declared prerequisites (#10948, #11165 and #9448) are actually merged.Tested
176068deee632b72a753f1495852b8e8e8a3df56on frozen main1e24993fa3a7da25e8fc27152af654687ba64552: normal Linux x86-64/GCC 16.2.1 Release providers and original core fixtures built. 69 runtime CTests and 65 public-header CTests passed, zero failures/skips. The runtime set includes LibreSSL/SSL3, crypto, 10 libSceSsl cases and mixed EVP in both requested load orders (3,824 cases each). It covers main's new X509, OCSP, cipher and initialization fixtures.libsbuild and its existing protocol dependencies completed successfully. The two protocol cases andpatched_librariespassed 3/3 after the 66 core cases, giving 69 unique runtime passes: each protocol exercised 7,056 generated pairs; 406 patched libraries loaded with zero failures. Dependencies, assertions and timeouts are unchanged.176068dewith frozen main1e24993f, built the full normal libraries and 57 original fixture targets, and passed 68/68 runtime plus 65/65 public-header tests, zero failures/skips/NotRun. This includes both EVP providers, protocol/NID fixtures, current main's added family fixtures and 406 patched libraries loaded, zero failed. Linux-only mixed-EVP has no Windows registration and was not run there. Actual CTest selection, executable targets, source identity and complete unique JUnit results were checked.X509_PUBKEY_get0_paramis retained.python3 tools/check_conventions.py --base origin/mainand the topic whitespace check pass.4a33c0bfwith frozen maind1ae628b: 59 runtime plus 65 header tests passed; 405 patched libraries loaded. Historical upstream run 41603606859 tested4a33c0bfwith main4f41f4c3: 2,116 passed, 976 skipped, zero failed; all 63 then-selected SSL-family cases passed. Neither historical run qualifies this current integration; skipped cases remain unexecuted.No current macOS, title execution, native-console ABI, GPU or full-project test result is claimed. Representation and unsupported-operation gaps remain documented debt.
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-25T12:06:58Z.
Review: APPROVED
Reviewed exact head
1f580e6c39c7c3d5bebaf80d47a602b97da32062against the pinned LibreSSLevp_digest.candevp_local.h. The SHA descriptors and context offsets/sizes match the stated 64-bit ABI layout; init/update/final callbacks route to existing SHA implementations with their expected context types. Allocation, secure clearing, cleanup-once, REUSE, CLEANED, and KEEP_PKEY_CTX handling follow the reference cleanup/init rules, with unsupported owned key-context and negative-size cases left explicit as debt. The tests cover known and million-byte vectors, split updates, custom descriptors, callbacks, allocation failure and ownership transitions. Localgit diff --checkandpython3 tools/check_conventions.py --base upstream/main --head refs/review/10960passed. Hosted eligibility, intake, conventions, labels, and report checks pass; hosted product jobs were skipped. I have not independently rerun the author-reported Linux focused suite or differential checks; Windows, macOS, and console execution remain unverified.Imported from boykopovar/AnyPS5. Originally posted by ahmadmuj on 2026-10-25T19:01:47Z.
Review: COMMENTED
Checked head
9e30098fa6c6(base5949d8bf924b; also merges clean onto maine1ef22e888d7). Linux, GCC 13.3, Release + an ASan build.What I ran:
guest_libressl3_evpon the head: pass.check_conventions.py --base origin/main: pass.evp_md_st/evp_md_ctx_stfromevp_local.hat ce488b78: 80 and 40 bytes, every offset matches your static_asserts. The SHA1/SHA224 descriptor values matchm_sha1.c(ctx_size 104/120 = 8 + 96/112).5994190d7094, 2.5.4 layouts) on top of this branch and ran a probe through both libraries.The 4.0.0 layout here is right on its own. The issue is what serves the rest of the digest API for a libSceLibreSsl3 title:
EVP_DigestInit_ex,EVP_DigestUpdate,EVP_DigestFinal_ex,EVP_Digest,EVP_MD_CTX_cleanup, andEVP_md5. Our libSceLibreSsl3 only implements the 89 extra names.libSceLibreSsl3.prxhasDT_NEEDED libSceLibreSsl.prx.LD_DEBUG=bindingson an exe that only needs libSceLibreSsl3 shows6LrAQY0Ka4c(EVP_DigestUpdate) bound tolibSceLibreSsl.prx.EVP_MD_CTX_new+ l3EVP_DigestInit+ l1EVP_DigestUpdate. Once #9448 lands, that l1 code reads its 48-byte/120-byte layout.Composed run (this PR + #9448), SHA1/SHA224 "abc", 56 and 1000 bytes:
EVP_DigestInit(ctx, EVP_sha1())-> l1EVP_DigestUpdate: ASanheap-buffer-overflow ... READ of size 8 ... 0 bytes after 40-byte regionat libSceLibreSslEvp.cpp:201(readsupdateat 40). The release build crashes.EVP_DigestInit_ex(ctx, EVP_sha1(), NULL): ASanglobal-buffer-overflow ... 24 bytes after global variable 'Sha1' ... of size 80atEvp.cpp:183(readsctx_sizeat 104). The release build crashes here too.The reverse also applies (read from the layouts, not run): l3
EVP_DigestInit(ctx, EVP_md5())gets #9448's 120-byte md5 descriptor and readsctx_sizeat 68, which in 2.5.4 is the upper half ofsign.The debt entry says the engine-bearing layout is incompatible. It frames that as a custom-method issue, though. The everyday new/init/update/final path breaks the same way.
Two ways out that I can see:
EvpMd/EvpMdContextlayout in l3 too. In 4.0.0 both structs live inevp_local.h, so an l3 guest has no public way to see the size or offsets. Then the shared l1 functions just work. This needs #9448 first.EVP_MD/EVP_MD_CTX, so l3 imports stop falling through to l1. That is a much bigger surface.I'd lean to 1, but either way it's worth settling with #9448 before both merge. Today on main the l1 functions are stubs, so nothing breaks yet; the break comes with whichever of the two lands second.
Small one: the debt text calls negative
ctx_size"undefined inputs". UpstreamEVP_MD_CTX_freewithmd_data == NULLfrees normally, andEVP_DigestInitgetscallocfailure and returns 0. The throw is fine; only the wording is off.