Skip to content

Repository files navigation

DoneZero

局域网安全方案:物理交互 + 密码学纵深防御
LAN Security: Physical Interaction + Cryptographic Defense-in-Depth

中文 | English


Overview

DoneZero is a Rust implementation of a layered defense architecture for securing local-area network (LAN) services. It anchors trust in a non-replicable physical interaction (QR code + 4-digit code + IP confirmation), then enforces that trust with cryptographic constraints that are non-extensible and non-reusable.

Core principle: Do subtraction, not addition. Trust battle-tested primitives audited by global cryptographers. Resist the urge to "add your own sauce" at the application layer.

Architecture

┌─────────────────────────────────────────────────────────┐
│ Physical Space Verification │
│ Rotating QR (3s) + 4-digit Code + IP Highlight │
├─────────────────────────────────────────────────────────┤
│ TOFU Certificate Pinning │
│ SHA-256 fingerprint embedded in QR payload │
├─────────────────────────────────────────────────────────┤
│ One-Time Handshake State Machine │
│ One code, one verification, atomic state transition │
├─────────────────────────────────────────────────────────┤
│ Dual-Token Depth + Channel Binding │
│ Refresh Token bound to TLS; Access Token random expiry │
├─────────────────────────────────────────────────────────┤
│ CSPRNG (OS-level) │
│ getrandom / OsRng — no app-layer entropy mixing │
├─────────────────────────────────────────────────────────┤
│ Memory Anti-Forensics │
│ mlock / VirtualLock + zeroize on Drop │
├─────────────────────────────────────────────────────────┤
│ Boundary Constraints + Traffic Padding (optional) │
│ NIC binding; constant-rate padding │
└─────────────────────────────────────────────────────────┘

Attack Surface Coverage

Attack TypeDefenseEffect
LAN MITM / SniffingTLS + TOFU cert fingerprintBlocked
QR Screenshot Replay3s rotation + 4-digit codeSingle-shot
Brute-force CodeOne-code-one-verify, atomic killZero expected
Token Leak / ReuseChannel Binding + random expiryLeak = revoke
Memory Forensics / Swapmlock + zeroizeNo trace
Concurrent PreemptionAtomic state machine409 / 410
Timing AttackConstantTimeEqNo leakage
Traffic AnalysisConstant-rate padding (optional)Flat profile

Quick Start

# Clone & build
git clone https://github.com/Ink-dark/DoneZero.git
cd DoneZero
cargo build --release
# Run
cargo run
# Server starts on detected LAN IP:8443

API Endpoints

MethodEndpointDescription
GET/healthHealth check
POST/api/handshakeCreate handshake (QR + code)
POST/api/verifyVerify handshake code
POST/api/token/refreshRefresh Access Token
GET/api/confirmScreen IP confirmation page

Project Structure

DoneZero/
├── src/
│ ├── main.rs # Entry point
│ ├── lib.rs # Module exports
│ ├── server.rs # HTTP service (axum)
│ ├── state_machine.rs # Handshake state machine
│ ├── tofu.rs # TOFU certificate pinning
│ ├── physical.rs # QR code + verification code
│ ├── token.rs # Dual-token + channel binding
│ ├── memory.rs # mlock + zeroize
│ ├── csprng.rs # OS-level CSPRNG
│ ├── boundary.rs # Network boundary constraints
│ └── error.rs # Error types
├── docs/ # Detailed documentation
├── Cargo.toml
└── README.md / README.zh-CN.md

Documentation

License

MIT License — see LICENSE for details.


Design Philosophy

  1. Do subtraction, not addition.
  2. The state machine is the anchor.
  3. Trust boundaries are precise.
  4. Defense-in-depth, not single-point.

About

LAN security with physical QR verification + cryptographic defense-in-depth. Rust implementation of 7-layer defense architecture. 局域网安全方案:物理二维码验证 + 密码学纵深防御,Rust七层防御架构实现。

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages