Class RBGNonce
java.lang.Object
org.cryptacular.generator.sp80038d.RBGNonce
- All Implemented Interfaces:
Nonce
RBG-based nonce generation strategy that uses a RBG component to produce values for the invocation field as described
in NIST SP-800-38D, section 8.2.2.
NOTE: users of this class are responsible for counting number of invocations and enforcing the constraints described in section 8.3; namely the following:
The total number of invocations of the authenticated encryption function shall not exceed 232, including all IV lengths and all instances of the authenticated encryption function with the given key.
Instances of this class are thread safe.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final byte[]Fixed field value.private final intNumber of bytes of random data in invocation field.private final org.bouncycastle.crypto.prng.drbg.SP80090DRBGRandom bit generator. -
Constructor Summary
ConstructorsConstructorDescriptionRBGNonce()Creates a new instance that produces 12-bytes (96-bits) of random data; that is, the fixed field of the nonce is null.RBGNonce(int randomLength) Creates a new instance that produces length bytes of random data; that is, the fixed field of the nonce is null.Creates a new instance using the given fixed field value. -
Method Summary
-
Field Details
-
fixed
private final byte[] fixedFixed field value. -
randomLength
private final int randomLengthNumber of bytes of random data in invocation field. -
rbg
private final org.bouncycastle.crypto.prng.drbg.SP80090DRBG rbgRandom bit generator.
-
-
Constructor Details
-
RBGNonce
public RBGNonce()Creates a new instance that produces 12-bytes (96-bits) of random data; that is, the fixed field of the nonce is null. -
RBGNonce
public RBGNonce(int randomLength) Creates a new instance that produces length bytes of random data; that is, the fixed field of the nonce is null.- Parameters:
randomLength- Number of bytes in the random part of the nonce. MUST be at least 12.
-
RBGNonce
Creates a new instance using the given fixed field value.- Parameters:
fixed- User-defined fixed field value.randomLength- Number of bytes in the random part of the nonce. MUST be at least 12.
-
-
Method Details
-
generate
Description copied from interface:NonceGenerates a nonce value.- Specified by:
generatein interfaceNonce- Returns:
- Nonce bytes.
- Throws:
LimitException- When a limit imposed by the nonce generation strategy, if any, is exceeded.
-
getLength
public int getLength() -
newRBG
private static org.bouncycastle.crypto.prng.drbg.SP80090DRBG newRBG(int length, byte[] domain) Creates a new DRBG instance.- Parameters:
length- Length in bits of values produced by DRBG.domain- Domain qualifier.- Returns:
- New DRBG instance.
-