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 machineNoiseHandshake- WhatsApp-specific wrapper with libsignal DHHandshakeUtils- 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§
Structs§
- Handshake
State - Full handshake state machine for WhatsApp Noise XX handshake.
- Handshake
Utils - Handshake utilities for WhatsApp protocol operations
- Noise
Cipher - A cipher wrapper that encapsulates AES-256-GCM encryption/decryption with counter-based IV generation.
- Noise
Handshake - A WhatsApp-specific Noise handshake wrapper that uses libsignal for DH operations.
- Noise
Keys - The final keys extracted from a completed Noise handshake.
- Noise
State - A generic Noise Protocol XX state machine.
Enums§
- Edge
Routing Error - Handshake
Error - Noise
Error - 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§
- Aes256
Gcm - AES-GCM with a 256-bit key and 96-bit nonce.
- Handshake
Result - Result