AesCtrDrbgFactory { public static Drbg fromDerivedSeed(final byte... bytes) { return ExceptionConverter.safe(() -> fromRandomSeed(hash(bytes)), "Unable to derive seed for AesCtrDrbg"); } private  AesCtrDrbgFactory(); static Drbg fromDerivedSeed(final byte... bytes); static Drbg fromRandomSeed(final byte[] seed); static Drbg fromSampledSeed(); static final String HASH_ALGORITHM; }
@Test public void testFromDerivedSeed() throws NoSuchAlgorithmException { MessageDigest md = MessageDigest.getInstance(AesCtrDrbgFactory.HASH_ALGORITHM); Drbg drbgA = AesCtrDrbgFactory.fromDerivedSeed((byte) 0x01, (byte) 0x02); byte[] seed = md.digest(new byte[] { 0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x02 }); assertEquals(AesCtrDrbg.SEED_LENGTH, seed.length); Drbg drbgB = new AesCtrDrbg(seed); byte[] bytesA = new byte[10000]; byte[] bytesB = new byte[10000]; drbgA.nextBytes(bytesA); drbgB.nextBytes(bytesB); assertArrayEquals(bytesA, bytesB); }