Skip to main content

Crate yip_crypto

Crate yip_crypto 

Source
Expand description

Noise-IKpsk2 post-quantum hybrid handshake and AEAD session crypto for the yip data plane, built on the snow Noise Protocol Framework. Establishing a Session requires completing an IKpsk2 Handshake; the session then seals/opens inner frames with explicit per-frame nonces and a sliding anti-replay window.

snow drives the Noise handshake only. Once the handshake completes, the two secret transport keys are extracted via snow’s dangerously_get_raw_split() (the same HKDF-derived bytes snow’s own split() uses internally) and handed to ring’s asm ChaCha20-Poly1305 for the data-plane hot path, keyed with the Noise nonce convention (4 zero bytes ++ 8-byte little-endian counter). This is byte-identical to snow’s own transport state but faster.

Structs§

ChaCha20Poly1305Cipher
ChaCha20-Poly1305 AEAD cipher supporting zero-copy in-place encryption and decryption directly within pre-allocated network packet buffers (such as AF_XDP UMEM chunks).
Handshake
An in-progress Noise-IKpsk2 post-quantum hybrid handshake.
Keypair
An X25519 static keypair (32-byte private and public halves).
PqCiphertext
An ML-KEM-512 encapsulated ciphertext.
PqDecapsKey
An ML-KEM-512 private decapsulation key wrapped in zeroizing memory.
PqEncapsKey
An ML-KEM-512 public encapsulation key.
ReplayWindow
A wide sliding replay window over a monotonic u64 counter using a circular word ring.
Sealed
A sealed frame: the AEAD ciphertext plus the explicit nonce it was sealed under. The caller carries counter on the wire so the peer can open.
Session
An established AEAD session. Seals outgoing frames under a monotonic counter and opens incoming frames out of order, rejecting replays.

Enums§

CryptoError
Errors from the crypto layer.
ReplayProfile
Sizing profile for the sliding replay window bitmap.

Constants§

PQ_CIPHERTEXT_LEN
ML-KEM-512 ciphertext length in bytes (FIPS 203).
PQ_ENCAPS_KEY_LEN
ML-KEM-512 encapsulation key length in bytes (FIPS 203).
PQ_SHARED_SECRET_LEN
ML-KEM-512 shared secret length in bytes (FIPS 203).
REPLAY_WINDOW_BITS
Number of past counters the replay window tracks behind the latest in HighThroughput mode.
REPLAY_WINDOW_BITS_HIGH_THROUGHPUT
HighThroughput profile replay window parameters (16 KB bitmap).
REPLAY_WINDOW_BITS_STANDARD
Standard profile replay window parameters (1 KB bitmap).
REPLAY_WORDS
REPLAY_WORDS_HIGH_THROUGHPUT
REPLAY_WORDS_STANDARD

Functions§

generate_keypair
Generate a fresh X25519 static keypair.
generate_pq_keypair
Generate a fresh ML-KEM-512 keypair.
pq_decapsulate
Decapsulate ct using dk, recovering the 32-byte shared secret wrapped in zeroizing memory.
pq_encapsulate
Encapsulate a shared secret toward ek, producing (ciphertext, shared_secret).