X931SecureRandomBuilder (Bouncy Castle Library 1.85 API Specification)
Date: 2026-07-12

org.bouncycastle.crypto.prng

## Class X931SecureRandomBuilder

- java.lang.Object
- - org.bouncycastle.crypto.prng.X931SecureRandomBuilder

-     public class X931SecureRandomBuilder
      extends java.lang.Object

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `X931SecureRandomBuilder()` Basic constructor, creates a builder using an EntropySourceProvider based on the default SecureRandom with predictionResistant set to false.
    `X931SecureRandomBuilder(EntropySourceProvider entropySourceProvider)` Create a builder which makes creates the SecureRandom objects from a specified entropy source provider.
    `X931SecureRandomBuilder(java.security.SecureRandom entropySource, boolean predictionResistant)` Construct a builder with an EntropySourceProvider based on the passed in SecureRandom and the passed in value for prediction resistance.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `X931SecureRandom` | `build(BlockCipher engine, KeyParameter key, boolean predictionResistant)` Construct a X9.31 secure random generator using the passed in engine and key.
    `X931SecureRandomBuilder` | `setDateTimeVector(byte[] dateTimeVector)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### X931SecureRandomBuilder

          public X931SecureRandomBuilder()

      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.

    - #### X931SecureRandomBuilder

          public X931SecureRandomBuilder(java.security.SecureRandom entropySource,
                                         boolean predictionResistant)

      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` -

    - #### X931SecureRandomBuilder

          public X931SecureRandomBuilder(EntropySourceProvider entropySourceProvider)

      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.

  - ### Method Detail

    - #### setDateTimeVector

          public X931SecureRandomBuilder setDateTimeVector(byte[] dateTimeVector)

    - #### build

          public X931SecureRandom build(BlockCipher engine,
                                        KeyParameter key,
                                        boolean predictionResistant)

      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.