feat(libSceLibreSsl3): implement libtls context and config lifecycle #15289

Closed
hyvvs wants to merge 7 commits from upstream-pr/15289 into main
hyvvs commented 2026-11-02 22:48:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hyvvs on 2026-11-02T22:48:17Z.


What

Implement 10 previously throwing libSceLibreSsl3 libtls exports: tls_config_new, tls_config_free, tls_config_error, tls_config_set_key_mem, tls_client, tls_server, tls_free, tls_error, tls_configure and tls_close. These exports now have typed guest SysV signatures and opaque public handles. Configurations own and securely clear copied key-memory buffers; contexts retain configurations until release or reconfiguration. A fresh client can be configured and closed, while a server configuration without a certificate fails with an error, matching LibreSSL's preconnection behavior.

Signatures and ownership follow OpenBSD libtls, specifically tls.c, tls_config.c, tls_keypair.c, tls_client.c and tls_server.c. Only preconnection lifecycle/configuration semantics are implemented. TLS handshakes, reads, writes, transport, certificate parsing, and tls_config_set_cert_mem remain throwing; this PR cannot establish a TLS session. Native PS5 firmware ABI and exact error strings remain unverified, as recorded in technical debt. No additional dependency is introduced.

The progress scanner measures libSceLibreSsl3 18/270 → 28/270, exactly ten new real function bodies; the pending inventory was updated accordingly.

Tested

  • Windows WinLibs GCC 15.2: compiled real src/LibTls.cpp into a DLL with an import library, linked tests/LibTls.cpp as a separate guest executable, and ran it successfully. It validates exact typed ABI and 8,192 config/key lifetime and ownership iterations.
  • Ubuntu WSL2 GCC: compiled the same source and tests with -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer; ASAN_OPTIONS=detect_leaks=1:halt_on_error=1, UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1; passed with no sanitizer errors.
  • core/libs/tests/test_public_headers.py --audit-only: 405 libraries / 27,906 exports verified, and affected public-header compilation batches 49, 50 and 51 passed.
  • tools/check_conventions.py --base upstream/main passed; git diff --check passed; tools/progress.py --module libSceLibreSsl3 confirmed ten newly implemented exports.
  • Full CMake/CTest not attempted in this clean worktree because required third-party submodules are not initialized. The focused guest test is registered under libSceLibreSsl3/CMakeLists.txt and links libSceLibreSsl3 and libc.

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 (none added)
  • 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:5128667566 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15289). Originally posted by [hyvvs](https://github.com/hyvvs) on 2026-11-02T22:48:17Z. --- ### What Implement **10** previously throwing `libSceLibreSsl3` libtls exports: `tls_config_new`, `tls_config_free`, `tls_config_error`, `tls_config_set_key_mem`, `tls_client`, `tls_server`, `tls_free`, `tls_error`, `tls_configure` and `tls_close`. These exports now have typed guest SysV signatures and opaque public handles. Configurations own and securely clear copied key-memory buffers; contexts retain configurations until release or reconfiguration. A fresh client can be configured and closed, while a server configuration without a certificate fails with an error, matching LibreSSL's preconnection behavior. Signatures and ownership follow [OpenBSD libtls](https://github.com/openbsd/src/tree/master/lib/libtls), specifically `tls.c`, `tls_config.c`, `tls_keypair.c`, `tls_client.c` and `tls_server.c`. **Only preconnection lifecycle/configuration semantics are implemented.** TLS handshakes, reads, writes, transport, certificate parsing, and `tls_config_set_cert_mem` remain throwing; this PR cannot establish a TLS session. Native PS5 firmware ABI and exact error strings remain unverified, as recorded in technical debt. No additional dependency is introduced. The progress scanner measures `libSceLibreSsl3` **18/270 → 28/270**, exactly ten new real function bodies; the pending inventory was updated accordingly. ### 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. --> - Windows WinLibs GCC 15.2: compiled real `src/LibTls.cpp` into a DLL with an import library, linked `tests/LibTls.cpp` as a separate guest executable, and ran it successfully. It validates exact typed ABI and 8,192 config/key lifetime and ownership iterations. - Ubuntu WSL2 GCC: compiled the same source and tests with `-fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer`; `ASAN_OPTIONS=detect_leaks=1:halt_on_error=1`, `UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1`; passed with no sanitizer errors. - `core/libs/tests/test_public_headers.py --audit-only`: **405 libraries / 27,906 exports** verified, and affected public-header compilation batches 49, 50 and 51 passed. - `tools/check_conventions.py --base upstream/main` passed; `git diff --check` passed; `tools/progress.py --module libSceLibreSsl3` confirmed ten newly implemented exports. - Full CMake/CTest not attempted in this clean worktree because required third-party submodules are not initialized. The focused guest test is registered under `libSceLibreSsl3/CMakeLists.txt` and links `libSceLibreSsl3` and `libc`. ### 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 (none added) - [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

Pull request closed

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!15289
No description provided.