Example usage for org.bouncycastle.crypto.prng EntropySource EntropySource

List of usage examples for org.bouncycastle.crypto.prng EntropySource EntropySource

Introduction

In this page you can find the example usage for org.bouncycastle.crypto.prng EntropySource EntropySource.

Prototype

EntropySource

Source Link

Usage

From source file:org.cryptacular.generator.sp80038d.RBGNonce.java

License:Open Source License

/**
 * Creates a new DRBG instance.//w  w w . j  a  va 2s .  c  o m
 *
 * @param  length  Length in bits of values produced by DRBG.
 * @param  domain  Domain qualifier.
 *
 * @return  New DRBG instance.
 */
private static SP80090DRBG newRBG(final int length, final byte[] domain) {
    return new HashSP800DRBG(new SHA256Digest(), length, new EntropySource() {
        @Override
        public boolean isPredictionResistant() {
            return false;
        }

        @Override
        public byte[] getEntropy() {
            return NonceUtil.timestampNonce(length);
        }

        @Override
        public int entropySize() {
            return length;
        }
    }, domain, NonceUtil.timestampNonce(8));
}

From source file:org.cryptacular.util.NonceUtil.java

License:Open Source License

/**
 * Creates a new hash-based DRBG instance that uses the given digest as the
 * pseudorandom source./*from   ww  w .  j  a va  2 s  .co m*/
 *
 * @param  digest  Digest algorithm.
 * @param  length  Length in bits of values to be produced by DRBG instance.
 *
 * @return  New DRGB instance.
 */
public static SP80090DRBG newRBG(final Digest digest, final int length) {
    return new HashSP800DRBG(digest, length, new EntropySource() {
        @Override
        public boolean isPredictionResistant() {
            return false;
        }

        @Override
        public byte[] getEntropy() {
            return NonceUtil.timestampNonce(length);
        }

        @Override
        public int entropySize() {
            return length;
        }
    }, null, NonceUtil.timestampNonce(8));
}