{
    "content": [
        {
            "type": "text",
            "text": "# provider-mac (man)\n\n## NAME\n\nprovider-mac - The mac 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 *OSSLFUNCmacnewctx(void *provctx);\nvoid OSSLFUNCmacfreectx(void *mctx);\nvoid *OSSLFUNCmacdupctx(void *src);\n/* Encryption/decryption */\nint OSSLFUNCmacinit(void *mctx, unsigned char *key, sizet keylen,\nconst OSSLPARAM params[]);\nint OSSLFUNCmacupdate(void *mctx, const unsigned char *in, sizet inl);\nint OSSLFUNCmacfinal(void *mctx, unsigned char *out, sizet *outl, sizet outsize);\n/* MAC parameter descriptors */\nconst OSSLPARAM *OSSLFUNCmacgettableparams(void *provctx);\nconst OSSLPARAM *OSSLFUNCmacgettablectxparams(void *mctx, void *provctx);\nconst OSSLPARAM *OSSLFUNCmacsettablectxparams(void *mctx, void *provctx);\n/* MAC parameters */\nint OSSLFUNCmacgetparams(OSSLPARAM params[]);\nint OSSLFUNCmacgetctxparams(void *mctx, OSSLPARAM params[]);\nint OSSLFUNCmacsetctxparams(void *mctx, 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**\n- **NOTES**\n- **RETURN VALUES**\n- **SEE ALSO**\n- **HISTORY**\n- **COPYRIGHT**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "provider-mac",
        "section": "",
        "mode": "man",
        "summary": "provider-mac - The mac 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 *OSSLFUNCmacnewctx(void *provctx);\nvoid OSSLFUNCmacfreectx(void *mctx);\nvoid *OSSLFUNCmacdupctx(void *src);\n/* Encryption/decryption */\nint OSSLFUNCmacinit(void *mctx, unsigned char *key, sizet keylen,\nconst OSSLPARAM params[]);\nint OSSLFUNCmacupdate(void *mctx, const unsigned char *in, sizet inl);\nint OSSLFUNCmacfinal(void *mctx, unsigned char *out, sizet *outl, sizet outsize);\n/* MAC parameter descriptors */\nconst OSSLPARAM *OSSLFUNCmacgettableparams(void *provctx);\nconst OSSLPARAM *OSSLFUNCmacgettablectxparams(void *mctx, void *provctx);\nconst OSSLPARAM *OSSLFUNCmacsettablectxparams(void *mctx, void *provctx);\n/* MAC parameters */\nint OSSLFUNCmacgetparams(OSSLPARAM params[]);\nint OSSLFUNCmacgetctxparams(void *mctx, OSSLPARAM params[]);\nint OSSLFUNCmacsetctxparams(void *mctx, 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": "EVPMAC-BLAKE2",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/EVPMAC-BLAKE2/7/json"
            },
            {
                "name": "EVPMAC-CMAC",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/EVPMAC-CMAC/7/json"
            },
            {
                "name": "EVPMAC-GMAC",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/EVPMAC-GMAC/7/json"
            },
            {
                "name": "EVPMAC-HMAC",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/EVPMAC-HMAC/7/json"
            },
            {
                "name": "EVPMAC-KMAC",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/EVPMAC-KMAC/7/json"
            },
            {
                "name": "EVPMAC-Poly1305",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/EVPMAC-Poly1305/7/json"
            },
            {
                "name": "EVPMAC-Siphash",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/EVPMAC-Siphash/7/json"
            },
            {
                "name": "lifecycle-mac",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/lifecycle-mac/7/json"
            },
            {
                "name": "EVPMAC",
                "section": "3",
                "url": "https://www.chedong.com/phpMan.php/man/EVPMAC/3/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 30,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 113,
                "subsections": []
            },
            {
                "name": "NOTES",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "RETURN VALUES",
                "lines": 11,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "HISTORY",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "COPYRIGHT",
                "lines": 7,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "provider-mac - The mac 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 *OSSLFUNCmacnewctx(void *provctx);\nvoid OSSLFUNCmacfreectx(void *mctx);\nvoid *OSSLFUNCmacdupctx(void *src);\n\n/* Encryption/decryption */\nint OSSLFUNCmacinit(void *mctx, unsigned char *key, sizet keylen,\nconst OSSLPARAM params[]);\nint OSSLFUNCmacupdate(void *mctx, const unsigned char *in, sizet inl);\nint OSSLFUNCmacfinal(void *mctx, unsigned char *out, sizet *outl, sizet outsize);\n\n/* MAC parameter descriptors */\nconst OSSLPARAM *OSSLFUNCmacgettableparams(void *provctx);\nconst OSSLPARAM *OSSLFUNCmacgettablectxparams(void *mctx, void *provctx);\nconst OSSLPARAM *OSSLFUNCmacsettablectxparams(void *mctx, void *provctx);\n\n/* MAC parameters */\nint OSSLFUNCmacgetparams(OSSLPARAM params[]);\nint OSSLFUNCmacgetctxparams(void *mctx, OSSLPARAM params[]);\nint OSSLFUNCmacsetctxparams(void *mctx, const OSSLPARAM params[]);\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "This documentation is primarily aimed at provider authors. See provider(7) for further\ninformation.\n\nThe MAC operation enables providers to implement mac algorithms and make them available to\napplications via the API functions EVPMACinit(3), EVPMACupdate(3) and EVPMACfinal(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\"\nOSSLFUNCmacnewctx() has these:\n\ntypedef void *(OSSLOSSLFUNCmacnewctxfn)(void *provctx);\nstatic osslinline OSSLOSSLFUNCmacnewctxfn\nOSSLFUNCmacnewctx(const OSSLDISPATCH *opf);\n\nOSSLDISPATCH arrays are indexed by numbers that are provided as macros in\nopenssl-coredispatch.h(7), as follows:\n\nOSSLFUNCmacnewctx               OSSLFUNCMACNEWCTX\nOSSLFUNCmacfreectx              OSSLFUNCMACFREECTX\nOSSLFUNCmacdupctx               OSSLFUNCMACDUPCTX\n\nOSSLFUNCmacinit                 OSSLFUNCMACINIT\nOSSLFUNCmacupdate               OSSLFUNCMACUPDATE\nOSSLFUNCmacfinal                OSSLFUNCMACFINAL\n\nOSSLFUNCmacgetparams           OSSLFUNCMACGETPARAMS\nOSSLFUNCmacgetctxparams       OSSLFUNCMACGETCTXPARAMS\nOSSLFUNCmacsetctxparams       OSSLFUNCMACSETCTXPARAMS\n\nOSSLFUNCmacgettableparams      OSSLFUNCMACGETTABLEPARAMS\nOSSLFUNCmacgettablectxparams  OSSLFUNCMACGETTABLECTXPARAMS\nOSSLFUNCmacsettablectxparams  OSSLFUNCMACSETTABLECTXPARAMS\n\nA mac 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:\nOSSLFUNCmacnewctx(), OSSLFUNCmacfreectx(), OSSLFUNCmacinit(),\nOSSLFUNCmacupdate(), OSSLFUNCmacfinal().  All other functions are optional.\n\nContext Management Functions\nOSSLFUNCmacnewctx() should create and return a pointer to a provider side structure for\nholding context information during a mac operation.  A pointer to this context will be passed\nback in a number of the other mac operation function calls.  The parameter provctx is the\nprovider context generated during provider initialisation (see provider(7)).\n\nOSSLFUNCmacfreectx() is passed a pointer to the provider side mac context in the mctx\nparameter.  If it receives NULL as mctx value, it should not do anything other than return.\nThis function should free any resources associated with that context.\n\nOSSLFUNCmacdupctx() should duplicate the provider side mac context in the mctx parameter\nand return the duplicate copy.\n\nEncryption/Decryption Functions\nOSSLFUNCmacinit() initialises a mac operation given a newly created provider side mac\ncontext in the mctx parameter.  The params are set before setting the MAC key of keylen\nbytes.\n\nOSSLFUNCmacupdate() is called to supply data for MAC computation of a previously\ninitialised mac operation.  The mctx parameter contains a pointer to a previously initialised\nprovider side context.  OSSLFUNCmacupdate() may be called multiple times for a single mac\noperation.\n\nOSSLFUNCmacfinal() completes the MAC computation started through previous\nOSSLFUNCmacinit() and OSSLFUNCmacupdate() calls.  The mctx parameter contains a pointer\nto the provider side context.  The resulting MAC should be written to out and the amount of\ndata written to *outl, which should not exceed outsize bytes.  The same expectations apply to\noutsize as documented for EVPMACfinal(3).\n\nMac Parameters\nSee OSSLPARAM(3) for further details on the parameters structure used by these functions.\n\nOSSLFUNCmacgetparams() gets details of parameter values associated with the provider\nalgorithm and stores them in params.\n\nOSSLFUNCmacsetctxparams() sets mac parameters associated with the given provider side\nmac context mctx to params.  Any parameter settings are additional to any that were\npreviously set.  Passing NULL for params should return true.\n\nOSSLFUNCmacgetctxparams() gets details of currently set parameter values associated with\nthe given provider side mac context mctx and stores them in params.  Passing NULL for params\nshould return true.\n\nOSSLFUNCmacgettableparams(), OSSLFUNCmacgettablectxparams(), and\nOSSLFUNCmacsettablectxparams() all return constant OSSLPARAM arrays as descriptors of\nthe parameters that OSSLFUNCmacgetparams(), OSSLFUNCmacgetctxparams(), and\nOSSLFUNCmacsetctxparams() can handle, respectively.  OSSLFUNCmacgettablectxparams()\nand OSSLFUNCmacsettablectxparams() will return the parameters associated with the\nprovider side context mctx in its current state if it is not NULL.  Otherwise, they return\nthe parameters associated with the provider side algorithm provctx.\n\nAll MAC implementations are expected to handle the following parameters:\n\nwith OSSLFUNCsetctxparams():\n\"key\" (OSSLMACPARAMKEY) <octet string>\nSets the key in the associated MAC ctx.  This is identical to passing a key argument\nto the OSSLFUNCmacinit() function.\n\nwith OSSLFUNCgetparams():\n\"size\" (OSSLMACPARAMSIZE) <integer>\nCan be used to get the default MAC size (which might be the only allowable MAC size\nfor the implementation).\n\nNote that some implementations allow setting the size that the resulting MAC should\nhave as well, see the documentation of the implementation.\n\n\"size\" (OSSLMACPARAMBLOCKSIZE) <integer>\nCan be used to get the MAC block size (if supported by the algorithm).\n",
                "subsections": []
            },
            "NOTES": {
                "content": "The MAC life-cycle is described in lifecycle-rand(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": []
            },
            "RETURN VALUES": {
                "content": "OSSLFUNCmacnewctx() and OSSLFUNCmacdupctx() should return the newly created provider\nside mac context, or NULL on failure.\n\nOSSLFUNCmacinit(), OSSLFUNCmacupdate(), OSSLFUNCmacfinal(),\nOSSLFUNCmacgetparams(), OSSLFUNCmacgetctxparams() and OSSLFUNCmacsetctxparams()\nshould return 1 for success or 0 on error.\n\nOSSLFUNCmacgettableparams(), OSSLFUNCmacgettablectxparams() and\nOSSLFUNCmacsettablectxparams() should return a constant OSSLPARAM array, or NULL if\nnone is offered.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "provider(7), EVPMAC-BLAKE2(7), EVPMAC-CMAC(7), EVPMAC-GMAC(7), EVPMAC-HMAC(7),\nEVPMAC-KMAC(7), EVPMAC-Poly1305(7), EVPMAC-Siphash(7), lifecycle-mac(7), EVPMAC(3)\n",
                "subsections": []
            },
            "HISTORY": {
                "content": "The provider MAC interface was introduced in OpenSSL 3.0.\n",
                "subsections": []
            },
            "COPYRIGHT": {
                "content": "Copyright 2019-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\n3.0.2                                       2026-06-02                         PROVIDER-MAC(7SSL)",
                "subsections": []
            }
        }
    }
}