public class BigIntegerCounterNonce extends java.lang.Object implements Nonce
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.
| Modifier and Type | Field and Description |
|---|---|
private java.math.BigInteger |
counter
Counter.
|
private int |
length
Length of generated counter nonce values in bytes.
|
| Constructor and Description |
|---|
BigIntegerCounterNonce(java.math.BigInteger counter,
int length)
Creates a new instance with given parameters.
|
| Modifier and Type | Method and Description |
|---|---|
byte[] |
generate()
Generates a nonce value.
|
int |
getLength() |
private java.math.BigInteger counter
private final int length
public BigIntegerCounterNonce(java.math.BigInteger counter,
int length)
counter - Initial counter value.length - Maximum length of generated counter values in bytes.public byte[] generate()
throws LimitException
Noncegenerate in interface NonceLimitException - When a limit imposed by the nonce generation strategy, if any, is exceeded.