feat(libSceLibreSsl3): implement EVP_MD_CTX_md #13663

Merged
alvaroelpob merged 3 commits from upstream-pr/13663 into main 2026-10-31 11:26:04 +00:00
alvaroelpob commented 2026-10-30 22:14:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by alvaroelpob on 2026-10-30T22:14:53Z.


What

Implements EVP_MD_CTX_md in libSceLibreSsl3, an additional export (13.60 table) that threw and was declared without parameters.

The signature const EVP_MD* EVP_MD_CTX_md(const EVP_MD_CTX*) and the behaviour follow LibreSSL 4.0.0 evp_digest.c: a null context returns null; otherwise it returns the context's digest. digest is the first field of EVP_MD_CTX in 4.0.0's evp_local.h and in the 2.5.4 layout of the contexts that the forwarded libSceLibreSsl EVP_MD_CTX_* exports handle. The two layouts differ after it (2.5.4 has engine), so the export reads only the first pointer and declares the context and digest as const void*. This adds no second context struct beside the one #10960 proposes.

The debt entry records the source and what is unverified. The additional-export inventory loses the function's row and its count drops from 180 to 179.

Tested

Ubuntu 26.04 (WSL2, kernel 6.18), GCC 15.2.0, Release, full build with BUILD_TESTING=ON on main d4de5943f6 (3028/3028 pass).

  • New guest_libressl3_digest_context test: on 48-byte contexts filled with 0xA5 or zero, EVP_MD_CTX_md returns the pointer stored at offset 0, including null, and leaves the context unchanged. A null context returns null.
  • Full ctest -j16 on head 339332c7ea: 3029/3029 pass. check_conventions.py --base upstream/main passes.
  • Not tested: Windows, a title.

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: #13659, #13662
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5091722162 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13663). Originally posted by [alvaroelpob](https://github.com/alvaroelpob) on 2026-10-30T22:14:53Z. --- ### What Implements `EVP_MD_CTX_md` in libSceLibreSsl3, an additional export (13.60 table) that threw and was declared without parameters. The signature `const EVP_MD* EVP_MD_CTX_md(const EVP_MD_CTX*)` and the behaviour follow [LibreSSL 4.0.0](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/evp/evp_digest.c) `evp_digest.c`: a null context returns null; otherwise it returns the context's `digest`. `digest` is the first field of `EVP_MD_CTX` in 4.0.0's `evp_local.h` and in the [2.5.4 layout](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/evp/evp.h) of the contexts that the forwarded libSceLibreSsl `EVP_MD_CTX_*` exports handle. The two layouts differ after it (2.5.4 has `engine`), so the export reads only the first pointer and declares the context and digest as `const void*`. This adds no second context struct beside the one #10960 proposes. The debt entry records the source and what is unverified. The additional-export inventory loses the function's row and its count drops from 180 to 179. ### 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. --> Ubuntu 26.04 (WSL2, kernel 6.18), GCC 15.2.0, Release, full build with `BUILD_TESTING=ON` on `main` d4de5943f6 (3028/3028 pass). - New `guest_libressl3_digest_context` test: on 48-byte contexts filled with 0xA5 or zero, `EVP_MD_CTX_md` returns the pointer stored at offset 0, including null, and leaves the context unchanged. A null context returns null. - Full `ctest -j16` on head 339332c7ea: 3029/3029 pass. `check_conventions.py --base upstream/main` passes. - Not tested: Windows, 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: #13659, #13662 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-30 22:18:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-30T22:18:26Z.

Review: COMMENTED


Reviewed — approval withheld pending test-report clarification

The accessor matches the pinned LibreSSL implementation and both cited context layouts, but the PR’s test section both reports and denies a full-suite run on this head.

What I ran

Reviewed head 339332c7ea824536875fe7415236cbf142384386 against base 9605300f293b88295e223a27ff8cfecf24d7ab2a; the individual merge preview is clean. Environment: Debian Linux x86-64, Python 3.11.2; GCC 12.2.0 available but not invoked. No build or C++ test was run locally.

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13663
python3 tools/pr_stack_check.py 13663 --repo boykopovar/AnyPS5 --output-dir /tmp/anyps5-pr13663-stack
python3 tools/pr_abi_audit.py --repo /marc/AnyPS5 --base 9605300f293b88295e223a27ff8cfecf24d7ab2a --head 339332c7ea824536875fe7415236cbf142384386 --json
python3 tools/pr_test_quality.py --root /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13663-339332c7ea82/head-339332c7ea82-65b0cf0d --json core/libs/prx/libSceLibreSsl3/tests/DigestContext.cpp
git worktree add --detach /tmp/anyps5-review-13663-header 339332c7ea824536875fe7415236cbf142384386
(cd /tmp/anyps5-review-13663-header && python3 core/libs/tests/test_public_headers.py --audit-only)
git worktree remove --force /tmp/anyps5-review-13663-header
git diff --check 9605300f293b88295e223a27ff8cfecf24d7ab2a...339332c7ea824536875fe7415236cbf142384386
gh pr checks 13663 --repo boykopovar/AnyPS5

For the declared integration order, I also applied gh pr diff patches for #13659, then #13662, to a temporary worktree at the base using git apply --3way. #13662 conflicted in CMakeLists.txt and docs/dev/debt/libSceLibreSsl3.md. I did not resolve those conflicts or claim a complete three-PR integration test.

Results

Check Result
Diff and conventions Passed on the exact head.
Individual merge/dependency preview #13659, #13662 and #13663 each preview cleanly against the current base; declared order is #13659 → #13662 → #13663.
Sequential patch composition Applying #13662 after #13659 conflicted in the shared CMake and debt files. The current individually clean previews do not establish that the whole stack lands without refreshes.
ABI audit Passed with no findings; the EVP_MD_CTX_md_nid_postfix declaration and definition map to NID H1dRCduUy+o.
Public-header audit Passed on this head: 389 libraries, 24,477 exports.
Test-quality heuristic It flagged a possible unregistered test, but the exact-head CMake file explicitly registers DigestContext.cpp; this is a false positive.
Hosted CI At final refresh, eligibility, conventions, intake, labels, library-portability and report were queued. No hosted product test had completed.
Author-reported tests The PR reports 3029/3029 CTest cases on 339332c7ea, then says the full suite on this branch is “not tested yet.” I did not independently run those tests.
Unedited outputs from checks
All conventions checks passed.
{
  "status": "passed",
  "symbol": [
    {
      "name": "EVP_MD_CTX_md_nid_postfix",
      "computed_nid": "H1dRCduUy+o",
      "declarations": [
        "core/libs/prx/libSceLibreSsl3/include/Api.hpp"
      ],
      "definitions": [
        "core/libs/prx/libSceLibreSsl3/src/DigestContext.cpp"
      ],
      "explicit_aliases": [],
      "version": "not encoded by these source declarations; not verified"
    }
  ],
  "findings": []
}
389 libraries, 24477 exports: unique declarations and umbrella coverage verified
{
  "findings": [
    {
      "path": "core/libs/prx/libSceLibreSsl3/tests/DigestContext.cpp",
      "line": 1,
      "kind": "possible-unregistered-cpp-test",
      "message": "Changed C++ test source path was not found literally in CMake files; inspect registration, generated source lists, and workflow coverage."
    }
  ],
  "negative_control_candidates": [],
  "limits": [
    "Heuristics can miss weak assertions and can flag valid tests; inspect every finding.",
    "A test that passes against base is not by itself proof that the PR test is inadequate.",
    "Negative controls are only candidates until the test actually runs against base and fails by assertion rather than import/setup error."
  ]
}
conventions	pending	0	https://github.com/boykopovar/AnyPS5/actions/runs/41136836916/job/124341261806
eligibility	pending	0	https://github.com/boykopovar/AnyPS5/actions/runs/41136837193/job/124341261010
intake	pending	0	https://github.com/boykopovar/AnyPS5/actions/runs/41136836950/job/124341261421
labels	pending	0	https://github.com/boykopovar/AnyPS5/actions/runs/41136836976/job/124341261411
library-portability	pending	0	https://github.com/boykopovar/AnyPS5/actions/runs/41136837062/job/124341260232
report	pending	0	https://github.com/boykopovar/AnyPS5/actions/runs/41136837055/job/124341260510
Applied patch to 'core/libs/prx/libSceLibreSsl3/AdditionalExports.cpp' cleanly.
Applied patch to 'core/libs/prx/libSceLibreSsl3/CMakeLists.txt' with conflicts.
Applied patch to 'core/libs/prx/libSceLibreSsl3/include/Api.hpp' cleanly.
Applied patch to 'docs/dev/debt/libSceLibreSsl3.md' with conflicts.
U core/libs/prx/libSceLibreSsl3/CMakeLists.txt
U docs/dev/debt/libSceLibreSsl3.md

git diff --check produced no output and exited 0.

Negative control

I did not build a test binary or run a local negative control. The author’s reported baseline and PR runs are not independently reproduced here.

Findings

Blocking

No implementation defect was confirmed. I am withholding approval until the contradictory test report is clarified; the submitted text does not establish unambiguously whether the claimed 3029-case run covered this head.

Non-blocking

The declared dependency order is clear, but the sequential patch check found conflicts in shared files when #13662 follows #13659. This is an integration refresh to revisit after its prerequisites land, not a request to rebase prematurely.

Sources

Not verified

No local build or runtime test was run. The hosted jobs were queued at the final check snapshot. The author-reported CTest result was not independently verified, and the full three-PR landing sequence was not simulated beyond the reported #13659 → #13662 patch conflict.

To get this to a good state

Please clarify whether ctest -j16 ran on head 339332c7ea824536875fe7415236cbf142384386, remove or correct the contradictory “Not tested yet” line, and preserve the exact head and command in the report. After #13659 and #13662 land and the branch is refreshed, rerun the relevant checks on the resulting head; I will reassess that update.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5719278855 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13663#pullrequestreview-5719278855). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-30T22:18:26Z. **Review:** COMMENTED --- # Reviewed — approval withheld pending test-report clarification The accessor matches the pinned LibreSSL implementation and both cited context layouts, but the PR’s test section both reports and denies a full-suite run on this head. ## What I ran Reviewed head `339332c7ea824536875fe7415236cbf142384386` against base `9605300f293b88295e223a27ff8cfecf24d7ab2a`; the individual merge preview is clean. Environment: Debian Linux x86-64, Python 3.11.2; GCC 12.2.0 available but not invoked. No build or C++ test was run locally. ```sh python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13663 python3 tools/pr_stack_check.py 13663 --repo boykopovar/AnyPS5 --output-dir /tmp/anyps5-pr13663-stack python3 tools/pr_abi_audit.py --repo /marc/AnyPS5 --base 9605300f293b88295e223a27ff8cfecf24d7ab2a --head 339332c7ea824536875fe7415236cbf142384386 --json python3 tools/pr_test_quality.py --root /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13663-339332c7ea82/head-339332c7ea82-65b0cf0d --json core/libs/prx/libSceLibreSsl3/tests/DigestContext.cpp git worktree add --detach /tmp/anyps5-review-13663-header 339332c7ea824536875fe7415236cbf142384386 (cd /tmp/anyps5-review-13663-header && python3 core/libs/tests/test_public_headers.py --audit-only) git worktree remove --force /tmp/anyps5-review-13663-header git diff --check 9605300f293b88295e223a27ff8cfecf24d7ab2a...339332c7ea824536875fe7415236cbf142384386 gh pr checks 13663 --repo boykopovar/AnyPS5 ``` For the declared integration order, I also applied `gh pr diff` patches for #13659, then #13662, to a temporary worktree at the base using `git apply --3way`. #13662 conflicted in `CMakeLists.txt` and `docs/dev/debt/libSceLibreSsl3.md`. I did not resolve those conflicts or claim a complete three-PR integration test. ## Results | Check | Result | |---|---| | Diff and conventions | Passed on the exact head. | | Individual merge/dependency preview | #13659, #13662 and #13663 each preview cleanly against the current base; declared order is #13659 → #13662 → #13663. | | Sequential patch composition | Applying #13662 after #13659 conflicted in the shared CMake and debt files. The current individually clean previews do not establish that the whole stack lands without refreshes. | | ABI audit | Passed with no findings; the `EVP_MD_CTX_md_nid_postfix` declaration and definition map to NID `H1dRCduUy+o`. | | Public-header audit | Passed on this head: 389 libraries, 24,477 exports. | | Test-quality heuristic | It flagged a possible unregistered test, but the exact-head CMake file explicitly registers `DigestContext.cpp`; this is a false positive. | | Hosted CI | At final refresh, eligibility, conventions, intake, labels, library-portability and report were queued. No hosted product test had completed. | | Author-reported tests | The PR reports 3029/3029 CTest cases on `339332c7ea`, then says the full suite on this branch is “not tested yet.” I did not independently run those tests. | <details><summary>Unedited outputs from checks</summary> ```text All conventions checks passed. ``` ```json { "status": "passed", "symbol": [ { "name": "EVP_MD_CTX_md_nid_postfix", "computed_nid": "H1dRCduUy+o", "declarations": [ "core/libs/prx/libSceLibreSsl3/include/Api.hpp" ], "definitions": [ "core/libs/prx/libSceLibreSsl3/src/DigestContext.cpp" ], "explicit_aliases": [], "version": "not encoded by these source declarations; not verified" } ], "findings": [] } ``` ```text 389 libraries, 24477 exports: unique declarations and umbrella coverage verified ``` ```text { "findings": [ { "path": "core/libs/prx/libSceLibreSsl3/tests/DigestContext.cpp", "line": 1, "kind": "possible-unregistered-cpp-test", "message": "Changed C++ test source path was not found literally in CMake files; inspect registration, generated source lists, and workflow coverage." } ], "negative_control_candidates": [], "limits": [ "Heuristics can miss weak assertions and can flag valid tests; inspect every finding.", "A test that passes against base is not by itself proof that the PR test is inadequate.", "Negative controls are only candidates until the test actually runs against base and fails by assertion rather than import/setup error." ] } ``` ```text conventions pending 0 https://github.com/boykopovar/AnyPS5/actions/runs/41136836916/job/124341261806 eligibility pending 0 https://github.com/boykopovar/AnyPS5/actions/runs/41136837193/job/124341261010 intake pending 0 https://github.com/boykopovar/AnyPS5/actions/runs/41136836950/job/124341261421 labels pending 0 https://github.com/boykopovar/AnyPS5/actions/runs/41136836976/job/124341261411 library-portability pending 0 https://github.com/boykopovar/AnyPS5/actions/runs/41136837062/job/124341260232 report pending 0 https://github.com/boykopovar/AnyPS5/actions/runs/41136837055/job/124341260510 ``` ```text Applied patch to 'core/libs/prx/libSceLibreSsl3/AdditionalExports.cpp' cleanly. Applied patch to 'core/libs/prx/libSceLibreSsl3/CMakeLists.txt' with conflicts. Applied patch to 'core/libs/prx/libSceLibreSsl3/include/Api.hpp' cleanly. Applied patch to 'docs/dev/debt/libSceLibreSsl3.md' with conflicts. U core/libs/prx/libSceLibreSsl3/CMakeLists.txt U docs/dev/debt/libSceLibreSsl3.md ``` `git diff --check` produced no output and exited 0. </details> ## Negative control I did not build a test binary or run a local negative control. The author’s reported baseline and PR runs are not independently reproduced here. ## Findings ### Blocking No implementation defect was confirmed. I am withholding approval until the contradictory test report is clarified; the submitted text does not establish unambiguously whether the claimed 3029-case run covered this head. ### Non-blocking The declared dependency order is clear, but the sequential patch check found conflicts in shared files when #13662 follows #13659. This is an integration refresh to revisit after its prerequisites land, not a request to rebase prematurely. ## Sources - [Accessor implementation at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/339332c7ea824536875fe7415236cbf142384386/core/libs/prx/libSceLibreSsl3/src/DigestContext.cpp) - [API declaration and test registration at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/339332c7ea824536875fe7415236cbf142384386/core/libs/prx/libSceLibreSsl3/CMakeLists.txt) - [LibreSSL 4.0.0 accessor behavior](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/evp/evp_digest.c#L1868-L1882) - [LibreSSL 4.0.0 context layout](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/evp/evp_local.h#L1266-L1282) - [LibreSSL 2.5.4 context layout](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/evp/evp.h#L2585-L2603) ## Not verified No local build or runtime test was run. The hosted jobs were queued at the final check snapshot. The author-reported CTest result was not independently verified, and the full three-PR landing sequence was not simulated beyond the reported #13659 → #13662 patch conflict. ## To get this to a good state Please clarify whether `ctest -j16` ran on head `339332c7ea824536875fe7415236cbf142384386`, remove or correct the contradictory “Not tested yet” line, and preserve the exact head and command in the report. After #13659 and #13662 land and the branch is refreshed, rerun the relevant checks on the resulting head; I will reassess that update.
MarcZX10 commented 2026-10-30 23:11:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-30T23:11:06Z.

Review: APPROVED


Reviewed — looks good

The exact change matches the pinned LibreSSL implementation and both cited context layouts; I found no blocking issue in the current head.

What I ran

Head 339332c7ea824536875fe7415236cbf142384386; PR base 9605300f293b88295e223a27ff8cfecf24d7ab2a. The isolated merge preview was clean against current main e9a33a703b3c0d1bd65e4dee7ec608428d62a5f0. Environment: Linux x86_64, Python 3.11.2; no compiler was invoked.

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13663
python3 tools/pr_abi_audit.py --base 9605300f293b88295e223a27ff8cfecf24d7ab2a --head 339332c7ea824536875fe7415236cbf142384386 --json
git diff --check 9605300f293b88295e223a27ff8cfecf24d7ab2a...339332c7ea824536875fe7415236cbf142384386

The diff, conventions/template check, direct ABI audit (passed, no findings), and individual merge preview passed. The precheck aggregate reported failures because its isolated checkout does not contain the workspace-only audit helpers; I ran the ABI audit directly. Its test-quality helper was unavailable in that checkout, so I manually checked CMakeLists.txt and confirmed the target and CTest registration. Hosted Windows and policy checks pass; Linux and specialized jobs were skipped. The author reports a full 3,029-test CTest pass on the head; I did not independently run it.

Sources

Not verified

I did not build locally, run CTest, or test a title/console. The stack checker identifies the declared landing order #13659 → #13662 → #13663; it checked each PR separately against current main, not the combined sequence. The debt entry records that the PS5 context layout has not been measured directly.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5719653597 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13663#pullrequestreview-5719653597). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-30T23:11:06Z. **Review:** APPROVED --- # Reviewed — looks good The exact change matches the pinned LibreSSL implementation and both cited context layouts; I found no blocking issue in the current head. ### What I ran Head `339332c7ea824536875fe7415236cbf142384386`; PR base `9605300f293b88295e223a27ff8cfecf24d7ab2a`. The isolated merge preview was clean against current `main` `e9a33a703b3c0d1bd65e4dee7ec608428d62a5f0`. Environment: Linux x86_64, Python 3.11.2; no compiler was invoked. ```sh python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13663 python3 tools/pr_abi_audit.py --base 9605300f293b88295e223a27ff8cfecf24d7ab2a --head 339332c7ea824536875fe7415236cbf142384386 --json git diff --check 9605300f293b88295e223a27ff8cfecf24d7ab2a...339332c7ea824536875fe7415236cbf142384386 ``` The diff, conventions/template check, direct ABI audit (passed, no findings), and individual merge preview passed. The precheck aggregate reported failures because its isolated checkout does not contain the workspace-only audit helpers; I ran the ABI audit directly. Its test-quality helper was unavailable in that checkout, so I manually checked `CMakeLists.txt` and confirmed the target and CTest registration. Hosted Windows and policy checks pass; Linux and specialized jobs were skipped. The author reports a full 3,029-test CTest pass on the head; I did not independently run it. ### Sources - [LibreSSL 4.0.0 `EVP_MD_CTX_md`](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/evp/evp_digest.c#L395-L402) and [context layout](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/evp/evp_local.h#L196-L204). - [LibreSSL 2.5.4 context layout](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/evp/evp.h#L260-L269); the first `digest` field is shared, while later fields differ. ### Not verified I did not build locally, run CTest, or test a title/console. The stack checker identifies the declared landing order `#13659 → #13662 → #13663`; it checked each PR separately against current `main`, not the combined sequence. The debt entry records that the PS5 context layout has not been measured directly.
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!13663
No description provided.