Files
VoidTeamspeak/include/echoion/protocol/License.hpp
T
faumaray 38e86d4a07 New arch
Signed-off-by: faumaray <faumaray@gmail.com>
2026-07-11 15:06:22 +03:00

46 lines
1.3 KiB
C++

#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 <array>
#include <cstdint>
#include <span>
#include <vector>
namespace Echoion::Protocol
{
using Bytes = std::vector<uint8_t>;
using ByteView = std::span<const uint8_t>;
struct LicenseBlock {
std::array<uint8_t, 32> key;
std::array<uint8_t, 32> hash; // first 32 bytes of SHA-512(content)
uint8_t type = 0;
};
struct TempKey {
std::array<uint8_t, 32> publicKey;
std::array<uint8_t, 32> privateKey;
};
// Parse the server license blob into its chain of blocks.
std::vector<LicenseBlock> parseLicense(ByteView data);
// Walk the chain from the root key to the final server public key (32 bytes).
std::array<uint8_t, 32>
deriveLicenseKey(const std::vector<LicenseBlock>& 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<uint8_t, 64>
getSharedSecret2(ByteView serverDerivedKey, ByteView tempPrivateKey);
} // namespace Echoion::Protocol