Skip to content

feat(wsserver): E2E PAKE handshake — X25519 ECDH + AES-256-GCM - #102

Open
blaspat wants to merge 3 commits into
mainfrom
feat/e2e-pake-handshake
Open

feat(wsserver): E2E PAKE handshake — X25519 ECDH + AES-256-GCM#102
blaspat wants to merge 3 commits into
mainfrom
feat/e2e-pake-handshake

Conversation

@blaspat

@blaspat blaspat commented Aug 4, 2026

Copy link
Copy Markdown
Owner

Summary

Server-side counterpart to the Go client E2E handshake. Implements the full PAKE-style handshake: X25519 ECDH → HKDF with pairing token → HMAC mutual auth → AES-256-GCM encryption for all operational messages.

Changes

  • wsserver/e2e.py (new) — X25519 keygen, ECDH, HKDF-SHA256 key derivation, HMAC proof generation/verification, AES-256-GCM encrypt/decrypt
  • wsserver/server.py — ECDH exchange in hello_ack, proof verification in auth, session key derivation after auth_ok. Encrypted send/receive wrappers in message dispatch loop. Ping/pong responses encrypted via local _send wrapper. Old clients without e2e flag fall back to plaintext auth
  • docs/e2e-spec.md (new) — Full protocol specification: handshake flow, cryptographic primitives, message structures, error codes, MITM/replay analysis
  • README.md — Document E2E encryption with security properties table
  • .github/workflows/release.yml — Fernet key for release workflow

Security properties

Property How
Token never on wire Only HMAC proofs exchanged; token mixed into HKDF during key derivation
Forward secrecy Ephemeral X25519 keys per session, discarded on disconnect
MITM resistance Without token, attacker can't forge HMAC proof → auth_err (4001)
Backward compatible Nodes without e2e: true fall back to legacy plaintext auth

Test plan

All 14 existing tests still pass. The handshake is backward compatible — old clients without e2e: true negotiate plaintext auth.

blaspat added 3 commits July 22, 2026 17:15
The Test job in release.yml was failing because HERMES_NODES_TOKEN_KEY
is required by the internal auth token system but was not set in CI.

Signed-off-by: Blasius Patrick <blasius.patrick@gmail.com>
Server-side counterpart to Go client E2E handshake:

- New e2e.py: X25519 keygen, ECDH, HKDF-SHA256 key derivation,
  HMAC proof verification, AES-256-GCM encrypt/decrypt
- server.py: ECDH exchange in hello_ack, proof verification
  in auth, session key derivation after auth_ok
- Encrypted send/receive wrappers in message dispatch loop
- Ping/pong responses encrypted via local _send wrapper
- Old clients without e2e flag fall back to plaintext auth
- All 14 existing tests still pass

Signed-off-by: Blasius Patrick <blasius.patrick@gmail.com>
Add End-to-End Encryption section: token never on wire, forward secrecy,
MITM resistance, backward compatibility. Link to full e2e-spec.md.

Signed-off-by: Blasius Patrick <blasius.patrick@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant