public class OneStepKDFBytesGenerator extends java.lang.Object implements DerivationFunction
For the hash and HMAC options the output is the concatenation of H(counter || Z || FixedInfo) for a
32-bit big-endian counter starting at 1, truncated to the requested length; with the hash option this is
the Concatenation KDF of SP 800-56A (ConcatenationKDFGenerator).
With the KMAC option the standard sets the KMAC output length to the requested length so that a single
call, with the counter at 1, produces the whole output. When no salt is given the default salt of the
standard is used: for HMAC an all-zero string the size of the hash block (which HMAC's key padding makes
equivalent to an empty key), for KMAC128 164 zero bytes and for KMAC256 132 zero bytes.
Initialise with a KDFParameters carrying the shared secret Z and the FixedInfo.
| Constructor and Description |
|---|
OneStepKDFBytesGenerator(Digest digest)
Option 1: a hash function as the auxiliary function.
|
OneStepKDFBytesGenerator(Mac mac,
byte[] salt)
Option 2 or 3: HMAC or KMAC as the auxiliary function, keyed with the salt.
|
| Modifier and Type | Method and Description |
|---|---|
int |
generateBytes(byte[] out,
int outOff,
int len) |
Digest |
getDigest() |
void |
init(DerivationParameters param) |
public OneStepKDFBytesGenerator(Digest digest)
digest - the hash function.public OneStepKDFBytesGenerator(Mac mac, byte[] salt)
mac - the HMAC or KMAC to use.salt - the salt, or null for the standard's default salt.public void init(DerivationParameters param)
init in interface DerivationFunctionpublic Digest getDigest()
public int generateBytes(byte[] out,
int outOff,
int len)
throws DataLengthException,
java.lang.IllegalArgumentException
generateBytes in interface DerivationFunctionDataLengthExceptionjava.lang.IllegalArgumentException