Example usage for org.bouncycastle.crypto.prng.drbg HashSP800DRBG HashSP800DRBG

List of usage examples for org.bouncycastle.crypto.prng.drbg HashSP800DRBG HashSP800DRBG

Introduction

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

Prototype

public HashSP800DRBG(Digest digest, int securityStrength, EntropySource entropySource,
        byte[] personalizationString, byte[] nonce) 

Source Link

Document

Construct a SP800-90A Hash DRBG.

Usage

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

License:Open Source License

/**
 * Creates a new DRBG instance./*from   w  w  w .  j  a  va 2 s  .  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. ja  va 2 s.  c o  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));
}

From source file:org.cryptoworkshop.ximix.common.util.challenge.SeededChallenger.java

License:Apache License

/**
 * Base constructor.//w  w w. ja  va2  s  .  c om
 *
 * @param size the number of messages on the board we are issuing challenges on.
 * @param stepNo the number of the step in the shuffling process.
 * @param seed a random seed for creating index numbers to challenge on - must be at least 55 bytes.
 */
public SeededChallenger(Integer size, Integer stepNo, byte[] seed) {
    this.counter = 0;
    this.startIndex = 0;

    this.bitSet = buildBitSet(size, new HashSP800DRBG(new SHA256Digest(), 256,
            new SingleEntropySourceProvider(seed).get(440), null, null));
    this.isMirror = (((seed[seed.length - 1] & 0xff) + stepNo) & 0x01) == 0;
    this.max = (isMirror) ? (size - (size / 2)) : (size / 2);
}