Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.bouncycastle.crypto.prng;
 
 
 
 public class X931SecureRandomBuilder
    private SecureRandom random;          // JDK 1.1 complains on final.
    private BlockCipher engine;
    private byte[] dateTimeVector;

    
Basic constructor, creates a builder using an EntropySourceProvider based on the default SecureRandom with predictionResistant set to false.

Any SecureRandom created from a builder constructed like this will make use of input passed to SecureRandom.setSeed() if the default SecureRandom does for its generateSeed() call.

    public X931SecureRandomBuilder()
    {
        this(new SecureRandom(), false);
    }

    
Construct a builder with an EntropySourceProvider based on the passed in SecureRandom and the passed in value for prediction resistance.

Any SecureRandom created from a builder constructed like this will make use of input passed to SecureRandom.setSeed() if the passed in SecureRandom does for its generateSeed() call.

Parameters:
entropySource
predictionResistant
    public X931SecureRandomBuilder(SecureRandom entropySourceboolean predictionResistant)
    {
        this. = entropySource;
        this. = new BasicEntropySourceProvider(predictionResistant);
    }

    
Create a builder which makes creates the SecureRandom objects from a specified entropy source provider.

Note: If this constructor is used any calls to setSeed() in the resulting SecureRandom will be ignored.

Parameters:
entropySourceProvider a provider of EntropySource objects.
    public X931SecureRandomBuilder(EntropySourceProvider entropySourceProvider)
    {
        this. = null;
        this. = entropySourceProvider;
    }
    public X931SecureRandomBuilder setDateTimeVector(byte[] dateTimeVector)
    {
        this. = dateTimeVector;
        return this;
    }

    
Construct a X9.31 secure random generator using the passed in engine and key. If predictionResistant is true the generator will be reseeded on each request.

Parameters:
engine a block cipher to use as the operator.
key the block cipher key to initialise engine with.
predictionResistant true if engine to be reseeded on each use, false otherwise.
Returns:
a SecureRandom.
    public X931SecureRandom build(BlockCipher engineKeyParameter keyboolean predictionResistant)
    {
        this. = engine;
        if ( == null)
        {
            if (engine.getBlockSize() == 8)
            {
                 = Pack.longToBigEndian(System.currentTimeMillis());
            }
            else
            {
                 = new byte[engine.getBlockSize()];
                byte[] date = Pack.longToBigEndian(System.currentTimeMillis());
                System.arraycopy(date, 0, , 0, date.length);
            }
        }
        engine.init(truekey);
        return new X931SecureRandom(new X931RNG(engine.get(engine.getBlockSize() * 8)), predictionResistant);
    }
New to GrepCode? Check out our FAQ X