Module crypto

Module crypto 

Source
Available on crate feature crypto only.
Expand description

NOMAD Protocol - Security Layer

Implements the cryptographic primitives for NOMAD:

  • Noise_IK handshake
  • XChaCha20-Poly1305 AEAD
  • Nonce construction
  • Anti-replay protection
  • Rekeying

Structs§

CryptoSession
A complete crypto session for secure communication.
HandshakeResult
Result of a completed handshake
InitiatorHandshake
Handshake state machine for the initiator (client).
OldKeyRetention
Manages old keys during the transition period after a rekey.
RekeyState
Tracks the current key epoch and when rekeying is needed.
ReplayWindow
Anti-replay sliding window.
ResponderHandshake
Handshake state machine for the responder (server).
SessionId
Session ID - 48-bit random identifier for session demultiplexing.
SessionKey
A session key for AEAD operations.
SessionKeys
Session keys derived from the Noise handshake.
StaticKeypair
A static X25519 keypair for long-term identity.

Enums§

Direction
Direction of communication for nonce construction.
Role
Role in the handshake (affects which key is used for send/receive)

Constants§

AAD_SIZE
Size of AAD for data frames (type + flags + session_id + nonce_counter)
SESSION_KEY_SIZE
Size of the session key (32 bytes for XChaCha20)

Functions§

construct_aad
Construct AAD (Additional Authenticated Data) for a data frame.
construct_nonce
Construct a 24-byte XChaCha20-Poly1305 nonce.
decrypt
Decrypt ciphertext using XChaCha20-Poly1305.
decrypt_in_place
Decrypt ciphertext in-place, removing the tag.
derive_rekey_auth_key
Derive the rekey authentication key from static DH secret.
derive_rekey_keys
Derive new session keys after a rekey with PCS protection.
encrypt
Encrypt plaintext using XChaCha20-Poly1305.
encrypt_in_place
Encrypt plaintext in-place, appending the tag.
parse_nonce
Parse a nonce back into its components.