5.6 KiB
AVA2 login transport and Python bootstrap
Implemented initial milestone 1 work (2026-10-03). This is a developer transport/bootstrap, not a complete login or character-selection screen.
Login path
LoginSession implements auth handshake → encrypted Login3 → AuthSuccess → a separate game connection → encrypted Login2 → character list + select phase. ava2_login supplies a POSIX TCP transport with explicit endpoints, connection/send timeouts and a 15-second protocol deadline. It stops after listing the five slots; it does not enter a map. LoginSession::select validates the selected slot and encodes the original sequenced packet; its output is verified independently.
- Handshake: header 255, 13 bytes; time reply is
time + 2 * delta, with delta reset to zero. - Locale encryption key comes from the original
LSS_SECURITY_KEY. The algorithm named TEA in AVA2 uses the XTEA round function, 32 rounds, uint32 arithmetic, little-endian words and zero padding to 8-byte blocks. - Login3 (111): 65 bytes before the sequence byte. Login2 (109): 52 bytes before the sequence byte. Version field is disabled in this baseline.
- Both auth and game connections start sequence indexing independently. The complete 32768-byte original table is preserved.
- Login2 is flushed under the locale key; subsequent sends use the client key and receives use the derived key. Key derivation follows the original dynamic seed loop and the unaligned key at offset 37.
- LoginSuccess (32): 444 bytes, with five 70-byte player records. Sash and conqueror fields are enabled. Client Windows
longfields remain 32 bits on 64-bit hosts. - Both phase-before-roster and roster-before-phase orders work. The original server uses the former. Selection becomes ready only after both arrive.
- Ping/pong, padding, legacy UDP binding metadata, Panama IV metadata and length-checked hybrid pack metadata are handled. Pack metadata is retained; applying it to encrypted packs is deferred because this milestone uses decoded assets.
- Unknown packet headers and malformed lengths report errors. Additional login challenge systems are not implemented.
Transport credentials are supplied at runtime through AVA2_PASSWORD; no real endpoint or account is configured in source. Do not pass passwords as command-line arguments. The CLI removes its own environment copy after constructing the session.
Python bootstrap
CPython 2.7.18 is copied from the established cross-platform runtime with per-platform configurations and a stored stdlib ZIP. The snapshot retains its notices and records SHA-256 provenance. Host Python 3 only runs build/audit tools.
The native pack.Exist / pack.Get bridge mounts a decoded root directory and resolves ASCII paths case-insensitively, supports backslashes, rejects traversal/symlink escapes, and limits individual reads to 64 MiB. A host importer runs original mixed-case module imports from lower-case files without modifying scripts. A minimal native app extension exposes the original ENABLE_STONEMINIMAP constant needed by colorInfo; application methods and the remaining feature constants are pending. No placeholder gameplay methods return fabricated success.
Original colorInfo and musicInfo import and run. The complete system.py → prototype.py → original login UI bootstrap still needs app/dbg/net/wndMgr/UI extension surfaces and resource mounts. Do not treat these module smoke checks as original login UI parity.
Evidence
ava2.login_oracle: compiles declarations extracted from original client and server headers with Win32-width types, verifies 70/444-byte sizes and field offsets, compares cipher output against the original cipher function across 512 deterministic inputs, verifies selection sequencing and empty-slot rejection.ava2.login_loopback: independent Python wire peer over loopback TCP, fragmented plaintext/encrypted transitions, auth/game key switching, ping sequence, pack metadata, both roster orders, wrong password, unknown header and malformed metadata.ava2.login_profile: preprocesses both original macro headers. Login-critical flags agree. Original wolfman, bank and support mismatches remain unresolved for later gameplay work.ava2.python: Python 2 integer division, original script imports, case-insensitive pack reads and traversal rejection.- Existing packet and GR2 regression checks continue to pass. Total: 7 CTest targets.
- macOS arm64 Debug: host + runtime window smoke test, 60 frames, exit 0.
- Android arm64, NDK 27.2.12479018 / API 26: host
libmain.so, embedded Python, shared GR2/codepage and wire libraries compile/link. SDL3 is an external Android dependency; this development build used the already installed SDL3 3.4.16 SDK from the sibling client's build. No sibling gameplay objects or libraries are linked. APK packaging and on-device runtime validation remain pending.
Real AVA2 server compatibility, original UI interaction, map loading and combat have not been verified. The existing server and stable client were not changed.
Subsequent loading/game handoff
The current transport continues receiving in loading and forwards decrypted bytes to PythonNetworkStream. Supported native game packets are sent through the same established encryption and continuing packet sequence. Original deferred StartGame, explicit multilingual EnterGame, main-character LoadData/version/BGM-volume, points/time, ping/chat and EOF login fallback are covered by the loopback bridge fixture. This supersedes the earlier loading-pause limitation, while real-server/map and full packet compatibility remain unverified. See docs/WINDOWS-PARITY.md for the latest detailed scope.