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

public Class CTRSP800DRBG

extends Object
implements SP80090DRBG
Class Inheritance
All Implemented Interfaces
org.bouncycastle.crypto.prng.drbg.SP80090DRBG
Imports
org.bouncycastle.crypto.BlockCipher, org.bouncycastle.crypto.params.KeyParameter, org.bouncycastle.crypto.prng.EntropySource, org.bouncycastle.util.Arrays, .Bytes, org.bouncycastle.util.encoders.Hex

A SP800-90A CTR DRBG.

Field Summary

Modifier and TypeField and Description
private BlockCipher
private EntropySource
private boolean
private byte[]
private int
private long
private int
private int
private byte[]
private static final int
private static final long
private static final byte[]
private static final int
private static final long

Constructor Summary

AccessConstructor and Description
public
CTRSP800DRBG(BlockCipher
underlying block cipher to use to support DRBG
engine
,
int
size of the key to use with the block cipher.
keySizeInBits
,
int
security strength required (in bits)
securityStrength
,
EntropySource
source of entropy to use for seeding/reseeding.
entropySource
,
byte[]
personalization string to distinguish this DRBG (may be null).
personalizationString
,
byte[]
nonce to further distinguish this DRBG (may be null).
nonce
)

Construct a SP800-90A CTR DRBG.

Method Summary

Modifier and TypeMethod and Description
private void
addOneTo(byte[] longer)

private void
BCC(byte[] bccOut, byte[] k, byte[] iV, byte[] data)

private byte[]
Block_Cipher_df(byte[] inputString, int bitLength)

private void
copyIntToByteArray(byte[] buf, int value, int offSet)

private void
CTR_DRBG_Instantiate_algorithm(byte[] entropy, byte[] nonce, byte[] personalisationString)

private void
CTR_DRBG_Reseed_algorithm(byte[] additionalInput)

private void
CTR_DRBG_Update(byte[] seed, byte[] key, byte[] v)

pack-priv byte[]
expandKey(byte[] key)

public int

Returns:

number of bits generated, -1 if a reseed required.
generate
(byte[]
output array for generated bits.
output
,
byte[]
additional input to be added to the DRBG in this step.
additionalInput
,
boolean
true if a reseed should be forced, false otherwise.
predictionResistant
)

Implements org.bouncycastle.crypto.prng.drbg.SP80090DRBG.generate.

Populate a passed in array with random data.

public int

Returns:

the number of bits produced on each internal round of the DRBG.
getBlockSize
()

Implements org.bouncycastle.crypto.prng.drbg.SP80090DRBG.getBlockSize.

Return the block size (in bits) of the DRBG.

private byte[]
private int
getMaxSecurityStrength(BlockCipher cipher, int keySizeInBits)

private boolean
private void
padKey(byte[] keyMaster, int keyOff, byte[] tmp, int tmpOff)

Pad out a key for TDEA, setting odd parity for each byte.

public void
reseed(byte[]
additional input to be added to the DRBG in this step.
additionalInput
)

Implements org.bouncycastle.crypto.prng.drbg.SP80090DRBG.reseed.

Reseed the DRBG.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_engineback to summary
private BlockCipher _engine
_entropySourceback to summary
private EntropySource _entropySource
_isTDEAback to summary
private boolean _isTDEA
_Keyback to summary
private byte[] _Key
_keySizeInBitsback to summary
private int _keySizeInBits
_reseedCounterback to summary
private long _reseedCounter
_securityStrengthback to summary
private int _securityStrength
_seedLengthback to summary
private int _seedLength
_Vback to summary
private byte[] _V
AES_MAX_BITS_REQUESTback to summary
private static final int AES_MAX_BITS_REQUEST
AES_RESEED_MAXback to summary
private static final long AES_RESEED_MAX
K_BITSback to summary
private static final byte[] K_BITS
TDEA_MAX_BITS_REQUESTback to summary
private static final int TDEA_MAX_BITS_REQUEST
TDEA_RESEED_MAXback to summary
private static final long TDEA_RESEED_MAX

Constructor Detail

CTRSP800DRBGback to summary
public CTRSP800DRBG(BlockCipher engine, int keySizeInBits, int securityStrength, EntropySource entropySource, byte[] personalizationString, byte[] nonce)

Construct a SP800-90A CTR DRBG.

Minimum entropy requirement is the security strength requested.

Parameters
engine:BlockCipher

underlying block cipher to use to support DRBG

keySizeInBits:int

size of the key to use with the block cipher.

securityStrength:int

security strength required (in bits)

entropySource:EntropySource

source of entropy to use for seeding/reseeding.

personalizationString:byte[]

personalization string to distinguish this DRBG (may be null).

nonce:byte[]

nonce to further distinguish this DRBG (may be null).

Method Detail

addOneToback to summary
private void addOneTo(byte[] longer)
BCCback to summary
private void BCC(byte[] bccOut, byte[] k, byte[] iV, byte[] data)
Block_Cipher_dfback to summary
private byte[] Block_Cipher_df(byte[] inputString, int bitLength)
copyIntToByteArrayback to summary
private void copyIntToByteArray(byte[] buf, int value, int offSet)
CTR_DRBG_Instantiate_algorithmback to summary
private void CTR_DRBG_Instantiate_algorithm(byte[] entropy, byte[] nonce, byte[] personalisationString)
CTR_DRBG_Reseed_algorithmback to summary
private void CTR_DRBG_Reseed_algorithm(byte[] additionalInput)
CTR_DRBG_Updateback to summary
private void CTR_DRBG_Update(byte[] seed, byte[] key, byte[] v)
expandKeyback to summary
pack-priv byte[] expandKey(byte[] key)
generateback to summary
public int generate(byte[] output, byte[] additionalInput, boolean predictionResistant)

Implements org.bouncycastle.crypto.prng.drbg.SP80090DRBG.generate.

Populate a passed in array with random data.

Parameters
output:byte[]

output array for generated bits.

additionalInput:byte[]

additional input to be added to the DRBG in this step.

predictionResistant:boolean

true if a reseed should be forced, false otherwise.

Returns:int

number of bits generated, -1 if a reseed required.

getBlockSizeback to summary
public int getBlockSize()

Implements org.bouncycastle.crypto.prng.drbg.SP80090DRBG.getBlockSize.

Return the block size (in bits) of the DRBG.

Returns:int

the number of bits produced on each internal round of the DRBG.

getEntropyback to summary
private byte[] getEntropy()
getMaxSecurityStrengthback to summary
private int getMaxSecurityStrength(BlockCipher cipher, int keySizeInBits)
isTDEAback to summary
private boolean isTDEA(BlockCipher cipher)
padKeyback to summary
private void padKey(byte[] keyMaster, int keyOff, byte[] tmp, int tmpOff)

Pad out a key for TDEA, setting odd parity for each byte.

reseedback to summary
public void reseed(byte[] additionalInput)

Implements org.bouncycastle.crypto.prng.drbg.SP80090DRBG.reseed.

Reseed the DRBG.

Parameters
additionalInput:byte[]

additional input to be added to the DRBG in this step.