List of usage examples for org.bouncycastle.crypto.prng SP800SecureRandom nextBytes
public void nextBytes(byte[] bytes)
From source file:org.cryptacular.util.NonceUtil.java
License:Open Source License
/** * Generates a random IV according to NIST <a href="http://goo.gl/S9z8qF"> * SP-800-63a</a>, appendix C, method 2 (pseudorandom), suitable for use with * any block cipher mode described in that standard. * * @param prng NIST SP800-63a approved pseudorandom number generator. * @param blockSize Cipher block size in bytes. * * @return Cipher block size number of random bytes. *//*from w w w . j av a 2s . com*/ public static byte[] nist80063a(final SP800SecureRandom prng, final int blockSize) { prng.setSeed(System.nanoTime()); final byte[] iv = new byte[blockSize]; prng.nextBytes(iv); return iv; }