mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-09-10 05:08:04 +02:00
This is a huge day. Thanks @Eloston. Only encrypt one way!
This commit is contained in:
parent
b44fa4c06f
commit
5c6463a2aa
@ -50,27 +50,12 @@ public class ServerConnection extends GenericConnection
|
|||||||
out.write(handshake.getPacket());
|
out.write(handshake.getPacket());
|
||||||
PacketFDEncryptionRequest encryptRequest = new PacketFDEncryptionRequest(in.readPacket());
|
PacketFDEncryptionRequest encryptRequest = new PacketFDEncryptionRequest(in.readPacket());
|
||||||
|
|
||||||
SecretKey myKey = EncryptionUtil.getSecret();
|
out.write(new PacketCDClientStatus((byte) 0).getPacket());
|
||||||
PublicKey pub = EncryptionUtil.getPubkey(encryptRequest);
|
|
||||||
|
|
||||||
PacketFCEncryptionResponse response = new PacketFCEncryptionResponse(EncryptionUtil.getShared(myKey, pub), EncryptionUtil.encrypt(pub, encryptRequest.verifyToken));
|
|
||||||
out.write(response.getPacket());
|
|
||||||
|
|
||||||
int ciphId = Util.getId(in.readPacket());
|
|
||||||
if (ciphId != 0xFC)
|
|
||||||
{
|
|
||||||
throw new RuntimeException("Server did not send encryption enable");
|
|
||||||
}
|
|
||||||
|
|
||||||
in = new PacketInputStream(new CipherInputStream(socket.getInputStream(), EncryptionUtil.getCipher(false, myKey)));
|
|
||||||
out = new CipherOutputStream(out, EncryptionUtil.getCipher(true, myKey));
|
|
||||||
|
|
||||||
for (byte[] custom : user.loginPackets)
|
for (byte[] custom : user.loginPackets)
|
||||||
{
|
{
|
||||||
out.write(custom);
|
out.write(custom);
|
||||||
}
|
}
|
||||||
|
|
||||||
out.write(new PacketCDClientStatus((byte) 0).getPacket());
|
|
||||||
byte[] loginResponse = in.readPacket();
|
byte[] loginResponse = in.readPacket();
|
||||||
if (Util.getId(loginResponse) == 0xFF)
|
if (Util.getId(loginResponse) == 0xFF)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user