feat(libSceLibreSsl3): implement cipher context flags #15163

Open
lost9409 wants to merge 1 commit from upstream-pr/15163 into main
lost9409 commented 2026-11-02 19:35:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by lost9409 on 2026-11-02T19:35:43Z.


What

Implements EVP_CIPHER_CTX_set_flags in libSceLibreSsl3, replacing its throwing placeholder with a typed void function.

The function accumulates flags without clearing existing bits. The signed 32-bit argument is converted to the guest's unsigned 64-bit flag field before OR, following LibreSSL's operation:
github.com/libressl/openbsd@ce488b78e0/src/lib/libcrypto/evp/evp_cipher.c

This uses the existing parent LibreSslEvpCipherCtx layout, whose flags are at offset 112, because this module forwards its context constructors to the parent library. It does not assume LibreSSL 4.0.0's different context layout. Console layout and behavior remain unverified and are documented in technical debt. Null contexts throw std::invalid_argument.

Tests cover zero and repeated masks, accumulation, negative masks, preservation of existing high bits, unchanged neighboring bytes and null rejection. This does not implement additional cipher algorithms.

Tested

Tested head: c2195d12e9849ac90ea432750e32f0967a0a7d04.
Rebased onto main commit: e8b9749c0bea648e02e57f6530378dce5d1113ac.

Windows 11, WinLibs GCC 15.2.0, CMake/Ninja, Release, BUILD_TESTING=ON:

  • Updated submodules and rebuilt guest_libressl3_cipher_tests.
  • Focused CTest guest_libressl3_cipher: 1/1 passed; test 0.03 s, total 1.11 s.
  • python tools/check_conventions.py --base HEAD~1: 0 errors, one debt-length warning (1829 characters).
  • git diff --check HEAD~1 HEAD passed; working tree clean before push.

The rebase preserves main's ERR_print_errors_cb and PKCS#8 implementations, SSL_CIPHER_get_id and its tests. The duplicate pending-export paragraph was removed, and the current count was changed from 14 to 13.

No Linux build, console execution, title execution or full-suite validation is claimed for this head.

Overlap review

The previous scan and manual shared-file review are recorded in:
https://github.com/boykopovar/AnyPS5/pull/15163#issuecomment-6876194732

PR #19535 landed first; this head is rebased after it and preserves its changes. No dependency on an unmerged PR has been identified. A fresh open-PR search for EVP_CIPHER_CTX_set_flags returned only this PR.

The earlier manual review is not a combined integration test with all remaining open PRs. Shared-file reconciliation may still be necessary as those branches evolve. This PR remains a draft pending final checks.

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 (ChatGPT; Windows build and tests executed by the author)

Historical d64c8e1f5a CTest log

Historical pre-rebase CTest log

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5126255903 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15163). Originally posted by [lost9409](https://github.com/lost9409) on 2026-11-02T19:35:43Z. --- ### What Implements `EVP_CIPHER_CTX_set_flags` in `libSceLibreSsl3`, replacing its throwing placeholder with a typed `void` function. The function accumulates flags without clearing existing bits. The signed 32-bit argument is converted to the guest's unsigned 64-bit flag field before OR, following LibreSSL's operation: https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/evp/evp_cipher.c This uses the existing parent `LibreSslEvpCipherCtx` layout, whose flags are at offset 112, because this module forwards its context constructors to the parent library. It does not assume LibreSSL 4.0.0's different context layout. Console layout and behavior remain unverified and are documented in technical debt. Null contexts throw `std::invalid_argument`. Tests cover zero and repeated masks, accumulation, negative masks, preservation of existing high bits, unchanged neighboring bytes and null rejection. This does not implement additional cipher algorithms. ### Tested Tested head: `c2195d12e9849ac90ea432750e32f0967a0a7d04`. Rebased onto main commit: `e8b9749c0bea648e02e57f6530378dce5d1113ac`. Windows 11, WinLibs GCC 15.2.0, CMake/Ninja, Release, BUILD_TESTING=ON: - Updated submodules and rebuilt `guest_libressl3_cipher_tests`. - Focused CTest `guest_libressl3_cipher`: 1/1 passed; test 0.03 s, total 1.11 s. - `python tools/check_conventions.py --base HEAD~1`: 0 errors, one debt-length warning (1829 characters). - `git diff --check HEAD~1 HEAD` passed; working tree clean before push. The rebase preserves main's ERR_print_errors_cb and PKCS#8 implementations, SSL_CIPHER_get_id and its tests. The duplicate pending-export paragraph was removed, and the current count was changed from 14 to 13. No Linux build, console execution, title execution or full-suite validation is claimed for this head. ### Overlap review The previous scan and manual shared-file review are recorded in: https://github.com/boykopovar/AnyPS5/pull/15163#issuecomment-6876194732 PR #19535 landed first; this head is rebased after it and preserves its changes. No dependency on an unmerged PR has been identified. A fresh open-PR search for EVP_CIPHER_CTX_set_flags returned only this PR. The earlier manual review is not a combined integration test with all remaining open PRs. Shared-file reconciliation may still be necessary as those branches evolve. This PR remains a draft pending final checks. ### 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 (ChatGPT; Windows build and tests executed by the author) [Historical d64c8e1f5a CTest log](https://github.com/user-attachments/files/34847953/AnyPS5-cipher-flags-rebase-CTest.log) [Historical pre-rebase CTest log](https://github.com/user-attachments/files/34288905/AnyPS5-cipher-flags-CTest-final.log)
MarcZX10 commented 2026-11-21 07:07:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T07:07:01Z.

Review: COMMENTED


Reviewed — no blocking findings

Nothing blocks this change; the points below are optional.

What I ran

Reviewed head c2195d12e9849ac90ea432750e32f0967a0a7d04. I read description.md, commits.md, manifest.json, diff.patch, and all five changed files: Export.cpp, include/Api.hpp, src/Cipher.cpp, tests/Cipher.cpp, and docs/dev/debt/libSceLibreSsl3.md. The reader was repo_read.py.

No commands or tests were run. The Windows test and convention-check results in the PR description are author-reported.

Results

Check Result Note
Diff and changed source passed Signature, implementation, and call registration inspected
Tests not run Author reports focused CTest passed
Console behavior not run Explicitly unverified in the PR description

Findings

Blocking

None.

Non-blocking

  • Consider adding a focused ABI or integration check for the context layout and signed-to-unsigned flag conversion on the intended guest target. The unit test verifies the modeled parent layout, while the PR documents that console layout and behavior remain unverified.

Not verified

No build, test, convention check, Linux run, console run, or title execution was performed. The full text of the five changed files was included and read; files.json was not present in the review bundle, so excluded files could not be checked independently. The manifest lists all changed files as included.

To get this to a good state

Nothing is required. Optional: verify the context layout and behavior against the console when that environment is available.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6003714707 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15163#pullrequestreview-6003714707). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-21T07:07:01Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing blocks this change; the points below are optional. ## What I ran Reviewed head `c2195d12e9849ac90ea432750e32f0967a0a7d04`. I read `description.md`, `commits.md`, `manifest.json`, `diff.patch`, and all five changed files: `Export.cpp`, `include/Api.hpp`, `src/Cipher.cpp`, `tests/Cipher.cpp`, and `docs/dev/debt/libSceLibreSsl3.md`. The reader was `repo_read.py`. No commands or tests were run. The Windows test and convention-check results in the PR description are author-reported. ## Results | Check | Result | Note | |---|---|---| | Diff and changed source | passed | Signature, implementation, and call registration inspected | | Tests | not run | Author reports focused CTest passed | | Console behavior | not run | Explicitly unverified in the PR description | ## Findings ### Blocking None. ### Non-blocking - Consider adding a focused ABI or integration check for the context layout and signed-to-unsigned flag conversion on the intended guest target. The unit test verifies the modeled parent layout, while the PR documents that console layout and behavior remain unverified. ## Not verified No build, test, convention check, Linux run, console run, or title execution was performed. The full text of the five changed files was included and read; `files.json` was not present in the review bundle, so excluded files could not be checked independently. The manifest lists all changed files as included. ## To get this to a good state Nothing is required. Optional: verify the context layout and behavior against the console when that environment is available.
ligmaSec commented 2026-12-03 13:16:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T13:16:27Z.

Review: COMMENTED


Checked the branch sources and built the focused tests against the existing Linux runtime. Cipher passed, including the cipher-context flag checks.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6170526352 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15163#pullrequestreview-6170526352). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T13:16:27Z. **Review:** COMMENTED --- Checked the branch sources and built the focused tests against the existing Linux runtime. `Cipher` passed, including the cipher-context flag checks. AI-assisted: yes.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/15163:upstream-pr/15163'
git switch 'upstream-pr/15163'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/15163'
git switch 'upstream-pr/15163'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/15163'
git switch 'upstream-pr/15163'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/15163'
git switch 'main'
git merge --squash 'upstream-pr/15163'
git switch 'main'
git merge --ff-only 'upstream-pr/15163'
git switch 'main'
git merge 'upstream-pr/15163'
git push origin 'main'
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!15163
No description provided.