public class CounterNonce extends Object implements Nonce
long
, thus the length of
the nonce is determined by the length of the fixed part: length = 8 +
fixed.length
.
NOTE: users of this class are responsible for maintaining the invocation count in order to support enforcement of 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 enforce this constraint by considering the nonce
length, which determines whether the constraint applies, and the invocation
count. The invocation count is incremented upon every invocation of generate()
method. The current invocation count is accessible via getInvocations()
.
Instances of this class are thread safe.
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_LENGTH
Default nonce getLength is 12 bytes.
|
static long |
MAX_INVOCATIONS
Maximum invocations is 232.
|
Constructor and Description |
---|
CounterNonce(byte[] fixed,
long invocations)
Creates a new instance.
|
CounterNonce(int fixed,
long invocations)
Creates a new instance.
|
CounterNonce(long fixed,
long invocations)
Creates a new instance.
|
CounterNonce(String fixed,
long invocations)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
generate()
Generates a nonce value.
|
long |
getInvocations() |
int |
getLength() |
public static final int DEFAULT_LENGTH
public static final long MAX_INVOCATIONS
public CounterNonce(String fixed, long invocations)
fixed
- User-defined fixed field value.invocations
- Initial invocation count. The invocations field is
incremented _before_ use in generate()
.public CounterNonce(int fixed, long invocations)
fixed
- User-defined fixed field value.invocations
- Initial invocation count. The invocations field is
incremented _before_ use in generate()
.public CounterNonce(long fixed, long invocations)
fixed
- User-defined fixed field value.invocations
- Initial invocation count. The invocations field is
incremented _before_ use in generate()
.public CounterNonce(byte[] fixed, long invocations)
fixed
- User-defined fixed field value.invocations
- Initial invocation count. The invocations field is
incremented _before_ use in generate()
.public byte[] generate() throws LimitException
generate
in interface Nonce
LimitException
- When a limit imposed by the nonce generation
strategy, if any, is exceeded.public int getLength()
public long getInvocations()
Copyright © 2016 JBoss by Red Hat. All rights reserved.