commit
38e86d4a07
23 files changed
+3219
No files matched your search
@@ -0,0 +1,45 @@
|
||||
#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
|
||||
Reference in new issue
Block a user