feat(libSceLibreSsl): implement SSL_set_verify, SSL_get0_alpn_selected, SSL_set_connect_state and SSL_ctrl #11143
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11143"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by ahmadmuj on 2026-10-25T19:31:49Z.
What
Implements
SSL_set_verify,SSL_get0_alpn_selected,SSL_set_connect_stateandSSL_ctrlin libSceLibreSsl, which threw and were declared without parameters.Parent #10481 has merged. This branch uses its
LibreSslSsl/LibreSslSslInternallayouts. The parent functions stay unchanged; the internal padding is split into the named fields these calls need (rwstateandshutdownstay where they were).Behaviour follows LibreSSL 2.5.4
ssl_lib.c,ssl_locl.handd1_both.c, the version in the firmware 13.40 measurements:void SSL_set_verify(SSL*, int mode, cb)verify_mode = mode;internal->verify_callback = cbonly whencbisn't nullvoid SSL_get0_alpn_selected(const SSL*, const unsigned char**, unsigned*)s3, elses3->internal->alpn_selectedand its lengthvoid SSL_set_connect_state(SSL*)server = 0,shutdown = 0,state = SSL_ST_CONNECT|SSL_ST_BEFORE,handshake_func = method->internal->ssl_connectlong SSL_ctrl(SSL*, int, long, void*)SSL_ctrlhandles itself: read ahead (int, so set truncates and get sign-extends), msg callback arg, options / mode set and clear (64-bit), max cert list,SET_MTU(signed compare against 228, DTLS only), max send fragment (512..16384), RI supportOffsets:
options8,mode16,handshake_func56,msg_callback_arg72,verify_callback88,read_ahead212, the cipher and hash contexts 240-264,max_cert_list296 andstate412 inssl_internal_st;s3->internal136 withalpn_selected1024 andsend_connection_binding1012;method->internal40 withssl_connect40;d1->internal32 withmtu636. All arestatic_asserted, and I checked them againstoffsetoffrom the 2.5.4 headers built on x86-64.What throws instead of matching:
SSL_ctrlcommands that 2.5.4 sends on tossl3_ctrl/dtls1_ctrl(that includesSSL_set_tlsext_host_name); the message names the command.SSL_set_connect_statewhen one of the six cipher or hash contexts is still set. LibreSSL frees those, and we can't do that yet. They're null until a handshake has run. It checks before writing anything.Nothing here creates an
SSLor anSSL_METHODyet (SSL_new,TLS_client_methodstill throw), so for now only structures the caller builds reach these. The debt entry records these limits.Left out on purpose:
SSL_get_ex_data/SSL_set_ex_data(set allocates the stack on its first call; get alone isn't useful while set throws). Other SSL exports remain outside this PR.Tested
Ubuntu 24.04 on WSL2, GCC 13.3, Release. Head
1d7fa6ebac59merges maind893997f1a6f, which includes #10481. Its entire LibreSSL source, header and build tree, plus the relevant tests, match the testedd708a2573e6aexactly. The following fresh checks ran at that unchanged tree before the parent merged; they are not repeated for this history-only alignment. The fresh focused build passes. All 5 selected tests pass:guest_libressl_ssl,guest_libressl_ssl_settings,guest_libressl_ssl_ctx,guest_libressl_ssl_ctx_fieldsandguest_libressl_error. All 65 public-header checks pass. Conventions and whitespace checks pass.The merge preserves the SSL feature source and tests, plus main's SSL context source and tests, byte for byte. It combines their build and header entries. The prior 60-test LibreSSL run at
485e945c38ddremains earlier evidence; this update runs the five integration tests above. Merged parent #10481 preserves the same SSL accessor source and test.The parent now calls the SSL type
LibreSslSsl. This branch adopts that name in the child declarations, implementation and test. It resolves the clash with main'snamespace LibreSsl. The guest layout and behavior stay unchanged. The old-header syntax failure reproduces before the rename and passes after it. Earlier differential and mutation checks are not repeated.guest_libressl_ssl_settingstest. It fills the structs with byte patterns and compares the whole struct after each call, so a write to a neighbour field fails. It covers eachSSL_ctrlcommand's boundaries (227/228 and -1 /INT64_MINfor MTU, 511/512/16384/16385 and 0x100000200 for the fragment size, read-ahead truncation 0x123456789ABCDEF0 -> -1698898192, options/mode with -1 and bits above 32),ssl_connectvsssl_acceptpicked from the method, and every null path. The refused live-context and forwarded-command cases aren't pinned by the test, so they can be implemented later without touching it.SSL_newobject and printed the field bytes before and after. The test's expected values match its output.SSL_ctrlcommand) all failed the test as first pushed. With the two loops gone, mutations on the refused paths no longer fail it. On #10481's base the test doesn't compile, since the stubs take no parameters.guest_libressl_ssl(#10481's test) still passes.public_headerspasses, and so doescheck_conventions.py --base origin/main.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T19:34:19Z.
Review: APPROVED
Reviewed the PR-specific
Ssl.cppimplementation against LibreSSL 2.5.4'sssl_lib.cand the declared #10481 structure dependency. The setter/getter field accesses, non-null verify-callback rule, ALPN null-state outputs, connect-state assignments, and the directly handledSSL_ctrlcommands match the pinned source.SET_MTUpreserves the source's minimum check, DTLS-only dispatch, stored-width conversion and return value; the unsupported delegated commands are explicitly recorded rather than partially implemented.Local checks:
Ssl.cpp,GuestLibreSslSsl.cpp, andGuestLibreSslSslSettings.cpp: passed.python3 tools/check_conventions.py --base upstream/main --head HEAD: passed.The author reports a field-by-field differential against LibreSSL 2.5.4, 44 mutation checks, and the prior #10481 focused test passing. Hosted eligibility, conventions, intake, labels and report pass; product/library jobs are skipped. I did not independently run the LibreSSL differential or Windows/console tests. The dependency on #10481 remains in the stated stack order. No blocking issue found in this PR-specific diff.