public void addRandomBytes(byte[] buffer) { addRandomBytes(buffer, 0, buffer.length); }
private byte nextByteInternal() {//throws LimitReachedException { if (buffer == null) throw new IllegalStateException("Random is shut down - do you have a static ref?"); if (ndx >= buffer.length) { this.fillBlock(); ndx = 0; } return buffer[ndx++]; }
public byte nextByte() throws IllegalStateException {//, LimitReachedException { if (!initialised) { throw new IllegalStateException(); } return nextByteInternal(); }
public void nextBytes(byte[] out) throws IllegalStateException {//, LimitReachedException { nextBytes(out, 0, out.length); }
public void init(Map<String, byte[]> attributes) { this.setup(attributes); ndx = 0; initialised = 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 void nextBytes(byte[] out, int offset, int length) throws IllegalStateException //, LimitReachedException { if (!initialised) throw new IllegalStateException("not initialized"); if (length == 0) return; if (offset < 0 || length < 0 || offset + length > out.length) throw new ArrayIndexOutOfBoundsException("offset=" + offset + " length=" + length + " limit=" + out.length); if (buffer == null) throw new IllegalStateException("Random is shut down - do you have a static ref?"); if (ndx >= buffer.length) { fillBlock(); ndx = 0; } int count = 0; while (count < length) { int amount = Math.min(buffer.length - ndx, length - count); System.arraycopy(buffer, ndx, out, offset+count, amount); count += amount; ndx += amount; if (ndx >= buffer.length) { fillBlock(); ndx = 0; } } }