354 private final byte[] nextBuffer; 355 356 // number of bytes left in nextBuffer 357 private int buffered; 358 359 // time we read the data into the nextBuffer 360 private long lastRead; 361 362 // mutex lock for nextBytes() 363 private final Object LOCK_GET_BYTES = new Object(); 364 365 // mutex lock for generateSeed() 366 private final Object LOCK_GET_SEED = new Object(); 367 368 // mutex lock for setSeed() 369 private final Object LOCK_SET_SEED = new Object(); 370 371 // constructor, called only once from initIO() 372 private RandomIO(File seedFile, File nextFile) throws IOException { 373 this.seedFile = seedFile; 374 seedIn = new FileInputStream(seedFile); 375 nextIn = new FileInputStream(nextFile); 376 nextBuffer = new byte[BUFFER_SIZE]; 377 } 378 379 // get the SHA1PRNG for mixing 380 // initialize if not yet created 381 private sun.security.provider.SecureRandom getMixRandom() { 382 sun.security.provider.SecureRandom r = mixRandom; 383 if (r == null) { 384 synchronized (LOCK_GET_BYTES) { 385 r = mixRandom; 386 if (r == null) { 387 r = new sun.security.provider.SecureRandom(); 388 try { 389 byte[] b = new byte[20]; 390 readFully(nextIn, b); 391 r.engineSetSeed(b); 392 } catch (IOException e) { 393 throw new ProviderException("init failed", e); 394 } 395 mixRandom = r; | 354 private final byte[] nextBuffer; 355 356 // number of bytes left in nextBuffer 357 private int buffered; 358 359 // time we read the data into the nextBuffer 360 private long lastRead; 361 362 // mutex lock for nextBytes() 363 private final Object LOCK_GET_BYTES = new Object(); 364 365 // mutex lock for generateSeed() 366 private final Object LOCK_GET_SEED = new Object(); 367 368 // mutex lock for setSeed() 369 private final Object LOCK_SET_SEED = new Object(); 370 371 // constructor, called only once from initIO() 372 private RandomIO(File seedFile, File nextFile) throws IOException { 373 this.seedFile = seedFile; 374 seedIn = FileInputStreamPool.getInputStream(seedFile); 375 nextIn = FileInputStreamPool.getInputStream(nextFile); 376 nextBuffer = new byte[BUFFER_SIZE]; 377 } 378 379 // get the SHA1PRNG for mixing 380 // initialize if not yet created 381 private sun.security.provider.SecureRandom getMixRandom() { 382 sun.security.provider.SecureRandom r = mixRandom; 383 if (r == null) { 384 synchronized (LOCK_GET_BYTES) { 385 r = mixRandom; 386 if (r == null) { 387 r = new sun.security.provider.SecureRandom(); 388 try { 389 byte[] b = new byte[20]; 390 readFully(nextIn, b); 391 r.engineSetSeed(b); 392 } catch (IOException e) { 393 throw new ProviderException("init failed", e); 394 } 395 mixRandom = r; |