public int generate(byte[] output,byte[] additionalInput,boolean predictionResistant){
  if (_isTDEA) {
    if (_reseedCounter > TDEA_RESEED_MAX) {
      return -1;
    }
    if (Utils.isTooLarge(output,TDEA_MAX_BITS_REQUEST / 8)) {
      throw new IllegalArgumentException("Number of bits per request limited to " + TDEA_MAX_BITS_REQUEST);
    }
  }
 else {
    if (_reseedCounter > AES_RESEED_MAX) {
      return -1;
    }
    if (Utils.isTooLarge(output,AES_MAX_BITS_REQUEST / 8)) {
      throw new IllegalArgumentException("Number of bits per request limited to " + AES_MAX_BITS_REQUEST);
    }
  }
  if (predictionResistant) {
    CTR_DRBG_Reseed_algorithm(_entropySource,additionalInput);
    additionalInput=null;
  }
  if (additionalInput != null) {
    additionalInput=Block_Cipher_df(additionalInput,_seedLength);
    CTR_DRBG_Update(additionalInput,_Key,_V);
  }
 else {
    additionalInput=new byte[_seedLength];
  }
  byte[] out=new byte[_V.length];
  _engine.init(true,new KeyParameter(expandKey(_Key)));
  for (int i=0; i <= output.length / out.length; i++) {
    int bytesToCopy=((output.length - i * out.length) > out.length) ? out.length : (output.length - i * _V.length);
    if (bytesToCopy != 0) {
      addOneTo(_V);
      _engine.processBlock(_V,0,out,0);
      System.arraycopy(out,0,output,i * out.length,bytesToCopy);
    }
  }
  CTR_DRBG_Update(additionalInput,_Key,_V);
  _reseedCounter++;
  return output.length * 8;
}

public int generate ( byte [ ] output , byte [ ] additionalInput , boolean predictionResistant ) { if ( _isTDEA ) { if ( _reseedCounter > TDEA_RESEED_MAX ) { return - 1 ; } if ( Utils . isTooLarge ( output , TDEA_MAX_BITS_REQUEST / 8 ) ) { throw new IllegalArgumentException ( "Number of bits per request limited to " + TDEA_MAX_BITS_REQUEST ) ; } } else { if ( _reseedCounter > AES_RESEED_MAX ) { return - 1 ; } if ( Utils . isTooLarge ( output , AES_MAX_BITS_REQUEST / 8 ) ) { throw new IllegalArgumentException ( "Number of bits per request limited to " + AES_MAX_BITS_REQUEST ) ; } } if ( predictionResistant ) { CTR_DRBG_Reseed_algorithm ( _entropySource , additionalInput ) ; additionalInput = null ; } if ( additionalInput != null ) { additionalInput = Block_Cipher_df ( additionalInput , _seedLength ) ; CTR_DRBG_Update ( additionalInput , _Key , _V ) ; } else { additionalInput = new byte [ _seedLength ] ; } byte [ ] out = new byte [ _V . length ] ; _engine . init ( true , new KeyParameter ( expandKey ( _Key ) ) ) ; for ( int i = 0 ; i <= output . length / out . length ; i ++ ) { int bytesToCopy = ( ( output . length - i * out . length ) > out . length ) ? out . length : ( output . length - i * _V . length ) ; if ( bytesToCopy != 0 ) { addOneTo ( _V ) ; _engine . processBlock ( _V , 0 , out , 0 ) ; System . arraycopy ( out , 0 , output , i * out . length , bytesToCopy ) ; } } CTR_DRBG_Update ( additionalInput , _Key , _V ) ; _reseedCounter ++ ; return output . length * 8 ; }
populate a passed in array with random data .
