public class HKDFParameterSpec extends HKDFExpandOnlyParameterSpec
HKDF
key derivation function.
This HKDFParameterSpec
maybe used to initialize a HKDF KeyGenerator
with the input keying material (IKM), salt value, context and application specific
information string, and the length of the output keying material to be derived (salt
and info string are optional; if not provided they are set to a strings of
hashLen
zeros and a zero-length string, respectively), e.g.:
// the salt: byte[] salt = ...; // the input keying material: byte[] ikm = ...; // the info string: byte[] info = ...; // the length of the output key: byte[] l = ...; // create a HKDF KeyGenerator for the desired hash function: KeyGenerator hkdf = KeyGenerator.getInstance("HKDFwithSHA256"); // initialize the HKDF: HKDFParameterSpec hkdfParamSpec = new HKDFParameterSpec(salt, ikm, info, L); hkdf.init(hkdfParamSpec, null); // generate the key: SecretKey key = hkdf.generateKey();
Constructor and Description |
---|
HKDFParameterSpec(byte[] salt,
byte[] ikm,
byte[] info,
int l)
Creates a HKDFParameterSpec for the given the salt value, the input keying material,
optional context and application specific information and length of
the output keying material.
|
HKDFParameterSpec(byte[] salt,
javax.crypto.SecretKey ikm,
byte[] info,
int l)
Creates a HKDFParameterSpec for the given the salt value, the input keying material,
optional context and application specific information and length of
the output keying material.
|
public HKDFParameterSpec(byte[] salt, byte[] ikm, byte[] info, int l)
salt
- the salt value (if null
it is set to a string of HashLen
zeros)ikm
- the input keying material (as byte array)info
- the optional context and application specific information (may be
null
)l
- the length of output keying material in octets (<= 255*hashLen)public HKDFParameterSpec(byte[] salt, javax.crypto.SecretKey ikm, byte[] info, int l)
salt
- the salt value (if null
it is set to a string of HashLen
zeros)ikm
- the input keying materialinfo
- the optional context and application specific information (may be
null
)l
- the length of output keying material in octets (<= 255*hashLen)