From dbca9acac3344a18a1faa4c7caf636cddede21ac Mon Sep 17 00:00:00 2001 From: md_5 Date: Mon, 19 Nov 2012 20:39:24 +1100 Subject: [PATCH] I don't think an all 0 key poses an issue. Also increase logging when cannot connect to server. --- src/main/java/net/md_5/bungee/EncryptionUtil.java | 6 ++---- src/main/java/net/md_5/bungee/ServerConnection.java | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/md_5/bungee/EncryptionUtil.java b/src/main/java/net/md_5/bungee/EncryptionUtil.java index a8e5b072..2ec09bca 100644 --- a/src/main/java/net/md_5/bungee/EncryptionUtil.java +++ b/src/main/java/net/md_5/bungee/EncryptionUtil.java @@ -14,7 +14,6 @@ import java.security.KeyPairGenerator; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.PublicKey; -import java.security.SecureRandom; import java.security.Security; import java.security.spec.InvalidKeySpecException; import java.security.spec.X509EncodedKeySpec; @@ -43,6 +42,7 @@ public class EncryptionUtil private static final Random random = new Random(); private static KeyPair keys; + private static SecretKey secret = new SecretKeySpec(new byte[16], "AES"); static { @@ -114,9 +114,7 @@ public class EncryptionUtil public static SecretKey getSecret() { - byte[] rand = new byte[16]; - random.nextBytes(rand); - return new SecretKeySpec(rand, "AES"); + return secret; } public static PublicKey getPubkey(PacketFDEncryptionRequest request) throws InvalidKeySpecException, NoSuchAlgorithmException diff --git a/src/main/java/net/md_5/bungee/ServerConnection.java b/src/main/java/net/md_5/bungee/ServerConnection.java index 5fd3fadf..2ed02b38 100644 --- a/src/main/java/net/md_5/bungee/ServerConnection.java +++ b/src/main/java/net/md_5/bungee/ServerConnection.java @@ -87,7 +87,7 @@ public class ServerConnection extends GenericConnection return connect(user, name, def, handshake, false); } else { - throw new RuntimeException("Could not connect to target server"); + throw new RuntimeException("Could not connect to target server " + Util.exception(ex)); } } }