Splamy/TS3AudioBot

Import identity from ts3audiobot to ts3

IxPrumxI opened this issue · 1 comments

Describe the problem
I have not found a clear way to import an identity to ts3

To Reproduce
Create a bot with identity. and try to import it in ts3

System Information

  • Platform: Doesn't matter

  • Mono version: Doesn't matter

  • Which commit did you download: 0.12.2/master/4c6be036

The other way around it’s easier because the bot can read identities created by the ts3 client.
The AudioBot has no functionality to export a ts3 client identity.

If you know some C#, you can write a simple program that uses IdentityData::ToTsIdentity:

public string ToTsIdentity()
{
var ident = ExportPrivateAndPublicKey(PrivateKey, PublicKey);
var encMaxLen = Base64.GetMaxEncodedToUtf8Length(ident.Length);
var final = new byte[encMaxLen];
if (Base64.EncodeToUtf8(ident, final, out _, out var length) != System.Buffers.OperationStatus.Done)
throw new InvalidOperationException();
TsCrypt.XorBinary(final, TsIdentityObfuscationKey, Math.Min(100, length), final);
int nullIdx = final.AsSpan(20).IndexOf((byte)0);
var hash = TsCrypt.Hash1It(final, 20, nullIdx < 0 ? length - 20 : nullIdx);
TsCrypt.XorBinary(final, hash, 20, final);
return ValidKeyOffset + "V" + Convert.ToBase64String(final);
}