dreamworkAPI
Ctrl K
GitHub
libraryDocs / crypto / hkdf

crypto.hkdf

librarysharedmenusource

HMAC-based Extract-and-Expand Key Derivation Function library.

Can be called directly as crypto.hkdf( options ), see hkdf.derive.

See RFC 5869 for the algorithm.

Functions

crypto.hkdf.deriveDerives a key using the hkdf algorithm, extract and expand in one step.
crypto.hkdf.expandHKDF-Expand step, expands the pseudorandom key into the output keying material (OKM).
crypto.hkdf.extractHKDF-Extract step, computes a pseudorandom key (PRK) from the input keying material.

#crypto.hkdf.derive

sharedmenunodiscardsource
function crypto.hkdf.derive(options: hkdf.Options): string

Derives a key using the hkdf algorithm, extract and expand in one step.

Parameters
NameTypeDescription
optionshkdf.Options
Returns
TypeNameDescription
stringhkdf_strThe derived key as a binary string of length bytes.

#crypto.hkdf.expand

sharedmenunodiscardsource
function crypto.hkdf.expand(hash: crypto.HashClass, prk: string, info?: string, length?: integer): string

HKDF-Expand step, expands the pseudorandom key into the output keying material (OKM).

Parameters
NameTypeDescription
hashcrypto.HashClassThe hash class to use, e.g. crypto.SHA256.
prkstringThe pseudorandom key, usually the result of hkdf.extract.
infooptionalstringThe optional context and application specific information, default is an empty string.
lengthoptionalintegerThe length of the output keying material in bytes, default is digest_size, must not exceed 255 * digest_size.
Returns
TypeNameDescription
stringokmThe output keying material as a binary string of length bytes.

#crypto.hkdf.extract

sharedmenunodiscardsource
function crypto.hkdf.extract(hash: crypto.HashClass, key: string, salt?: string): string

HKDF-Extract step, computes a pseudorandom key (PRK) from the input keying material.

Parameters
NameTypeDescription
hashcrypto.HashClassThe hash class to use, e.g. crypto.SHA256.
keystringThe input keying material (IKM).
saltoptionalstringThe optional salt, default is a string of digest_size zero bytes.
Returns
TypeNameDescription
stringprkThe pseudorandom key as a binary string of digest_size bytes.
Generated from the dreamwork meta branch.