feat(libSceLibreSsl3): implement SSL_CTX_set_keylog_callback #16977

Merged
GalaxyGamingFR merged 2 commits from upstream-pr/16977 into main 2026-11-11 16:17:26 +00:00
GalaxyGamingFR commented 2026-11-08 03:34:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by GalaxyGamingFR on 2026-11-08T03:34:24Z.


What

Implement SSL_CTX_set_keylog_callback in libSceLibreSsl3, replacing its parameterless throwing placeholder in AdditionalExports.cpp.

  • Source: LibreSSL 4.0.0 at ce488b78 ssl_lib.c, the revision the library's debt file already uses. Upstream only stores the callback in ctx->keylog_callback. ssl_local.h marks that field "Unused. For OpenSSL compatibility.", and nothing in libssl calls it, so no key material is ever logged.
  • LibreSsl3SslCtx in Key.hpp previously stopped at max_proto_version (136 bytes). It now covers the full ssl_ctx_st LP64 layout, 568 bytes, with keylog_callback at 552. The existing asserts are kept, and new ones pin info_callback (216), ex_data (376), srtp_profiles (480) and keylog_callback (552), so a wrong field in the middle fails to compile. Nothing in the tree allocates an SSL_CTX by sizeof, so the larger size changes no existing behaviour.
  • Api.hpp now declares it as void SSL_CTX_set_keylog_callback(LibreSsl3SslCtx* context, LibreSsl3KeylogCallback callback), with LibreSsl3KeylogCallback as void (*)(const LibreSsl3Ssl*, const char*), matching SSL_CTX_keylog_cb_func.
  • A null context throws std::invalid_argument, where upstream would dereference it.

The gap is recorded in docs/dev/debt/libSceLibreSsl3.md: the console layout is not measured. The export inventory is updated (138 exports, 128 named).

No title's trace or disassembly was used, and the export was not measured on a PS5.

Tested

Windows 11, WinLibs GCC 15.2.0 UCRT. This is not a full CMake build. I compiled tests/GuestLibreSsl3Ssl.cpp with libSceLibreSsl3's Ssl.cpp, Key.cpp, X509.cpp, Asn1Values.cpp and IntegerDecoder.cpp and libSceLibreSsl's Error.cpp into one executable, with APS5_VABI defined empty, a one-line NotImplementedAt_nid_no_patch that throws, and malloc/calloc/free shims. No title or homebrew, and not built on Linux or macOS.

  • The test passes. The new CheckKeylogCallback fills a guarded context with 0x5A, sets a callback and checks that only the 8 bytes at offset 552 changed and now hold the callback. It then sets a null callback and checks that those bytes are cleared, and checks that a null context throws.
  • A deliberate bug that stores the callback in num_tickets (offset 560) makes the test fail.
  • -Wall -Wextra is clean for the changed files, and python tools/check_conventions.py --base origin/main passes.

I searched open and merged pull requests for keylog just before opening this one, and none implements it. #16586, #16588, #16589, #16848 and #16918 change the same export inventory count, so whichever lands later needs a one-line rebase.

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:5208333621 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16977). Originally posted by [GalaxyGamingFR](https://github.com/GalaxyGamingFR) on 2026-11-08T03:34:24Z. --- ### What Implement `SSL_CTX_set_keylog_callback` in `libSceLibreSsl3`, replacing its parameterless throwing placeholder in `AdditionalExports.cpp`. - Source: LibreSSL 4.0.0 at [`ce488b78` `ssl_lib.c`](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libssl/ssl_lib.c#L806-L810), the revision the library's debt file already uses. Upstream only stores the callback in `ctx->keylog_callback`. [`ssl_local.h`](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libssl/ssl_local.h#L855-L860) marks that field "Unused. For OpenSSL compatibility.", and nothing in libssl calls it, so no key material is ever logged. - `LibreSsl3SslCtx` in `Key.hpp` previously stopped at `max_proto_version` (136 bytes). It now covers the full [`ssl_ctx_st`](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libssl/ssl_local.h#L665-L860) LP64 layout, 568 bytes, with `keylog_callback` at 552. The existing asserts are kept, and new ones pin `info_callback` (216), `ex_data` (376), `srtp_profiles` (480) and `keylog_callback` (552), so a wrong field in the middle fails to compile. Nothing in the tree allocates an `SSL_CTX` by `sizeof`, so the larger size changes no existing behaviour. - `Api.hpp` now declares it as `void SSL_CTX_set_keylog_callback(LibreSsl3SslCtx* context, LibreSsl3KeylogCallback callback)`, with `LibreSsl3KeylogCallback` as `void (*)(const LibreSsl3Ssl*, const char*)`, matching `SSL_CTX_keylog_cb_func`. - A null context throws `std::invalid_argument`, where upstream would dereference it. The gap is recorded in `docs/dev/debt/libSceLibreSsl3.md`: the console layout is not measured. The export inventory is updated (138 exports, 128 named). No title's trace or disassembly was used, and the export was not measured on a PS5. ### Tested Windows 11, WinLibs GCC 15.2.0 UCRT. This is not a full CMake build. I compiled `tests/GuestLibreSsl3Ssl.cpp` with libSceLibreSsl3's `Ssl.cpp`, `Key.cpp`, `X509.cpp`, `Asn1Values.cpp` and `IntegerDecoder.cpp` and libSceLibreSsl's `Error.cpp` into one executable, with `APS5_VABI` defined empty, a one-line `NotImplementedAt_nid_no_patch` that throws, and `malloc`/`calloc`/`free` shims. No title or homebrew, and not built on Linux or macOS. - The test passes. The new `CheckKeylogCallback` fills a guarded context with `0x5A`, sets a callback and checks that only the 8 bytes at offset 552 changed and now hold the callback. It then sets a null callback and checks that those bytes are cleared, and checks that a null context throws. - A deliberate bug that stores the callback in `num_tickets` (offset 560) makes the test fail. - `-Wall -Wextra` is clean for the changed files, and `python tools/check_conventions.py --base origin/main` passes. I searched open and merged pull requests for `keylog` just before opening this one, and none implements it. #16586, #16588, #16589, #16848 and #16918 change the same export inventory count, so whichever lands later needs a one-line rebase. ### Checklist - [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)
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!16977
No description provided.