Reduce encryption keygen time

This commit is contained in:
md_5 2012-11-19 20:34:55 +11:00
parent 7b682df899
commit 02e00313bd

View File

@ -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");
}