Files
WoW-Hybrid-gateway/docs/NATIVE_SOCKET_FREE_AUTH.md
praxisandClaude Fable 5.2 60b6d4b7a5 Design records
59 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

91 lines
5.8 KiB
Markdown

# Socket-free world authentication for engine transport
Continuation ofd2c02f5. **Native Forever character selection and world entry still
do not work.** This change supplies a reusable authenticated transport component;
it does not manufacture an engine account or connect a dummy socket for state5.
`WorldAuthentication`, created internally from `LegacyLogin`'s genuine verified
SRP/M2 result, owns its username/key/addon context. It constructs the same
CMSG_AUTH_SESSION proof for an actual SMSG_AUTH_CHALLENGE and initializes the
shared directional40-byte header ciphers exactly once. The original key copy is
wiped after cipher creation and on destruction. Invalid initialization does not
copy the account key. `accept` requires an actual decoded0x1ee response with
result0x0c and exactly10 bytes; rejects, queues and malformed results fail.
The existing `LegacySession::connect_world` now uses that same implementation.
Authoritative references: Tortoise
`src/game/Protocol/WorldSocket.cpp::HandleAuthSession` and `ProcessIncoming`,
`src/realmd/AuthSocket.cpp` SRP proof/realm handling; existing verified
`src/legacy_client.cpp` / `src/srp.cpp` retain SRP/M2, group, version and opaque
addon verification. No server source/configuration, credential or account
permission was changed. Unsupported integrity challenges remain fatal.
The additive `gw_native_transport_*` C ABI in `native/session.h` prepares a
**socket-free** channel only from a real authenticated login and selected actual
local online realm. It returns that advertised port. The channel's private key
copy survives closing the auth handle, without exposing the key or casting a
POSIX descriptor into a Windows object. Its caller must own the real network I/O.
| Operation | Contract |
|---|---|
|open|Validate M2-backed account, discovered realm, local online endpoint and build5875; no world socket opened|
|challenge|Process the real decoded server challenge once; retain generated auth request privately|
|auth_request|Required-size/capacity retry, then transfer request bytes for actual transport send|
|feed|Consume bounded encrypted segments with backpressure; preserve excess; validate actual world auth result|
|packet|Return one owned decoded Turtle packet; required-size retry never loses it|
|send|Only after valid world auth; no auth replacement/integrity replies; insufficient capacity never advances cipher|
|authenticated|Backend fact only; never implies a Forever account/UI state|
|close|Release owned channel/ciphers/request; owns no external socket|
The pending world-auth request must be consumed before incoming encrypted data.
Fatal parse/auth failures latch-2; unsupported integrity challenge latches-4.
The caller closes/re-authenticates after failure. No exception, secret, owning C++
type or engine callback crosses the C ABI. One owner must serialize handle use.
The interface is not yet called by Forever's Windows packet pipe.
Tortoise may reject world auth before enabling its cipher. The shared reader now
recognizes only the exact fragmented plaintext failure header while auth is
pending, failing immediately. Real accepted auth disables this special case.
This preserves the existing socket client's policy and avoids waiting for EOF
in the new ABI. The independent socket-free fixture suite improved4.02s→0.99s
because its negative test no longer waits three seconds; this is not a measured
Forever login-speed improvement.
## Real engine observation and client regression
The fixed observer catalog adds `realm-open`, reloaded safely between requests.
Real reference WowB89113 naturally entered0x141e46020 from returnPC0x1422bc164 on
its main thread. The owned derived connection was initialized2, realm address
0x46010046, direct vector contained one IPv4 loopback endpoint19085, proxy vector
was empty. The reader does not inspect the account/session prefix, endpoint tail
or proxy elements. Bounds, ownership, initialized state and fixed import/profile
selection are tested. No engine function was invoked by the observer.
Actual private WowB93279, with every external gateway/reference listener stopped,
then ran the refactored shared handshake: genuine SRP/M2, realm discovery, real
world authentication,4-character roster and4 valid encrypted heartbeats. The
normal copied queue received the roster but the engine remained2 and actual UI
remained login. No character login/world entry. This verifies the changed shared
handshake in the real process, **not the new ABI's engine transport binding**.
That native ready-login process also had naturally executable OpenRealmConnection
code matching its known entry prefix; code protection was not changed. There is
still no safe complete account/transport adapter. No readiness flag, connected
event or auth-provider string was fabricated, and no guessed function called.
The original vtable/debug state and private DXVK were restored, the client closed
normally, and the backend released both handles on bounded expiry with error0.
Original client/prefix, StartupFiles, trust-key service and characters unchanged;
latest crash remains the earlier05.49.40 report.
Normal28/28 passed19.87s; ASan/UBSan28/28 passed21.14s. The independent server
fixture verifies actual SRP/world proofs and encrypted roster via the new ABI,
including auth-handle release, bad M2, wrong group, rejected proofs, early roster,
integrity rejection, buffer retries and fragmented/coalesced ciphertext.
Sanitized evidence: `evidence/gameplay/native-socket-free-world-auth.json`.
Next: a verified own-module Windows/Wine ABI for this prepared channel, proper
packet-pipe lifetime/thread integration and genuine engine account/realm adoption.
Use the installed Wine11.19 Unix-call interface as a candidate, not a guessed
SysV/Windows function-pointer cast. Standalone ABI fixtures alone will not prove
Forever connection ownership or character-selection consumption.