OPENSSL-KDF(1ossl)
π openssl-kdf β perform Key Derivation Function operations π
Okay bestie, listen. This is the openssl-kdf page from the OpenSSL manual (section 1ossl), and it's genuinely so iconic β it's literally the tool that takes your secret-or-password and spins it into a derived key. Let's get into it β¨
β¨ SYNOPSIS β¨
openssl kdf [-help] [-cipher] [-digest] [-mac] [-kdfopt nm:v] [-keylen
num] [-out filename] [-binary] [-provider name] [-provider-path path]
[-provparam [name:]key=value] [-propquery propq] kdf_name
π¦ DESCRIPTION π¦
So like, key derivation functions generate a derived key from either a secret or a password. That's the whole vibe. Secret in, derived key out. π₯
π OPTIONS π
-helpβ prints a usage message. The classic "wait what do I do" button π«Ά-keylen numβ the output size of the derived key. This field is required, no cap. You literally cannot skip it. π-out filenameβ the filename to output to. Or, if you don't say anything, it goes to standard output. Default queen behavior π-binaryβ outputs the derived key in binary form. If you don't specify this, it uses hexadecimal text format instead.-cipher nameβ specifies the cipher to be used by the KDF. But heads up: not all KDFs require a cipher, and it is an error to use this option in those cases. Read the room, bestie π-digest nameβ specifies the digest to be used by the KDF. Same deal: not all KDFs require a digest, and it is an error to use this option in such cases. Wanna see the list of supported digests? Runopenssl list -digest-commands. Slay.-mac nameβ specifies the MAC to be used by the KDF. And yes, again: not all KDFs require a MAC, and it is an error to use this option in such cases. Pattern recognition is a skill π-kdfopt nm:vβ passes options to the KDF algorithm. A comprehensive list of parameters lives in"PARAMETERS" in EVP_KDF(3). The common parameter names used byEVP_KDF_CTX_set_params()are:key:stringβ specifies the secret key as an alphanumeric string (use this if the key contains printable characters only). The string length must conform to any restrictions of the KDF algorithm. A key must be specified for most KDF algorithms. Most. Not all. iykyk.hexkey:stringβ alternative to thekey:option, where the secret key is specified in hexadecimal form (two hex digits per byte). Hex girlies rise πΈpass:stringβ specifies the password as an alphanumeric string (use if the password contains printable characters only). The password must be specified for PBKDF2 and scrypt. Non-negotiable, fr fr.hexpass:stringβ alternative to thepass:option where the password is specified in hexadecimal form (two hex digits per byte).salt:stringβ specifies a non-secret unique cryptographic salt as an alphanumeric string (use if it contains printable characters only). The length must conform to any restrictions of the KDF algorithm. A salt parameter is required for several KDF algorithms, such asEVP_KDF-PBKDF2(7). Salt is not optional, it's a lifestyle π§hexsalt:stringβ alternative to thesalt:option where the salt is specified in hexadecimal form (two hex digits per byte).info:stringβ some KDF implementations, such asEVP_KDF-HKDF(7), take an 'info' parameter for binding the derived key material to application- and context-specific information. Specifies the info, fixed info, other info or shared info argument as an alphanumeric string (use if it contains printable characters only). The length must conform to any restrictions of the KDF algorithm. So many info names, one parameter πhexinfo:stringβ alternative to theinfo:option where the info is specified in hexadecimal form (two hex digits per byte).digest:stringβ this option is identical to the-digestoption.cipher:stringβ this option is identical to the-cipheroption.mac:stringβ this option is identical to the-macoption.
-provider name,-provider-path path,-provparam [name:]key=value,-propquery propqβ see"Provider Options" in openssl(1),provider(7), andproperty(7). Provider lore, go read it πkdf_nameβ specifies the name of a supported KDF algorithm which will be used. The supported algorithm names includeTLS1-PRF,HKDF,SSKDF,PBKDF2,SSHKDF,X942KDF-ASN1,X942KDF-CONCAT,X963KDFandSCRYPT. Pick your fighter β
π EXAMPLES π
TLS1-PRF β create a hex-encoded derived key from a secret key and seed:
openssl kdf -keylen 16 -kdfopt digest:SHA2-256 -kdfopt key:secret \
-kdfopt seed:seed TLS1-PRF
HKDF β create a hex-encoded derived key from a secret key, salt and info:
openssl kdf -keylen 10 -kdfopt digest:SHA2-256 -kdfopt key:secret \
-kdfopt salt:salt -kdfopt info:label HKDF
SSKDF with KMAC β create a hex-encoded derived key from a secret key, salt and info:
openssl kdf -keylen 64 -kdfopt mac:KMAC-128 -kdfopt maclen:20 \
-kdfopt hexkey:b74a149a161545 -kdfopt hexinfo:348a37a2 \
-kdfopt hexsalt:3638271ccd68a2 SSKDF
SSKDF with HMAC β create a hex-encoded derived key from a secret key, salt and info:
openssl kdf -keylen 16 -kdfopt mac:HMAC -kdfopt digest:SHA2-256 \
-kdfopt hexkey:b74a149a -kdfopt hexinfo:348a37a2 \
-kdfopt hexsalt:3638271c SSKDF
SSKDF with Hash β create a hex-encoded derived key from a secret key, salt and info:
openssl kdf -keylen 14 -kdfopt digest:SHA2-256 \
-kdfopt hexkey:6dbdc23f045488 \
-kdfopt hexinfo:a1b2c3d4 SSKDF
SSHKDF β create a hex-encoded derived key from a secret key, hash and session_id:
openssl kdf -keylen 16 -kdfopt digest:SHA2-256 \
-kdfopt hexkey:0102030405 \
-kdfopt hexxcghash:06090A \
-kdfopt hexsession_id:01020304 \
-kdfopt type:A SSHKDF
PBKDF2 β create a hex-encoded derived key from a password and salt:
openssl kdf -keylen 32 -kdfopt digest:SHA256 -kdfopt pass:password \
-kdfopt salt:salt -kdfopt iter:2 PBKDF2
scrypt β create a hex-encoded derived key from a password and salt:
openssl kdf -keylen 64 -kdfopt pass:password -kdfopt salt:NaCl \
-kdfopt n:1024 -kdfopt r:8 -kdfopt p:16 \
-kdfopt maxmem_bytes:10485760 SCRYPT
π NOTES π
The KDF mechanisms that are available will depend on the options used when building OpenSSL. So like, your build determines your destiny. Build flags matter, bestie π οΈ
π¦ SEE ALSO π¦
openssl(1), openssl-pkeyutl(1), EVP_KDF(3), EVP_KDF-SCRYPT(7), EVP_KDF-TLS1_PRF(7), EVP_KDF-PBKDF2(7), EVP_KDF-HKDF(7), EVP_KDF-SS(7), EVP_KDF-SSHKDF(7), EVP_KDF-X942-ASN1(7), EVP_KDF-X942-CONCAT(7), EVP_KDF-X963(7)
β HISTORY β
Added in OpenSSL 3.0. A modern icon, honestly.
π COPYRIGHT π
Copyright 2019-2023 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
Legal said I have to keep this: you may not use this file except in compliance with the License. Do with that what you will π
Okay that's the whole page, bestie, we ate and left zero crumbs π This glorious thing is from OpenSSL 3.5.9, dated 2026-09-29 β go forth and derive some keys, mwah πβ¨π
π¦ where this page comes from
- alpine 3.23: openssl-doc 3.5.9-r0 Β· Apache-2.0
- alpine 3.24: openssl-doc 3.5.9-r0 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms