code wiki / (root) / nx_tls13_client_session_run.nx

nx_tls13_client_session_run.nx

buildroot/runtime/nx_tls13_client_session_run.nx

13638 B308 linesdepth 18pulls 108 transitivereach 485 importersview sourcekind tooltopic tls13
docsdependenciesstructsconstsfunctions

about

nx_tls13_client_session_run.nx -- step 3c.6b of the nx_https_client wiring arc. THE top-level TLS 1.3 client handshake orchestrator. Takes a connected TCP fd (from step 2 nx_https_url_connect) + an SNI hostname + caller-supplied entropy + a TrustValidationContext, and drives the full handshake to CONNECTED state. After this primitive returns OK, the returned session can be used by step 4 (nx_https_get_complete) to send + receive application data records. Pipeline: 1. session = session_new(client_random, x25519_priv) (3c.1) 2. emit_ch(session, sni, ch_buf, ch_cap) (3c.1) 3. write_n(fd, ch_buf, ch_len) 4. read_record_from_fd(fd, sh_record, max) (3c.6a) 5. recv_sh(session, sh_record_body, sh_body_len) (3c.2) -- the ServerHello arrives as a TLSPlaintext record so we strip the 5-byte header and pass the handshake bytes 6. Loop until session.state == WAIT_CLIENT_FIN: 6a. read_record_from_fd(fd, hs_record, max) 6b. handle: either ChangeCipherSpec (skip; legacy compat) OR encrypted handshake -- recv_hs(session, record, val_ctx) (3c.3) 7. emit_finished(session, cf_buf, cf_cap) → 58-byte encrypted record (3c.4) 8. write_n(fd, cf_buf, cf_len) 9. derive_app(session) (3c.5) Public API: nx_tls13_client_session_run( fd, sni, sni_len, client_random, x25519_priv, val_ctx ) -> *Tls13ClientSession on success, NULL on failure nx_tls13_run_last_verdict() -> i64 -- last error verdict nx_tls13_run_verdict_is_valid(v) -> 0|1 Sealed verdict (latched in a module-private static when

dependencies 10 imports · 75 importers

nx_syscalls.nx nx_tls13.nx nx_tls13_record.nx nx_tls13_client_validate_certifica nx_tls13_client_session.nx nx_tls13_client_session_recv_sh.nx nx_tls13_client_session_recv_hs.nx nx_tls13_client_session_emit_finis nx_tls13_client_session_derive_app nx_tls13_read_record_from_fd.nx nx_tls13_client_session_run.nx _dlr_probe.nx nx_acme_directory_live.nx nx_acme_directory_live_real_ca_tes nx_acme_http.nx nx_app_monitor.nx nx_aw_verify_gate.nx nx_browser_own_site_live_test.nx nx_cad_verify_gate.nx nx_cert_autorenew.nx nx_cms_tls_gate.nx

diagram shows first 10 each side; +0 more imports, +65 more importers in the complete lists below.

imports: nx_syscalls.nxnx_tls13.nxnx_tls13_record.nxnx_tls13_client_validate_certificate.nxnx_tls13_client_session.nxnx_tls13_client_session_recv_sh.nxnx_tls13_client_session_recv_hs.nxnx_tls13_client_session_emit_finished.nxnx_tls13_client_session_derive_app.nxnx_tls13_read_record_from_fd.nx

imported by: _dlr_probe.nxnx_acme_directory_live.nxnx_acme_directory_live_real_ca_test.nxnx_acme_http.nxnx_app_monitor.nxnx_aw_verify_gate.nxnx_browser_own_site_live_test.nxnx_cad_verify_gate.nxnx_cert_autorenew.nxnx_cms_tls_gate.nxnx_connect_live_verify.nxnx_crew_live_verify.nxnx_dev_api_build_probe.nxnx_edge_probe.nxnx_fetch_jellyfin_test.nxnx_funcheck.nxnx_gallery_auth_research_fetch.nxnx_golive_dns_gate.nxnx_hf_probe.nxnx_hifigan_stream_fetch.nxnx_hls_live_probe.nxnx_https_fetch.nxnx_https_fetch_file.nxnx_https_fetch_follow.nxnx_https_fetch_lib.nxnx_https_get.nxnx_https_get_cli.nxnx_https_get_cli2.nxnx_https_get_happy_test.nxnx_https_get_live_demo_test.nxnx_https_get_live_google_test.nxnx_https_get_live_real_ca_test.nxnx_https_ka_probe.nxnx_hub_lib_verify_gate.nxnx_hub_verify_gate.nxnx_iot_fetch_probe.nxnx_iot_verify_gate.nxnx_kaprobe.nxnx_lib_fetch.nxnx_lib_fetch_cookie.nxnx_library_fetch.nxnx_login_e2e_probe.nxnx_mcp_call.nxnx_mgmt_client.nxnx_model_fetch.nxnx_night_fetch_test.nxnx_nist_verify_gate.nxnx_office_live_verify.nxnx_onsite_frontier_fetch.nxnx_onsite_research_fetch.nxnx_orch_verify_gate.nxnx_porkbun_ping_probe.nxnx_research_fetch_wiki_test.nxnx_research_ka.nxnx_room_live_gate.nxnx_room_perf_gate.nxnx_scilib_verify_gate.nxnx_sclass_ux_research_fetch.nxnx_semantic_research_fetch.nxnx_site_probe.nxnx_sovgit_push.nxnx_survey_live_verify.nxnx_tls13_chrome_session.nxnx_tls13_client_session_run_test.nxnx_tlsprobe.nxnx_torrent_live_probe.nxnx_url_probe.nxnx_url_truth_gate.nxnx_uxf_fetch_avro.nxnx_uxf_fetch_protobuf.nxnx_web_crawl_breadth.nxnx_web_crawl_index.nxnx_webpub_fetch.nxnx_ws_client_session.nxnx_zerodt_fetch.nx

structs

none

consts

83const NX_MAGIC_1024: i64 = 1024
85const NX_TLS13_RUN_OK: i64 = 1
86const NX_TLS13_RUN_EMIT_CH_FAIL: i64 = 2
87const NX_TLS13_RUN_WRITE_CH_FAIL: i64 = 3
88const NX_TLS13_RUN_READ_SH_FAIL: i64 = 4
89const NX_TLS13_RUN_RECV_SH_FAIL: i64 = 5
90const NX_TLS13_RUN_READ_HS_FAIL: i64 = 6
91const NX_TLS13_RUN_RECV_HS_FAIL: i64 = 7
92const NX_TLS13_RUN_EMIT_CF_FAIL: i64 = 8
93const NX_TLS13_RUN_WRITE_CF_FAIL: i64 = 9
94const NX_TLS13_RUN_DERIVE_APP_FAIL: i64 = 10
95const NX_TLS13_RUN_LOOP_BUDGET_EXCEEDED: i64 = 11
96const NX_TLS13_RUN_VERDICT_N: i64 = 12
102const NX_TLS13_RUN_MAX_HS_RECORDS: i64 = 8
107const NX_TLS13_RUN_RECORD_BUF_BYTES: i64 = 16645

functions

109func nx_tls13_run_verdict_is_valid(v: i64) -> i64
called by 1: main
132func _write_n(fd: i64, buf: *u8, n: i64) -> i64
146func _is_change_cipher_spec(buf: *u8, n: i64) -> i64
159func _run_pn(v: i64) -> i64
170func nx_tls13_client_session_run(
306func main() -> i64