test(libSceLibreSsl): guard SHA padding and digest output extents #14283

Merged
StoneDC merged 1 commit from upstream-pr/14283 into main 2026-11-05 08:46:11 +00:00
StoneDC commented 2026-11-01 06:18:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by StoneDC on 2026-11-01T06:18:41Z.


What

Guards SHA-256 and SHA-512 input, existing context storage and exact 32/64-byte digest outputs. Twenty message lengths cross the 56/64-byte and 112/128-byte padding boundaries, with five update chunk sizes per algorithm. Existing known-answer tests use ordinary arrays and canaries.

Implementation basis: SHA-256/SHA-512 digest semantics follow FIPS 180-4; literals were generated independently with Python hashlib for the stated deterministic byte pattern. Tests use the canonical Sha256Context/Sha512Context declarations and actual Init/Update/Final functions without introducing a layout. FIPS 180-4.

Known limits: Does not validate a firmware context layout, EVP private fields, side channels or other digest algorithms.

Source and canonical declarations: core/libs/prx/libSceLibreSsl/src/Digest.cpp; core/libs/prx/libSceLibreSsl/include/Api.hpp.

One independent commit e5ea5512af20f4b35d0c8f546ceea6e3d0a53ed8 on synchronized main 588f2f6fe3a41f795bc4143b2369e4bee7b26605. A final merge check against main 3ee28266a3eea1f59d7ecead00b1e760f778ccac passed. The repository overlap checker against 3ee28266a3eea1f59d7ecead00b1e760f778ccac reported no confirmed overlap. It could not finish full-branch comparisons for older PRs already conflicting with main: #9446, #9448, #10078, #10418, #10508, #10570, #11003, #11128, #11129, #11138, #11143, #11146, #11151, #11175, #11176, #11359, #11466, #12729, #12730, #13266, #13285, #13546, #13547, #13877. Shared-file diffs were inspected separately. 22 scoped file changes projected onto main and then combined with this topic without a new conflict; 2 scoped peer changes already conflict with main and are not claimed automatically mergeable. They do not supply this boundary-test matrix. The target and fixture are self-contained and use APIs already on main; no other PR must land first. Shared registration changes made before landing require a refreshed merge/test check. No new production exports, ABI layouts, dependencies or production behavior changes are introduced.

Tested

Exact topic head: e5ea5512af20f4b35d0c8f546ceea6e3d0a53ed8. Product validation used integration e793e5fbb89451d5daf6d1d7783b8b6dc909a019, containing all ten independent topic heads and current main 3ee28266a3eea1f59d7ecead00b1e760f778ccac. Ubuntu/WSL GCC 15.2; Windows MinGW GCC 15.2; both C++20.

This registered fixture exercises the actual library through canonical headers, with OS-protected/read-only pages: 200 cases passed on each platform. Linux and Windows each passed all 10 new tests and 10 related existing tests, with zero skips. New-test command: ctest --test-dir <build> -R '^(guest_random_extent|guest_zlib_window|guest_jpeg_encode_capacity|guest_png_input_extent|guest_jpeg_input_extent|guest_digest_extents|guest_unicode_extents|guest_icu_version_extents|guest_outline_bounds_extents|guest_rtc_parse_extents)$' -j 8 -V --output-on-failure. Each new test has a 20-second timeout and completed below 1 second locally.

cmake --build <linux-full-build> --parallel 8: complete default Linux product build passed. Windows used the full configuration, built the ten new and ten related test targets plus relinker with --parallel 8, and ran both filtered CTest groups; a complete default Windows build is not claimed.

Fault-detection control on Linux: exact fixture head e5ea5512af20f4b35d0c8f546ceea6e3d0a53ed8, module context ced276fb83b0404be919f0597b2d030f42c7ae13. The complete production source unit was compiled and linked into the actual shared module using the product compile/link commands and its other unchanged module objects. The registered fixture passed with that unchanged module and failed after this deliberate defect in SHA256_Final_nid_postfix: digest[32] = 0;. This is a separate module-injection control, not PS5 execution.

Conventions (including this body), whitespace, test registration and public-header declaration/umbrella audits passed. No PS5 hardware, game-title, macOS, WASM or GPU runtime validation is claimed. Hosted CI is not a local result and is pending when this PR opens.

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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5104958570 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14283). Originally posted by [StoneDC](https://github.com/StoneDC) on 2026-11-01T06:18:41Z. --- ### What Guards SHA-256 and SHA-512 input, existing context storage and exact 32/64-byte digest outputs. Twenty message lengths cross the 56/64-byte and 112/128-byte padding boundaries, with five update chunk sizes per algorithm. Existing known-answer tests use ordinary arrays and canaries. Implementation basis: SHA-256/SHA-512 digest semantics follow FIPS 180-4; literals were generated independently with Python hashlib for the stated deterministic byte pattern. Tests use the canonical Sha256Context/Sha512Context declarations and actual Init/Update/Final functions without introducing a layout. [FIPS 180-4](https://csrc.nist.gov/pubs/fips/180-4/upd1/final). Known limits: Does not validate a firmware context layout, EVP private fields, side channels or other digest algorithms. Source and canonical declarations: [core/libs/prx/libSceLibreSsl/src/Digest.cpp](https://github.com/boykopovar/AnyPS5/blob/588f2f6fe3a41f795bc4143b2369e4bee7b26605/core/libs/prx/libSceLibreSsl/src/Digest.cpp); [core/libs/prx/libSceLibreSsl/include/Api.hpp](https://github.com/boykopovar/AnyPS5/blob/588f2f6fe3a41f795bc4143b2369e4bee7b26605/core/libs/prx/libSceLibreSsl/include/Api.hpp). One independent commit `e5ea5512af20f4b35d0c8f546ceea6e3d0a53ed8` on synchronized main `588f2f6fe3a41f795bc4143b2369e4bee7b26605`. A final merge check against main `3ee28266a3eea1f59d7ecead00b1e760f778ccac` passed. The repository overlap checker against `3ee28266a3eea1f59d7ecead00b1e760f778ccac` reported no confirmed overlap. It could not finish full-branch comparisons for older PRs already conflicting with main: #9446, #9448, #10078, #10418, #10508, #10570, #11003, #11128, #11129, #11138, #11143, #11146, #11151, #11175, #11176, #11359, #11466, #12729, #12730, #13266, #13285, #13546, #13547, #13877. Shared-file diffs were inspected separately. 22 scoped file changes projected onto main and then combined with this topic without a new conflict; 2 scoped peer changes already conflict with main and are not claimed automatically mergeable. They do not supply this boundary-test matrix. The target and fixture are self-contained and use APIs already on main; no other PR must land first. Shared registration changes made before landing require a refreshed merge/test check. No new production exports, ABI layouts, dependencies or production behavior changes are introduced. ### 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. --> Exact topic head: `e5ea5512af20f4b35d0c8f546ceea6e3d0a53ed8`. Product validation used integration `e793e5fbb89451d5daf6d1d7783b8b6dc909a019`, containing all ten independent topic heads and current main `3ee28266a3eea1f59d7ecead00b1e760f778ccac`. Ubuntu/WSL GCC 15.2; Windows MinGW GCC 15.2; both C++20. This registered fixture exercises the actual library through canonical headers, with OS-protected/read-only pages: 200 cases passed on each platform. Linux and Windows each passed all 10 new tests and 10 related existing tests, with zero skips. New-test command: `ctest --test-dir <build> -R '^(guest_random_extent|guest_zlib_window|guest_jpeg_encode_capacity|guest_png_input_extent|guest_jpeg_input_extent|guest_digest_extents|guest_unicode_extents|guest_icu_version_extents|guest_outline_bounds_extents|guest_rtc_parse_extents)$' -j 8 -V --output-on-failure`. Each new test has a 20-second timeout and completed below 1 second locally. `cmake --build <linux-full-build> --parallel 8`: complete default Linux product build passed. Windows used the full configuration, built the ten new and ten related test targets plus relinker with `--parallel 8`, and ran both filtered CTest groups; a complete default Windows build is not claimed. Fault-detection control on Linux: exact fixture head `e5ea5512af20f4b35d0c8f546ceea6e3d0a53ed8`, module context `ced276fb83b0404be919f0597b2d030f42c7ae13`. The complete production source unit was compiled and linked into the actual shared module using the product compile/link commands and its other unchanged module objects. The registered fixture passed with that unchanged module and failed after this deliberate defect in `SHA256_Final_nid_postfix`: `digest[32] = 0;`. This is a separate module-injection control, not PS5 execution. Conventions (including this body), whitespace, test registration and public-header declaration/umbrella audits passed. No PS5 hardware, game-title, macOS, WASM or GPU runtime validation is claimed. Hosted CI is not a local result and is pending when this PR opens. ### 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: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes
MarcZX10 commented 2026-11-02 06:45:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-02T06:45:02Z.

Review: COMMENTED


Reviewed — no blocking findings

This is a test-only change: a guarded-memory test for the SHA-256 and SHA-512 exports of libSceLibreSsl. The input, the context and the digest output sit between guard pages, and the test covers the padding cases. The Windows CTest run passed guest_digest_extents.

What I ran

  • Head e5ea5512af20f4b35d0c8f546ceea6e3d0a53ed8; base 3a1457d34f4eb9d61b448677a2bab712eecbbf9c. 2 files: core/libs/prx/libSceLibreSsl/CMakeLists.txt (registers guest_digest_extents) and core/libs/tests/GuestDigestExtents.cpp (143 lines, new).
  • Read main in full and the last 14 lines of the check helper. The helpers above them (the guarded-buffer class and the per-hash check) were not read in full.
  • Hosted: the Windows CTest run passed guest_digest_extents (Test #2305, 0.01 s). The run reports 2577 of 2577.
  • Read-only checks from the trusted main checkout: diff check, conventions and PR template, and the stack check all passed. The ABI audit is not applicable.
  • No MarcZX10 review at this head.

Results

Check Result Note
Diff check passed
Conventions and PR template passed conventions check from the main checkout
Mergeability and dependencies passed stack check passed; no declared dependencies
SHA-256 and SHA-512 digests match the expected vectors (read in part) passed by reading main runs both hashes; the helper's end compares the digest and checks the input is unchanged
Prefix checks on input, context and output (read in part) passed by reading Prefix on each buffer after the call
guest_digest_extents (hosted, Windows) passed Test #2305, 0.01 s
Linux behaviour (mprotect guard pages) not run Linux is skipped on pull requests
ABI audit not applicable no export changed
Negative controls not run no local build
Hosted CI passed windows passed (2577 of 2577); report, conventions and library-portability succeeded; linux, relinkers and write-watch skipped
Read-only check output

Precheck was not run: no PR-head code is run here. Diff check: passed. Conventions: passed. ABI audit: not applicable. Stack check: passed. Hosted: gh api repos/boykopovar/AnyPS5/commits/e5ea5512af20f4b35d0c8f546ceea6e3d0a53ed8/check-runs, and the Windows job log.

Negative control

Not run here. A negative control needs a local build, and code from this head is not run here.

Findings

Blocking

None.

Non-blocking

None.

Sources

Not verified

  • The guarded-buffer class and the per-hash helper above main (not read in full).
  • The Linux behaviour of the guard pages.

To get this to a good state

  • Nothing to change.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5732928726 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14283#pullrequestreview-5732928726). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-02T06:45:02Z. **Review:** COMMENTED --- # Reviewed — no blocking findings This is a test-only change: a guarded-memory test for the SHA-256 and SHA-512 exports of `libSceLibreSsl`. The input, the context and the digest output sit between guard pages, and the test covers the padding cases. The Windows CTest run passed `guest_digest_extents`. ## What I ran - Head `e5ea5512af20f4b35d0c8f546ceea6e3d0a53ed8`; base `3a1457d34f4eb9d61b448677a2bab712eecbbf9c`. 2 files: `core/libs/prx/libSceLibreSsl/CMakeLists.txt` (registers `guest_digest_extents`) and `core/libs/tests/GuestDigestExtents.cpp` (143 lines, new). - Read `main` in full and the last 14 lines of the check helper. The helpers above them (the guarded-buffer class and the per-hash check) were not read in full. - Hosted: the Windows CTest run passed `guest_digest_extents` (`Test #2305`, 0.01 s). The run reports 2577 of 2577. - Read-only checks from the trusted main checkout: diff check, conventions and PR template, and the stack check all passed. The ABI audit is not applicable. - No MarcZX10 review at this head. ## Results | Check | Result | Note | | --- | --- | --- | | Diff check | passed | | | Conventions and PR template | passed | conventions check from the main checkout | | Mergeability and dependencies | passed | stack check passed; no declared dependencies | | SHA-256 and SHA-512 digests match the expected vectors (read in part) | passed by reading | `main` runs both hashes; the helper's end compares the digest and checks the input is unchanged | | Prefix checks on input, context and output (read in part) | passed by reading | `Prefix` on each buffer after the call | | `guest_digest_extents` (hosted, Windows) | passed | `Test #2305`, 0.01 s | | Linux behaviour (`mprotect` guard pages) | not run | Linux is skipped on pull requests | | ABI audit | not applicable | no export changed | | Negative controls | not run | no local build | | Hosted CI | passed | windows passed (2577 of 2577); report, conventions and library-portability succeeded; linux, relinkers and write-watch skipped | <details><summary>Read-only check output</summary> Precheck was not run: no PR-head code is run here. Diff check: passed. Conventions: passed. ABI audit: not applicable. Stack check: passed. Hosted: `gh api repos/boykopovar/AnyPS5/commits/e5ea5512af20f4b35d0c8f546ceea6e3d0a53ed8/check-runs`, and the Windows job log. </details> ## Negative control Not run here. A negative control needs a local build, and code from this head is not run here. ## Findings **Blocking** None. **Non-blocking** None. ## Sources - Test: https://github.com/boykopovar/AnyPS5/blob/e5ea5512af20f4b35d0c8f546ceea6e3d0a53ed8/core/libs/tests/GuestDigestExtents.cpp - CMake: https://github.com/boykopovar/AnyPS5/blob/e5ea5512af20f4b35d0c8f546ceea6e3d0a53ed8/core/libs/prx/libSceLibreSsl/CMakeLists.txt - Windows job log: check-run `windows` on e5ea5512af20f4b35d0c8f546ceea6e3d0a53ed8 ## Not verified - The guarded-buffer class and the per-hash helper above `main` (not read in full). - The Linux behaviour of the guard pages. ## To get this to a good state - Nothing to change.
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!14283
No description provided.