Class BigIntegerCounterNonce
java.lang.Object
org.cryptacular.generator.sp80038a.BigIntegerCounterNonce
- All Implemented Interfaces:
Nonce
Uses a
BigInteger to back a counter in order to produce nonces of arbitrary length.
A common use case for this component is creation of IVs for ciphers with 16-byte block size, e.g. AES.
Instances of this class are thread safe.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate BigIntegerCounter.private final intLength of generated counter nonce values in bytes. -
Constructor Summary
ConstructorsConstructorDescriptionBigIntegerCounterNonce(BigInteger counter, int length) Creates a new instance with given parameters. -
Method Summary
-
Field Details
-
counter
Counter. -
length
private final int lengthLength of generated counter nonce values in bytes.
-
-
Constructor Details
-
BigIntegerCounterNonce
Creates a new instance with given parameters.- Parameters:
counter- Initial counter value.length- Maximum length of generated counter values in bytes.
-
-
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()
-