{
    "mode": "man",
    "parameter": "provider-keymgmt",
    "section": "7",
    "url": "https://www.chedong.com/phpMan.php/man/provider-keymgmt/7/json",
    "generated": "2026-05-30T06:08:14Z",
    "synopsis": "#include <openssl/coredispatch.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/* Key object (keydata) creation and destruction */\nvoid *OSSLFUNCkeymgmtnew(void *provctx);\nvoid OSSLFUNCkeymgmtfree(void *keydata);\n/* Generation, a more complex constructor */\nvoid *OSSLFUNCkeymgmtgeninit(void *provctx, int selection,\nconst OSSLPARAM params[]);\nint OSSLFUNCkeymgmtgensettemplate(void *genctx, void *template);\nint OSSLFUNCkeymgmtgensetparams(void *genctx, const OSSLPARAM params[]);\nconst OSSLPARAM *OSSLFUNCkeymgmtgensettableparams(void *genctx,\nvoid *provctx);\nvoid *OSSLFUNCkeymgmtgen(void *genctx, OSSLCALLBACK *cb, void *cbarg);\nvoid OSSLFUNCkeymgmtgencleanup(void *genctx);\n/* Key loading by object reference, also a constructor */\nvoid *OSSLFUNCkeymgmtload(const void *reference, sizet *referencesz);\n/* Key object information */\nint OSSLFUNCkeymgmtgetparams(void *keydata, OSSLPARAM params[]);\nconst OSSLPARAM *OSSLFUNCkeymgmtgettableparams(void *provctx);\nint OSSLFUNCkeymgmtsetparams(void *keydata, const OSSLPARAM params[]);\nconst OSSLPARAM *OSSLFUNCkeymgmtsettableparams(void *provctx);\n/* Key object content checks */\nint OSSLFUNCkeymgmthas(const void *keydata, int selection);\nint OSSLFUNCkeymgmtmatch(const void *keydata1, const void *keydata2,\nint selection);\n/* Discovery of supported operations */\nconst char *OSSLFUNCkeymgmtqueryoperationname(int operationid);\n/* Key object import and export functions */\nint OSSLFUNCkeymgmtimport(int selection, void *keydata, const OSSLPARAM params[]);\nconst OSSLPARAM *OSSLFUNCkeymgmtimporttypes(int selection);\nint OSSLFUNCkeymgmtexport(int selection, void *keydata,\nOSSLCALLBACK *paramcb, void *cbarg);\nconst OSSLPARAM *OSSLFUNCkeymgmtexporttypes(int selection);\n/* Key object duplication, a constructor */\nvoid *OSSLFUNCkeymgmtdup(const void *keydatafrom, int selection);\n/* Key object validation */\nint OSSLFUNCkeymgmtvalidate(const void *keydata, int selection, int checktype);",
    "sections": {
        "NAME": {
            "content": "provider-keymgmt - The KEYMGMT library <-> provider functions\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "#include <openssl/coredispatch.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/* Key object (keydata) creation and destruction */\nvoid *OSSLFUNCkeymgmtnew(void *provctx);\nvoid OSSLFUNCkeymgmtfree(void *keydata);\n\n/* Generation, a more complex constructor */\nvoid *OSSLFUNCkeymgmtgeninit(void *provctx, int selection,\nconst OSSLPARAM params[]);\nint OSSLFUNCkeymgmtgensettemplate(void *genctx, void *template);\nint OSSLFUNCkeymgmtgensetparams(void *genctx, const OSSLPARAM params[]);\nconst OSSLPARAM *OSSLFUNCkeymgmtgensettableparams(void *genctx,\nvoid *provctx);\nvoid *OSSLFUNCkeymgmtgen(void *genctx, OSSLCALLBACK *cb, void *cbarg);\nvoid OSSLFUNCkeymgmtgencleanup(void *genctx);\n\n/* Key loading by object reference, also a constructor */\nvoid *OSSLFUNCkeymgmtload(const void *reference, sizet *referencesz);\n\n/* Key object information */\nint OSSLFUNCkeymgmtgetparams(void *keydata, OSSLPARAM params[]);\nconst OSSLPARAM *OSSLFUNCkeymgmtgettableparams(void *provctx);\nint OSSLFUNCkeymgmtsetparams(void *keydata, const OSSLPARAM params[]);\nconst OSSLPARAM *OSSLFUNCkeymgmtsettableparams(void *provctx);\n\n/* Key object content checks */\nint OSSLFUNCkeymgmthas(const void *keydata, int selection);\nint OSSLFUNCkeymgmtmatch(const void *keydata1, const void *keydata2,\nint selection);\n\n/* Discovery of supported operations */\nconst char *OSSLFUNCkeymgmtqueryoperationname(int operationid);\n\n/* Key object import and export functions */\nint OSSLFUNCkeymgmtimport(int selection, void *keydata, const OSSLPARAM params[]);\nconst OSSLPARAM *OSSLFUNCkeymgmtimporttypes(int selection);\nint OSSLFUNCkeymgmtexport(int selection, void *keydata,\nOSSLCALLBACK *paramcb, void *cbarg);\nconst OSSLPARAM *OSSLFUNCkeymgmtexporttypes(int selection);\n\n/* Key object duplication, a constructor */\nvoid *OSSLFUNCkeymgmtdup(const void *keydatafrom, int selection);\n\n/* Key object validation */\nint OSSLFUNCkeymgmtvalidate(const void *keydata, int selection, int checktype);\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The KEYMGMT operation doesn't have much public visibility in OpenSSL libraries, it's rather\nan internal operation that's designed to work in tandem with operations that use\nprivate/public key pairs.\n\nBecause the KEYMGMT operation shares knowledge with the operations it works with in tandem,\nthey must belong to the same provider.  The OpenSSL libraries will ensure that they do.\n\nThe primary responsibility of the KEYMGMT operation is to hold the provider side key data for\nthe OpenSSL library EVPPKEY structure.\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 a\nOSSLDISPATCH element named OSSLFUNC{name}.  For example, the \"function\"\nOSSLFUNCkeymgmtnew() has these:\n\ntypedef void *(OSSLFUNCkeymgmtnewfn)(void *provctx);\nstatic osslinline OSSLFUNCkeymgmtnewfn\nOSSLFUNCkeymgmtnew(const OSSLDISPATCH *opf);\n\nOSSLDISPATCH arrays are indexed by numbers that are provided as macros in\nopenssl-coredispatch.h(7), as follows:\n\nOSSLFUNCkeymgmtnew                  OSSLFUNCKEYMGMTNEW\nOSSLFUNCkeymgmtfree                 OSSLFUNCKEYMGMTFREE\n\nOSSLFUNCkeymgmtgeninit             OSSLFUNCKEYMGMTGENINIT\nOSSLFUNCkeymgmtgensettemplate     OSSLFUNCKEYMGMTGENSETTEMPLATE\nOSSLFUNCkeymgmtgensetparams       OSSLFUNCKEYMGMTGENSETPARAMS\nOSSLFUNCkeymgmtgensettableparams  OSSLFUNCKEYMGMTGENSETTABLEPARAMS\nOSSLFUNCkeymgmtgen                  OSSLFUNCKEYMGMTGEN\nOSSLFUNCkeymgmtgencleanup          OSSLFUNCKEYMGMTGENCLEANUP\n\nOSSLFUNCkeymgmtload                 OSSLFUNCKEYMGMTLOAD\n\nOSSLFUNCkeymgmtgetparams           OSSLFUNCKEYMGMTGETPARAMS\nOSSLFUNCkeymgmtgettableparams      OSSLFUNCKEYMGMTGETTABLEPARAMS\nOSSLFUNCkeymgmtsetparams           OSSLFUNCKEYMGMTSETPARAMS\nOSSLFUNCkeymgmtsettableparams      OSSLFUNCKEYMGMTSETTABLEPARAMS\n\nOSSLFUNCkeymgmtqueryoperationname OSSLFUNCKEYMGMTQUERYOPERATIONNAME\n\nOSSLFUNCkeymgmthas                  OSSLFUNCKEYMGMTHAS\nOSSLFUNCkeymgmtvalidate             OSSLFUNCKEYMGMTVALIDATE\nOSSLFUNCkeymgmtmatch                OSSLFUNCKEYMGMTMATCH\n\nOSSLFUNCkeymgmtimport               OSSLFUNCKEYMGMTIMPORT\nOSSLFUNCkeymgmtimporttypes         OSSLFUNCKEYMGMTIMPORTTYPES\nOSSLFUNCkeymgmtexport               OSSLFUNCKEYMGMTEXPORT\nOSSLFUNCkeymgmtexporttypes         OSSLFUNCKEYMGMTEXPORTTYPES\n\nOSSLFUNCkeymgmtdup                  OSSLFUNCKEYMGMTDUP\n",
            "subsections": [
                {
                    "name": "Key Objects",
                    "content": "A key object is a collection of data for an asymmetric key, and is represented as keydata in\nthis manual.\n\nThe exact contents of a key object are defined by the provider, and it is assumed that\ndifferent operations in one and the same provider use the exact same structure to represent\nthis collection of data, so that for example, a key object that has been created using the\nKEYMGMT interface that we document here can be passed as is to other provider operations,\nsuch as OPsignaturesigninit() (see provider-signature(7)).\n\nWith some of the KEYMGMT functions, it's possible to select a specific subset of data to\nhandle, governed by the bits in a selection indicator.  The bits are:\n\nOSSLKEYMGMTSELECTPRIVATEKEY\nIndicating that the private key data in a key object should be considered.\n\nOSSLKEYMGMTSELECTPUBLICKEY\nIndicating that the public key data in a key object should be considered.\n\nOSSLKEYMGMTSELECTDOMAINPARAMETERS\nIndicating that the domain parameters in a key object should be considered.\n\nOSSLKEYMGMTSELECTOTHERPARAMETERS\nIndicating that other parameters in a key object should be considered.\n\nOther parameters are key parameters that don't fit any other classification.  In other\nwords, this particular selector bit works as a last resort bit bucket selector.\n\nSome selector bits have also been combined for easier use:\n\nOSSLKEYMGMTSELECTALLPARAMETERS\nIndicating that all key object parameters should be considered, regardless of their more\ngranular classification.\n\nThis is a combination of OSSLKEYMGMTSELECTDOMAINPARAMETERS and\nOSSLKEYMGMTSELECTOTHERPARAMETERS.\n\nOSSLKEYMGMTSELECTKEYPAIR\nIndicating that both the whole key pair in a key object should be considered, i.e. the\ncombination of public and private key.\n\nThis is a combination of OSSLKEYMGMTSELECTPRIVATEKEY and\nOSSLKEYMGMTSELECTPUBLICKEY.\n\nOSSLKEYMGMTSELECTALL\nIndicating that everything in a key object should be considered.\n\nThe exact interpretation of those bits or how they combine is left to each function where you\ncan specify a selector.\n\nIt's left to the provider implementation to decide what is reasonable to do with regards to\nreceived selector bits and how to do it.  Among others, an implementation of\nOSSLFUNCkeymgmtmatch() might opt to not compare the private half if it has compared the\npublic half, since a match of one half implies a match of the other half.\n"
                },
                {
                    "name": "Constructing and Destructing Functions",
                    "content": "OSSLFUNCkeymgmtnew() should create a provider side key object.  The provider context\nprovctx is passed and may be incorporated in the key object, but that is not mandatory.\n\nOSSLFUNCkeymgmtfree() should free the passed keydata.\n\nOSSLFUNCkeymgmtgeninit(), OSSLFUNCkeymgmtgensettemplate(),\nOSSLFUNCkeymgmtgensetparams(), OSSLFUNCkeymgmtgensettableparams(),\nOSSLFUNCkeymgmtgen() and OSSLFUNCkeymgmtgencleanup() work together as a more elaborate\ncontext based key object constructor.\n\nOSSLFUNCkeymgmtgeninit() should create the key object generation context and initialize\nit with selections, which will determine what kind of contents the key object to be generated\nshould get.  The params, if not NULL, should be set on the context in a manner similar to\nusing OSSLFUNCkeymgmtsetparams().\n\nOSSLFUNCkeymgmtgensettemplate() should add template to the context genctx.  The template\nis assumed to be a key object constructed with the same KEYMGMT, and from which content that\nthe implementation chooses can be used as a template for the key object to be generated.\nTypically, the generation of a DSA or DH key would get the domain parameters from this\ntemplate.\n\nOSSLFUNCkeymgmtgensetparams() should set additional parameters from params in the key\nobject generation context genctx.\n\nOSSLFUNCkeymgmtgensettableparams() should return a constant array of descriptor\nOSSLPARAM, for parameters that OSSLFUNCkeymgmtgensetparams() can handle.\n\nOSSLFUNCkeymgmtgen() should perform the key object generation itself, and return the\nresult.  The callback cb should be called at regular intervals with indications on how the\nkey object generation progresses.\n\nOSSLFUNCkeymgmtgencleanup() should clean up and free the key object generation context\ngenctx\n\nOSSLFUNCkeymgmtload() creates a provider side key object based on a reference object with\na size of referencesz bytes, that only the provider knows how to interpret, but that may\ncome from other operations.  Outside the provider, this reference is simply an array of\nbytes.\n\nAt least one of OSSLFUNCkeymgmtnew(), OSSLFUNCkeymgmtgen() and OSSLFUNCkeymgmtload()\nare mandatory, as well as OSSLFUNCkeymgmtfree() and OSSLFUNCkeymgmthas(). Additionally,\nif OSSLFUNCkeymgmtgen() is present, OSSLFUNCkeymgmtgeninit() and\nOSSLFUNCkeymgmtgencleanup() must be present as well.\n"
                },
                {
                    "name": "Key Object Information Functions",
                    "content": "OSSLFUNCkeymgmtgetparams() should extract information data associated with the given\nkeydata, see \"Common Information Parameters\".\n\nOSSLFUNCkeymgmtgettableparams() should return a constant array of descriptor OSSLPARAM,\nfor parameters that OSSLFUNCkeymgmtgetparams() can handle.\n\nIf OSSLFUNCkeymgmtgettableparams() is present, OSSLFUNCkeymgmtgetparams() must also\nbe present, and vice versa.\n\nOSSLFUNCkeymgmtsetparams() should update information data associated with the given\nkeydata, see \"Common Information Parameters\".\n\nOSSLFUNCkeymgmtsettableparams() should return a constant array of descriptor OSSLPARAM,\nfor parameters that OSSLFUNCkeymgmtsetparams() can handle.\n\nIf OSSLFUNCkeymgmtsettableparams() is present, OSSLFUNCkeymgmtsetparams() must also\nbe present, and vice versa.\n"
                },
                {
                    "name": "Key Object Checking Functions",
                    "content": "OSSLFUNCkeymgmtqueryoperationname() should return the name of the supported algorithm\nfor the operation operationid.  This is similar to providerqueryoperation() (see\nprovider-base(7)), but only works as an advisory.  If this function is not present, or\nreturns NULL, the caller is free to assume that there's an algorithm from the same provider,\nof the same name as the one used to fetch the keymgmt and try to use that.\n\nOSSLFUNCkeymgmthas() should check whether the given keydata contains the subsets of data\nindicated by the selector.  A combination of several selector bits must consider all those\nsubsets, not just one.  An implementation is, however, free to consider an empty subset of\ndata to still be a valid subset. For algorithms where some selection is not meaningful such\nas OSSLKEYMGMTSELECTDOMAINPARAMETERS for RSA keys the function should just return 1 as\nthe selected subset is not really missing in the key.\n\nOSSLFUNCkeymgmtvalidate() should check if the keydata contains valid data subsets\nindicated by selection.  Some combined selections of data subsets may cause validation of the\ncombined data.  For example, the combination of OSSLKEYMGMTSELECTPRIVATEKEY and\nOSSLKEYMGMTSELECTPUBLICKEY (or OSSLKEYMGMTSELECTKEYPAIR for short) is expected to\ncheck that the pairwise consistency of keydata is valid. The checktype parameter controls\nwhat type of check is performed on the subset of data. Two types of check are defined:\nOSSLKEYMGMTVALIDATEFULLCHECK and OSSLKEYMGMTVALIDATEQUICKCHECK.  The interpretation\nof how much checking is performed in a full check versus a quick check is key type specific.\nSome providers may have no distinction between a full check and a quick check. For algorithms\nwhere some selection is not meaningful such as OSSLKEYMGMTSELECTDOMAINPARAMETERS for RSA\nkeys the function should just return 1 as there is nothing to validate for that selection.\n\nOSSLFUNCkeymgmtmatch() should check if the data subset indicated by selection in keydata1\nand keydata2 match.  It is assumed that the caller has ensured that keydata1 and keydata2 are\nboth owned by the implementation of this function.\n"
                },
                {
                    "name": "Key Object Import, Export and Duplication Functions",
                    "content": "OSSLFUNCkeymgmtimport() should import data indicated by selection into keydata with values\ntaken from the OSSLPARAM array params.\n\nOSSLFUNCkeymgmtexport() should extract values indicated by selection from keydata, create\nan OSSLPARAM array with them and call paramcb with that array as well as the given cbarg.\n\nOSSLFUNCkeymgmtimporttypes() should return a constant array of descriptor OSSLPARAM for\ndata indicated by selection, for parameters that OSSLFUNCkeymgmtimport() can handle.\n\nOSSLFUNCkeymgmtexporttypes() should return a constant array of descriptor OSSLPARAM for\ndata indicated by selection, that the OSSLFUNCkeymgmtexport() callback can expect to\nreceive.\n\nOSSLFUNCkeymgmtdup() should duplicate data subsets indicated by selection or the whole key\ndata keydatafrom and create a new provider side key object with the data.\n"
                },
                {
                    "name": "Common Information Parameters",
                    "content": "See OSSLPARAM(3) for further details on the parameters structure.\n\nCommon information parameters currently recognised by all built-in keymgmt algorithms are as\nfollows:\n\n\"bits\" (OSSLPKEYPARAMBITS) <integer>\nThe value should be the cryptographic length of the cryptosystem to which the key\nbelongs, in bits.  The definition of cryptographic length is specific to the key\ncryptosystem.\n\n\"max-size\" (OSSLPKEYPARAMMAXSIZE) <integer>\nThe value should be the maximum size that a caller should allocate to safely store a\nsignature (called sig in provider-signature(7)), the result of asymmmetric encryption /\ndecryption (out in provider-asymcipher(7), a derived secret (secret in\nprovider-keyexch(7), and similar data).\n\nBecause an EVPKEYMGMT method is always tightly bound to another method (signature,\nasymmetric cipher, key exchange, ...) and must be of the same provider, this number only\nneeds to be synchronised with the dimensions handled in the rest of the same provider.\n\n\"security-bits\" (OSSLPKEYPARAMSECURITYBITS) <integer>\nThe value should be the number of security bits of the given key.  Bits of security is\ndefined in SP800-57.\n"
                }
            ]
        },
        "RETURN VALUES": {
            "content": "OSSLFUNCkeymgmtnew() and OSSLFUNCkeymgmtdup() should return a valid reference to the\nnewly created provider side key object, or NULL on failure.\n\nOSSLFUNCkeymgmtimport(), OSSLFUNCkeymgmtexport(), OSSLFUNCkeymgmtgetparams() and\nOSSLFUNCkeymgmtsetparams() should return 1 for success or 0 on error.\n\nOSSLFUNCkeymgmtvalidate() should return 1 on successful validation, or 0 on failure.\n\nOSSLFUNCkeymgmthas() should return 1 if all the selected data subsets are contained in the\ngiven keydata or 0 otherwise.\n\nOSSLFUNCkeymgmtqueryoperationname() should return a pointer to a string matching the\nrequested operation, or NULL if the same name used to fetch the keymgmt applies.\n\nOSSLFUNCkeymgmtgettableparams() and OSSLFUNCkeymgmtsettableparams()\nOSSLFUNCkeymgmtimporttypes(), OSSLFUNCkeymgmtexporttypes() should always return a\nconstant OSSLPARAM array.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "provider(7), EVPPKEY-X25519(7), EVPPKEY-X448(7), EVPPKEY-ED25519(7), EVPPKEY-ED448(7),\nEVPPKEY-EC(7), EVPPKEY-RSA(7), EVPPKEY-DSA(7), EVPPKEY-DH(7)\n",
            "subsections": []
        },
        "HISTORY": {
            "content": "The KEYMGMT 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\n\n\n3.0.2                                        2026-04-07                       PROVIDER-KEYMGMT(7SSL)",
            "subsections": []
        }
    },
    "summary": "provider-keymgmt - The KEYMGMT library <-> provider functions",
    "flags": [],
    "examples": [],
    "see_also": [
        {
            "name": "provider",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/provider/7/json"
        },
        {
            "name": "EVPPKEY-X25519",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/EVPPKEY-X25519/7/json"
        },
        {
            "name": "EVPPKEY-X448",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/EVPPKEY-X448/7/json"
        },
        {
            "name": "EVPPKEY-ED25519",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/EVPPKEY-ED25519/7/json"
        },
        {
            "name": "EVPPKEY-ED448",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/EVPPKEY-ED448/7/json"
        },
        {
            "name": "EVPPKEY-EC",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/EVPPKEY-EC/7/json"
        },
        {
            "name": "EVPPKEY-RSA",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/EVPPKEY-RSA/7/json"
        },
        {
            "name": "EVPPKEY-DSA",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/EVPPKEY-DSA/7/json"
        },
        {
            "name": "EVPPKEY-DH",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/EVPPKEY-DH/7/json"
        }
    ]
}