Skip to content

ours-vlessenc ​

libs/vlessenc — Xray's VLESS encryption (encryption/decryption): forward secrecy on ML-KEM-768 + X25519.

API ​

  • Client::new(text) / with_cipher(text, aes) — parsing the client's encryption string (None for none); connect(io) — the handshake and an encrypted stream.
  • Server::new(text), validate(text) — the server's decryption string; reload(text) — replace the keys of a running server (through arc-swap); accept(io).
  • Encrypted — the encrypted stream: take_pending, can_splice, poll_raw_* — access to the underlying stream when the protocol (Vision) switches to direct mode.

Internals ​

Private modules:

  • config — modes, padding, parsing/generating keys (Config, Mode, Padding).
  • crypto — AES-CTR/AEAD wrappers; kdf — BLAKE3 derive-key with arbitrary context bytes (Xray uses a non-UTF-8 context, while the API of the upstream blake3 crate accepts only UTF-8; the hashing of the key material itself is in the upstream crate).

Who uses it ​

ours-mod-vless (the vlessenc feature; the binary — the vlessenc feature).

Specifics ​

  • #![forbid(unsafe_code)] in lib.rs.
  • Secrets are zeroed (zeroize).
  • Dependencies: ml-kem, x25519-dalek, blake3, ring, aes, ctr, rand_core + getrandom, base64, arc-swap, tokio, ours-bufpool.

Tests ​

Unit tests in src/; compatibility with Xray — benchlab (--mode compat, the case vless.tcp.none.vlessenc), see Benchmarks.

GPL-3.0-or-later