Skip to content

ours-ktls-sys ​

libs/ktls-sys — a workspace crate with unsafe: kernel TLS system calls that are not in rustix.

What it does ​

  • set_keys — hand the kernel the TLS 1.3 keys (kernel_tx/kernel_rx) for the cipher Cipher.
  • send_record — send a record of a type other than application data (alert, handshake — for example, KeyUpdate) through sendmsg with the control message TLS_SET_RECORD_TYPE.
  • attach — attach the tls ULP to a TCP socket, before the keys.
  • recv_record — receive one decrypted record and its type from the control message TLS_GET_RECORD_TYPE; a record that fails to decrypt (EBADMSG) is InvalidData.
  • supports_key_update — whether the kernel accepts new keys on a live connection: Linux 6.14 or later, read from uname.

Everything else (splice, reading records before the handover) is done by ours-tls13.

Why a separate crate ​

The workspace forbids unsafe. The kTLS calls need it, so they live in this small crate with its own [lints]; see unsafe.

Who uses it ​

ours-tls13 (the unstable-ktls feature, an optional dependency). As a dev dependency — the tests of ours-mod-tls and ours-mod-vless.

Specifics ​

  • Dependencies: libc and rustix (for uname).
  • Works only on Linux; when kTLS is unavailable, the decision to stay in userspace TLS is made by ours-tls13, not by this crate.

Tests ​

None of its own; kTLS is checked by modules/system/tls/tests/ktls.rs and the VLESS/HTTP tests, partly #[ignore] (they need the tls module and a kernel with key updates).

GPL-3.0-or-later