2020-05-02 02:18:09 +02:00
|
|
|
package com.eu.habbo.messages.incoming.handshake;
|
|
|
|
|
2020-05-02 03:38:22 +02:00
|
|
|
import com.eu.habbo.Emulator;
|
2020-05-02 02:18:09 +02:00
|
|
|
import com.eu.habbo.crypto.HabboRC4;
|
|
|
|
import com.eu.habbo.messages.NoAuthMessage;
|
|
|
|
import com.eu.habbo.messages.incoming.MessageHandler;
|
|
|
|
import com.eu.habbo.messages.outgoing.handshake.CompleteDiffieHandshakeComposer;
|
2020-05-02 03:17:59 +02:00
|
|
|
import com.eu.habbo.networking.gameserver.decoders.GameByteDecryption;
|
|
|
|
import com.eu.habbo.networking.gameserver.encoders.GameByteEncryption;
|
2020-05-02 02:18:09 +02:00
|
|
|
import com.eu.habbo.networking.gameserver.GameServerAttributes;
|
|
|
|
|
|
|
|
@NoAuthMessage
|
|
|
|
public class CompleteDiffieHandshakeEvent extends MessageHandler {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void handle() throws Exception {
|
2020-05-02 03:38:22 +02:00
|
|
|
if (this.client.getEncryption() == null) {
|
|
|
|
Emulator.getGameServer().getGameClientManager().disposeClient(this.client);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-05-02 02:18:09 +02:00
|
|
|
byte[] sharedKey = this.client.getEncryption().getDiffie().getSharedKey(this.packet.readString());
|
|
|
|
|
2020-05-02 04:36:26 +02:00
|
|
|
this.client.setHandshakeFinished(true);
|
2020-05-02 02:18:09 +02:00
|
|
|
this.client.sendResponse(new CompleteDiffieHandshakeComposer(this.client.getEncryption().getDiffie().getPublicKey()));
|
|
|
|
|
|
|
|
this.client.getChannel().attr(GameServerAttributes.CRYPTO_CLIENT).set(new HabboRC4(sharedKey));
|
|
|
|
this.client.getChannel().attr(GameServerAttributes.CRYPTO_SERVER).set(new HabboRC4(sharedKey));
|
|
|
|
|
|
|
|
this.client.getChannel().pipeline().addFirst(new GameByteDecryption());
|
|
|
|
this.client.getChannel().pipeline().addFirst(new GameByteEncryption());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|