{
    "content": [
        {
            "type": "text",
            "text": "# EVP_MAC-KMAC (man)\n\n## NAME\n\nEVPMAC-KMAC, EVPMAC-KMAC128, EVPMAC-KMAC256 - The KMAC EVPMAC implementations\n\n## DESCRIPTION\n\nSupport for computing KMAC MACs through the EVPMAC API.\n\n## Sections\n\n- **NAME**\n- **DESCRIPTION** (2 subsections)\n- **EXAMPLES**\n- **SEE ALSO**\n- **COPYRIGHT**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "EVP_MAC-KMAC",
        "section": "",
        "mode": "man",
        "summary": "EVPMAC-KMAC, EVPMAC-KMAC128, EVPMAC-KMAC256 - The KMAC EVPMAC implementations",
        "synopsis": null,
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [
            "#include <openssl/evp.h>",
            "#include <openssl/params.h>",
            "static int dokmac(const unsigned char *in, sizet inlen,",
            "const unsigned char *key, sizet keylen,",
            "const unsigned char *custom, sizet customlen,",
            "int xofenabled, unsigned char *out, int outlen)",
            "EVPMACCTX *ctx = NULL;",
            "EVPMAC *mac = NULL;",
            "OSSLPARAM params[4], *p;",
            "int ret = 0;",
            "sizet l = 0;",
            "mac = EVPMACfetch(NULL, \"KMAC-128\", NULL);",
            "if (mac == NULL)",
            "goto err;",
            "ctx = EVPMACCTXnew(mac);",
            "/* The mac can be freed after it is used by EVPMACCTXnew */",
            "EVPMACfree(mac);",
            "if (ctx == NULL)",
            "goto err;",
            "/*",
            "* Setup parameters required before calling EVPMACinit()",
            "* The parameters OSSLMACPARAMXOF and OSSLMACPARAMSIZE may also be",
            "* used at this point.",
            "*/",
            "p = params;",
            "*p++ = OSSLPARAMconstructoctetstring(OSSLMACPARAMKEY,",
            "(void *)key, keylen);",
            "if (custom != NULL && customlen != 0)",
            "*p++ = OSSLPARAMconstructoctetstring(OSSLMACPARAMCUSTOM,",
            "(void *)custom, customlen);",
            "*p = OSSLPARAMconstructend();",
            "if (!EVPMACCTXsetparams(ctx, params))",
            "goto err;",
            "if (!EVPMACinit(ctx))",
            "goto err;",
            "/*",
            "* Note: the following optional parameters can be set any time",
            "* before EVPMACfinal().",
            "*/",
            "p = params;",
            "*p++ = OSSLPARAMconstructint(OSSLMACPARAMXOF, &xofenabled);",
            "*p++ = OSSLPARAMconstructint(OSSLMACPARAMSIZE, &outlen);",
            "*p = OSSLPARAMconstructend();",
            "if (!EVPMACCTXsetparams(ctx, params))",
            "goto err;",
            "/* The update may be called multiple times here for streamed input */",
            "if (!EVPMACupdate(ctx, in, inlen))",
            "goto err;",
            "if (!EVPMACfinal(ctx, out, &l, outlen))",
            "goto err;",
            "ret = 1;",
            "err:",
            "EVPMACCTXfree(ctx);",
            "return ret;"
        ],
        "see_also": [
            {
                "name": "EVPMACCTXgetparams",
                "section": "3",
                "url": "https://www.chedong.com/phpMan.php/man/EVPMACCTXgetparams/3/json"
            },
            {
                "name": "EVPMACCTXsetparams",
                "section": "3",
                "url": "https://www.chedong.com/phpMan.php/man/EVPMACCTXsetparams/3/json"
            },
            {
                "name": "EVPMAC",
                "section": "3",
                "url": "https://www.chedong.com/phpMan.php/man/EVPMAC/3/json"
            },
            {
                "name": "OSSLPARAM",
                "section": "3",
                "url": "https://www.chedong.com/phpMan.php/man/OSSLPARAM/3/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 2,
                "subsections": [
                    {
                        "name": "Identity",
                        "lines": 6
                    },
                    {
                        "name": "Supported parameters",
                        "lines": 30
                    }
                ]
            },
            {
                "name": "EXAMPLES",
                "lines": 63,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "COPYRIGHT",
                "lines": 9,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "EVPMAC-KMAC, EVPMAC-KMAC128, EVPMAC-KMAC256 - The KMAC EVPMAC implementations\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "Support for computing KMAC MACs through the EVPMAC API.\n",
                "subsections": [
                    {
                        "name": "Identity",
                        "content": "These implementations are identified with one of these names and properties, to be used with\nEVPMACfetch():\n\n\"KMAC-128\", \"provider=default\" or \"provider=fips\"\n\"KMAC-256\", \"provider=default\" or \"provider=fips\"\n"
                    },
                    {
                        "name": "Supported parameters",
                        "content": "The general description of these parameters can be found in \"PARAMETERS\" in EVPMAC(3).\n\nAll these parameters can be set with EVPMACCTXsetparams().  Furthermore, the \"size\"\nparameter can be retrieved with EVPMACCTXgetparams(), or with EVPMACCTXgetmacsize().\nThe length of the \"size\" parameter should not exceed that of a sizet.  Likewise, the \"block-\nsize\" parameter can be retrieved with EVPMACCTXgetparams(), or with\nEVPMACCTXgetblocksize().\n\n\"key\" (OSSLMACPARAMKEY) <octet string>\nSets the MAC key.  Setting this parameter is identical to passing a key to\nEVPMACinit(3).\n\n\"custom\" (OSSLMACPARAMCUSTOM) <octet string>\nSets the custom value.  It is an optional value of at most 256 bytes, and is empty by\ndefault.\n\n\"size\" (OSSLMACPARAMSIZE) <unsigned integer>\nSets the MAC size.  By default, it is 16 for \"KMAC-128\" and 32 for \"KMAC-256\".\n\n\"block-size\" (OSSLMACPARAMSIZE) <unsigned integer>\nGets the MAC block size.  By default, it is 168 for \"KMAC-128\" and 136 for \"KMAC-256\".\n\n\"xof\" (OSSLMACPARAMXOF) <integer>\nThe \"xof\" parameter value is expected to be 1 or 0. Use 1 to enable XOF mode.  The\ndefault value is 0.\n\nThe \"custom\" parameter must be set as part of or before the EVPMACinit() call.  The \"xof\"\nand \"size\" parameters can be set at any time before EVPMACfinal().  The \"key\" parameter is\nset as part of the EVPMACinit() call, but can be set before it instead.\n"
                    }
                ]
            },
            "EXAMPLES": {
                "content": "#include <openssl/evp.h>\n#include <openssl/params.h>\n\nstatic int dokmac(const unsigned char *in, sizet inlen,\nconst unsigned char *key, sizet keylen,\nconst unsigned char *custom, sizet customlen,\nint xofenabled, unsigned char *out, int outlen)\n{\nEVPMACCTX *ctx = NULL;\nEVPMAC *mac = NULL;\nOSSLPARAM params[4], *p;\nint ret = 0;\nsizet l = 0;\n\nmac = EVPMACfetch(NULL, \"KMAC-128\", NULL);\nif (mac == NULL)\ngoto err;\nctx = EVPMACCTXnew(mac);\n/* The mac can be freed after it is used by EVPMACCTXnew */\nEVPMACfree(mac);\nif (ctx == NULL)\ngoto err;\n\n/*\n* Setup parameters required before calling EVPMACinit()\n* The parameters OSSLMACPARAMXOF and OSSLMACPARAMSIZE may also be\n* used at this point.\n*/\np = params;\n*p++ = OSSLPARAMconstructoctetstring(OSSLMACPARAMKEY,\n(void *)key, keylen);\nif (custom != NULL && customlen != 0)\n*p++ = OSSLPARAMconstructoctetstring(OSSLMACPARAMCUSTOM,\n(void *)custom, customlen);\n*p = OSSLPARAMconstructend();\nif (!EVPMACCTXsetparams(ctx, params))\ngoto err;\n\nif (!EVPMACinit(ctx))\ngoto err;\n\n/*\n* Note: the following optional parameters can be set any time\n* before EVPMACfinal().\n*/\np = params;\n*p++ = OSSLPARAMconstructint(OSSLMACPARAMXOF, &xofenabled);\n*p++ = OSSLPARAMconstructint(OSSLMACPARAMSIZE, &outlen);\n*p = OSSLPARAMconstructend();\nif (!EVPMACCTXsetparams(ctx, params))\ngoto err;\n\n/* The update may be called multiple times here for streamed input */\nif (!EVPMACupdate(ctx, in, inlen))\ngoto err;\nif (!EVPMACfinal(ctx, out, &l, outlen))\ngoto err;\nret = 1;\nerr:\nEVPMACCTXfree(ctx);\nreturn ret;\n}\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "EVPMACCTXgetparams(3), EVPMACCTXsetparams(3), \"PARAMETERS\" in EVPMAC(3),\nOSSLPARAM(3)\n",
                "subsections": []
            },
            "COPYRIGHT": {
                "content": "Copyright 2018-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                           EVPMAC-KMAC(7SSL)",
                "subsections": []
            }
        }
    }
}