Top Description Inners Fields Constructors Methods
org.bouncycastle.crypto.general

public final Class X931PRNG

extends Object
Class Inheritance
Imports
java.security.SecureRandom, org.bouncycastle.crypto.Algorithm, .EntropySourceProvider, .IllegalKeyException, .Parameters, .SymmetricKey, org.bouncycastle.crypto.fips.FipsAES, .FipsTripleDES, org.bouncycastle.crypto.internal.BlockCipher, org.bouncycastle.crypto.internal.params.KeyParameterImpl, org.bouncycastle.crypto.util.BasicEntropySourceProvider, org.bouncycastle.util.Arrays, .Pack

Source class for implementations of Pseudo Random Number Generator (PRNG) from X9.31

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
X931PRNG.Base

Base for Builder for SecureRandom objects based on the X9.31 PRNG.

public static class
X931PRNG.Builder

Builder for SecureRandom objects based on the X9.31 PRNG.

private static enum

Field Summary

Modifier and TypeField and Description
public static final X931PRNG.Base
AES_128

X9.31 PRNG - 128 bit AES

public static final X931PRNG.Base
AES_192

X9.31 PRNG - 192 bit AES

public static final X931PRNG.Base
AES_256

X9.31 PRNG - 256 bit AES

public static final X931PRNG.Base
Triple_DES_168

X9.31 PRNG - 3-Key TripleDES

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

AES_128back to summary
public static final X931PRNG.Base AES_128

X9.31 PRNG - 128 bit AES

AES_192back to summary
public static final X931PRNG.Base AES_192

X9.31 PRNG - 192 bit AES

AES_256back to summary
public static final X931PRNG.Base AES_256

X9.31 PRNG - 256 bit AES

Triple_DES_168back to summary
public static final X931PRNG.Base Triple_DES_168

X9.31 PRNG - 3-Key TripleDES

Constructor Detail

X931PRNGback to summary
private X931PRNG()
org.bouncycastle.crypto.general back to summary

public Class X931PRNG.Base

extends Object
implements Parameters
Class Inheritance
All Implemented Interfaces
org.bouncycastle.crypto.Parameters

Base for Builder for SecureRandom objects based on the X9.31 PRNG.

Field Summary

Modifier and TypeField and Description
private final GeneralAlgorithm

Constructor Summary

AccessConstructor and Description
private
Base(GeneralAlgorithm algorithm)

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

Method Summary

Modifier and TypeMethod and Description
public X931PRNG.Builder

Returns:

a new Builder instance.
fromDefaultEntropy
()

Return a builder using an EntropySourceProvider based on the default SecureRandom with predictionResistant set to false.

public X931PRNG.Builder

Returns:

a new builder instance.
fromEntropySource
(SecureRandom
a SecureRandom to use as a source of entropy for the PRNG.
entropySource
,
boolean
true if the SecureRandom should be regarded as prediction resistant, false otherwise.
predictionResistant
)

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

public X931PRNG.Builder

Returns:

a new builder instance.
fromEntropySource
(EntropySourceProvider
a provider of EntropySource objects.
entropySourceProvider
)

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

public Algorithm
getAlgorithm()

Implements org.bouncycastle.crypto.Parameters.getAlgorithm.

Return the algorithm these parameters are associated with.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

algorithmback to summary
private final GeneralAlgorithm algorithm

Constructor Detail

Baseback to summary
private Base(GeneralAlgorithm algorithm)

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.

Method Detail

fromDefaultEntropyback to summary
public X931PRNG.Builder fromDefaultEntropy()

Return 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.

Returns:X931PRNG.Builder

a new Builder instance.

fromEntropySourceback to summary
public X931PRNG.Builder fromEntropySource(SecureRandom entropySource, boolean predictionResistant)

Return 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:SecureRandom

a SecureRandom to use as a source of entropy for the PRNG.

predictionResistant:boolean

true if the SecureRandom should be regarded as prediction resistant, false otherwise.

Returns:X931PRNG.Builder

a new builder instance.

fromEntropySourceback to summary
public X931PRNG.Builder fromEntropySource(EntropySourceProvider entropySourceProvider)

Return 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:EntropySourceProvider

a provider of EntropySource objects.

Returns:X931PRNG.Builder

a new builder instance.

getAlgorithmback to summary
public Algorithm getAlgorithm()

Implements org.bouncycastle.crypto.Parameters.getAlgorithm.

Doc from org.bouncycastle.crypto.Parameters.getAlgorithm.

Return the algorithm these parameters are associated with.

Returns:Algorithm

the algorithm these parameters are for.

org.bouncycastle.crypto.general back to summary

public Class X931PRNG.Builder

extends Object
Class Inheritance

Builder for SecureRandom objects based on the X9.31 PRNG.

Field Summary

Modifier and TypeField and Description
private final GeneralAlgorithm
private byte[]
private final EntropySourceProvider
private final SecureRandom

Constructor Summary

AccessConstructor and Description
pack-priv
Builder(GeneralAlgorithm algorithm, SecureRandom random, EntropySourceProvider entropySourceProvider, byte[] dateTimeVector)

Method Summary

Modifier and TypeMethod and Description
public GeneralSecureRandom

Returns:

a SecureRandom.
build
(SymmetricKey
the block cipher key to initialise algorithm implementation with.
key
,
boolean
true if engine to be reseeded on each use, false otherwise.
predictionResistant
)

Construct a X9.31 secure random generator using the passed in engine and key.

public X931PRNG.Builder

Returns:

the current Builder instance.
setDateTimeVector
(byte[]
a dateTime vector - needs to be the same size as the block size of the cipher.
dateTimeVector
)

Set the dateTime vector to be used with the generator.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

algorithmback to summary
private final GeneralAlgorithm algorithm
dateTimeVectorback to summary
private byte[] dateTimeVector
entropySourceProviderback to summary
private final EntropySourceProvider entropySourceProvider
randomback to summary
private final SecureRandom random

Constructor Detail

Builderback to summary
pack-priv Builder(GeneralAlgorithm algorithm, SecureRandom random, EntropySourceProvider entropySourceProvider, byte[] dateTimeVector)

Method Detail

buildback to summary
public GeneralSecureRandom build(SymmetricKey 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
key:SymmetricKey

the block cipher key to initialise algorithm implementation with.

predictionResistant:boolean

true if engine to be reseeded on each use, false otherwise.

Returns:GeneralSecureRandom

a SecureRandom.

setDateTimeVectorback to summary
public X931PRNG.Builder setDateTimeVector(byte[] dateTimeVector)

Set the dateTime vector to be used with the generator. If this method is not called a vector is calculated based on System.currentTimeMillis().

Parameters
dateTimeVector:byte[]

a dateTime vector - needs to be the same size as the block size of the cipher.

Returns:X931PRNG.Builder

the current Builder instance.

org.bouncycastle.crypto.general back to summary

private final Enum X931PRNG.Variations

extends Enum<X931PRNG.Variations>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final X931PRNG.Variations
public static final X931PRNG.Variations
public static final X931PRNG.Variations
public static final X931PRNG.Variations

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static X931PRNG.Variations
public static X931PRNG.Variations[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

AES_128back to summary
public static final X931PRNG.Variations AES_128
AES_192back to summary
public static final X931PRNG.Variations AES_192
AES_256back to summary
public static final X931PRNG.Variations AES_256
Triple_DES_168back to summary
public static final X931PRNG.Variations Triple_DES_168

Constructor Detail

Variationsback to summary
private Variations()

Method Detail

valueOfback to summary
public static X931PRNG.Variations valueOf(String name)
valuesback to summary
public static X931PRNG.Variations[] values()