From 02e00313bd844376de9a5a18ef629241cd13024b Mon Sep 17 00:00:00 2001 From: md_5 Date: Mon, 19 Nov 2012 20:34:55 +1100 Subject: [PATCH] Reduce encryption keygen time --- src/main/java/net/md_5/bungee/EncryptionUtil.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/md_5/bungee/EncryptionUtil.java b/src/main/java/net/md_5/bungee/EncryptionUtil.java index d4ec2b87..a8e5b072 100644 --- a/src/main/java/net/md_5/bungee/EncryptionUtil.java +++ b/src/main/java/net/md_5/bungee/EncryptionUtil.java @@ -41,7 +41,6 @@ import org.bouncycastle.jce.provider.BouncyCastleProvider; public class EncryptionUtil { - private static final Random secure = new SecureRandom(); private static final Random random = new Random(); private static KeyPair keys; @@ -109,14 +108,14 @@ public class EncryptionUtil public static BufferedBlockCipher getCipher(boolean forEncryption, Key shared) { BufferedBlockCipher cip = new BufferedBlockCipher(new CFBBlockCipher(new AESFastEngine(), 8)); - cip.init(forEncryption, new ParametersWithIV(new KeyParameter(shared.getEncoded()), shared.getEncoded(), 0, 16)); + cip.init(forEncryption, new ParametersWithIV(new KeyParameter(shared.getEncoded()), shared.getEncoded())); return cip; } public static SecretKey getSecret() { - byte[] rand = new byte[32]; - secure.nextBytes(rand); + byte[] rand = new byte[16]; + random.nextBytes(rand); return new SecretKeySpec(rand, "AES"); }