Skip to main content

Crate wacore_noise

Crate wacore_noise 

Source
Expand description

Noise Protocol implementation for WhatsApp with AES-256-GCM.

This crate provides both a generic Noise Protocol XX state machine and WhatsApp-specific handshake utilities.

§Structure

  • NoiseState - Generic Noise XX protocol state machine
  • NoiseHandshake - WhatsApp-specific wrapper with libsignal DH
  • HandshakeUtils - WhatsApp protocol message building/parsing

§Example (Generic)

use wacore_noise::{NoiseState, generate_iv};

let mut noise = NoiseState::new(b"Noise_XX_25519_AESGCM_SHA256\0\0\0\0", &prologue)?;
noise.authenticate(&my_ephemeral_public);
noise.mix_key(&shared_secret)?;
let ciphertext = noise.encrypt(plaintext)?;
let keys = noise.split()?;

§Example (WhatsApp)

use wacore_noise::{NoiseHandshake, HandshakeUtils};

let mut nh = NoiseHandshake::new(NOISE_START_PATTERN, &WA_CONN_HEADER)?;
nh.authenticate(&ephemeral_public);
nh.mix_shared_secret(&private_key, &their_public)?;
let (write_key, read_key) = nh.finish()?;

Modules§

framing

Structs§

HandshakeState
Full handshake state machine for WhatsApp Noise XX handshake.
HandshakeUtils
Handshake utilities for WhatsApp protocol operations
NoiseCipher
A cipher wrapper that encapsulates AES-256-GCM encryption/decryption with counter-based IV generation.
NoiseHandshake
A WhatsApp-specific Noise handshake wrapper that uses libsignal for DH operations.
NoiseKeys
The final keys extracted from a completed Noise handshake.
NoiseState
A generic Noise Protocol XX state machine.

Enums§

EdgeRoutingError
HandshakeError
NoiseError
Errors that can occur during Noise protocol operations.

Constants§

MAX_EDGE_ROUTING_LEN
Maximum length for edge routing data (3 bytes max = 0xFFFFFF)
WA_CERT_PUB_KEY
The public key for verifying the server’s intermediate certificate.

Functions§

build_edge_routing_preintro
Builds the edge routing pre-intro header. Format: ED\0\1 (4 bytes) + length (3 bytes big-endian) + routing_data
build_handshake_header
Builds the complete handshake connection header.
generate_iv
Generates an IV (nonce) for AES-GCM from a counter value. The counter is placed in the last 4 bytes of a 12-byte IV.

Type Aliases§

Aes256Gcm
AES-GCM with a 256-bit key and 96-bit nonce.
HandshakeResult
Result