AesCtrDrbgFactory { public static Drbg fromRandomSeed(final byte[] seed) { return new AesCtrDrbg(seed); } 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 testFromRandomSeed() { byte[] seed = new byte[AesCtrDrbg.SEED_LENGTH]; for (int i = 0; i < AesCtrDrbg.SEED_LENGTH; i++) { seed[i] = (byte) i; } Drbg drbgA = AesCtrDrbgFactory.fromRandomSeed(seed); Drbg drbgB = new AesCtrDrbg(seed); byte[] bytesA = new byte[10000]; byte[] bytesB = new byte[10000]; drbgA.nextBytes(bytesA); drbgB.nextBytes(bytesB); assertArrayEquals(bytesA, bytesB); }
@Test(expected = IllegalArgumentException.class) public void testFromRandomSeedShortSeed() { AesCtrDrbgFactory.fromRandomSeed(new byte[] { 0x42 }); }
@Test(expected = IllegalArgumentException.class) public void testFromRandomSeedLongSeed() { byte[] bytes = new byte[33]; AesCtrDrbgFactory.fromRandomSeed(bytes); }