OPENSSL-KDF(1ossl)
π openssl-kdf β like, the whole KDF situation, explained
Hey bestie π«Ά so you're reading the openssl-kdf page from the 1ossl manual β that's the one you want. Welcome. This is the command that does Key Derivation Function operations. Which is basically: take a secret (or a password), wave a cryptographic wand at it, and get a shiny brand-new key out the other side. Slay. β¨
β¨ 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 πΈ
Okay so, the key derivation functions obviously derive a key. Where from? Either from a secret or from a password. That's it, that's the whole vibe check π
π OPTIONS π
-helpβ prints a usage message. You know her. You love her. She's the "wait what were the flags again" flag π-keylen numβ the output size of the derived key. This field is required, no cap, you literally cannot skip it π-out filenameβ the file you're dumping output into. Don't give it one and it just goes to standard output, the default bestie β¨-binaryβ outputs the derived key in binary form. Skip this and you get hexadecimal text format instead. Choose your fighter π-cipher nameβ specifies the cipher the KDF should use. Not all KDFs need a cipher, and using this option on one of those is an error. Read the room, girl π-digest nameβ specifies the digest the KDF should use. Same deal: not all KDFs need a digest, and passing it anyway is an error. Wanna see what digests you actually have? Run"openssl list -digest-commands"π¦-mac nameβ specifies the MAC the KDF should use. And yes, same energy as the last two: not all KDFs require a MAC, and it's an error to use this option in those cases π-kdfopt nm:vβ passes options through to the KDF algorithm. There's a comprehensive list of parameters over in"PARAMETERS" in EVP_KDF(3). The common parameter names thatEVP_KDF_CTX_set_params()uses are:key:stringβ specifies the secret key as an alphanumeric string (so use this only if the key is printable characters only). The string length has to conform to whatever restrictions the KDF algorithm has. Most KDF algorithms want a key specified πhexkey:stringβ the alternative to thekey:option, where the secret key is given in hexadecimal form (two hex digits per byte).pass:stringβ specifies the password as an alphanumeric string (use it if the password is printable characters only). The password must be specified for PBKDF2 and scrypt π₯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, likeEVP_KDF-PBKDF2(7)π§hexsalt:stringβ alternative to thesalt:option where the salt is specified in hexadecimal form (two hex digits per byte).info:stringβ some KDF implementations, likeEVP_KDF-HKDF(7), take an'info'parameter for binding the derived key material to application- and context-specific information. This 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.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β all four of these cuties go see"Provider Options" in openssl(1),provider(7), andproperty(7). Go read those, iykyk πkdf_nameβ specifies the name of a supported KDF algorithm that's gonna get used. The supported algorithm names includeTLS1-PRF,HKDF,SSKDF,PBKDF2,SSHKDF,X942KDF-ASN1,X942KDF-CONCAT,X963KDFandSCRYPT. Pick one, bestie, she's waiting π
π¦ EXAMPLES π¦
Not me giving you a whole demo reel π here's every single one, verbatim, because they're all iconic:
TLS1-PRF to 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 to 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 to 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 to 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 to 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 to 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 to 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 to 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 might not have everything. It's giving "depends on your config" π
π 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)
Go read them all, bestie, they're literally the whole lore π«Ά
π HISTORY π
Added in OpenSSL 3.0. Ancient history at this point, but we respect the origin story π
π 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>.
Okay that's the whole page, bestie β go derive some keys, you absolute main character π₯
Source: OpenSSL 3.5.6, dated 2026-04-07. Manual page OPENSSL-KDF(1ossl) signing off πβ¨
π¦ where this page comes from
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms