/** * Construct a X9.31 secure random generator using the passed in engine and key. If predictionResistant is true the * generator will be reseeded on each request. * * @param engine a block cipher to use as the operator. * @param key the block cipher key to initialise engine with. * @param predictionResistant true if engine to be reseeded on each use, false otherwise. * @return a SecureRandom. */ public X931SecureRandom build(BlockCipher engine, KeyParameter key, boolean predictionResistant) { if (dateTimeVector == null) { dateTimeVector = new byte[engine.getBlockSize()]; Pack.longToBigEndian(System.currentTimeMillis(), dateTimeVector, 0); } engine.init(true, key); return new X931SecureRandom(random, new X931RNG(engine, dateTimeVector, entropySourceProvider.get(engine.getBlockSize() * 8)), predictionResistant); } }
return new X931SecureRandom(random, new X931RNG(engine, dateTimeVector, entropySourceProvider.get(engine.getBlockSize() * 8)), predictionResistant);