mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-11-04 01:30:25 +01:00
Reduce encryption keygen time
This commit is contained in:
parent
7b682df899
commit
02e00313bd
@ -41,7 +41,6 @@ import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
|||||||
public class EncryptionUtil
|
public class EncryptionUtil
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final Random secure = new SecureRandom();
|
|
||||||
private static final Random random = new Random();
|
private static final Random random = new Random();
|
||||||
private static KeyPair keys;
|
private static KeyPair keys;
|
||||||
|
|
||||||
@ -109,14 +108,14 @@ public class EncryptionUtil
|
|||||||
public static BufferedBlockCipher getCipher(boolean forEncryption, Key shared)
|
public static BufferedBlockCipher getCipher(boolean forEncryption, Key shared)
|
||||||
{
|
{
|
||||||
BufferedBlockCipher cip = new BufferedBlockCipher(new CFBBlockCipher(new AESFastEngine(), 8));
|
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;
|
return cip;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SecretKey getSecret()
|
public static SecretKey getSecret()
|
||||||
{
|
{
|
||||||
byte[] rand = new byte[32];
|
byte[] rand = new byte[16];
|
||||||
secure.nextBytes(rand);
|
random.nextBytes(rand);
|
||||||
return new SecretKeySpec(rand, "AES");
|
return new SecretKeySpec(rand, "AES");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user