feat(libSceLibreSsl3): implement EVP_get_digestbyname #16258

Merged
Ducengarth merged 3 commits from upstream-pr/16258 into main 2026-11-06 22:24:12 +00:00
Ducengarth commented 2026-11-06 01:19:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Ducengarth on 2026-11-06T01:19:18Z.


What

Implement EVP_get_digestbyname (Wm24hhTLqWM) in libSceLibreSsl3, replacing its parameterless throwing placeholder in AdditionalExports.cpp. Source: LibreSSL 4.0.0 at ce488b78, the revision the library's debt file already uses: evp_names.c (digest_names[], digest_cmp, EVP_get_digestbyname).

  • In 4.0.0 the lookup is a fixed, sorted table searched with bsearch and strcmp, not the old dynamic OBJ_NAME table, so there is no registration step (OpenSSL_add_all_digests) to depend on.
  • The table has the same 91 names, in the same order, as 4.0.0's digest_names[]. The SN_* and LN_* macros were resolved to strings from the same revision's objects/objects.txt. Their order is checked at compile time by a static_assert that the names strictly increase under strcmp, the property regress/lib/libcrypto/evp/evp_test.c checks. 44 of the names also appear in libSceLibreSsl's 2.5.4 ObjectTable.cpp; the other 47 belong to objects added after 2.5.4 or are plain aliases such as rmd160 and ssl3-sha1.
  • Matching is exact and case-sensitive, as in 4.0.0: SHA256, sha256, RSA-SHA256 and ssl3-sha1 match, Sha256, SHA-256 and sha256 do not. A null or unknown name returns null.
  • 43 names map to digests this library already has: EVP_md5, EVP_sha1, EVP_sha224, EVP_sha256, EVP_sha384 and EVP_sha512. The lookup returns the same pointer those functions return, so the result works with the forwarded EVP_Digest* functions.
  • The other 48 names map to digests AnyPS5 does not have yet (MD4, MD5-SHA1, RIPEMD-160, SHA-512/224, SHA-512/256, SHA-3 and SM3). They throw through NotImplemented_nid_no_patch, with the missing getter in the message, instead of returning null, which would tell the caller the name is unknown. When a digest lands (#15625 adds EVP_sha512_256), its case in Resolve becomes a return.
  • 4.0.0 calls OPENSSL_init_crypto(0, NULL) first and returns null if it fails. It only fails after OPENSSL_cleanup, which neither libSceLibreSsl3 nor libSceLibreSsl exports, so the call is left out.

The gap is recorded in docs/dev/debt/libSceLibreSsl3.md, and the export inventory is updated (170 exports, 160 named).

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

pr_overlap reports no pull request with the same exports or new files. The "same exports" it lists (Allocate, Align, Calloc, Free, PosixAlign, Realign, Reallocate) are the test's file-local guest-heap callbacks, which other tests also define. It could not compare 53 pull requests that conflict with main and share AdditionalExports.cpp, CMakeLists.txt, include/Api.hpp or the debt file. I checked their diffs by hand: none adds EVP_get_digestbyname, its NID or a digest name table. Line conflicts to expect:

  • #15625 (EVP_sha512_256) removes the placeholder right after this one in AdditionalExports.cpp and the declaration after it in Api.hpp. If it merges first, the Sha512_256 case in Resolve should return EVP_sha512_256 and the test's available count goes from 43 to 47; I will rebase and do that.
  • Most of the other libSceLibreSsl3 pull requests edit the export inventory count in the debt file and the neighbouring lines of CMakeLists.txt.

I scanned the libSceLibreSsl3 and libSceLibreSsl diffs of all 1888 open pull requests for EVP_get_digestbyname, and none adds it.

Tested

Windows 11, MinGW-w64 GCC (WinLibs), Release build. No title or homebrew, and not built on Linux or macOS.

  • guest_libressl3_digest_names (new) passes:
    • Every name: the test has its own copy of 4.0.0's 91 names with each name's getter. Each of the 43 available names returns the same pointer as its getter, and hashing a message through the forwarded EVP_Digest with the result matches mbedtls. Each of the 48 others throws and names its getter.
    • Unknown names: null, empty, prefixes and extensions (sha, sha2560), case and spacing variants, other spellings (SHA-256, SHA512/256), digests 4.0.0 does not list (md2, whirlpool, blake2b512), cipher names and non-digest object names all return null.
    • Long names: 4096-byte names return null.
    • Repeated lookups return the same objects.
  • Two deliberate bugs, a lookup that accepts the nearest name and SHA-224 resolving to SHA-256, both make the test fail.
  • All 73 guest_libressl* and guest_crypto_memcmp tests pass.
  • tools/check_test_registration.py passes.
  • objdump -p on libSceLibreSsl3.prx lists EVP_get_digestbyname_nid_postfix and no mbedtls_* symbol.
  • python3 tools/check_conventions.py --base upstream/main passes.

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

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5181308675 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16258). Originally posted by [Ducengarth](https://github.com/Ducengarth) on 2026-11-06T01:19:18Z. --- ### What Implement `EVP_get_digestbyname` (`Wm24hhTLqWM`) in `libSceLibreSsl3`, replacing its parameterless throwing placeholder in `AdditionalExports.cpp`. Source: LibreSSL 4.0.0 at [`ce488b78`](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/evp/evp_names.c), the revision the library's debt file already uses: `evp_names.c` (`digest_names[]`, `digest_cmp`, `EVP_get_digestbyname`). - In 4.0.0 the lookup is a fixed, sorted table searched with `bsearch` and `strcmp`, not the old dynamic `OBJ_NAME` table, so there is no registration step (`OpenSSL_add_all_digests`) to depend on. - The table has the same 91 names, in the same order, as 4.0.0's `digest_names[]`. The `SN_*` and `LN_*` macros were resolved to strings from the same revision's `objects/objects.txt`. Their order is checked at compile time by a `static_assert` that the names strictly increase under `strcmp`, the property `regress/lib/libcrypto/evp/evp_test.c` checks. 44 of the names also appear in libSceLibreSsl's 2.5.4 `ObjectTable.cpp`; the other 47 belong to objects added after 2.5.4 or are plain aliases such as `rmd160` and `ssl3-sha1`. - Matching is exact and case-sensitive, as in 4.0.0: `SHA256`, `sha256`, `RSA-SHA256` and `ssl3-sha1` match, `Sha256`, `SHA-256` and `sha256 ` do not. A null or unknown name returns null. - 43 names map to digests this library already has: `EVP_md5`, `EVP_sha1`, `EVP_sha224`, `EVP_sha256`, `EVP_sha384` and `EVP_sha512`. The lookup returns the same pointer those functions return, so the result works with the forwarded `EVP_Digest*` functions. - The other 48 names map to digests AnyPS5 does not have yet (MD4, MD5-SHA1, RIPEMD-160, SHA-512/224, SHA-512/256, SHA-3 and SM3). They throw through `NotImplemented_nid_no_patch`, with the missing getter in the message, instead of returning null, which would tell the caller the name is unknown. When a digest lands (#15625 adds `EVP_sha512_256`), its case in `Resolve` becomes a return. - 4.0.0 calls `OPENSSL_init_crypto(0, NULL)` first and returns null if it fails. It only fails after `OPENSSL_cleanup`, which neither `libSceLibreSsl3` nor `libSceLibreSsl` exports, so the call is left out. The gap is recorded in `docs/dev/debt/libSceLibreSsl3.md`, and the export inventory is updated (170 exports, 160 named). No title's trace or disassembly was used, and the export was not measured on a PS5. `pr_overlap` reports no pull request with the same exports or new files. The "same exports" it lists (`Allocate`, `Align`, `Calloc`, `Free`, `PosixAlign`, `Realign`, `Reallocate`) are the test's file-local guest-heap callbacks, which other tests also define. It could not compare 53 pull requests that conflict with `main` and share `AdditionalExports.cpp`, `CMakeLists.txt`, `include/Api.hpp` or the debt file. I checked their diffs by hand: none adds `EVP_get_digestbyname`, its NID or a digest name table. Line conflicts to expect: - #15625 (`EVP_sha512_256`) removes the placeholder right after this one in `AdditionalExports.cpp` and the declaration after it in `Api.hpp`. If it merges first, the `Sha512_256` case in `Resolve` should return `EVP_sha512_256` and the test's available count goes from 43 to 47; I will rebase and do that. - Most of the other libSceLibreSsl3 pull requests edit the export inventory count in the debt file and the neighbouring lines of `CMakeLists.txt`. I scanned the `libSceLibreSsl3` and `libSceLibreSsl` diffs of all 1888 open pull requests for `EVP_get_digestbyname`, and none adds it. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows 11, MinGW-w64 GCC (WinLibs), Release build. No title or homebrew, and not built on Linux or macOS. - `guest_libressl3_digest_names` (new) passes: - **Every name**: the test has its own copy of 4.0.0's 91 names with each name's getter. Each of the 43 available names returns the same pointer as its getter, and hashing a message through the forwarded `EVP_Digest` with the result matches mbedtls. Each of the 48 others throws and names its getter. - **Unknown names**: null, empty, prefixes and extensions (`sha`, `sha2560`), case and spacing variants, other spellings (`SHA-256`, `SHA512/256`), digests 4.0.0 does not list (`md2`, `whirlpool`, `blake2b512`), cipher names and non-digest object names all return null. - **Long names**: 4096-byte names return null. - **Repeated lookups** return the same objects. - Two deliberate bugs, a lookup that accepts the nearest name and SHA-224 resolving to SHA-256, both make the test fail. - All 73 `guest_libressl*` and `guest_crypto_memcmp` tests pass. - `tools/check_test_registration.py` passes. - `objdump -p` on `libSceLibreSsl3.prx` lists `EVP_get_digestbyname_nid_postfix` and no `mbedtls_*` symbol. - `python3 tools/check_conventions.py --base upstream/main` passes. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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)
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!16258
No description provided.