(PHP 7 >= 7.2.0, PHP 8)
sodium_crypto_kdf_derive_from_key — Derive a subkey
$subkey_length,$subkey_id,$context,$keyDerive a subkey from a root key and additional context.
Similar to hash_hkdf().
subkey_lengthLength of the key to return (in bytes)
subkey_idReturn the Nth subkey from a given root key. Useful for seeking.
contextApplication-specific context.
keyThe root key from which the subkey is derived.
A string of pseudorandom (raw binary) bytes.
Throws a SodiumException if
subkey_length is less than
SODIUM_CRYPTO_KDF_BYTES_MIN or greater than
SODIUM_CRYPTO_KDF_BYTES_MAX.
Throws a SodiumException if
subkey_id is negative.
Throws a SodiumException if
context is not
SODIUM_CRYPTO_KDF_CONTEXTBYTES bytes long.
Throws a SodiumException if
key is not
SODIUM_CRYPTO_KDF_KEYBYTES bytes long.