public void setup(Map<String, byte[]> attributes) { seeded = false; Arrays.fill(key, (byte) 0); Arrays.fill(counter, (byte) 0); byte[] seed = attributes.get(SEED); if (seed != null) addRandomBytes(seed); }
private void doFill(byte buf[]) { //long start = System.currentTimeMillis(); if (pool0Count >= MIN_POOL_SIZE && System.currentTimeMillis() - lastReseed > 100) { reseedCount++; //byte[] seed = new byte[0]; for (int i = 0; i < NUM_POOLS; i++) { if (reseedCount % (1 << i) == 0) { generator.addRandomBytes(pools[i].digest()); } } lastReseed = System.currentTimeMillis(); } generator.nextBytes(buf); //long now = System.currentTimeMillis(); //long diff = now-lastRefill; //lastRefill = now; //long refillTime = now-start; //System.out.println("Refilling " + (++refillCount) + " after " + diff + " for the PRNG took " + refillTime); }
/** Unused, see AsyncFortunaStandalone */ public void fillBlock() { //long start = System.currentTimeMillis(); if (pool0Count >= MIN_POOL_SIZE && System.currentTimeMillis() - lastReseed > 100) { reseedCount++; //byte[] seed = new byte[0]; for (int i = 0; i < NUM_POOLS; i++) { if (reseedCount % (1 << i) == 0) { generator.addRandomBytes(pools[i].digest()); } } lastReseed = System.currentTimeMillis(); } generator.nextBytes(buffer); //long now = System.currentTimeMillis(); //long diff = now-lastRefill; //lastRefill = now; //long refillTime = now-start; //System.out.println("Refilling " + (++refillCount) + " after " + diff + " for the PRNG took " + refillTime); }
@Override public final void addRandomByte(byte b) { addRandomBytes(new byte[] { b }); }
private void readObject(ObjectInputStream in) throws IOException { byte[] seed = new byte[SEED_FILE_SIZE]; in.readFully(seed); generator.addRandomBytes(seed); }