Skip to content

Bridge protocol 1: prove the token with an HMAC challenge instead of sending it (T57) - #125

Merged
AlxcBTW merged 6 commits into
mainfrom
feat/bridge-hmac-hello-v2
Oct 27, 2026
Merged

AlxcBTW merged 6 commits into
mainfrom
feat/bridge-hmac-hello-v2

Conversation

@AlxcBTW

@AlxcBTW AlxcBTW commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Board task T57 (taken over from TideOPL). Bridge protocol version 1: hello no longer carries the token.

What changes on the wire

  • hello is version: u16 + a 32-byte nonce. New challenge (0x0004: version, service nonce, service proof) and auth (0x0005: bridge proof). Then welcome or reject.
  • A proof is HMAC-SHA-256 keyed with the token over AnyPlay bridge v1, a role byte (1 bridge, 2 service) and both nonces. The bridge checks the service's proof before it sends its own. Constant-time compare. Test vectors in the spec, checked by both sides (same bytes).
  • Until the handshake is done frames are limited to 1024 bytes of payload, and the whole handshake has 5 seconds. This builds on feat(net): cap payload accepted before bridge hello #111; it extends the cap from hello to all three handshake frames.
  • Version: clean bump 0 to 1. Old bridge, new service: reject naming both versions ("update AnyPS5 and the launcher"). New bridge, old service: the old service reads the nonce as a token and rejects with "token does not match"; it learns only a random nonce. No negotiation down, since version 0 is the raw token.
  • ADR 0039, spec, CONTEXT.md term, crates/bridge-protocol (auth module with SHA-256/HMAC, no new dependency, so no Cargo.lock change beyond fake-game using rand), net listener runs the handshake itself (the service only sees authenticated bridges), fake-game does the real handshake, new fuzz target bridge_handshake.

Fork

The bridge change is anyplaynet/AnyPS5#31. Do not merge this before that PR's Windows build is green; the launcher's network.ref must not move to a net service whose matching AnyPS5 build is not offered.

Tested

Not built locally (no cargo on this PC today); CI is the first run. The auth primitives and vectors were cross-checked with Node's crypto and a g++ build of the C++ header.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

…tead of sending it (T57)

Each side contributes a fresh 32-byte nonce and proves the token with
HMAC-SHA-256 over a context string, its role and both nonces. The token is
never on the wire; proofs are compared in constant time; frames carry at most
1024 bytes and the whole handshake has 5 seconds until it is done. An old
bridge meets a reject that names both versions.

ADR 0039, spec/bridge-protocol.md with test vectors, bridge-protocol crate,
net service listener, fake-game, fuzz target bridge_handshake.
@AlxcBTW
AlxcBTW merged commit f6c0bcb into main Oct 27, 2026
24 of 25 checks passed
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