code wiki / (root) / nx_tls13_io.nx

nx_tls13_io.nx

buildroot/runtime/nx_tls13_io.nx

7184 B190 linesdepth 5pulls 7 transitivereach 12 importersview sourcekind librarytopic tls13
docsdependenciesstructsconstsfunctions

about

nx_tls13_io.nx -- TLS 1.3 record I/O over TCP (Linux x86_64). Phase 0c of the Nishi TLS 1.3 stack per docs/NISHI_TLS13_GAP_AUDIT.md. Turns the in-memory record-layer primitives shipped in T4 (nx_tls13_record) into byte streams on real TCP sockets. Pure wire-format wrapper; doesn't touch handshake state or AEAD -- that's the caller's job using nx_tls13_client / nx_tls13_server. Architecture pinning: uses Linux x86_64 syscalls (sys_socket / sys_bind / sys_listen / sys_accept / sys_connect / sys_read / sys_write). Runs natively via the x86_64 smoke driver; doesn't run under qemu-RV64 because the socket-syscall wrappers aren't yet in the RV64 nx_syscalls.nx (queued separately as "RV64 socket parity"). TLSPlaintext wire format (RFC 8446 ยง5.1): struct { ContentType type; // 1 byte ProtocolVersion legacy; // 2 bytes, big-endian, 0x0303 uint16 length; // 2 bytes, big-endian opaque fragment[length]; // length bytes } TLSPlaintext; What it does today: - tls13_io_send_record(fd, type, payload, payload_len) Constructs the 5-byte header + payload, writes to fd in one buffer (single sys_write to minimize Nagle effects). - tls13_io_recv_record(fd, out_type, out_buf, out_cap, out_len) Reads 5-byte header, parses length, reads exactly length bytes of body (loops on partial recv). - tcp_listen_loopback(port): bind 127.0.0.1:port + listen - tcp_connect_loopback(port): connect to 127.0.0.1:port What it doesn't do yet: - TLSCiphertext encrypt/decrypt orchestration (caller wraps each app record via nx_tls13_record + seq counter; this file is plain wire-format only) - Handshake-driving wrapper (next turn: nx_tls13_https.nx will compose this + nx_tls13_handshake + nx_tls13_client to do

dependencies 3 imports · 7 importers

nx_syscalls_x86_64.nx nx_connect.nx nx_tls13.nx nx_tls13_io.nx nx_iot_ctl_gate.nx nx_moonraker_io.nx nx_moonraker_io_ipv4_test.nx nx_moonraker_io_test.nx nx_moonraker_ready_check_test.nx nx_printer_ctl_gate.nx nx_tls13_handshake_io.nx

imports: nx_syscalls_x86_64.nxnx_connect.nxnx_tls13.nx

imported by: nx_iot_ctl_gate.nxnx_moonraker_io.nxnx_moonraker_io_ipv4_test.nxnx_moonraker_io_test.nxnx_moonraker_ready_check_test.nxnx_printer_ctl_gate.nxnx_tls13_handshake_io.nx

structs

none

consts

66const NX_TLS13_IO_VERDICT_OK: i64 = 1
67const NX_TLS13_IO_VERDICT_SHORT_HEADER: i64 = 2
68const NX_TLS13_IO_VERDICT_SHORT_BODY: i64 = 3
69const NX_TLS13_IO_VERDICT_OVERSIZE: i64 = 4
70const NX_TLS13_IO_VERDICT_SOCKET_FAIL: i64 = 5
71const NX_TLS13_IO_VERDICT_N: i64 = 6
73const NX_TLS13_IO_MAX_RECORD: i64 = 16640 // TLSCiphertext.length ceiling

functions

79func tcp_listen_loopback(port: i64) -> i64
102func tcp_connect_loopback(port: i64) -> i64
121func tls13_io_send_record(
155func tls13_io_recv_record(
186func nx_tls13_io_verdict_is_valid(v: i64) -> i64