PROVIDER-KDF(7ossl)
π PROVIDER-KDF π
okay so bestie, welcome to provider-kdf, a page from the OpenSSL manual set (that's the 7ossl bit β manual section 7, OpenSSL gang, iykyk π«Ά). this one's all about the KDF library <-> provider functions, and honestly? it's giving glue code, and glue code ate. β¨
this is part 1 of the page β keep scrolling, there's more coming π
π NAME π
provider-kdf β the KDF library <-> provider functions. literally that's it, that's the whole name section. no cap π
β¨ SYNOPSIS β¨
okay so here's the whole thing, copied exactly, don't touch a single character bestie π
#include <openssl/core_dispatch.h>
#include <openssl/core_names.h>
/*
* None of these are actual functions, but are displayed like this for
* the function signatures for functions that are offered as function
* pointers in OSSL_DISPATCH arrays.
*/
π«Ά real talk before you read the code: none of these are actual functions babe. they're displayed like this so you can see the function signatures for functions that get offered as function pointers in OSSL_DISPATCH arrays. so don't go tryna call them like normal functions, mwah π
π§ Context management
void *OSSL_FUNC_kdf_newctx(void *provctx);
void OSSL_FUNC_kdf_freectx(void *kctx);
void *OSSL_FUNC_kdf_dupctx(void *src);
OSSL_FUNC_kdf_newctxβ makes you a fresh new context, takesprovctx, hands back avoid *πOSSL_FUNC_kdf_freectxβ frees that context (kctx) so you're not leaking, we love a clean exit πOSSL_FUNC_kdf_dupctxβ duplicates a context fromsrc, returns the new one π¦
πΈ Encryption/decryption
int OSSL_FUNC_kdf_reset(void *kctx);
int OSSL_FUNC_kdf_derive(void *kctx, unsigned char *key, size_t keylen,
const OSSL_PARAM params[]);
OSSL_FUNC_kdf_resetβ resets the contextkctx, returns anintβOSSL_FUNC_kdf_deriveβ the main character fr π₯ takeskctx, yourkeybuffer as anunsigned char *, thekeylenas asize_t, and theparamsas aconst OSSL_PARAM params[]. returns anint.
π KDF parameter descriptors
const OSSL_PARAM *OSSL_FUNC_kdf_gettable_params(void *provctx);
const OSSL_PARAM *OSSL_FUNC_kdf_gettable_ctx_params(void *kcxt, void *provctx);
const OSSL_PARAM *OSSL_FUNC_kdf_settable_ctx_params(void *kcxt, void *provctx);
OSSL_FUNC_kdf_gettable_paramsβ tells you which params you can get, takesprovctx, returns aconst OSSL_PARAM *πOSSL_FUNC_kdf_gettable_ctx_paramsβ same vibe but for the context: takeskcxtandprovctx, returns aconst OSSL_PARAM *πΈOSSL_FUNC_kdf_settable_ctx_paramsβ the set list this time, takeskcxtandprovctx, returns aconst OSSL_PARAM *β¨
π¦ KDF parameters
int OSSL_FUNC_kdf_get_params(OSSL_PARAM params[]);
int OSSL_FUNC_kdf_get_ctx_params(void *kctx, OSSL_PARAM params[]);
int OSSL_FUNC_kdf_set_ctx_params(void *kctx, const OSSL_PARAM params[]);
OSSL_FUNC_kdf_get_paramsβ grabs params intoparams(OSSL_PARAM params[]), returns anintπOSSL_FUNC_kdf_get_ctx_paramsβ grabs context params fromkctxintoparams, returns anintπOSSL_FUNC_kdf_set_ctx_paramsβ sets context params fromparams(const OSSL_PARAM params[]) onkctx, returns anintπ₯
and that's the synopsis bestie, every signature intact, nothing dropped, periodt π β¨ more coming in the next part, don't go anywhere π«Ά
π DESCRIPTION π
okay so bestie, real talk β this page is primarily aimed at provider authors. If that's not you yet, go peek at provider(7) first, no cap, it'll set you up. β¨
So the KDF operation is literally the thing that lets providers implement KDF algorithms and serve them up to applications through the API functions EVP_KDF_CTX_reset(3) and EVP_KDF_derive(3). Slay. π
Now, all the "functions" we're yapping about here? They get passed as function pointers between libcrypto and the provider inside OSSL_DISPATCH(3) arrays, which ride along in OSSL_ALGORITHM(3) arrays that come back from the provider's provider_query_operation() function (see "Provider Functions" in provider-base(7)). Iconic chain of custody, honestly. π
Every single one of these "functions" has a matching function type definition named OSSL_FUNC_{name}_fn, plus a helper function that fishes the function pointer out of an OSSL_DISPATCH(3) element, named OSSL_FUNC_{name}. Like, for example, the "function" OSSL_FUNC_kdf_newctx() has these two cuties:
typedef void *(OSSL_FUNC_kdf_newctx_fn)(void *provctx);
static ossl_inline OSSL_FUNC_kdf_newctx_fn
OSSL_FUNC_kdf_newctx(const OSSL_DISPATCH *opf);
OSSL_DISPATCH(3) array entries get identified by numbers that are handed to you as macros in openssl-core_dispatch.h(7), and the whole roster goes like this:
OSSL_FUNC_kdf_newctxβOSSL_FUNC_KDF_NEWCTXOSSL_FUNC_kdf_freectxβOSSL_FUNC_KDF_FREECTXOSSL_FUNC_kdf_dupctxβOSSL_FUNC_KDF_DUPCTXOSSL_FUNC_kdf_resetβOSSL_FUNC_KDF_RESETOSSL_FUNC_kdf_deriveβOSSL_FUNC_KDF_DERIVEOSSL_FUNC_kdf_get_paramsβOSSL_FUNC_KDF_GET_PARAMSOSSL_FUNC_kdf_get_ctx_paramsβOSSL_FUNC_KDF_GET_CTX_PARAMSOSSL_FUNC_kdf_set_ctx_paramsβOSSL_FUNC_KDF_SET_CTX_PARAMSOSSL_FUNC_kdf_gettable_paramsβOSSL_FUNC_KDF_GETTABLE_PARAMSOSSL_FUNC_kdf_gettable_ctx_paramsβOSSL_FUNC_KDF_GETTABLE_CTX_PARAMSOSSL_FUNC_kdf_settable_ctx_paramsβOSSL_FUNC_KDF_SETTABLE_CTX_PARAMS
A KDF algorithm implementation does not have to implement all of these, bestie β it's not a collect-them-all situation. But to be a consistent set of functions, at least these four are mandatory: OSSL_FUNC_kdf_newctx(), OSSL_FUNC_kdf_freectx(), OSSL_FUNC_kdf_set_ctx_params(), and OSSL_FUNC_kdf_derive(). Everything else is optional. π¦
πΈ Context Management Functions πΈ
OSSL_FUNC_kdf_newctx()β should create and return a pointer to a provider-side structure that holds context information during a KDF operation. That pointer gets passed right back in a bunch of the other KDF operation function calls. The parameterprovctxis the provider context that got generated during provider initialisation (seeprovider(7)). π«ΆOSSL_FUNC_kdf_freectx()β gets handed a pointer to the provider-side KDF context in thekctxparameter. And listen: if it receivesNULLas thekctxvalue, it should not do anything other than return. Do not touch. Do not free. Just vibe and return. π Otherwise, this function should free any resources associated with that context.OSSL_FUNC_kdf_dupctx()β should duplicate the provider-side KDF context in thekctxparameter and return the duplicate copy. Copy-paste but make it cryptography. β¨
π Encryption/Decryption Functions π
OSSL_FUNC_kdf_reset()β initialises a KDF operation, given a provider-side KDF context in thekctxparameter.OSSL_FUNC_kdf_derive()β performs the actual KDF operation, after processing theparamsas perOSSL_FUNC_kdf_set_ctx_params(). Thekctxparameter contains a pointer to the provider-side context. The resulting key, of the desiredkeylen, should be written tokey. And here's the important bit, fr fr: if the algorithm does not support the requestedkeylen, the function must return error. No silently truncating, no pretending, no "close enough". π
π KDF Parameters π
See OSSL_PARAM(3) for further details on the parameters structure these functions use. It's giving essential reading. π
OSSL_FUNC_kdf_get_params()β gets details of parameter values associated with the provider algorithm and stores them inparams.OSSL_FUNC_kdf_set_ctx_params()β sets KDF parameters associated with the given provider-side KDF contextkctxtoparams. Any parameter settings are additional to any that were previously set (they stack, they don't reset β noted bestie π ). PassingNULLforparamsshould return true.OSSL_FUNC_kdf_get_ctx_params()β retrieves gettable parameter values associated with the given provider-side KDF contextkctxand stores them inparams. PassingNULLforparamsshould return true.OSSL_FUNC_kdf_gettable_params(),OSSL_FUNC_kdf_gettable_ctx_params(), andOSSL_FUNC_kdf_settable_ctx_params()β these three all return constantOSSL_PARAM(3)arrays as descriptors of the parameters thatOSSL_FUNC_kdf_get_params(),OSSL_FUNC_kdf_get_ctx_params(), andOSSL_FUNC_kdf_set_ctx_params()can handle, respectively. AndOSSL_FUNC_kdf_gettable_ctx_params()andOSSL_FUNC_kdf_settable_ctx_params()will return the parameters associated with the provider-side contextkctxin its current state if it is notNULL. Otherwise, they return the parameters associated with the provider-side algorithmprovctx. iykyk π
So the parameters currently recognised by built-in KDFs are as follows, bestie. Big list incoming, drink some water π. And heads up: not all parameters are relevant to, or are understood by, all KDFs β so don't come for me if your favourite KDF ignores one.
"size"(OSSL_KDF_PARAM_SIZE)<unsigned integer>β gets the output size from the associated KDF ctx. If the algorithm produces a variable amount of output,SIZE_MAXshould be returned. And if the input parameters required to calculate the fixed output size haven't been supplied yet, return0, which signals an error. β"key"(OSSL_KDF_PARAM_KEY)<octet string>β sets the key in the associated KDF ctx."secret"(OSSL_KDF_PARAM_SECRET)<octet string>β sets the secret in the associated KDF ctx."pass"(OSSL_KDF_PARAM_PASSWORD)<octet string>β sets the password in the associated KDF ctx."cipher"(OSSL_KDF_PARAM_CIPHER)<UTF8 string>,"digest"(OSSL_KDF_PARAM_DIGEST)<UTF8 string>,"mac"(OSSL_KDF_PARAM_MAC)<UTF8 string>β these three set the name of the underlying cipher, digest or MAC to be used. It must name a suitable algorithm for the KDF that's being used. No rogue picks. π ββοΈ"maclen"(OSSL_KDF_PARAM_MAC_SIZE)<octet string>β sets the length of the MAC in the associated KDF ctx."properties"(OSSL_KDF_PARAM_PROPERTIES)<UTF8 string>β sets the properties to be queried when trying to fetch the underlying algorithm. This must be given together with the algorithm naming parameter to be considered valid. They're a package deal. π«Ά"iter"(OSSL_KDF_PARAM_ITER)<unsigned integer>β sets the number of iterations in the associated KDF ctx."mode"(OSSL_KDF_PARAM_MODE)<UTF8 string>β sets the mode in the associated KDF ctx."pkcs5"(OSSL_KDF_PARAM_PKCS5)<integer>β enables or disables the SP800-132 compliance checks. A mode of0enables the compliance checks (yes, zero means on, we don't make the rules π). The checks performed are:- the iteration count is at least
1000. - the salt length is at least
128bits. - the derived key length is at least
112bits.
- the iteration count is at least
"ukm"(OSSL_KDF_PARAM_UKM)<octet string>β sets an optional random string that is provided by the sender, called"partyAInfo". In CMS this is the user keying material. π"cekalg"(OSSL_KDF_PARAM_CEK_ALG)<UTF8 string>β sets the CEK wrapping algorithm name in the associated KDF ctx."n"(OSSL_KDF_PARAM_SCRYPT_N)<unsigned integer>β sets the scrypt work factor parameterNin the associated KDF ctx."r"(OSSL_KDF_PARAM_SCRYPT_R)<unsigned integer>β sets the scrypt work factor parameterrin the associated KDF ctx."p"(OSSL_KDF_PARAM_SCRYPT_P)<unsigned integer>β sets the scrypt work factor parameterpin the associated KDF ctx."maxmem_bytes"(OSSL_KDF_PARAM_SCRYPT_MAXMEM)<unsigned integer>β sets the scrypt work factor parametermaxmemin the associated KDF ctx."prefix"(OSSL_KDF_PARAM_PREFIX)<octet string>β sets the prefix string using by the TLS 1.3 version of HKDF in the associated KDF ctx."label"(OSSL_KDF_PARAM_LABEL)<octet string>β sets the label string using by the TLS 1.3 version of HKDF in the associated KDF ctx."data"(OSSL_KDF_PARAM_DATA)<octet string>β sets the context string using by the TLS 1.3 version of HKDF in the associated KDF ctx."info"(OSSL_KDF_PARAM_INFO)<octet string>β sets the optional shared info in the associated KDF ctx."seed"(OSSL_KDF_PARAM_SEED)<octet string>β sets the IV in the associated KDF ctx."xcghash"(OSSL_KDF_PARAM_SSHKDF_XCGHASH)<octet string>β sets thexcghashin the associated KDF ctx."session_id"(OSSL_KDF_PARAM_SSHKDF_SESSION_ID)<octet string>β sets the session ID in the associated KDF ctx."type"(OSSL_KDF_PARAM_SSHKDF_TYPE)<UTF8 string>β sets the SSH KDF type parameter in the associated KDF ctx. There are six supported types, and they are:EVP_KDF_SSHKDF_TYPE_INITIAL_IV_CLI_TO_SRVβ the Initial IV from client to server. A single char of value65(ASCII char'A'). πEVP_KDF_SSHKDF_TYPE_INITIAL_IV_SRV_TO_CLIβ the Initial IV from server to client. A single char of value66(ASCII char'B'). πΈEVP_KDF_SSHKDF_TYPE_ENCRYPTION_KEY_CLI_TO_SRVβ the Encryption Key from client to server. A single char of value67(ASCII char'C'). π¦EVP_KDF_SSHKDF_TYPE_ENCRYPTION_KEY_SRV_TO_CLIβ the Encryption Key from server to client. A single char of value68(ASCII char'D'). β¨EVP_KDF_SSHKDF_TYPE_INTEGRITY_KEY_CLI_TO_SRVβ the Integrity Key from client to server. A single char of value69(ASCII char'E'). πEVP_KDF_SSHKDF_TYPE_INTEGRITY_KEY_SRV_TO_CLIβ the Integrity Key from client to server. A single char of value70(ASCII char'F'). π
π COPYRIGHT π
okay so before anyone comes for me β this whole page is copyrighted, bestie. fr fr.
- Copyright 2020-2022 The OpenSSL Project Authors. All Rights Reserved. π«Ά
Like, all the rights. Reserved. Every single one. π
β¨ the license tea β¨
This file is licensed under the Apache License 2.0 (yep, the one they just call "the License" β capital L, main character energy π).
β οΈ real talk: you may not use this file except in compliance with the License. that's not a vibe, that's a rule. π
You can grab a copy of the License from the file LICENSE in the source distribution, or online at:
wait, no, let me give you the actual line so you can copy-paste it exactly, no typos, no cap:
<https://www.openssl.org/source/license.html>
and the file path, exact, character for character:
LICENSE
in the source distribution. that's it, that's the whole license situation. π¦
πΈ the cute lil sign-off πΈ
This gorgeous page comes from OpenSSL version 3.5.9, dated 2026-09-29 β so you know it's fresh β¨. That's the source and the date right there at the bottom of the page, and honestly? iconic. periodt. ππ§ββοΈ
π¦ 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