@Test public void testEngineSetSeedWritesToRandomDevice() throws Exception { if (!(OsUtils.isLinux())) { System.err.println("WARNING: Skipping test, can't run on this OS"); return; } File urandom = new File(testDir, "urandom"); urandom.delete(); assertTrue(urandom.createNewFile()); assertEquals(0, urandom.length()); byte[] seed = TestUtils.getRandomBytes(SEED_BYTES); LinuxSecureRandomSpi engine = new LinuxSecureRandomSpi(RANDOM_DEVICE, urandom); engine.engineSetSeed(seed); assertEquals(SEED_BYTES, urandom.length()); byte[] written = new byte[SEED_BYTES]; FileInputStream in = new FileInputStream(urandom); IoUtils.read(in, written); in.close(); assertArrayEquals(seed, written); }
@Override protected void engineSetSeed(byte[] seed) { try { DataOutputStream out = new DataOutputStream( new FileOutputStream(outputDevice)); out.write(seed); out.flush(); out.close(); } catch (IOException e) { logException(LOG, WARNING, e); } }
LinuxSecureRandomSpi extends SecureRandomSpi { @Override protected void engineSetSeed(byte[] seed) { try { DataOutputStream out = new DataOutputStream( new FileOutputStream(outputDevice)); out.write(seed); out.flush(); out.close(); } catch (IOException e) { logException(LOG, WARNING, e); } } }
LinuxSecureRandomSpi extends SecureRandomSpi { @Override protected void engineSetSeed(byte[] seed) { try { DataOutputStream out = new DataOutputStream( new FileOutputStream(outputDevice)); out.write(seed); out.flush(); out.close(); } catch (IOException e) { logException(LOG, WARNING, e); } } LinuxSecureRandomSpi();   LinuxSecureRandomSpi(File inputDevice, File outputDevice); }
LinuxSecureRandomSpi extends SecureRandomSpi { @Override protected void engineSetSeed(byte[] seed) { try { DataOutputStream out = new DataOutputStream( new FileOutputStream(outputDevice)); out.write(seed); out.flush(); out.close(); } catch (IOException e) { logException(LOG, WARNING, e); } } LinuxSecureRandomSpi();   LinuxSecureRandomSpi(File inputDevice, File outputDevice);  }
LinuxSecureRandomSpi extends SecureRandomSpi { @Override protected void engineSetSeed(byte[] seed) { try { DataOutputStream out = new DataOutputStream( new FileOutputStream(outputDevice)); out.write(seed); out.flush(); out.close(); } catch (IOException e) { logException(LOG, WARNING, e); } } LinuxSecureRandomSpi();   LinuxSecureRandomSpi(File inputDevice, File outputDevice);   }