@Override public final void addRandomBytes(byte[] seed, int offset, int length) { hash.update(key, 0, key.length); hash.update(seed, offset, length); byte[] newkey = hash.digest(); System.arraycopy(newkey, 0, key, 0, Math.min(key.length, newkey.length)); //hash.doFinal(key, 0); resetKey(); incrementCounter(); seeded = true; }
@Override public final void nextBytes(byte[] out, int offset, int length) { if (!seeded) throw new IllegalStateException("generator not seeded"); int count = 0; do { int amount = Math.min(LIMIT, length - count); super.nextBytes(out, offset+count, amount); count += amount; for (int i = 0; i < key.length; i += counter.length) { //fillBlock(); // inlined CryptixRijndael_Algorithm.blockEncrypt(counter, buffer, 0, 0, cryptixKey); incrementCounter(); int l = Math.min(key.length - i, 16);//cipher.currentBlockSize()); System.arraycopy(buffer, 0, key, i, l); } resetKey(); } while (count < length); //fillBlock(); // inlined CryptixRijndael_Algorithm.blockEncrypt(counter, buffer, 0, 0, cryptixKey); incrementCounter(); ndx = 0; }
public final void fillBlock() { ////i2p: this is not being checked as a microoptimization //if (!seeded) // throw new IllegalStateException("generator not seeded"); CryptixRijndael_Algorithm.blockEncrypt(counter, buffer, 0, 0, cryptixKey); incrementCounter(); }