public SecureRandomPool(String algorithm,int poolSize,SecureRandom seed){
  if (algorithm == null) {
    throw new IllegalArgumentException("algorithm is null");
  }
  pool=new ArrayList<SecureRandom>(poolSize);
  seedSource=getSeedSource(algorithm,(seed != null) ? seed : new SecureRandom());
  try {
    for (int i=0; i < poolSize; i++) {
      byte[] seedBytes=new byte[20];
      seedSource.nextBytes(seedBytes);
      SecureRandom random=SecureRandom.getInstance(algorithm);
      random.setSeed(seedBytes);
      pool.add(random);
    }
  }
 catch (  NoSuchAlgorithmException e) {
    String msg="Error getting SecureRandom using " + algorithm + " algorithm.";
    log.error(msg,e);
    throw new RuntimeException(msg,e);
  }
}

public SecureRandomPool ( String algorithm , int poolSize , SecureRandom seed ) { if ( algorithm == null ) { throw new IllegalArgumentException ( "algorithm is null" ) ; } pool = new ArrayList < SecureRandom > ( poolSize ) ; seedSource = getSeedSource ( algorithm , ( seed != null ) ? seed : new SecureRandom ( ) ) ; try { for ( int i = 0 ; i < poolSize ; i ++ ) { byte [ ] seedBytes = new byte [ 20 ] ; seedSource . nextBytes ( seedBytes ) ; SecureRandom random = SecureRandom . getInstance ( algorithm ) ; random . setSeed ( seedBytes ) ; pool . add ( random ) ; } } catch ( NoSuchAlgorithmException e ) { String msg = "Error getting SecureRandom using " + algorithm + " algorithm." ; log . error ( msg , e ) ; throw new RuntimeException ( msg , e ) ; } }
creates a securerandompool using the specified algorithm . the provided securerandom is used to seed each new securerandom in the pool .
