Skip to main content

Module enc

Module enc 

Source
Expand description

Opt-in negotiated transport encryption (enc/1, docs/roadmap.md, step 14).

Uses published standards implemented by the reviewed ring crate (no custom cryptography):

  • Ephemeral X25519 key agreement (RFC 7748) carried in Labstream-Features: enc/1=<64-hex-pubkey> with zero extra round-trips.
  • HKDF-SHA256 (RFC 5869) key derivation bound to both public keys and an optional pre-shared key (labstream.EncryptionKey) for mutual peer authentication.
  • Length-prefixed ChaCha20-Poly1305 AEAD framing (RFC 8439) with strict 64-bit monotonic nonces and frame-length AAD binding on every byte after the two plain test-pattern samples.

enc/1 is off by default. Users enable it by adding enc to labstream.Features, setting labstream.RequireEncryption = 1, or calling set_runtime_policy.

Structs§

EncReader
Authenticated ChaCha20-Poly1305 frame reader that decrypts ciphertext chunks into plaintext bytes.
EncWriter
Authenticated ChaCha20-Poly1305 frame writer wrapping any Write stream.
EncryptionPolicy
Process-wide encryption policy.
EphemeralKey
Ephemeral X25519 keypair for one feed handshake.

Constants§

MAX_FRAME_CIPHER
Maximum ciphertext bytes accepted in one frame (plaintext + Poly1305 tag).
MAX_FRAME_PLAIN
Maximum plaintext bytes sealed into one ChaCha20-Poly1305 frame.
TAG_LEN
Poly1305 authentication tag width in bytes.

Functions§

compiled_in
True when this binary was compiled with the encryption Cargo feature.
effective_policy
Active encryption policy from set_runtime_policy or lsl_api.cfg.
set_runtime_policy
Override the active encryption policy at runtime (pass None to revert to lsl_api.cfg defaults).