feat(libSceLibreSsl3): implement MD5 and SHA1 #9043

Merged
HQasper merged 3 commits from upstream-pr/9043 into main 2026-10-23 00:00:09 +00:00
HQasper commented 2026-10-21 10:38:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by HQasper on 2026-10-21T10:38:05Z.


What

All 87 libSceLibreSsl3 exports threw. This implements the MD5 and SHA1 one-shots. CRYPTO_memcmp is left to #8956, which implements it first; this PR is built on top of it.

  • MD5(d, n, md) and SHA1(d, n, md) run Init, Update and Final through libSceLibreSsl's MD5_* and SHA1_* (#9025), so there is a single digest implementation. They return md. libSceLibreSsl3 links libSceLibreSsl, and the patched module imports the six NIDs, which libSceLibreSsl exports.
  • A null digest buffer throws through NotImplemented_nid_no_patch. LibreSSL up to 3.8 hashes into a static buffer and returns it, while later versions do not check the argument, and the console's version is unknown.
  • The debt entry records this, and the pending-export count goes from 86 (after #8956) to 84. The CMakeLists.txt that #8956 adds now also builds src/Digest.cpp, links libSceLibreSsl and adds the new test next to #8956's.

Tested

Linux (Ubuntu 24.04.5 container, GCC 13.3, Release, BUILD_TESTING=ON):

  • New guest_libressl3_digest: passed. It checks MD5 and SHA1 against the RFC 1321 and FIPS 180 values for abc, the empty string and one million a, and that they write only the digest length and return the buffer. It also checks the throwing cases.
  • guest_crypto_memcmp (from #8956), guest_libressl_digest (from #9025) and patched_libraries: passed. The patched libSceLibreSsl3.prx needs libSceLibreSsl.prx, and all six imported NIDs are defined there. Its export set is unchanged (87 names).
  • python3 tools/check_conventions.py --base origin/main: passed.
  • Not tested: Windows, and any title or homebrew.

Note: until #8956 and #9025 merge, this PR also shows their commits. After they merge, I rebase it onto main so only its own commit is left.

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: #8956, #9025
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4950218017 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9043). Originally posted by [HQasper](https://github.com/HQasper) on 2026-10-21T10:38:05Z. --- ### What All 87 libSceLibreSsl3 exports threw. This implements the `MD5` and `SHA1` one-shots. `CRYPTO_memcmp` is left to #8956, which implements it first; this PR is built on top of it. - `MD5(d, n, md)` and `SHA1(d, n, md)` run `Init`, `Update` and `Final` through libSceLibreSsl's `MD5_*` and `SHA1_*` (#9025), so there is a single digest implementation. They return `md`. libSceLibreSsl3 links libSceLibreSsl, and the patched module imports the six NIDs, which libSceLibreSsl exports. - A null digest buffer throws through `NotImplemented_nid_no_patch`. LibreSSL up to 3.8 hashes into a static buffer and returns it, while later versions do not check the argument, and the console's version is unknown. - The debt entry records this, and the pending-export count goes from 86 (after #8956) to 84. The `CMakeLists.txt` that #8956 adds now also builds `src/Digest.cpp`, links libSceLibreSsl and adds the new test next to #8956's. ### Tested Linux (Ubuntu 24.04.5 container, GCC 13.3, Release, `BUILD_TESTING=ON`): - New `guest_libressl3_digest`: passed. It checks `MD5` and `SHA1` against the RFC 1321 and FIPS 180 values for `abc`, the empty string and one million `a`, and that they write only the digest length and return the buffer. It also checks the throwing cases. - `guest_crypto_memcmp` (from #8956), `guest_libressl_digest` (from #9025) and `patched_libraries`: passed. The patched `libSceLibreSsl3.prx` needs `libSceLibreSsl.prx`, and all six imported NIDs are defined there. Its export set is unchanged (87 names). - `python3 tools/check_conventions.py --base origin/main`: passed. - Not tested: Windows, and any title or homebrew. Note: until #8956 and #9025 merge, this PR also shows their commits. After they merge, I rebase it onto main so only its own commit is left. ### 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 (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: #8956, #9025 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-21 10:38:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-21T10:38:56Z.


Progress report (950388b → 71ce2fe)

📈 System libraries: 42.29% (+0.19%, +21 implemented functions)

✅ 21 implemented
Library Name
libSceLibreSsl MD4_Final_nid_postfix
libSceLibreSsl MD4_Init_nid_postfix
libSceLibreSsl MD4_Update_nid_postfix
libSceLibreSsl MD5_Final_nid_postfix
libSceLibreSsl MD5_Init_nid_postfix
libSceLibreSsl MD5_Update_nid_postfix
libSceLibreSsl SHA1_Final_nid_postfix
libSceLibreSsl SHA1_Init_nid_postfix
libSceLibreSsl SHA1_Update_nid_postfix
libSceLibreSsl SHA224_Final_nid_postfix
libSceLibreSsl SHA224_Init_nid_postfix
libSceLibreSsl SHA224_Update_nid_postfix
libSceLibreSsl SHA256_Final_nid_postfix
libSceLibreSsl SHA256_Init_nid_postfix
libSceLibreSsl SHA256_Update_nid_postfix
libSceLibreSsl SHA384_Final_nid_postfix
libSceLibreSsl SHA384_Init_nid_postfix
libSceLibreSsl SHA384_Update_nid_postfix
libSceLibreSsl SHA512_Init_nid_postfix
libSceLibreSsl SHA512_Update_nid_postfix
libSceLibreSsl3 CRYPTO_memcmp_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6313941275 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9043#issuecomment-6313941275). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-21T10:38:56Z. --- <!-- progress-report --> ### Progress report (950388b → 71ce2fe) 📈 **System libraries**: 42.29% (+0.19%, +21 implemented functions) <details> <summary>✅ 21 implemented</summary> | Library | Name | | - | - | | libSceLibreSsl | `MD4_Final_nid_postfix` | | libSceLibreSsl | `MD4_Init_nid_postfix` | | libSceLibreSsl | `MD4_Update_nid_postfix` | | libSceLibreSsl | `MD5_Final_nid_postfix` | | libSceLibreSsl | `MD5_Init_nid_postfix` | | libSceLibreSsl | `MD5_Update_nid_postfix` | | libSceLibreSsl | `SHA1_Final_nid_postfix` | | libSceLibreSsl | `SHA1_Init_nid_postfix` | | libSceLibreSsl | `SHA1_Update_nid_postfix` | | libSceLibreSsl | `SHA224_Final_nid_postfix` | | libSceLibreSsl | `SHA224_Init_nid_postfix` | | libSceLibreSsl | `SHA224_Update_nid_postfix` | | libSceLibreSsl | `SHA256_Final_nid_postfix` | | libSceLibreSsl | `SHA256_Init_nid_postfix` | | libSceLibreSsl | `SHA256_Update_nid_postfix` | | libSceLibreSsl | `SHA384_Final_nid_postfix` | | libSceLibreSsl | `SHA384_Init_nid_postfix` | | libSceLibreSsl | `SHA384_Update_nid_postfix` | | libSceLibreSsl | `SHA512_Init_nid_postfix` | | libSceLibreSsl | `SHA512_Update_nid_postfix` | | libSceLibreSsl3 | `CRYPTO_memcmp_nid_postfix` | </details>
blawesom commented 2026-10-21 17:06:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-21T17:06:36Z.


Support triage — overlap note: this PR's CRYPTO_memcmp for libSceLibreSsl3 (Export.cpp removal + Digest.cpp implementation, constant-time XOR fold) is the same function #8956 (ynkmyz233, opened earlier) implements in libSceLibreSsl3/Export.cpp with its own test file. Whichever lands first will conflict the other in Export.cpp; please coordinate with the author of #8956 and declare Depends on on the checklist line. Note the two implementations differ subtly: #8956 reads through volatile pointers to defeat compiler optimization of the fold; this one does not — worth aligning on the constant-time property either way.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6321842017 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9043#issuecomment-6321842017). Originally posted by [blawesom](https://github.com/blawesom) on 2026-10-21T17:06:36Z. --- Support triage — overlap note: this PR's `CRYPTO_memcmp` for `libSceLibreSsl3` (Export.cpp removal + Digest.cpp implementation, constant-time XOR fold) is the same function #8956 (ynkmyz233, opened earlier) implements in `libSceLibreSsl3/Export.cpp` with its own test file. Whichever lands first will conflict the other in `Export.cpp`; please coordinate with the author of #8956 and declare `Depends on` on the checklist line. Note the two implementations differ subtly: #8956 reads through `volatile` pointers to defeat compiler optimization of the fold; this one does not — worth aligning on the constant-time property either way.
ycbuzi commented 2026-10-21 17:51:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ycbuzi on 2026-10-21T17:51:09Z.


Windows run of 352eae4f2a merged onto main 745b394629 (650f732293, clean), the platform the description lists as not tested. Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, BUILD_TESTING=ON.

Built libSceLibreSsl, libSceLibreSsl3, guest_libressl_digest_tests and guest_libressl3_digest_tests with no errors or warnings. ctest --repeat until-fail:2 on guest_libressl_digest and guest_libressl3_digest: both pass on both repeats. Not run: a title.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6322739638 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9043#issuecomment-6322739638). Originally posted by [ycbuzi](https://github.com/ycbuzi) on 2026-10-21T17:51:09Z. --- Windows run of 352eae4f2a merged onto `main` 745b394629 (650f732293, clean), the platform the description lists as not tested. Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, `BUILD_TESTING=ON`. Built `libSceLibreSsl`, `libSceLibreSsl3`, `guest_libressl_digest_tests` and `guest_libressl3_digest_tests` with no errors or warnings. `ctest --repeat until-fail:2` on `guest_libressl_digest` and `guest_libressl3_digest`: both pass on both repeats. Not run: a title.
HQasper commented 2026-10-21 18:05:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by HQasper on 2026-10-21T18:05:33Z.


@blawesom Thanks for the note. #8956 is older, so it goes first. I have removed CRYPTO_memcmp from this PR and rebuilt it on top of #8956, so it now only implements MD5 and SHA1 and no longer conflicts with #8956. The checklist says Depends on: #8956, #9025. Until both merge, this PR also shows their commits, and I will rebase it onto main after they land.

@ycbuzi Thanks for validating the Windows build and confirming guest_libressl_digest and guest_libressl3_digest pass on repeated runs. Much appreciated.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6323023322 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9043#issuecomment-6323023322). Originally posted by [HQasper](https://github.com/HQasper) on 2026-10-21T18:05:33Z. --- @blawesom Thanks for the note. #8956 is older, so it goes first. I have removed `CRYPTO_memcmp` from this PR and rebuilt it on top of #8956, so it now only implements `MD5` and `SHA1` and no longer conflicts with #8956. The checklist says Depends on: #8956, #9025. Until both merge, this PR also shows their commits, and I will rebase it onto `main` after they land. @ycbuzi Thanks for validating the Windows build and confirming `guest_libressl_digest` and `guest_libressl3_digest` pass on repeated runs. Much appreciated.
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!9043
No description provided.