#pragma once // TeamSpeak license chain handling for the modern handshake (initivexpand2). // The chain is walked with Ed25519 point arithmetic (scalar-mult + point-add), // which OpenSSL does not expose, so this module uses libsodium. // Ported from ts6-manager tslib/license.ts. #include #include #include #include namespace Echoion::Protocol { using Bytes = std::vector; using ByteView = std::span; struct LicenseBlock { std::array key; std::array hash; // first 32 bytes of SHA-512(content) uint8_t type = 0; }; struct TempKey { std::array publicKey; std::array privateKey; }; // Parse the server license blob into its chain of blocks. std::vector parseLicense(ByteView data); // Walk the chain from the root key to the final server public key (32 bytes). std::array deriveLicenseKey(const std::vector& blocks); // Generate an ephemeral Ed25519 keypair (clamped like the reference). TempKey generateTemporaryKey(); // initivexpand2 shared secret: SHA-512( tempPriv * serverDerivedKey ), // 64 bytes. Returns the raw digest. std::array getSharedSecret2(ByteView serverDerivedKey, ByteView tempPrivateKey); } // namespace Echoion::Protocol