feat(libSceLibreSsl3): implement EVP_sha512_256 #15625

Merged
alvaroelpob merged 3 commits from upstream-pr/15625 into main 2026-11-10 11:43:00 +00:00
alvaroelpob commented 2026-11-03 22:17:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by alvaroelpob on 2026-11-03T22:17:01Z.


What

Implements EVP_sha512_256 in libSceLibreSsl3: the SHA-512/256 digest of LibreSSL 4.0.0 m_sha1.c (FIPS 180-4 initial hash, SHA-512 compression, 32-byte output), in the EVP_MD layout the forwarded libSceLibreSsl EVP_Digest* exports use.

Tested

Linux x86-64 (WSL2), Release: the full build passes and ctest --test-dir build -j16 passes 3829 of 3829 tests, including the new guest_libressl3_sha512_256. python3 tools/check_conventions.py --base upstream/main passes. Not run on a console or in a title.

Checklist

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5145352672 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15625). Originally posted by [alvaroelpob](https://github.com/alvaroelpob) on 2026-11-03T22:17:01Z. --- ### What Implements `EVP_sha512_256` in libSceLibreSsl3: the SHA-512/256 digest of LibreSSL 4.0.0 [`m_sha1.c`](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/evp/m_sha1.c#L321-L358) (FIPS 180-4 initial hash, SHA-512 compression, 32-byte output), in the `EVP_MD` layout the forwarded libSceLibreSsl `EVP_Digest*` exports use. ### 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. --> Linux x86-64 (WSL2), Release: the full build passes and `ctest --test-dir build -j16` passes 3829 of 3829 tests, including the new `guest_libressl3_sha512_256`. `python3 tools/check_conventions.py --base upstream/main` passes. Not run on a console or in a title. ### 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: #12945, #14366, #14889, #14890, #14992, #15031, #15045, #15119, #15289, #15303, #15449, #15472, #15514, #15544, #15591, #15599, #15616, #15618, #15620, #15622, #15623, #15624 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
BunnyFl commented 2026-11-04 02:32:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-04T02:32:12Z.

Review: APPROVED


@alvaroelpob thanks. The test's expected digests for "", "abc" and the two-block FIPS message (tests/Sha512_256.cpp:80, :81 and :83) are exactly what Python's hashlib.new('sha512_256') gives on this machine, so the initial hash and the truncation are right. The NIDs match LibreSSL 4.0.0's objects/obj_mac.num at the commit you cite: sha512_256 is 1030 and sha512_256WithRSAEncryption is 1026. Taking the first 32 bytes of the SHA-512 output after the custom initial state is the FIPS truncation.

What I ran: head 7c088237cf merged onto main 1c8c0efc8c, Windows 11, WinLibs GCC, Release:

  • guest_libressl3_sha512_256 and public_headers pass (2 of 2);
  • mutation, the first initial hash word changed from 0x22312194fc2bf72c to 0x22312194fc2bf72d: guest_libressl3_sha512_256 fails;
  • tools/check_conventions.py --base upstream/main on the head: all checks passed;
  • tools/pr_overlap.py --branch: no shared exports. None of the 10 PRs it couldn't compare adds EVP_sha512_256.

As on #15618, your open LibreSsl3 PRs conflict with one another on the export count line and adjacent lines.

Approving.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5762396201 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15625#pullrequestreview-5762396201). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-11-04T02:32:12Z. **Review:** APPROVED --- @alvaroelpob thanks. The test's expected digests for `""`, `"abc"` and the two-block FIPS message (`tests/Sha512_256.cpp:80`, `:81` and `:83`) are exactly what Python's `hashlib.new('sha512_256')` gives on this machine, so the initial hash and the truncation are right. The NIDs match LibreSSL 4.0.0's `objects/obj_mac.num` at the commit you cite: `sha512_256` is 1030 and `sha512_256WithRSAEncryption` is 1026. Taking the first 32 bytes of the SHA-512 output after the custom initial state is the FIPS truncation. **What I ran:** head `7c088237cf` merged onto `main` `1c8c0efc8c`, Windows 11, WinLibs GCC, Release: - `guest_libressl3_sha512_256` and `public_headers` pass (2 of 2); - mutation, the first initial hash word changed from `0x22312194fc2bf72c` to `0x22312194fc2bf72d`: `guest_libressl3_sha512_256` fails; - `tools/check_conventions.py --base upstream/main` on the head: all checks passed; - `tools/pr_overlap.py --branch`: no shared exports. None of the 10 PRs it couldn't compare adds `EVP_sha512_256`. As on #15618, your open LibreSsl3 PRs conflict with one another on the export count line and adjacent lines. Approving.
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!15625
No description provided.