License hash is failing. Need to fix that
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package com.github.manevolent.ts3j.license;
|
package com.github.manevolent.ts3j.license;
|
||||||
|
|
||||||
import Punisher.NaCl.Internal.Ed25519Ref10.*;
|
import Punisher.NaCl.Internal.Ed25519Ref10.*;
|
||||||
|
import com.github.manevolent.ts3j.util.Ts3Logging;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
@@ -132,21 +133,28 @@ public class License {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String readNullTerminatedLicenseString(ByteBuffer buffer) {
|
public static String readNullTerminatedLicenseString(ByteBuffer buffer) {
|
||||||
StringBuilder builder = new StringBuilder();
|
int len = 0;
|
||||||
while (buffer.remaining() > 0) {
|
while (buffer.remaining() > 0) {
|
||||||
char c = (char) buffer.get();
|
int c = buffer.get();
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '\0':
|
case 0:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
builder.append(c);
|
len++;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return builder.toString();
|
|
||||||
|
byte[] stringBytes = new byte[len];
|
||||||
|
buffer.position(buffer.position() - len);
|
||||||
|
buffer.get(stringBytes);
|
||||||
|
|
||||||
|
return new String(stringBytes, Charset.forName("UTF8"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void writeNullTerminatedLicenseString(ByteBuffer buffer, String s) {
|
public static void writeNullTerminatedLicenseString(ByteBuffer buffer, String s) {
|
||||||
buffer.put((s + "\0").getBytes(Charset.forName("ASCII")));
|
byte[] b = (s + (char) 0).getBytes();
|
||||||
|
buffer.put(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<License> readLicenses(ByteBuffer buffer) {
|
public static List<License> readLicenses(ByteBuffer buffer) {
|
||||||
@@ -178,8 +186,14 @@ public class License {
|
|||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
digest.update(buffer.array(), 1, buffer.array().length - 1);
|
digest.update(buffer.array(), 2, buffer.array().length - 2);
|
||||||
return digest.digest();
|
|
||||||
|
byte[] sliced = new byte[32];
|
||||||
|
System.arraycopy(digest.digest(), 0, sliced, 0, 32);
|
||||||
|
|
||||||
|
Ts3Logging.debug(Ts3Logging.getHex(buffer.array()));
|
||||||
|
|
||||||
|
return sliced;
|
||||||
}
|
}
|
||||||
|
|
||||||
return computedHash;
|
return computedHash;
|
||||||
@@ -187,10 +201,13 @@ public class License {
|
|||||||
|
|
||||||
public byte[] deriveKey(byte[] parent) {
|
public byte[] deriveKey(byte[] parent) {
|
||||||
// ScalarOperations.sc_clamp(Hash);
|
// ScalarOperations.sc_clamp(Hash);
|
||||||
|
Ts3Logging.debug("ScalarOperations.sc_clamp: " + Ts3Logging.getHex(getHash()));
|
||||||
ScalarOperations.sc_clamp(getHash(), 0);
|
ScalarOperations.sc_clamp(getHash(), 0);
|
||||||
|
Ts3Logging.debug("ScalarOperations.sc_clamp: " + Ts3Logging.getHex(getHash()));
|
||||||
|
|
||||||
// GroupOperations.ge_frombytes_negate_vartime(out var pubkey, Key);
|
// GroupOperations.ge_frombytes_negate_vartime(out var pubkey, Key);
|
||||||
GroupElementP3 pubkey = new GroupElementP3();
|
GroupElementP3 pubkey = new GroupElementP3();
|
||||||
|
Ts3Logging.debug("ScalarOperations.ge_frombytes_negate_vartime: " + Ts3Logging.getHex(getPublicKey()));
|
||||||
GroupOperations.ge_frombytes_negate_vartime(pubkey, getPublicKey(), 0);
|
GroupOperations.ge_frombytes_negate_vartime(pubkey, getPublicKey(), 0);
|
||||||
|
|
||||||
// GroupOperations.ge_frombytes_negate_vartime(out var parkey, parent);
|
// GroupOperations.ge_frombytes_negate_vartime(out var parkey, parent);
|
||||||
|
|||||||
+23
-1
@@ -203,7 +203,29 @@ public class LocalClientHandlerConnecting extends LocalClientHandler {
|
|||||||
Ts3Crypt.cryptoInit2(license, alphaBytes, omega, proof, beta, keyPair.getValue())
|
Ts3Crypt.cryptoInit2(license, alphaBytes, omega, proof, beta, keyPair.getValue())
|
||||||
);
|
);
|
||||||
|
|
||||||
getClient().setState(ClientConnectionState.NEGOTIATING);
|
PacketBody2Command clientinit = new PacketBody2Command(ProtocolRole.CLIENT);
|
||||||
|
|
||||||
|
clientinit.setText(
|
||||||
|
new SimpleCommand(
|
||||||
|
"clientinit", ProtocolRole.CLIENT,
|
||||||
|
new CommandSingleParameter("client_nickname", "test"),
|
||||||
|
new CommandSingleParameter("client_version", "3.0.19.3"),
|
||||||
|
new CommandSingleParameter("client_platform", "Windows"),
|
||||||
|
new CommandSingleParameter("client_version_sign", "a1OYzvM18mrmfUQBUgxYBxYz2DUU6y5k3/mEL6FurzU0y97Bd1FL7+PRpcHyPkg4R+kKAFZ1nhyzbgkGphDWDg=="),
|
||||||
|
new CommandSingleParameter("client_input_hardware", "true"),
|
||||||
|
new CommandSingleParameter("client_output_hardware", "false"),
|
||||||
|
new CommandSingleParameter("client_default_channel", ""),
|
||||||
|
new CommandSingleParameter("client_default_channel_password", ""),
|
||||||
|
new CommandSingleParameter("client_server_password", ""),
|
||||||
|
new CommandSingleParameter("client_nickname_phonetic", "test"),
|
||||||
|
new CommandSingleParameter("client_meta_data", ""),
|
||||||
|
new CommandSingleParameter("client_default_token", ""),
|
||||||
|
new CommandSingleParameter("client_key_offset", Long.toString(getClient().getIdentity().getKeyOffset())),
|
||||||
|
new CommandSingleParameter("hwid", "87056c6e1268aaf5055abf8256415e0e,408978b6d98810cc03f0aa16a4c75600")
|
||||||
|
).build()
|
||||||
|
);
|
||||||
|
|
||||||
|
getClient().writePacket(clientinit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-26
@@ -1,9 +1,5 @@
|
|||||||
package com.github.manevolent.ts3j.protocol.packet.handler.local;
|
package com.github.manevolent.ts3j.protocol.packet.handler.local;
|
||||||
|
|
||||||
import com.github.manevolent.ts3j.command.SimpleCommand;
|
|
||||||
import com.github.manevolent.ts3j.command.part.CommandSingleParameter;
|
|
||||||
import com.github.manevolent.ts3j.protocol.ProtocolRole;
|
|
||||||
import com.github.manevolent.ts3j.protocol.packet.PacketBody2Command;
|
|
||||||
import com.github.manevolent.ts3j.protocol.socket.client.LocalTeamspeakClientSocket;
|
import com.github.manevolent.ts3j.protocol.socket.client.LocalTeamspeakClientSocket;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -16,28 +12,6 @@ public class LocalClientHandlerNegotiating extends LocalClientHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAssigned() throws IOException, TimeoutException {
|
public void onAssigned() throws IOException, TimeoutException {
|
||||||
PacketBody2Command clientinit = new PacketBody2Command(ProtocolRole.CLIENT);
|
|
||||||
|
|
||||||
clientinit.setText(
|
|
||||||
new SimpleCommand(
|
|
||||||
"clientinit", ProtocolRole.CLIENT,
|
|
||||||
new CommandSingleParameter("client_nickname", "test"),
|
|
||||||
new CommandSingleParameter("client_version", "3.0.19.3"),
|
|
||||||
new CommandSingleParameter("client_platform", "Windows"),
|
|
||||||
new CommandSingleParameter("client_version_sign", "a1OYzvM18mrmfUQBUgxYBxYz2DUU6y5k3/mEL6FurzU0y97Bd1FL7+PRpcHyPkg4R+kKAFZ1nhyzbgkGphDWDg=="),
|
|
||||||
new CommandSingleParameter("client_input_hardware", "true"),
|
|
||||||
new CommandSingleParameter("client_output_hardware", "false"),
|
|
||||||
new CommandSingleParameter("client_default_channel", ""),
|
|
||||||
new CommandSingleParameter("client_default_channel_password", ""),
|
|
||||||
new CommandSingleParameter("client_server_password", ""),
|
|
||||||
new CommandSingleParameter("client_nickname_phonetic", "test"),
|
|
||||||
new CommandSingleParameter("client_meta_data", ""),
|
|
||||||
new CommandSingleParameter("client_default_token", ""),
|
|
||||||
new CommandSingleParameter("client_key_offset", Long.toString(getClient().getIdentity().getKeyOffset())),
|
|
||||||
new CommandSingleParameter("hwid", "87056c6e1268aaf5055abf8256415e0e,408978b6d98810cc03f0aa16a4c75600")
|
|
||||||
).build()
|
|
||||||
);
|
|
||||||
|
|
||||||
getClient().writePacket(clientinit);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -213,7 +213,7 @@ public abstract class AbstractTeamspeakClientSocket
|
|||||||
// Set header values
|
// Set header values
|
||||||
packet.getBody().setHeaderValues(packet.getHeader());
|
packet.getBody().setHeaderValues(packet.getHeader());
|
||||||
|
|
||||||
if (!packet.getHeader().getPacketFlag(HeaderFlag.NEW_PROTOCOL)) {
|
if (packet.getHeader().getType() != PacketBodyType.INIT1) {
|
||||||
packetId++;
|
packetId++;
|
||||||
packetId = packetId & 0x0000FFFF;
|
packetId = packetId & 0x0000FFFF;
|
||||||
|
|
||||||
|
|||||||
@@ -34,14 +34,16 @@ public final class Ts3Crypt {
|
|||||||
// 3.2.2.2 Parsing the license
|
// 3.2.2.2 Parsing the license
|
||||||
List<License> licenses = License.readLicenses(ByteBuffer.wrap(license));
|
List<License> licenses = License.readLicenses(ByteBuffer.wrap(license));
|
||||||
|
|
||||||
|
Ts3Logging.debug("License.deriveKey: " + Ts3Logging.getHex(license));
|
||||||
byte[] key = License.deriveKey(licenses);
|
byte[] key = License.deriveKey(licenses);
|
||||||
|
Ts3Logging.debug("License.deriveKey: " + Ts3Logging.getHex(key));
|
||||||
|
|
||||||
Ts3Logging.debug("Computed license key: " + Ts3Logging.getHex(key));
|
Ts3Logging.debug("Ts3Crypt.generateSharedSecret2: " + Ts3Logging.getHex(key) + " " + Ts3Logging.getHex(privateKey));
|
||||||
|
|
||||||
byte[] sharedSecret = Ts3Crypt.generateSharedSecret2(key, privateKey);
|
byte[] sharedSecret = Ts3Crypt.generateSharedSecret2(key, privateKey);
|
||||||
|
Ts3Logging.debug("Ts3Crypt.generateSharedSecret2: " + Ts3Logging.getHex(sharedSecret));
|
||||||
|
|
||||||
Ts3Logging.debug("Computed shared secret: " + Ts3Logging.getHex(sharedSecret));
|
Ts3Logging.debug("Ts3Crypt.SecureChannelParameters: " + Ts3Logging.getHex(alpha) + " " + Ts3Logging.getHex(beta) +
|
||||||
|
" " + Ts3Logging.getHex(sharedSecret));
|
||||||
Ts3Crypt.SecureChannelParameters parameters =
|
Ts3Crypt.SecureChannelParameters parameters =
|
||||||
Ts3Crypt.getSecureParameters(alpha, beta, sharedSecret);
|
Ts3Crypt.getSecureParameters(alpha, beta, sharedSecret);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user