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

public Class SP800SecureRandomBuilder

extends Object
Class Inheritance
Imports
java.security.SecureRandom, org.bouncycastle.crypto.BlockCipher, .CryptoServicesRegistrar, .Digest, .Mac, org.bouncycastle.crypto.engines.DESedeEngine, org.bouncycastle.crypto.macs.HMac, org.bouncycastle.crypto.prng.drbg.CTRSP800DRBG, .HMacSP800DRBG, .HashSP800DRBG, .SP80090DRBG, org.bouncycastle.util.Arrays

Builder class for making SecureRandom objects based on SP 800-90A Deterministic Random Bit Generators (DRBG).

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
private static class

Field Summary

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

Constructor Summary

AccessConstructor and Description
public
SP800SecureRandomBuilder()

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

public
SP800SecureRandomBuilder(SecureRandom
the SecureRandom acting as a source of entropy for DRBGs made by this builder.
entropySource
,
boolean
true if the SecureRandom seeder can be regarded as predictionResistant.
predictionResistant
)

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

public
SP800SecureRandomBuilder(EntropySourceProvider
a provider of EntropySource objects.
entropySourceProvider
)

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

Method Summary

Modifier and TypeMethod and Description
public SP800SecureRandom

Returns:

a SecureRandom supported by a CTR DRBG.
buildCTR
(BlockCipher
the block cipher to base the DRBG on.
cipher
,
int
key size in bits to be used with the block cipher.
keySizeInBits
,
byte[]
nonce value to use in DRBG construction.
nonce
,
boolean
specify whether the underlying DRBG in the resulting SecureRandom should reseed on each request for bytes.
predictionResistant
)

Build a SecureRandom based on a SP 800-90A CTR DRBG.

public SP800SecureRandom

Returns:

a SecureRandom supported by a Hash DRBG.
buildHash
(Digest
digest algorithm to use in the DRBG underneath the SecureRandom.
digest
,
byte[]
nonce value to use in DRBG construction.
nonce
,
boolean
specify whether the underlying DRBG in the resulting SecureRandom should reseed on each request for bytes.
predictionResistant
)

Build a SecureRandom based on a SP 800-90A Hash DRBG.

public SP800SecureRandom

Returns:

a SecureRandom supported by a HMAC DRBG.
buildHMAC
(Mac
HMAC algorithm to use in the DRBG underneath the SecureRandom.
hMac
,
byte[]
nonce value to use in DRBG construction.
nonce
,
boolean
specify whether the underlying DRBG in the resulting SecureRandom should reseed on each request for bytes.
predictionResistant
)

Build a SecureRandom based on a SP 800-90A HMAC DRBG.

private static String
public SP800SecureRandomBuilder

Returns:

the current builder.
setEntropyBitsRequired
(int
the number of bits of entropy to be requested from the entropy source on each seed/reseed.
entropyBitsRequired
)

Set the amount of entropy bits required for seeding and reseeding DRBGs used in building SecureRandom objects.

public SP800SecureRandomBuilder

Returns:

the current builder.
setPersonalizationString
(byte[]
the personalisation string for the underlying DRBG.
personalizationString
)

Set the personalization string for DRBG SecureRandoms created by this builder

public SP800SecureRandomBuilder

Returns:

the current builder.
setSecurityStrength
(int
the security strength (in bits)
securityStrength
)

Set the security strength required for DRBGs used in building SecureRandom objects.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

entropyBitsRequiredback to summary
private int entropyBitsRequired
entropySourceProviderback to summary
private final EntropySourceProvider entropySourceProvider
personalizationStringback to summary
private byte[] personalizationString
randomback to summary
private final SecureRandom random
securityStrengthback to summary
private int securityStrength

Constructor Detail

SP800SecureRandomBuilderback to summary
public SP800SecureRandomBuilder()

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.

SP800SecureRandomBuilderback to summary
public SP800SecureRandomBuilder(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:SecureRandom

the SecureRandom acting as a source of entropy for DRBGs made by this builder.

predictionResistant:boolean

true if the SecureRandom seeder can be regarded as predictionResistant.

SP800SecureRandomBuilderback to summary
public SP800SecureRandomBuilder(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:EntropySourceProvider

a provider of EntropySource objects.

Method Detail

buildCTRback to summary
public SP800SecureRandom buildCTR(BlockCipher cipher, int keySizeInBits, byte[] nonce, boolean predictionResistant)

Build a SecureRandom based on a SP 800-90A CTR DRBG.

Parameters
cipher:BlockCipher

the block cipher to base the DRBG on.

keySizeInBits:int

key size in bits to be used with the block cipher.

nonce:byte[]

nonce value to use in DRBG construction.

predictionResistant:boolean

specify whether the underlying DRBG in the resulting SecureRandom should reseed on each request for bytes.

Returns:SP800SecureRandom

a SecureRandom supported by a CTR DRBG.

buildHashback to summary
public SP800SecureRandom buildHash(Digest digest, byte[] nonce, boolean predictionResistant)

Build a SecureRandom based on a SP 800-90A Hash DRBG.

Parameters
digest:Digest

digest algorithm to use in the DRBG underneath the SecureRandom.

nonce:byte[]

nonce value to use in DRBG construction.

predictionResistant:boolean

specify whether the underlying DRBG in the resulting SecureRandom should reseed on each request for bytes.

Returns:SP800SecureRandom

a SecureRandom supported by a Hash DRBG.

buildHMACback to summary
public SP800SecureRandom buildHMAC(Mac hMac, byte[] nonce, boolean predictionResistant)

Build a SecureRandom based on a SP 800-90A HMAC DRBG.

Parameters
hMac:Mac

HMAC algorithm to use in the DRBG underneath the SecureRandom.

nonce:byte[]

nonce value to use in DRBG construction.

predictionResistant:boolean

specify whether the underlying DRBG in the resulting SecureRandom should reseed on each request for bytes.

Returns:SP800SecureRandom

a SecureRandom supported by a HMAC DRBG.

getSimplifiedNameback to summary
private static String getSimplifiedName(Digest digest)
setEntropyBitsRequiredback to summary
public SP800SecureRandomBuilder setEntropyBitsRequired(int entropyBitsRequired)

Set the amount of entropy bits required for seeding and reseeding DRBGs used in building SecureRandom objects.

Parameters
entropyBitsRequired:int

the number of bits of entropy to be requested from the entropy source on each seed/reseed.

Returns:SP800SecureRandomBuilder

the current builder.

setPersonalizationStringback to summary
public SP800SecureRandomBuilder setPersonalizationString(byte[] personalizationString)

Set the personalization string for DRBG SecureRandoms created by this builder

Parameters
personalizationString:byte[]

the personalisation string for the underlying DRBG.

Returns:SP800SecureRandomBuilder

the current builder.

setSecurityStrengthback to summary
public SP800SecureRandomBuilder setSecurityStrength(int securityStrength)

Set the security strength required for DRBGs used in building SecureRandom objects.

Parameters
securityStrength:int

the security strength (in bits)

Returns:SP800SecureRandomBuilder

the current builder.

org.bouncycastle.crypto.prng back to summary

private Class SP800SecureRandomBuilder.CTRDRBGProvider

extends Object
implements DRBGProvider
Class Inheritance
  • java.lang.Object
  • org.bouncycastle.crypto.prng.SP800SecureRandomBuilder.CTRDRBGProvider
All Implemented Interfaces
org.bouncycastle.crypto.prng.DRBGProvider

Field Summary

Modifier and TypeField and Description
private final BlockCipher
private final int
private final byte[]
private final byte[]
private final int

Constructor Summary

AccessConstructor and Description
public
CTRDRBGProvider(BlockCipher blockCipher, int keySizeInBits, byte[] nonce, byte[] personalizationString, int securityStrength)

Method Summary

Modifier and TypeMethod and Description
public SP80090DRBG
public String
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

blockCipherback to summary
private final BlockCipher blockCipher
keySizeInBitsback to summary
private final int keySizeInBits
nonceback to summary
private final byte[] nonce
personalizationStringback to summary
private final byte[] personalizationString
securityStrengthback to summary
private final int securityStrength

Constructor Detail

CTRDRBGProviderback to summary
public CTRDRBGProvider(BlockCipher blockCipher, int keySizeInBits, byte[] nonce, byte[] personalizationString, int securityStrength)

Method Detail

getback to summary
public SP80090DRBG get(EntropySource entropySource)

Implements org.bouncycastle.crypto.prng.DRBGProvider.get.

getAlgorithmback to summary
public String getAlgorithm()

Implements org.bouncycastle.crypto.prng.DRBGProvider.getAlgorithm.

org.bouncycastle.crypto.prng back to summary

private Class SP800SecureRandomBuilder.HashDRBGProvider

extends Object
implements DRBGProvider
Class Inheritance
  • java.lang.Object
  • org.bouncycastle.crypto.prng.SP800SecureRandomBuilder.HashDRBGProvider
All Implemented Interfaces
org.bouncycastle.crypto.prng.DRBGProvider

Field Summary

Modifier and TypeField and Description
private final Digest
private final byte[]
private final byte[]
private final int

Constructor Summary

AccessConstructor and Description
public
HashDRBGProvider(Digest digest, byte[] nonce, byte[] personalizationString, int securityStrength)

Method Summary

Modifier and TypeMethod and Description
public SP80090DRBG
public String
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

digestback to summary
private final Digest digest
nonceback to summary
private final byte[] nonce
personalizationStringback to summary
private final byte[] personalizationString
securityStrengthback to summary
private final int securityStrength

Constructor Detail

HashDRBGProviderback to summary
public HashDRBGProvider(Digest digest, byte[] nonce, byte[] personalizationString, int securityStrength)

Method Detail

getback to summary
public SP80090DRBG get(EntropySource entropySource)

Implements org.bouncycastle.crypto.prng.DRBGProvider.get.

getAlgorithmback to summary
public String getAlgorithm()

Implements org.bouncycastle.crypto.prng.DRBGProvider.getAlgorithm.

org.bouncycastle.crypto.prng back to summary

private Class SP800SecureRandomBuilder.HMacDRBGProvider

extends Object
implements DRBGProvider
Class Inheritance
  • java.lang.Object
  • org.bouncycastle.crypto.prng.SP800SecureRandomBuilder.HMacDRBGProvider
All Implemented Interfaces
org.bouncycastle.crypto.prng.DRBGProvider

Field Summary

Modifier and TypeField and Description
private final Mac
private final byte[]
private final byte[]
private final int

Constructor Summary

AccessConstructor and Description
public
HMacDRBGProvider(Mac hMac, byte[] nonce, byte[] personalizationString, int securityStrength)

Method Summary

Modifier and TypeMethod and Description
public SP80090DRBG
public String
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

hMacback to summary
private final Mac hMac
nonceback to summary
private final byte[] nonce
personalizationStringback to summary
private final byte[] personalizationString
securityStrengthback to summary
private final int securityStrength

Constructor Detail

HMacDRBGProviderback to summary
public HMacDRBGProvider(Mac hMac, byte[] nonce, byte[] personalizationString, int securityStrength)

Method Detail

getback to summary
public SP80090DRBG get(EntropySource entropySource)

Implements org.bouncycastle.crypto.prng.DRBGProvider.get.

getAlgorithmback to summary
public String getAlgorithm()

Implements org.bouncycastle.crypto.prng.DRBGProvider.getAlgorithm.