Top Description Fields Constructors Methods
org.bouncycastle.crypto.fips

pack-priv Class CTRSP800DRBG

extends Object
implements SP80090DRBG
Class Inheritance
All Implemented Interfaces
org.bouncycastle.crypto.fips.SP80090DRBG, org.bouncycastle.crypto.fips.DRBG
Imports
java.util.HashMap, .Map, org.bouncycastle.crypto.CryptoServicesRegistrar, .EntropySource, org.bouncycastle.crypto.internal.BlockCipher, org.bouncycastle.crypto.internal.params.KeyParameter, .KeyParameterImpl, org.bouncycastle.util.Arrays, .Properties, 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 Map<String, byte[][]>
private static final Map<String, byte[][]>
private static final Map<String, 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, KeyParameter k, byte[] iV, byte[] data)

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

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

public VariantInternalKatTest
createReseedSelfTest(FipsAlgorithm
the FipsAlgorithm type
algorithm
)

Implements org.bouncycastle.crypto.fips.DRBG.createReseedSelfTest.

Return a KAT for the DRBG - used prior to reseed.
public VariantInternalKatTest
createSelfTest(FipsAlgorithm algorithm)

Implements org.bouncycastle.crypto.fips.SP80090DRBG.createSelfTest.

Perform a instantiate/generate/reseed test.
private void
CTR_DRBG_Instantiate_algorithm(byte[] personalisationString, byte[] nonce)

private void
CTR_DRBG_Reseed_algorithm(byte[] additionalInput)

private void
CTR_DRBG_Update(byte[] seedMaterial)

private void
expandKey(byte[] key)

Note that the input key must already be large enough to hold its expanded form

protected void
finalize()

Overrides java.lang.Object.finalize.

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
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.fips.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.fips.SP80090DRBG.getBlockSize.

Return the block size (in bits) of the DRBG.
private byte[]
private int
private int
private int
getMaxSecurityStrength(BlockCipher cipher, int keySizeInBits)

public int

Returns:

the security strength (in bits) of the DRBG.
getSecurityStrength
()

Implements org.bouncycastle.crypto.fips.DRBG.getSecurityStrength.

Return the security strength of the DRBG.
private void
init(int securityStrength, EntropySource entropySource, byte[] personalizationString, byte[] nonce)

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.fips.SP80090DRBG.reseed.

Reseed the DRBG.
private void
XOR(byte[] out, byte[] a, byte[] b, int bOff)

Inherited from java.lang.Object:
cloneequalsgetClasshashCodenotifynotifyAlltoStringwaitwaitwait

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
katsback to summary
private static final Map<String, byte[][]> kats
reseedKatsback to summary
private static final Map<String, byte[][]> reseedKats
reseedValuesback to summary
private static final Map<String, byte[][]> reseedValues
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, KeyParameter 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)
createReseedSelfTestback to summary
public VariantInternalKatTest createReseedSelfTest(FipsAlgorithm algorithm)

Implements org.bouncycastle.crypto.fips.DRBG.createReseedSelfTest.

Doc from org.bouncycastle.crypto.fips.DRBG.createReseedSelfTest.

Return a KAT for the DRBG - used prior to reseed.

Parameters
algorithm:FipsAlgorithm

the FipsAlgorithm type

Returns:VariantInternalKatTest

a self test

createSelfTestback to summary
public VariantInternalKatTest createSelfTest(FipsAlgorithm algorithm)

Implements org.bouncycastle.crypto.fips.SP80090DRBG.createSelfTest.

Doc from org.bouncycastle.crypto.fips.SP80090DRBG.createSelfTest.

Perform a instantiate/generate/reseed test.

Returns:VariantInternalKatTest

Doc from org.bouncycastle.crypto.fips.DRBG.createSelfTest.

a self test

CTR_DRBG_Instantiate_algorithmback to summary
private void CTR_DRBG_Instantiate_algorithm(byte[] personalisationString, byte[] nonce)
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[] seedMaterial)
expandKeyback to summary
private void expandKey(byte[] key)

Note that the input key must already be large enough to hold its expanded form

finalizeback to summary
protected void finalize() throws Throwable

Overrides java.lang.Object.finalize.

Doc from java.lang.Object.finalize.

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. A subclass overrides the finalize method to dispose of system resources or to perform other cleanup.

When running in a Java virtual machine in which finalization has been disabled or removed, the garbage collector will never call finalize(). In a Java virtual machine in which finalization is enabled, the garbage collector might call finalize only after an indefinite delay.

The general contract of finalize is that it is invoked if and when the Java virtual machine has determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, except as a result of an action taken by the finalization of some other object or class which is ready to be finalized. The finalize method may take any action, including making this object available again to other threads; the usual purpose of finalize, however, is to perform cleanup actions before the object is irrevocably discarded. For example, the finalize method for an object that represents an input/output connection might perform explicit I/O transactions to break the connection before the object is permanently discarded.

The finalize method of class Object performs no special action; it simply returns normally. Subclasses of Object may override this definition.

The Java programming language does not guarantee which thread will invoke the finalize method for any given object. It is guaranteed, however, that the thread that invokes finalize will not be holding any user-visible synchronization locks when finalize is invoked. If an uncaught exception is thrown by the finalize method, the exception is ignored and finalization of that object terminates.

After the finalize method has been invoked for an object, no further action is taken until the Java virtual machine has again determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, including possible actions by other objects or classes which are ready to be finalized, at which point the object may be discarded.

The finalize method is never invoked more than once by a Java virtual machine for any given object.

Any exception thrown by the finalize method causes the finalization of this object to be halted, but is otherwise ignored.

Annotations
@Override
Exceptions
Throwable:
the Exception raised by this method
generateback to summary
public int generate(byte[] output, byte[] additionalInput, boolean predictionResistant)

Implements org.bouncycastle.crypto.fips.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.fips.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()
getExpandedKeySizeInBytesback to summary
private int getExpandedKeySizeInBytes()
getKeySizeInBytesback to summary
private int getKeySizeInBytes()
getMaxSecurityStrengthback to summary
private int getMaxSecurityStrength(BlockCipher cipher, int keySizeInBits)
getSecurityStrengthback to summary
public int getSecurityStrength()

Implements org.bouncycastle.crypto.fips.DRBG.getSecurityStrength.

Return the security strength of the DRBG.

Returns:int

the security strength (in bits) of the DRBG.

initback to summary
private void init(int securityStrength, EntropySource entropySource, byte[] personalizationString, byte[] nonce)
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.fips.SP80090DRBG.reseed.

Reseed the DRBG.

Parameters
additionalInput:byte[]

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

XORback to summary
private void XOR(byte[] out, byte[] a, byte[] b, int bOff)