diff --git a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/commons/util/crypt/ScrambledKeyPair.java b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/commons/util/crypt/ScrambledKeyPair.java index 4e790a21be..a2f78c7c94 100644 --- a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/commons/util/crypt/ScrambledKeyPair.java +++ b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/commons/util/crypt/ScrambledKeyPair.java @@ -17,13 +17,11 @@ package com.l2jmobius.commons.util.crypt; import java.math.BigInteger; +import java.security.Key; import java.security.KeyPair; import java.security.interfaces.RSAPublicKey; import java.util.logging.Logger; -/** - * - */ public class ScrambledKeyPair { private static Logger _log = Logger.getLogger(ScrambledKeyPair.class.getName()); @@ -77,4 +75,14 @@ public class ScrambledKeyPair { return _scrambledModulus; } + + public Key getPrivateKey() + { + return _pair.getPrivate(); + } + + public Key getPublicKey() + { + return _pair.getPublic(); + } } diff --git a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/loginserver/GameServerThread.java b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/loginserver/GameServerThread.java index d1e9b5d9b6..10188d5589 100644 --- a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/loginserver/GameServerThread.java +++ b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/loginserver/GameServerThread.java @@ -21,7 +21,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.Socket; -import java.security.KeyPair; import java.security.interfaces.RSAPrivateKey; import java.security.interfaces.RSAPublicKey; import java.util.Set; @@ -29,6 +28,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Logger; import com.l2jmobius.commons.util.crypt.NewCrypt; +import com.l2jmobius.commons.util.crypt.ScrambledKeyPair; import com.l2jmobius.commons.util.network.BaseSendablePacket; import com.l2jmobius.loginserver.GameServerTable.GameServerInfo; import com.l2jmobius.loginserver.network.L2JGameServerPacketHandler; @@ -211,9 +211,9 @@ public class GameServerThread extends Thread { _log.warning(getClass().getSimpleName() + ": " + e.getMessage()); } - final KeyPair pair = GameServerTable.getInstance().getKeyPair(); - _privateKey = (RSAPrivateKey) pair.getPrivate(); - _publicKey = (RSAPublicKey) pair.getPublic(); + final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair(); + _privateKey = (RSAPrivateKey) pair.getPrivateKey(); + _publicKey = (RSAPublicKey) pair.getPublicKey(); _blowfish = new NewCrypt("_;v.]05-31!|+-%xT!^[$\00"); setName(getClass().getSimpleName() + "-" + getId() + "@" + _connectionIp); start(); diff --git a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/loginserver/network/L2LoginClient.java b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/loginserver/network/L2LoginClient.java index 0408187972..461a2917ea 100644 --- a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/loginserver/network/L2LoginClient.java +++ b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/loginserver/network/L2LoginClient.java @@ -18,7 +18,6 @@ package com.l2jmobius.loginserver.network; import java.net.InetAddress; import java.net.InetSocketAddress; -import java.security.interfaces.RSAPrivateKey; import java.util.HashMap; import java.util.Map; import java.util.logging.Logger; @@ -69,8 +68,8 @@ public final class L2LoginClient extends ChannelInboundHandler public L2LoginClient(SecretKey blowfishKey) { super(); - _scrambledPair = LoginController.getInstance().getScrambledRSAKeyPair(); _blowfishKey = blowfishKey; + _scrambledPair = LoginController.getInstance().getScrambledRSAKeyPair(); } @Override @@ -115,16 +114,6 @@ public final class L2LoginClient extends ChannelInboundHandler return _addr; } - public byte[] getScrambledModulus() - { - return _scrambledPair._scrambledModulus; - } - - public RSAPrivateKey getRSAPrivateKey() - { - return (RSAPrivateKey) _scrambledPair._pair.getPrivate(); - } - public String getAccount() { return _account; @@ -160,6 +149,11 @@ public final class L2LoginClient extends ChannelInboundHandler return _sessionId; } + public ScrambledKeyPair getScrambledKeyPair() + { + return _scrambledPair; + } + public boolean hasJoinedGS() { return _joinedGS; diff --git a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/loginserver/network/clientpackets/RequestAuthLogin.java b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/loginserver/network/clientpackets/RequestAuthLogin.java index 3891272de6..60d7ed1647 100644 --- a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/loginserver/network/clientpackets/RequestAuthLogin.java +++ b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/loginserver/network/clientpackets/RequestAuthLogin.java @@ -80,7 +80,7 @@ public class RequestAuthLogin implements IIncomingPacket try { final Cipher rsaCipher = Cipher.getInstance("RSA/ECB/nopadding"); - rsaCipher.init(Cipher.DECRYPT_MODE, client.getRSAPrivateKey()); + rsaCipher.init(Cipher.DECRYPT_MODE, client.getScrambledKeyPair().getPrivateKey()); rsaCipher.doFinal(_raw1, 0, 128, decrypted, 0); if (_newAuthMethod) { diff --git a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/commons/util/crypt/ScrambledKeyPair.java b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/commons/util/crypt/ScrambledKeyPair.java index 4e790a21be..a2f78c7c94 100644 --- a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/commons/util/crypt/ScrambledKeyPair.java +++ b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/commons/util/crypt/ScrambledKeyPair.java @@ -17,13 +17,11 @@ package com.l2jmobius.commons.util.crypt; import java.math.BigInteger; +import java.security.Key; import java.security.KeyPair; import java.security.interfaces.RSAPublicKey; import java.util.logging.Logger; -/** - * - */ public class ScrambledKeyPair { private static Logger _log = Logger.getLogger(ScrambledKeyPair.class.getName()); @@ -77,4 +75,14 @@ public class ScrambledKeyPair { return _scrambledModulus; } + + public Key getPrivateKey() + { + return _pair.getPrivate(); + } + + public Key getPublicKey() + { + return _pair.getPublic(); + } } diff --git a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/loginserver/GameServerThread.java b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/loginserver/GameServerThread.java index d1e9b5d9b6..10188d5589 100644 --- a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/loginserver/GameServerThread.java +++ b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/loginserver/GameServerThread.java @@ -21,7 +21,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.Socket; -import java.security.KeyPair; import java.security.interfaces.RSAPrivateKey; import java.security.interfaces.RSAPublicKey; import java.util.Set; @@ -29,6 +28,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Logger; import com.l2jmobius.commons.util.crypt.NewCrypt; +import com.l2jmobius.commons.util.crypt.ScrambledKeyPair; import com.l2jmobius.commons.util.network.BaseSendablePacket; import com.l2jmobius.loginserver.GameServerTable.GameServerInfo; import com.l2jmobius.loginserver.network.L2JGameServerPacketHandler; @@ -211,9 +211,9 @@ public class GameServerThread extends Thread { _log.warning(getClass().getSimpleName() + ": " + e.getMessage()); } - final KeyPair pair = GameServerTable.getInstance().getKeyPair(); - _privateKey = (RSAPrivateKey) pair.getPrivate(); - _publicKey = (RSAPublicKey) pair.getPublic(); + final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair(); + _privateKey = (RSAPrivateKey) pair.getPrivateKey(); + _publicKey = (RSAPublicKey) pair.getPublicKey(); _blowfish = new NewCrypt("_;v.]05-31!|+-%xT!^[$\00"); setName(getClass().getSimpleName() + "-" + getId() + "@" + _connectionIp); start(); diff --git a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/loginserver/network/L2LoginClient.java b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/loginserver/network/L2LoginClient.java index 0408187972..461a2917ea 100644 --- a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/loginserver/network/L2LoginClient.java +++ b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/loginserver/network/L2LoginClient.java @@ -18,7 +18,6 @@ package com.l2jmobius.loginserver.network; import java.net.InetAddress; import java.net.InetSocketAddress; -import java.security.interfaces.RSAPrivateKey; import java.util.HashMap; import java.util.Map; import java.util.logging.Logger; @@ -69,8 +68,8 @@ public final class L2LoginClient extends ChannelInboundHandler public L2LoginClient(SecretKey blowfishKey) { super(); - _scrambledPair = LoginController.getInstance().getScrambledRSAKeyPair(); _blowfishKey = blowfishKey; + _scrambledPair = LoginController.getInstance().getScrambledRSAKeyPair(); } @Override @@ -115,16 +114,6 @@ public final class L2LoginClient extends ChannelInboundHandler return _addr; } - public byte[] getScrambledModulus() - { - return _scrambledPair._scrambledModulus; - } - - public RSAPrivateKey getRSAPrivateKey() - { - return (RSAPrivateKey) _scrambledPair._pair.getPrivate(); - } - public String getAccount() { return _account; @@ -160,6 +149,11 @@ public final class L2LoginClient extends ChannelInboundHandler return _sessionId; } + public ScrambledKeyPair getScrambledKeyPair() + { + return _scrambledPair; + } + public boolean hasJoinedGS() { return _joinedGS; diff --git a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/loginserver/network/clientpackets/RequestAuthLogin.java b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/loginserver/network/clientpackets/RequestAuthLogin.java index 3891272de6..60d7ed1647 100644 --- a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/loginserver/network/clientpackets/RequestAuthLogin.java +++ b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/loginserver/network/clientpackets/RequestAuthLogin.java @@ -80,7 +80,7 @@ public class RequestAuthLogin implements IIncomingPacket try { final Cipher rsaCipher = Cipher.getInstance("RSA/ECB/nopadding"); - rsaCipher.init(Cipher.DECRYPT_MODE, client.getRSAPrivateKey()); + rsaCipher.init(Cipher.DECRYPT_MODE, client.getScrambledKeyPair().getPrivateKey()); rsaCipher.doFinal(_raw1, 0, 128, decrypted, 0); if (_newAuthMethod) { diff --git a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/commons/util/crypt/ScrambledKeyPair.java b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/commons/util/crypt/ScrambledKeyPair.java index f1042817e0..a2f78c7c94 100644 --- a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/commons/util/crypt/ScrambledKeyPair.java +++ b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/commons/util/crypt/ScrambledKeyPair.java @@ -17,6 +17,7 @@ package com.l2jmobius.commons.util.crypt; import java.math.BigInteger; +import java.security.Key; import java.security.KeyPair; import java.security.interfaces.RSAPublicKey; import java.util.logging.Logger; @@ -74,4 +75,14 @@ public class ScrambledKeyPair { return _scrambledModulus; } + + public Key getPrivateKey() + { + return _pair.getPrivate(); + } + + public Key getPublicKey() + { + return _pair.getPublic(); + } } diff --git a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/loginserver/GameServerThread.java b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/loginserver/GameServerThread.java index d1e9b5d9b6..10188d5589 100644 --- a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/loginserver/GameServerThread.java +++ b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/loginserver/GameServerThread.java @@ -21,7 +21,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.Socket; -import java.security.KeyPair; import java.security.interfaces.RSAPrivateKey; import java.security.interfaces.RSAPublicKey; import java.util.Set; @@ -29,6 +28,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Logger; import com.l2jmobius.commons.util.crypt.NewCrypt; +import com.l2jmobius.commons.util.crypt.ScrambledKeyPair; import com.l2jmobius.commons.util.network.BaseSendablePacket; import com.l2jmobius.loginserver.GameServerTable.GameServerInfo; import com.l2jmobius.loginserver.network.L2JGameServerPacketHandler; @@ -211,9 +211,9 @@ public class GameServerThread extends Thread { _log.warning(getClass().getSimpleName() + ": " + e.getMessage()); } - final KeyPair pair = GameServerTable.getInstance().getKeyPair(); - _privateKey = (RSAPrivateKey) pair.getPrivate(); - _publicKey = (RSAPublicKey) pair.getPublic(); + final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair(); + _privateKey = (RSAPrivateKey) pair.getPrivateKey(); + _publicKey = (RSAPublicKey) pair.getPublicKey(); _blowfish = new NewCrypt("_;v.]05-31!|+-%xT!^[$\00"); setName(getClass().getSimpleName() + "-" + getId() + "@" + _connectionIp); start(); diff --git a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/loginserver/network/L2LoginClient.java b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/loginserver/network/L2LoginClient.java index 0408187972..461a2917ea 100644 --- a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/loginserver/network/L2LoginClient.java +++ b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/loginserver/network/L2LoginClient.java @@ -18,7 +18,6 @@ package com.l2jmobius.loginserver.network; import java.net.InetAddress; import java.net.InetSocketAddress; -import java.security.interfaces.RSAPrivateKey; import java.util.HashMap; import java.util.Map; import java.util.logging.Logger; @@ -69,8 +68,8 @@ public final class L2LoginClient extends ChannelInboundHandler public L2LoginClient(SecretKey blowfishKey) { super(); - _scrambledPair = LoginController.getInstance().getScrambledRSAKeyPair(); _blowfishKey = blowfishKey; + _scrambledPair = LoginController.getInstance().getScrambledRSAKeyPair(); } @Override @@ -115,16 +114,6 @@ public final class L2LoginClient extends ChannelInboundHandler return _addr; } - public byte[] getScrambledModulus() - { - return _scrambledPair._scrambledModulus; - } - - public RSAPrivateKey getRSAPrivateKey() - { - return (RSAPrivateKey) _scrambledPair._pair.getPrivate(); - } - public String getAccount() { return _account; @@ -160,6 +149,11 @@ public final class L2LoginClient extends ChannelInboundHandler return _sessionId; } + public ScrambledKeyPair getScrambledKeyPair() + { + return _scrambledPair; + } + public boolean hasJoinedGS() { return _joinedGS; diff --git a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/loginserver/network/clientpackets/RequestAuthLogin.java b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/loginserver/network/clientpackets/RequestAuthLogin.java index 6df3a998ad..1cd1aceac3 100644 --- a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/loginserver/network/clientpackets/RequestAuthLogin.java +++ b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/loginserver/network/clientpackets/RequestAuthLogin.java @@ -80,7 +80,7 @@ public class RequestAuthLogin implements IIncomingPacket try { final Cipher rsaCipher = Cipher.getInstance("RSA/ECB/nopadding"); - rsaCipher.init(Cipher.DECRYPT_MODE, client.getRSAPrivateKey()); + rsaCipher.init(Cipher.DECRYPT_MODE, client.getScrambledKeyPair().getPrivateKey()); rsaCipher.doFinal(_raw1, 0, 128, decrypted, 0); if (_newAuthMethod) { diff --git a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/commons/util/crypt/ScrambledKeyPair.java b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/commons/util/crypt/ScrambledKeyPair.java index 4e790a21be..a2f78c7c94 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/commons/util/crypt/ScrambledKeyPair.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/commons/util/crypt/ScrambledKeyPair.java @@ -17,13 +17,11 @@ package com.l2jmobius.commons.util.crypt; import java.math.BigInteger; +import java.security.Key; import java.security.KeyPair; import java.security.interfaces.RSAPublicKey; import java.util.logging.Logger; -/** - * - */ public class ScrambledKeyPair { private static Logger _log = Logger.getLogger(ScrambledKeyPair.class.getName()); @@ -77,4 +75,14 @@ public class ScrambledKeyPair { return _scrambledModulus; } + + public Key getPrivateKey() + { + return _pair.getPrivate(); + } + + public Key getPublicKey() + { + return _pair.getPublic(); + } } diff --git a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/loginserver/GameServerThread.java b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/loginserver/GameServerThread.java index d1e9b5d9b6..10188d5589 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/loginserver/GameServerThread.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/loginserver/GameServerThread.java @@ -21,7 +21,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.Socket; -import java.security.KeyPair; import java.security.interfaces.RSAPrivateKey; import java.security.interfaces.RSAPublicKey; import java.util.Set; @@ -29,6 +28,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Logger; import com.l2jmobius.commons.util.crypt.NewCrypt; +import com.l2jmobius.commons.util.crypt.ScrambledKeyPair; import com.l2jmobius.commons.util.network.BaseSendablePacket; import com.l2jmobius.loginserver.GameServerTable.GameServerInfo; import com.l2jmobius.loginserver.network.L2JGameServerPacketHandler; @@ -211,9 +211,9 @@ public class GameServerThread extends Thread { _log.warning(getClass().getSimpleName() + ": " + e.getMessage()); } - final KeyPair pair = GameServerTable.getInstance().getKeyPair(); - _privateKey = (RSAPrivateKey) pair.getPrivate(); - _publicKey = (RSAPublicKey) pair.getPublic(); + final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair(); + _privateKey = (RSAPrivateKey) pair.getPrivateKey(); + _publicKey = (RSAPublicKey) pair.getPublicKey(); _blowfish = new NewCrypt("_;v.]05-31!|+-%xT!^[$\00"); setName(getClass().getSimpleName() + "-" + getId() + "@" + _connectionIp); start(); diff --git a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/loginserver/network/L2LoginClient.java b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/loginserver/network/L2LoginClient.java index 0408187972..461a2917ea 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/loginserver/network/L2LoginClient.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/loginserver/network/L2LoginClient.java @@ -18,7 +18,6 @@ package com.l2jmobius.loginserver.network; import java.net.InetAddress; import java.net.InetSocketAddress; -import java.security.interfaces.RSAPrivateKey; import java.util.HashMap; import java.util.Map; import java.util.logging.Logger; @@ -69,8 +68,8 @@ public final class L2LoginClient extends ChannelInboundHandler public L2LoginClient(SecretKey blowfishKey) { super(); - _scrambledPair = LoginController.getInstance().getScrambledRSAKeyPair(); _blowfishKey = blowfishKey; + _scrambledPair = LoginController.getInstance().getScrambledRSAKeyPair(); } @Override @@ -115,16 +114,6 @@ public final class L2LoginClient extends ChannelInboundHandler return _addr; } - public byte[] getScrambledModulus() - { - return _scrambledPair._scrambledModulus; - } - - public RSAPrivateKey getRSAPrivateKey() - { - return (RSAPrivateKey) _scrambledPair._pair.getPrivate(); - } - public String getAccount() { return _account; @@ -160,6 +149,11 @@ public final class L2LoginClient extends ChannelInboundHandler return _sessionId; } + public ScrambledKeyPair getScrambledKeyPair() + { + return _scrambledPair; + } + public boolean hasJoinedGS() { return _joinedGS; diff --git a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/loginserver/network/clientpackets/RequestAuthLogin.java b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/loginserver/network/clientpackets/RequestAuthLogin.java index 6df3a998ad..1cd1aceac3 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/loginserver/network/clientpackets/RequestAuthLogin.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/loginserver/network/clientpackets/RequestAuthLogin.java @@ -80,7 +80,7 @@ public class RequestAuthLogin implements IIncomingPacket try { final Cipher rsaCipher = Cipher.getInstance("RSA/ECB/nopadding"); - rsaCipher.init(Cipher.DECRYPT_MODE, client.getRSAPrivateKey()); + rsaCipher.init(Cipher.DECRYPT_MODE, client.getScrambledKeyPair().getPrivateKey()); rsaCipher.doFinal(_raw1, 0, 128, decrypted, 0); if (_newAuthMethod) { diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/commons/util/crypt/ScrambledKeyPair.java b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/commons/util/crypt/ScrambledKeyPair.java index 4e790a21be..a2f78c7c94 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/commons/util/crypt/ScrambledKeyPair.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/commons/util/crypt/ScrambledKeyPair.java @@ -17,13 +17,11 @@ package com.l2jmobius.commons.util.crypt; import java.math.BigInteger; +import java.security.Key; import java.security.KeyPair; import java.security.interfaces.RSAPublicKey; import java.util.logging.Logger; -/** - * - */ public class ScrambledKeyPair { private static Logger _log = Logger.getLogger(ScrambledKeyPair.class.getName()); @@ -77,4 +75,14 @@ public class ScrambledKeyPair { return _scrambledModulus; } + + public Key getPrivateKey() + { + return _pair.getPrivate(); + } + + public Key getPublicKey() + { + return _pair.getPublic(); + } } diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/loginserver/GameServerThread.java b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/loginserver/GameServerThread.java index d1e9b5d9b6..10188d5589 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/loginserver/GameServerThread.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/loginserver/GameServerThread.java @@ -21,7 +21,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.Socket; -import java.security.KeyPair; import java.security.interfaces.RSAPrivateKey; import java.security.interfaces.RSAPublicKey; import java.util.Set; @@ -29,6 +28,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Logger; import com.l2jmobius.commons.util.crypt.NewCrypt; +import com.l2jmobius.commons.util.crypt.ScrambledKeyPair; import com.l2jmobius.commons.util.network.BaseSendablePacket; import com.l2jmobius.loginserver.GameServerTable.GameServerInfo; import com.l2jmobius.loginserver.network.L2JGameServerPacketHandler; @@ -211,9 +211,9 @@ public class GameServerThread extends Thread { _log.warning(getClass().getSimpleName() + ": " + e.getMessage()); } - final KeyPair pair = GameServerTable.getInstance().getKeyPair(); - _privateKey = (RSAPrivateKey) pair.getPrivate(); - _publicKey = (RSAPublicKey) pair.getPublic(); + final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair(); + _privateKey = (RSAPrivateKey) pair.getPrivateKey(); + _publicKey = (RSAPublicKey) pair.getPublicKey(); _blowfish = new NewCrypt("_;v.]05-31!|+-%xT!^[$\00"); setName(getClass().getSimpleName() + "-" + getId() + "@" + _connectionIp); start(); diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/loginserver/network/L2LoginClient.java b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/loginserver/network/L2LoginClient.java index 0408187972..461a2917ea 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/loginserver/network/L2LoginClient.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/loginserver/network/L2LoginClient.java @@ -18,7 +18,6 @@ package com.l2jmobius.loginserver.network; import java.net.InetAddress; import java.net.InetSocketAddress; -import java.security.interfaces.RSAPrivateKey; import java.util.HashMap; import java.util.Map; import java.util.logging.Logger; @@ -69,8 +68,8 @@ public final class L2LoginClient extends ChannelInboundHandler public L2LoginClient(SecretKey blowfishKey) { super(); - _scrambledPair = LoginController.getInstance().getScrambledRSAKeyPair(); _blowfishKey = blowfishKey; + _scrambledPair = LoginController.getInstance().getScrambledRSAKeyPair(); } @Override @@ -115,16 +114,6 @@ public final class L2LoginClient extends ChannelInboundHandler return _addr; } - public byte[] getScrambledModulus() - { - return _scrambledPair._scrambledModulus; - } - - public RSAPrivateKey getRSAPrivateKey() - { - return (RSAPrivateKey) _scrambledPair._pair.getPrivate(); - } - public String getAccount() { return _account; @@ -160,6 +149,11 @@ public final class L2LoginClient extends ChannelInboundHandler return _sessionId; } + public ScrambledKeyPair getScrambledKeyPair() + { + return _scrambledPair; + } + public boolean hasJoinedGS() { return _joinedGS; diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/loginserver/network/clientpackets/RequestAuthLogin.java b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/loginserver/network/clientpackets/RequestAuthLogin.java index 6df3a998ad..1cd1aceac3 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/loginserver/network/clientpackets/RequestAuthLogin.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/loginserver/network/clientpackets/RequestAuthLogin.java @@ -80,7 +80,7 @@ public class RequestAuthLogin implements IIncomingPacket try { final Cipher rsaCipher = Cipher.getInstance("RSA/ECB/nopadding"); - rsaCipher.init(Cipher.DECRYPT_MODE, client.getRSAPrivateKey()); + rsaCipher.init(Cipher.DECRYPT_MODE, client.getScrambledKeyPair().getPrivateKey()); rsaCipher.doFinal(_raw1, 0, 128, decrypted, 0); if (_newAuthMethod) {