{
    "mode": "man",
    "parameter": "EVP_KDF-KB",
    "section": "7SSL",
    "url": "https://www.chedong.com/phpMan.php/man/EVP_KDF-KB/7SSL/json",
    "generated": "2026-10-06T04:07:55Z",
    "sections": {
        "NAME": {
            "content": "EVPKDF-KB - The Key-Based EVPKDF implementation\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The EVPKDF-KB algorithm implements the Key-Based key derivation function (KBKDF).  KBKDF\nderives a key from repeated application of a keyed MAC to an input secret (and other optional\nvalues).\n",
            "subsections": [
                {
                    "name": "Identity",
                    "content": "\"KBKDF\" is the name for this implementation; it can be used with the EVPKDFfetch()\nfunction.\n"
                },
                {
                    "name": "Supported parameters",
                    "content": "The supported parameters are:\n\n\"mode\" (OSSLKDFPARAMMODE) <UTF8 string>\nThe  mode  parameter  determines which flavor of KBKDF to use - currently the choices are\n\"counter\" and \"feedback\". \"counter\" is the default, and will be used if unspecified.\n\n\"mac\" (OSSLKDFPARAMMAC) <UTF8 string>\nThe value is either CMAC or HMAC.\n\n\"digest\" (OSSLKDFPARAMDIGEST) <UTF8 string>\n\"cipher\" (OSSLKDFPARAMCIPHER) <UTF8 string>\n\"properties\" (OSSLKDFPARAMPROPERTIES) <UTF8 string>\n\"key\" (OSSLKDFPARAMKEY) <octet string>\n\"salt\" (OSSLKDFPARAMSALT) <octet string>\n\"info (OSSLKDFPARAMINFO) <octet string>\n\"seed\" (OSSLKDFPARAMSEED) <octet string>\nThe seed parameter is unused in counter mode.\n\n\"use-l\" (OSSLKDFPARAMKBKDFUSEL) <integer>\nSet to 0 to disable use of the optional  Fixed  Input  data  'L'  (see  SP800-108).   The\ndefault value of 1 will be used if unspecified.\n\n\"use-separator\" (OSSLKDFPARAMKBKDFUSESEPARATOR) <integer>\nSet to 0 to disable use of the optional Fixed Input data 'zero separator' (see SP800-108)\nthat  is  placed  between  the Label and Context.  The default value of 1 will be used if\nunspecified.\n\nDepending on whether mac is CMAC or HMAC, either digest or cipher is required  (respectively)\nand the other is unused.\n\nThe  parameters  key,  salt,  info,  and  seed  correspond  to  KI,  Label,  Context,  and IV\n(respectively) in SP800-108.  As in that document, salt, info, and seed are optional and  may\nbe omitted.\n\n\"mac\", \"digest\", cipher\" and \"properties\" are described in \"PARAMETERS\" in EVPKDF(3).\n"
                }
            ]
        },
        "NOTES": {
            "content": "A context for KBKDF can be obtained by calling:\n\nEVPKDF *kdf = EVPKDFfetch(NULL, \"KBKDF\", NULL);\nEVPKDFCTX *kctx = EVPKDFCTXnew(kdf);\n\nThe   output   length   of   an  KBKDF  is  specified  via  the  \"keylen\"  parameter  to  the\nEVPKDFderive(3) function.\n\nNote that currently OpenSSL only implements counter and feedback modes.  Other  variants  may\nbe supported in the future.\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "This example derives 10 bytes using COUNTER-HMAC-SHA256, with KI \"secret\", Label \"label\", and\nContext \"context\".\n\nEVPKDF *kdf;\nEVPKDFCTX *kctx;\nunsigned char out[10];\nOSSLPARAM params[6], *p = params;\n\nkdf = EVPKDFfetch(NULL, \"KBKDF\", NULL);\nkctx = EVPKDFCTXnew(kdf);\nEVPKDFfree(kdf);\n\n*p++ = OSSLPARAMconstructutf8string(OSSLKDFPARAMDIGEST,\n\"SHA2-256\", 0);\n*p++ = OSSLPARAMconstructutf8string(OSSLKDFPARAMMAC,\n\"HMAC\", 0);\n*p++ = OSSLPARAMconstructoctetstring(OSSLKDFPARAMKEY,\n\"secret\", strlen(\"secret\"));\n*p++ = OSSLPARAMconstructoctetstring(OSSLKDFPARAMSALT,\n\"label\", strlen(\"label\"));\n*p++ = OSSLPARAMconstructoctetstring(OSSLKDFPARAMINFO,\n\"context\", strlen(\"context\"));\n*p = OSSLPARAMconstructend();\nif (EVPKDFderive(kctx, out, sizeof(out), params) <= 0)\nerror(\"EVPKDFderive\");\n\nEVPKDFCTXfree(kctx);\n\nThis  example  derives  10 bytes using FEEDBACK-CMAC-AES256, with KI \"secret\", Label \"label\",\nand IV \"sixteen bytes iv\".\n\nEVPKDF *kdf;\nEVPKDFCTX *kctx;\nunsigned char out[10];\nOSSLPARAM params[8], *p = params;\nunsigned char *iv = \"sixteen bytes iv\";\n\nkdf = EVPKDFfetch(NULL, \"KBKDF\", NULL);\nkctx = EVPKDFCTXnew(kdf);\nEVPKDFfree(kdf);\n\n*p++ = OSSLPARAMconstructutf8string(OSSLKDFPARAMCIPHER, \"AES256\", 0);\n*p++ = OSSLPARAMconstructutf8string(OSSLKDFPARAMMAC, \"CMAC\", 0);\n*p++ = OSSLPARAMconstructutf8string(OSSLKDFPARAMMODE, \"FEEDBACK\", 0);\n*p++ = OSSLPARAMconstructoctetstring(OSSLKDFPARAMKEY,\n\"secret\", strlen(\"secret\"));\n*p++ = OSSLPARAMconstructoctetstring(OSSLKDFPARAMSALT,\n\"label\", strlen(\"label\"));\n*p++ = OSSLPARAMconstructoctetstring(OSSLKDFPARAMINFO,\n\"context\", strlen(\"context\"));\n*p++ = OSSLPARAMconstructoctetstring(OSSLKDFPARAMSEED,\niv, strlen(iv));\n*p = OSSLPARAMconstructend();\nif (EVPKDFderive(kctx, out, sizeof(out), params) <= 0)\nerror(\"EVPKDFderive\");\n\nEVPKDFCTXfree(kctx);\n",
            "subsections": []
        },
        "CONFORMING TO": {
            "content": "NIST SP800-108, IETF RFC 6803, IETF RFC 8009.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "EVPKDF(3), EVPKDFCTXfree(3), EVPKDFCTXgetkdfsize(3), EVPKDFderive(3), \"PARAMETERS\"\nin EVPKDF(3)\n",
            "subsections": []
        },
        "HISTORY": {
            "content": "This functionality was added in OpenSSL 3.0.\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright 2019-2021 The OpenSSL Project Authors. All Rights  Reserved.   Copyright  2019  Red\nHat, Inc.\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\n3.0.13                                       2026-07-29                             EVPKDF-KB(7SSL)",
            "subsections": []
        }
    },
    "summary": "EVPKDF-KB - The Key-Based EVPKDF implementation",
    "flags": [],
    "examples": [
        "This example derives 10 bytes using COUNTER-HMAC-SHA256, with KI \"secret\", Label \"label\", and",
        "Context \"context\".",
        "EVPKDF *kdf;",
        "EVPKDFCTX *kctx;",
        "unsigned char out[10];",
        "OSSLPARAM params[6], *p = params;",
        "kdf = EVPKDFfetch(NULL, \"KBKDF\", NULL);",
        "kctx = EVPKDFCTXnew(kdf);",
        "EVPKDFfree(kdf);",
        "*p++ = OSSLPARAMconstructutf8string(OSSLKDFPARAMDIGEST,",
        "\"SHA2-256\", 0);",
        "*p++ = OSSLPARAMconstructutf8string(OSSLKDFPARAMMAC,",
        "\"HMAC\", 0);",
        "*p++ = OSSLPARAMconstructoctetstring(OSSLKDFPARAMKEY,",
        "\"secret\", strlen(\"secret\"));",
        "*p++ = OSSLPARAMconstructoctetstring(OSSLKDFPARAMSALT,",
        "\"label\", strlen(\"label\"));",
        "*p++ = OSSLPARAMconstructoctetstring(OSSLKDFPARAMINFO,",
        "\"context\", strlen(\"context\"));",
        "*p = OSSLPARAMconstructend();",
        "if (EVPKDFderive(kctx, out, sizeof(out), params) <= 0)",
        "error(\"EVPKDFderive\");",
        "EVPKDFCTXfree(kctx);",
        "This  example  derives  10 bytes using FEEDBACK-CMAC-AES256, with KI \"secret\", Label \"label\",",
        "and IV \"sixteen bytes iv\".",
        "EVPKDF *kdf;",
        "EVPKDFCTX *kctx;",
        "unsigned char out[10];",
        "OSSLPARAM params[8], *p = params;",
        "unsigned char *iv = \"sixteen bytes iv\";",
        "kdf = EVPKDFfetch(NULL, \"KBKDF\", NULL);",
        "kctx = EVPKDFCTXnew(kdf);",
        "EVPKDFfree(kdf);",
        "*p++ = OSSLPARAMconstructutf8string(OSSLKDFPARAMCIPHER, \"AES256\", 0);",
        "*p++ = OSSLPARAMconstructutf8string(OSSLKDFPARAMMAC, \"CMAC\", 0);",
        "*p++ = OSSLPARAMconstructutf8string(OSSLKDFPARAMMODE, \"FEEDBACK\", 0);",
        "*p++ = OSSLPARAMconstructoctetstring(OSSLKDFPARAMKEY,",
        "\"secret\", strlen(\"secret\"));",
        "*p++ = OSSLPARAMconstructoctetstring(OSSLKDFPARAMSALT,",
        "\"label\", strlen(\"label\"));",
        "*p++ = OSSLPARAMconstructoctetstring(OSSLKDFPARAMINFO,",
        "\"context\", strlen(\"context\"));",
        "*p++ = OSSLPARAMconstructoctetstring(OSSLKDFPARAMSEED,",
        "iv, strlen(iv));",
        "*p = OSSLPARAMconstructend();",
        "if (EVPKDFderive(kctx, out, sizeof(out), params) <= 0)",
        "error(\"EVPKDFderive\");",
        "EVPKDFCTXfree(kctx);"
    ],
    "see_also": [
        {
            "name": "EVPKDF",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/EVPKDF/3/json"
        },
        {
            "name": "EVPKDFCTXfree",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/EVPKDFCTXfree/3/json"
        },
        {
            "name": "EVPKDFCTXgetkdfsize",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/EVPKDFCTXgetkdfsize/3/json"
        },
        {
            "name": "EVPKDFderive",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/EVPKDFderive/3/json"
        },
        {
            "name": "EVPKDF",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/EVPKDF/3/json"
        }
    ]
}