A proof-of-concept synchronous trust-establishment protocol designed for Signal-style secure messaging architectures. Implemented entirely in Rust, this project enforces mandatory out-of-band user verification using Short Authentication Strings (SAS). It establishes forward-secret key material via a Hybrid Key Encapsulation Mechanism (KEM) to mitigate Man-in-the-Middle (MitM) attacks without relying on trusted relay servers.
This implementation prioritizes memory safety, side-channel attack (SCA) mitigation, and strict control flow:
- Memory Zeroization: Sensitive structures and intermediate Finite State Machine (FSM) states are explicitly wiped from memory immediately after use via the
ZeroizeandZeroizeOnDroptraits. - Constant-Time Execution: Decapsulation and MAC validation use the
subtlecrate to ensure constant-time operations, neutralizing timing attacks. - Implicit Rejection: The Hybrid KEM mitigates validation leaks by deterministically deriving a "fake" key using an internal random seed and an HKDF if the MAC is invalid.
- Compile-Time State Safety: The protocol's FSM is enforced using Rust's typestate pattern, encapsulating protocol steps within a generic
Session<S>structure to prevent arbitrary state modifications. - Domain Separation: Hash-reuse attacks are thwarted by integrating constant byte strings into SHA-256 hash updates based on the protocol step.
The protocol outputs two mutually authenticated 32-byte shared secrets (
- Hybrid KEM Combiner: Implements the XOR-then-MAC (XtM) secure combiner.
- Post-Quantum KEM: Utilizes ML-KEM for IND-CCA security against quantum adversaries with classical access.
- Classical KEM: Utilizes Elliptic-Curve DHKEM.
- Authentication & Integrity: Employs Ed25519 for EUF-CMA digital signatures and Poly1305 (via XOR adaptation) for the deterministic MAC.
- Commitment Scheme: Uses a hash-then-open instantiation with SHA-256 for secure SAS verification.
- The FSM is managed by a custom
Protocol Controllerthat maintains theActiveSessionenum and exposes a centralhandle_message()method. - State transitions are strictly validated at compile time and runtime to guarantee a secure control flow.
This module implements standardized traits from the kem crate (RustCrypto), such as TryDecapsulate and Encapsulate, acting as a drop-in replacement for standard cryptographic APIs.
The architecture was designed following the OWASP threat modeling methodology. It addresses:
- Theoretical vulnerabilities: Mitigates Dolev-Yao active adversaries and passive quantum adversaries (harvest now, decrypt later).
- Practical threats: Defends against RAM-based threats and execution monitoring via hardware compromise.