{
    "content": [
        {
            "type": "text",
            "text": "# provider-kdf (man)\n\n## NAME\n\nprovider-kdf - The KDF library <-> provider functions\n\n## SYNOPSIS\n\n#include <openssl/coredispatch.h>\n#include <openssl/corenames.h>\n/*\n* None of these are actual functions, but are displayed like this for\n* the function signatures for functions that are offered as function\n* pointers in OSSLDISPATCH arrays.\n*/\n/* Context management */\nvoid *OSSLFUNCkdfnewctx(void *provctx);\nvoid OSSLFUNCkdffreectx(void *kctx);\nvoid *OSSLFUNCkdfdupctx(void *src);\n/* Encryption/decryption */\nint OSSLFUNCkdfreset(void *kctx);\nint OSSLFUNCkdfderive(void *kctx, unsigned char *key, sizet keylen,\nconst OSSLPARAM params[]);\n/* KDF parameter descriptors */\nconst OSSLPARAM *OSSLFUNCkdfgettableparams(void *provctx);\nconst OSSLPARAM *OSSLFUNCkdfgettablectxparams(void *kcxt, void *provctx);\nconst OSSLPARAM *OSSLFUNCkdfsettablectxparams(void *kcxt, void *provctx);\n/* KDF parameters */\nint OSSLFUNCkdfgetparams(OSSLPARAM params[]);\nint OSSLFUNCkdfgetctxparams(void *kctx, OSSLPARAM params[]);\nint OSSLFUNCkdfsetctxparams(void *kctx, const OSSLPARAM params[]);\n\n## DESCRIPTION\n\nThis documentation is primarily aimed at provider authors. See provider(7) for further\ninformation.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION** (3 subsections)\n- **RETURN VALUES**\n- **NOTES**\n- **SEE ALSO**\n- **HISTORY**\n- **COPYRIGHT**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "provider-kdf",
        "section": "",
        "mode": "man",
        "summary": "provider-kdf - The KDF library <-> provider functions",
        "synopsis": "#include <openssl/coredispatch.h>\n#include <openssl/corenames.h>\n/*\n* None of these are actual functions, but are displayed like this for\n* the function signatures for functions that are offered as function\n* pointers in OSSLDISPATCH arrays.\n*/\n/* Context management */\nvoid *OSSLFUNCkdfnewctx(void *provctx);\nvoid OSSLFUNCkdffreectx(void *kctx);\nvoid *OSSLFUNCkdfdupctx(void *src);\n/* Encryption/decryption */\nint OSSLFUNCkdfreset(void *kctx);\nint OSSLFUNCkdfderive(void *kctx, unsigned char *key, sizet keylen,\nconst OSSLPARAM params[]);\n/* KDF parameter descriptors */\nconst OSSLPARAM *OSSLFUNCkdfgettableparams(void *provctx);\nconst OSSLPARAM *OSSLFUNCkdfgettablectxparams(void *kcxt, void *provctx);\nconst OSSLPARAM *OSSLFUNCkdfsettablectxparams(void *kcxt, void *provctx);\n/* KDF parameters */\nint OSSLFUNCkdfgetparams(OSSLPARAM params[]);\nint OSSLFUNCkdfgetctxparams(void *kctx, OSSLPARAM params[]);\nint OSSLFUNCkdfsetctxparams(void *kctx, const OSSLPARAM params[]);",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [
            {
                "name": "provider",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/provider/7/json"
            },
            {
                "name": "lifecycle-kdf",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/lifecycle-kdf/7/json"
            },
            {
                "name": "EVPKDF",
                "section": "3",
                "url": "https://www.chedong.com/phpMan.php/man/EVPKDF/3/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 29,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 43,
                "subsections": [
                    {
                        "name": "Context Management Functions",
                        "lines": 12
                    },
                    {
                        "name": "Encryption/Decryption Functions",
                        "lines": 8
                    },
                    {
                        "name": "KDF Parameters",
                        "lines": 136
                    }
                ]
            },
            {
                "name": "RETURN VALUES",
                "lines": 10,
                "subsections": []
            },
            {
                "name": "NOTES",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "HISTORY",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "COPYRIGHT",
                "lines": 9,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "provider-kdf - The KDF library <-> provider functions\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "#include <openssl/coredispatch.h>\n#include <openssl/corenames.h>\n\n/*\n* None of these are actual functions, but are displayed like this for\n* the function signatures for functions that are offered as function\n* pointers in OSSLDISPATCH arrays.\n*/\n\n/* Context management */\nvoid *OSSLFUNCkdfnewctx(void *provctx);\nvoid OSSLFUNCkdffreectx(void *kctx);\nvoid *OSSLFUNCkdfdupctx(void *src);\n\n/* Encryption/decryption */\nint OSSLFUNCkdfreset(void *kctx);\nint OSSLFUNCkdfderive(void *kctx, unsigned char *key, sizet keylen,\nconst OSSLPARAM params[]);\n\n/* KDF parameter descriptors */\nconst OSSLPARAM *OSSLFUNCkdfgettableparams(void *provctx);\nconst OSSLPARAM *OSSLFUNCkdfgettablectxparams(void *kcxt, void *provctx);\nconst OSSLPARAM *OSSLFUNCkdfsettablectxparams(void *kcxt, void *provctx);\n\n/* KDF parameters */\nint OSSLFUNCkdfgetparams(OSSLPARAM params[]);\nint OSSLFUNCkdfgetctxparams(void *kctx, OSSLPARAM params[]);\nint OSSLFUNCkdfsetctxparams(void *kctx, const OSSLPARAM params[]);\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "This documentation is primarily aimed at provider authors. See provider(7) for further\ninformation.\n\nThe KDF operation enables providers to implement KDF algorithms and make them available to\napplications via the API functions EVPKDFCTXreset(3), and EVPKDFderive(3).\n\nAll \"functions\" mentioned here are passed as function pointers between libcrypto and the\nprovider in OSSLDISPATCH arrays via OSSLALGORITHM arrays that are returned by the\nprovider's providerqueryoperation() function (see \"Provider Functions\" in\nprovider-base(7)).\n\nAll these \"functions\" have a corresponding function type definition named\nOSSLFUNC{name}fn, and a helper function to retrieve the function pointer from an\nOSSLDISPATCH element named OSSLFUNC{name}.  For example, the \"function\"\nOSSLFUNCkdfnewctx() has these:\n\ntypedef void *(OSSLOSSLFUNCkdfnewctxfn)(void *provctx);\nstatic osslinline OSSLOSSLFUNCkdfnewctxfn\nOSSLFUNCkdfnewctx(const OSSLDISPATCH *opf);\n\nOSSLDISPATCH array entries are identified by numbers that are provided as macros in\nopenssl-coredispatch.h(7), as follows:\n\nOSSLFUNCkdfnewctx               OSSLFUNCKDFNEWCTX\nOSSLFUNCkdffreectx              OSSLFUNCKDFFREECTX\nOSSLFUNCkdfdupctx               OSSLFUNCKDFDUPCTX\n\nOSSLFUNCkdfreset                OSSLFUNCKDFRESET\nOSSLFUNCkdfderive               OSSLFUNCKDFDERIVE\n\nOSSLFUNCkdfgetparams           OSSLFUNCKDFGETPARAMS\nOSSLFUNCkdfgetctxparams       OSSLFUNCKDFGETCTXPARAMS\nOSSLFUNCkdfsetctxparams       OSSLFUNCKDFSETCTXPARAMS\n\nOSSLFUNCkdfgettableparams      OSSLFUNCKDFGETTABLEPARAMS\nOSSLFUNCkdfgettablectxparams  OSSLFUNCKDFGETTABLECTXPARAMS\nOSSLFUNCkdfsettablectxparams  OSSLFUNCKDFSETTABLECTXPARAMS\n\nA KDF algorithm implementation may not implement all of these functions.  In order to be a\nconsistent set of functions, at least the following functions must be implemented:\nOSSLFUNCkdfnewctx(), OSSLFUNCkdffreectx(), OSSLFUNCkdfsetctxparams(),\nOSSLFUNCkdfderive().  All other functions are optional.\n",
                "subsections": [
                    {
                        "name": "Context Management Functions",
                        "content": "OSSLFUNCkdfnewctx() should create and return a pointer to a provider side structure for\nholding context information during a KDF operation.  A pointer to this context will be passed\nback in a number of the other KDF operation function calls.  The parameter provctx is the\nprovider context generated during provider initialisation (see provider(7)).\n\nOSSLFUNCkdffreectx() is passed a pointer to the provider side KDF context in the kctx\nparameter.  If it receives NULL as kctx value, it should not do anything other than return.\nThis function should free any resources associated with that context.\n\nOSSLFUNCkdfdupctx() should duplicate the provider side KDF context in the kctx parameter\nand return the duplicate copy.\n"
                    },
                    {
                        "name": "Encryption/Decryption Functions",
                        "content": "OSSLFUNCkdfreset() initialises a KDF operation given a provider side KDF context in the\nkctx parameter.\n\nOSSLFUNCkdfderive() performs the KDF operation after processing the params as per\nOSSLFUNCkdfsetctxparams().  The kctx parameter contains a pointer to the provider side\ncontext.  The resulting key of the desired keylen should be written to key.  If the algorithm\ndoes not support the requested keylen the function must return error.\n"
                    },
                    {
                        "name": "KDF Parameters",
                        "content": "See OSSLPARAM(3) for further details on the parameters structure used by these functions.\n\nOSSLFUNCkdfgetparams() gets details of parameter values associated with the provider\nalgorithm and stores them in params.\n\nOSSLFUNCkdfsetctxparams() sets KDF parameters associated with the given provider side\nKDF context kctx to params.  Any parameter settings are additional to any that were\npreviously set.  Passing NULL for params should return true.\n\nOSSLFUNCkdfgetctxparams() retrieves gettable parameter values associated with the given\nprovider side KDF context kctx and stores them in params.  Passing NULL for params should\nreturn true.\n\nOSSLFUNCkdfgettableparams(), OSSLFUNCkdfgettablectxparams(), and\nOSSLFUNCkdfsettablectxparams() all return constant OSSLPARAM arrays as descriptors of\nthe parameters that OSSLFUNCkdfgetparams(), OSSLFUNCkdfgetctxparams(), and\nOSSLFUNCkdfsetctxparams() can handle, respectively.  OSSLFUNCkdfgettablectxparams()\nand OSSLFUNCkdfsettablectxparams() will return the parameters associated with the\nprovider side context kctx in its current state if it is not NULL.  Otherwise, they return\nthe parameters associated with the provider side algorithm provctx.\n\nParameters currently recognised by built-in KDFs are as follows. Not all parameters are\nrelevant to, or are understood by all KDFs:\n\n\"size\" (OSSLKDFPARAMSIZE) <unsigned integer>\nGets the output size from the associated KDF ctx.  If the algorithm produces a variable\namount of output, SIZEMAX should be returned.  If the input parameters required to\ncalculate the fixed output size have not yet been supplied, 0 should be returned\nindicating an error.\n\n\"key\" (OSSLKDFPARAMKEY) <octet string>\nSets the key in the associated KDF ctx.\n\n\"secret\" (OSSLKDFPARAMSECRET) <octet string>\nSets the secret in the associated KDF ctx.\n\n\"pass\" (OSSLKDFPARAMPASSWORD) <octet string>\nSets the password in the associated KDF ctx.\n\n\"cipher\" (OSSLKDFPARAMCIPHER) <UTF8 string>\n\"digest\" (OSSLKDFPARAMDIGEST) <UTF8 string>\n\"mac\" (OSSLKDFPARAMMAC) <UTF8 string>\nSets the name of the underlying cipher, digest or MAC to be used.  It must name a\nsuitable algorithm for the KDF that's being used.\n\n\"maclen\" (OSSLKDFPARAMMACSIZE) <octet string>\nSets the length of the MAC in the associated KDF ctx.\n\n\"properties\" (OSSLKDFPARAMPROPERTIES) <UTF8 string>\nSets the properties to be queried when trying to fetch the underlying algorithm.  This\nmust be given together with the algorithm naming parameter to be considered valid.\n\n\"iter\" (OSSLKDFPARAMITER) <unsigned integer>\nSets the number of iterations in the associated KDF ctx.\n\n\"mode\" (OSSLKDFPARAMMODE) <UTF8 string>\nSets the mode in the associated KDF ctx.\n\n\"pkcs5\" (OSSLKDFPARAMPKCS5) <integer>\nEnables or diables the SP800-132 compliance checks.  A mode of 0 enables the compliance\nchecks.\n\nThe checks performed are:\n\n- the iteration count is at least 1000.\n- the salt length is at least 128 bits.\n- the derived key length is at least 112 bits.\n\"ukm\" (OSSLKDFPARAMUKM) <octet string>\nSets an optional random string that is provided by the sender called \"partyAInfo\".  In\nCMS this is the user keying material.\n\n\"cekalg\" (OSSLKDFPARAMCEKALG) <UTF8 string>\nSets the CEK wrapping algorithm name in the associated KDF ctx.\n\n\"n\" (OSSLKDFPARAMSCRYPTN) <unsigned integer>\nSets the scrypt work factor parameter N in the associated KDF ctx.\n\n\"r\" (OSSLKDFPARAMSCRYPTR) <unsigned integer>\nSets the scrypt work factor parameter r in the associated KDF ctx.\n\n\"p\" (OSSLKDFPARAMSCRYPTP) <unsigned integer>\nSets the scrypt work factor parameter p in the associated KDF ctx.\n\n\"maxmembytes\" (OSSLKDFPARAMSCRYPTMAXMEM) <unsigned integer>\nSets the scrypt work factor parameter maxmem in the associated KDF ctx.\n\n\"prefix\" (OSSLKDFPARAMPREFIX) <octet string>\nSets the prefix string using by the TLS 1.3 version of HKDF in the associated KDF ctx.\n\n\"label\" (OSSLKDFPARAMLABEL) <octet string>\nSets the label string using by the TLS 1.3 version of HKDF in the associated KDF ctx.\n\n\"data\" (OSSLKDFPARAMDATA) <octet string>\nSets the context string using by the TLS 1.3 version of HKDF in the associated KDF ctx.\n\n\"info\" (OSSLKDFPARAMINFO) <octet string>\nSets the optional shared info in the associated KDF ctx.\n\n\"seed\" (OSSLKDFPARAMSEED) <octet string>\nSets the IV in the associated KDF ctx.\n\n\"xcghash\" (OSSLKDFPARAMSSHKDFXCGHASH) <octet string>\nSets the xcghash in the associated KDF ctx.\n\n\"sessionid\" (OSSLKDFPARAMSSHKDFSESSIONID) <octet string>\nSets the session ID in the associated KDF ctx.\n\n\"type\" (OSSLKDFPARAMSSHKDFTYPE) <UTF8 string>\nSets the SSH KDF type parameter in the associated KDF ctx.  There are six supported\ntypes:\n\nEVPKDFSSHKDFTYPEINITIALIVCLITOSRV\nThe Initial IV from client to server.  A single char of value 65 (ASCII char 'A').\n\nEVPKDFSSHKDFTYPEINITIALIVSRVTOCLI\nThe Initial IV from server to client A single char of value 66 (ASCII char 'B').\n\nEVPKDFSSHKDFTYPEENCRYPTIONKEYCLITOSRV\nThe Encryption Key from client to server A single char of value 67 (ASCII char 'C').\n\nEVPKDFSSHKDFTYPEENCRYPTIONKEYSRVTOCLI\nThe Encryption Key from server to client A single char of value 68 (ASCII char 'D').\n\nEVPKDFSSHKDFTYPEINTEGRITYKEYCLITOSRV\nThe Integrity Key from client to server A single char of value 69 (ASCII char 'E').\n\nEVPKDFSSHKDFTYPEINTEGRITYKEYSRVTOCLI\nThe Integrity Key from client to server A single char of value 70 (ASCII char 'F').\n\n\"constant\" (OSSLKDFPARAMCONSTANT) <octet string>\nSets the constant value in the associated KDF ctx.\n\n\"id\" (OSSLKDFPARAMPKCS12ID) <integer>\nSets the intended usage of the output bits in the associated KDF ctx.  It is defined as\nper RFC 7292 section B.3.\n"
                    }
                ]
            },
            "RETURN VALUES": {
                "content": "OSSLFUNCkdfnewctx() and OSSLFUNCkdfdupctx() should return the newly created provider\nside KDF context, or NULL on failure.\n\nOSSLFUNCkdfderive(), OSSLFUNCkdfgetparams(), OSSLFUNCkdfgetctxparams() and\nOSSLFUNCkdfsetctxparams() should return 1 for success or 0 on error.\n\nOSSLFUNCkdfgettableparams(), OSSLFUNCkdfgettablectxparams() and\nOSSLFUNCkdfsettablectxparams() should return a constant OSSLPARAM array, or NULL if\nnone is offered.\n",
                "subsections": []
            },
            "NOTES": {
                "content": "The KDF life-cycle is described in lifecycle-kdf(7).  Providers should ensure that the\nvarious transitions listed there are supported.  At some point the EVP layer will begin\nenforcing the listed transitions.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "provider(7), lifecycle-kdf(7), EVPKDF(3).\n",
                "subsections": []
            },
            "HISTORY": {
                "content": "The provider KDF interface was introduced in OpenSSL 3.0.\n",
                "subsections": []
            },
            "COPYRIGHT": {
                "content": "Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved.\n\nLicensed under the Apache License 2.0 (the \"License\").  You may not use this file except in\ncompliance with the License.  You can obtain a copy in the file LICENSE in the source\ndistribution or at <https://www.openssl.org/source/license.html>.\n\n\n\n3.0.2                                        2026-06-02                           PROVIDER-KDF(7SSL)",
                "subsections": []
            }
        }
    }
}