feat(libSceLibreSsl3): implement tls_config_set_ciphers for the libtls presets #18760

Merged
bagodees merged 5 commits from upstream-pr/18760 into main 2026-11-16 13:41:05 +00:00
bagodees commented 2026-11-12 05:37:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by bagodees on 2026-11-12T05:37:26Z.


What

Implements tls_config_set_ciphers in libSceLibreSsl3 for the libtls preset names, following LibreSSL 4.0.0 tls_config.c and tls_internal.h:

  • secure/default select TLSv1.3:TLSv1.2+AEAD+ECDHE:TLSv1.2+AEAD+DHE, compat selects HIGH:!aNULL, legacy selects HIGH:MEDIUM:!aNULL, and all/insecure select ALL:!aNULL:!eNULL. Names are matched case-insensitively, as LibreSSL does, and the expanded strings are also accepted.
  • A null cipher string resets the stored value to the default, and the call returns 0.
  • Any other string throws std::runtime_error, because LibreSSL validates it with SSL_CTX_new and SSL_CTX_set_cipher_list, and both are still stubs in libSceLibreSsl. This is recorded in docs/dev/debt/libSceLibreSsl3.md.
  • A null configuration returns -1.

The stored string is owned by the configuration and freed with it. The debt inventory drops the export, which brings the count to 78.

Tested

Windows 11 Pro, MinGW (winlibs) full build of 0dfe72d5d0 on main 6340804728. ctest --test-dir build -R "libressl3|libtls|LibreSsl3|public_headers" passed 122/122, including LibTlsSettings, which checks every preset name in mixed case, the expanded preset strings, null resets, a caller-owned string, rejected custom strings and a null configuration over 256 iterations. python tools/check_conventions.py --base upstream/main passed. Not tested on a console or with 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: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5272175624 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18760). Originally posted by [bagodees](https://github.com/bagodees) on 2026-11-12T05:37:26Z. --- ### What Implements `tls_config_set_ciphers` in libSceLibreSsl3 for the libtls preset names, following LibreSSL 4.0.0 [`tls_config.c`](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libtls/tls_config.c) and `tls_internal.h`: - `secure`/`default` select `TLSv1.3:TLSv1.2+AEAD+ECDHE:TLSv1.2+AEAD+DHE`, `compat` selects `HIGH:!aNULL`, `legacy` selects `HIGH:MEDIUM:!aNULL`, and `all`/`insecure` select `ALL:!aNULL:!eNULL`. Names are matched case-insensitively, as LibreSSL does, and the expanded strings are also accepted. - A null cipher string resets the stored value to the default, and the call returns 0. - Any other string throws `std::runtime_error`, because LibreSSL validates it with `SSL_CTX_new` and `SSL_CTX_set_cipher_list`, and both are still stubs in libSceLibreSsl. This is recorded in `docs/dev/debt/libSceLibreSsl3.md`. - A null configuration returns -1. The stored string is owned by the configuration and freed with it. The debt inventory drops the export, which brings the count to 78. ### Tested Windows 11 Pro, MinGW (winlibs) full build of `0dfe72d5d0` on `main` `6340804728`. `ctest --test-dir build -R "libressl3|libtls|LibreSsl3|public_headers"` passed 122/122, including `LibTlsSettings`, which checks every preset name in mixed case, the expanded preset strings, null resets, a caller-owned string, rejected custom strings and a null configuration over 256 iterations. `python tools/check_conventions.py --base upstream/main` passed. Not tested on a console or with 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: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-11-12 06:10:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-12T06:10:31Z.

Review: COMMENTED


Reviewed — no blocking findings

The preset expansion and stored-value behavior match the pinned LibreSSL source; hosted checks remain queued, so this is a comment rather than an approval.

What I ran

Head 0dfe72d5d00f028451457351c41fc95e07994920; base 145e689adab572c44a99369516565d28e85f6c12. No merged-preview build was run.

Environment: Linux 6.1, Python 3.11.2, GCC C++ 12.2.0.

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 18760 --output-dir /tmp/pr18760-precheck

I read all six changed files, checked the preset and string ownership behavior against LibreSSL 4.0.0, and verified the added test registration in CMake. The overlap report identifies shared edits to the debt inventory, but no same-export overlap.

Results

Check Result Note
Diff, conventions, ABI audit passed Exact head and base remained unchanged.
Dependency and mergeability check passed Clean preview against the current base.
New test registration passed CMake registers guest_libressl3_libtls_settings.
Local C++ test not run This no-build pass did not build the exact head.
Hosted CI pending Six jobs were queued at the final refresh.
Precheck result
/tmp/pr18760-precheck/report.md
/tmp/pr18760-precheck/report.json
Conclusion: checks incomplete

The test-quality heuristic flagged possible missing registration; inspection of the pinned CMake file confirmed the test is registered. The precheck reported both head and base unchanged.

Findings

Blocking

None found in the six changed files.

Non-blocking

Custom cipher strings still throw until cipher-list validation is implemented, and the stored setting is not yet consumed by TLS transport. The PR and debt entry disclose these limits.

Sources

Not verified

  • The local C++ test, Windows behavior, and console behavior were not independently tested.
  • Hosted CI had six queued jobs at the final refresh.

To get this to a good state

Let the hosted checks finish. I’ll re-check this head and its results before deciding whether an approval is appropriate.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5869906478 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18760#pullrequestreview-5869906478). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-12T06:10:31Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The preset expansion and stored-value behavior match the pinned LibreSSL source; hosted checks remain queued, so this is a comment rather than an approval. ## What I ran Head `0dfe72d5d00f028451457351c41fc95e07994920`; base `145e689adab572c44a99369516565d28e85f6c12`. No merged-preview build was run. Environment: Linux 6.1, Python 3.11.2, GCC C++ 12.2.0. ```sh python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 18760 --output-dir /tmp/pr18760-precheck ``` I read all six changed files, checked the preset and string ownership behavior against LibreSSL 4.0.0, and verified the added test registration in CMake. The overlap report identifies shared edits to the debt inventory, but no same-export overlap. ## Results | Check | Result | Note | |---|---|---| | Diff, conventions, ABI audit | passed | Exact head and base remained unchanged. | | Dependency and mergeability check | passed | Clean preview against the current base. | | New test registration | passed | CMake registers `guest_libressl3_libtls_settings`. | | Local C++ test | not run | This no-build pass did not build the exact head. | | Hosted CI | pending | Six jobs were queued at the final refresh. | <details> <summary>Precheck result</summary> ```text /tmp/pr18760-precheck/report.md /tmp/pr18760-precheck/report.json Conclusion: checks incomplete ``` The test-quality heuristic flagged possible missing registration; inspection of the pinned CMake file confirmed the test is registered. The precheck reported both head and base unchanged. </details> ## Findings ### Blocking None found in the six changed files. ### Non-blocking Custom cipher strings still throw until cipher-list validation is implemented, and the stored setting is not yet consumed by TLS transport. The PR and debt entry disclose these limits. ## Sources - [Reviewed setter and tests at the pinned PR head](https://github.com/boykopovar/AnyPS5/blob/0dfe72d5d00f028451457351c41fc95e07994920/core/libs/prx/libSceLibreSsl3/src/LibTls.cpp) - [Pinned CMake test registration](https://github.com/boykopovar/AnyPS5/blob/0dfe72d5d00f028451457351c41fc95e07994920/core/libs/prx/libSceLibreSsl3/CMakeLists.txt) - [LibreSSL 4.0.0 preset expansion and validation](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libtls/tls_config.c#L483-L515) - [LibreSSL 4.0.0 preset strings](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libtls/tls_internal.h#L35-L38) ## Not verified - The local C++ test, Windows behavior, and console behavior were not independently tested. - Hosted CI had six queued jobs at the final refresh. ## To get this to a good state Let the hosted checks finish. I’ll re-check this head and its results before deciding whether an approval is appropriate.
PrivacyOnion commented 2026-11-12 07:50:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-12T07:50:27Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 0dfe72d5d0:

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: guest_libressl3_libtls_settings_tests built cleanly.
  • CTest (guest_libressl3_libtls_settings):
    1/1 Test #3635: guest_libressl3_libtls_settings ...   Passed    0.02 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceLibreSsl3/AdditionalExports.cpp, core/libs/prx/libSceLibreSsl3/include/Api.hpp, core/libs/prx/libSceLibreSsl3/include/LibTls.hpp, core/libs/prx/libSceLibreSsl3/src/LibTls.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • core/libs/prx/libSceLibreSsl3/src/LibTls.cpp:tls_config_set_ciphers_nid_postfix: Verified null config pointer validation returns -1 before dereferencing, and null ciphers argument resets to CiphersDefault ('TLSv1.3:TLSv1.2+AEAD+ECDHE:TLSv1.2+AEAD+DHE') and returns 0.
    • core/libs/prx/libSceLibreSsl3/src/LibTls.cpp:ResolveCiphers: Verified case-insensitive comparison in EqualsIgnoringCase and LowerAscii across all libtls preset aliases ('default', 'secure', 'compat', 'legacy', 'all', 'insecure') and exact matching of expanded preset strings in IsPresetCiphers.
    • core/libs/prx/libSceLibreSsl3/src/LibTls.cpp:tls_config_set_ciphers_nid_postfix: Verified that non-preset cipher strings throw std::runtime_error, satisfying AGENTS.md requirements for unimplemented paths in the absence of SSL_CTX cipher-list validation.
    • core/libs/prx/libSceLibreSsl3/src/LibTls.cpp:Release: Verified memory lifecycle of ConfigStorage::ciphers, confirming proper zero-initialization, cleanup of old strings during reassignment, and safe freeing on context/config destruction in Release without leaking memory.
    • core/libs/prx/libSceLibreSsl3/include/LibTls.hpp & tests/LibTlsSettings.cpp: Verified function signature correctness under APS5_VABI, removal of the parameterless stub from AdditionalExports.cpp and Api.hpp, and comprehensive test assertions for case variants, string resets, caller buffers, and invalid inputs.
    • docs/dev/debt/libSceLibreSsl3.md: Verified the technical debt inventory was accurately updated, decrementing remaining unimplemented exports from 79 to 78 (74 named, 4 NID-only), increasing implemented libtls exports from 14 to 15, and recording the non-preset cipher string behavior.
    • AGENTS.md conventions: Verified zero comments were introduced in source and test files, Conventional Commits formatting is maintained, and no extra untracked files were added.
  • Minor: please drop the Generated with footer from the description; the AI-assisted checkbox can stay.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5870918114 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18760#pullrequestreview-5870918114). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-12T07:50:27Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `0dfe72d5d0`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `guest_libressl3_libtls_settings_tests` built cleanly. - **CTest** (`guest_libressl3_libtls_settings`): ``` 1/1 Test #3635: guest_libressl3_libtls_settings ... Passed 0.02 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceLibreSsl3/AdditionalExports.cpp`, `core/libs/prx/libSceLibreSsl3/include/Api.hpp`, `core/libs/prx/libSceLibreSsl3/include/LibTls.hpp`, `core/libs/prx/libSceLibreSsl3/src/LibTls.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - core/libs/prx/libSceLibreSsl3/src/LibTls.cpp:tls_config_set_ciphers_nid_postfix: Verified null config pointer validation returns -1 before dereferencing, and null ciphers argument resets to CiphersDefault ('TLSv1.3:TLSv1.2+AEAD+ECDHE:TLSv1.2+AEAD+DHE') and returns 0. - core/libs/prx/libSceLibreSsl3/src/LibTls.cpp:ResolveCiphers: Verified case-insensitive comparison in EqualsIgnoringCase and LowerAscii across all libtls preset aliases ('default', 'secure', 'compat', 'legacy', 'all', 'insecure') and exact matching of expanded preset strings in IsPresetCiphers. - core/libs/prx/libSceLibreSsl3/src/LibTls.cpp:tls_config_set_ciphers_nid_postfix: Verified that non-preset cipher strings throw std::runtime_error, satisfying AGENTS.md requirements for unimplemented paths in the absence of SSL_CTX cipher-list validation. - core/libs/prx/libSceLibreSsl3/src/LibTls.cpp:Release: Verified memory lifecycle of ConfigStorage::ciphers, confirming proper zero-initialization, cleanup of old strings during reassignment, and safe freeing on context/config destruction in Release without leaking memory. - core/libs/prx/libSceLibreSsl3/include/LibTls.hpp & tests/LibTlsSettings.cpp: Verified function signature correctness under APS5_VABI, removal of the parameterless stub from AdditionalExports.cpp and Api.hpp, and comprehensive test assertions for case variants, string resets, caller buffers, and invalid inputs. - docs/dev/debt/libSceLibreSsl3.md: Verified the technical debt inventory was accurately updated, decrementing remaining unimplemented exports from 79 to 78 (74 named, 4 NID-only), increasing implemented libtls exports from 14 to 15, and recording the non-preset cipher string behavior. - AGENTS.md conventions: Verified zero comments were introduced in source and test files, Conventional Commits formatting is maintained, and no extra untracked files were added. - Minor: please drop the `Generated with` footer from the description; the AI-assisted checkbox can stay. Looks Good To Me
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!18760
No description provided.