{
    "mode": "man",
    "parameter": "provider-encoder",
    "section": "7ssl",
    "url": "https://www.chedong.com/phpMan.php/man/provider-encoder/7ssl/json",
    "generated": "2026-05-30T05:11:44Z",
    "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/* Encoder parameter accessor and descriptor */\nconst OSSLPARAM *OSSLFUNCencodergettableparams(void *provctx);\nint OSSLFUNCencodergetparams(OSSLPARAM params[]);\n/* Functions to construct / destruct / manipulate the encoder context */\nvoid *OSSLFUNCencodernewctx(void *provctx);\nvoid OSSLFUNCencoderfreectx(void *ctx);\nint OSSLFUNCencodersetctxparams(void *ctx, const OSSLPARAM params[]);\nconst OSSLPARAM *OSSLFUNCencodersettablectxparams(void *provctx);\n/* Functions to check selection support */\nint OSSLFUNCencoderdoesselection(void *provctx, int selection);\n/* Functions to encode object data */\nint OSSLFUNCencoderencode(void *ctx, OSSLCOREBIO *out,\nconst void *objraw,\nconst OSSLPARAM objabstract[],\nint selection,\nOSSLPASSPHRASECALLBACK *cb,\nvoid *cbarg);\n/* Functions to import and free a temporary object to be encoded */\nvoid *OSSLFUNCencoderimportobject(void *ctx, int selection,\nconst OSSLPARAM params[]);\nvoid OSSLFUNCencoderfreeobject(void *obj);",
    "sections": {
        "NAME": {
            "content": "provider-encoder - The OSSLENCODER 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/* Encoder parameter accessor and descriptor */\nconst OSSLPARAM *OSSLFUNCencodergettableparams(void *provctx);\nint OSSLFUNCencodergetparams(OSSLPARAM params[]);\n\n/* Functions to construct / destruct / manipulate the encoder context */\nvoid *OSSLFUNCencodernewctx(void *provctx);\nvoid OSSLFUNCencoderfreectx(void *ctx);\nint OSSLFUNCencodersetctxparams(void *ctx, const OSSLPARAM params[]);\nconst OSSLPARAM *OSSLFUNCencodersettablectxparams(void *provctx);\n\n/* Functions to check selection support */\nint OSSLFUNCencoderdoesselection(void *provctx, int selection);\n\n/* Functions to encode object data */\nint OSSLFUNCencoderencode(void *ctx, OSSLCOREBIO *out,\nconst void *objraw,\nconst OSSLPARAM objabstract[],\nint selection,\nOSSLPASSPHRASECALLBACK *cb,\nvoid *cbarg);\n\n/* Functions to import and free a temporary object to be encoded */\nvoid *OSSLFUNCencoderimportobject(void *ctx, int selection,\nconst OSSLPARAM params[]);\nvoid OSSLFUNCencoderfreeobject(void *obj);\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "We use the wide term \"encode\" in this manual.  This includes but is not limited to\nserialization.\n\nThe ENCODER operation is a generic method to encode a provider-native object (objraw) or an\nobject abstraction (objectabstract, see provider-object(7)) into an encoded form, and write\nthe result to the given OSSLCOREBIO.  If the caller wants to get the encoded stream to\nmemory, it should provide a BIOsmem(3) BIO.\n\nThe encoder doesn't need to know more about the OSSLCOREBIO pointer than being able to pass\nit to the appropriate BIO upcalls (see \"Core functions\" in provider-base(7)).\n\nThe ENCODER implementation may be part of a chain, where data is passed from one to the next.\nFor example, there may be an implementation to encode an object to DER (that object is\nassumed to be provider-native and thereby passed via objraw), and another one that encodes\nDER to PEM (that one would receive the DER encoding via objabstract).\n\nThe encoding using the OSSLPARAM(3) array form allows a encoder to be used for data that's\nbeen exported from another provider, and thereby allow them to exist independently of each\nother.\n\nThe encoding using a provider side object can only be safely used with provider data coming\nfrom the same provider, for example keys with the KEYMGMT provider.\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\"\nOSSLFUNCencoderencode() has these:\n\ntypedef int\n(OSSLFUNCencoderencodefn)(void *ctx, OSSLCOREBIO *out,\nconst void *objraw,\nconst OSSLPARAM objabstract[],\nint selection,\nOSSLPASSPHRASECALLBACK *cb, void *cbarg);\nstatic osslinline OSSLFUNCencoderencodefn\nOSSLFUNCencoderencode(const OSSLDISPATCH *opf);\n\nOSSLDISPATCH arrays are indexed by numbers that are provided as macros in\nopenssl-coredispatch.h(7), as follows:\n\nOSSLFUNCencodergetparams          OSSLFUNCENCODERGETPARAMS\nOSSLFUNCencodergettableparams     OSSLFUNCENCODERGETTABLEPARAMS\n\nOSSLFUNCencodernewctx              OSSLFUNCENCODERNEWCTX\nOSSLFUNCencoderfreectx             OSSLFUNCENCODERFREECTX\nOSSLFUNCencodersetctxparams      OSSLFUNCENCODERSETCTXPARAMS\nOSSLFUNCencodersettablectxparams OSSLFUNCENCODERSETTABLECTXPARAMS\n\nOSSLFUNCencoderdoesselection      OSSLFUNCENCODERDOESSELECTION\n\nOSSLFUNCencoderencode              OSSLFUNCENCODERENCODE\n\nOSSLFUNCencoderimportobject       OSSLFUNCENCODERIMPORTOBJECT\nOSSLFUNCencoderfreeobject         OSSLFUNCENCODERFREEOBJECT\n",
            "subsections": [
                {
                    "name": "Names and properties",
                    "content": "The name of an implementation should match the type of object it handles.  For example, an\nimplementation that encodes an RSA key should be named \"RSA\".  Likewise, an implementation\nthat further encodes DER should be named \"DER\".\n\nProperties can be used to further specify details about an implementation:\n\noutput\nThis property is used to specify what type of output the implementation produces.\n\nThis property is mandatory.\n\nOpenSSL providers recognize the following output types:\n\ntext\nAn implementation with that output type outputs human readable text, making that\nimplementation suitable for \"-text\" output in diverse openssl(1) commands.\n\npem An implementation with that output type outputs PEM formatted data.\n\nder An implementation with that output type outputs DER formatted data.\n\nmsblob\nAn implementation with that output type outputs MSBLOB formatted data.\n\npvk An implementation with that output type outputs PVK formatted data.\n\nstructure\nThis property is used to specify the structure that is used for the encoded object.  An\nexample could be \"pkcs8\", to specify explicitly that an object (presumably an asymmetric\nkey pair, in this case) will be wrapped in a PKCS#8 structure as part of the encoding.\n\nThis property is optional.\n\nThe possible values of both these properties is open ended.  A provider may very well specify\noutput types and structures that libcrypto doesn't know anything about.\n"
                },
                {
                    "name": "Subset selections",
                    "content": "Sometimes, an object has more than one subset of data that is interesting to treat separately\nor together.  It's possible to specify what subsets are to be encoded, with a set of bits\nselection that are passed in an int.\n\nThis set of bits depend entirely on what kind of provider-side object is passed.  For\nexample, those bits are assumed to be the same as those used with provider-keymgmt(7) (see\n\"Key Objects\" in provider-keymgmt(7)) when the object is an asymmetric keypair.\n\nENCODER implementations are free to regard the selection as a set of hints, but must do so\nwith care.  In the end, the output must make sense, and if there's a corresponding decoder,\nthe resulting decoded object must match the original object that was encoded.\n\nOSSLFUNCencoderdoesselection() should tell if a particular implementation supports any of\nthe combinations given by selection.\n"
                },
                {
                    "name": "Context functions",
                    "content": "OSSLFUNCencodernewctx() returns a context to be used with the rest of the functions.\n\nOSSLFUNCencoderfreectx() frees the given ctx, if it was created by\nOSSLFUNCencodernewctx().\n\nOSSLFUNCencodersetctxparams() sets context data according to parameters from params that\nit recognises.  Unrecognised parameters should be ignored.  Passing NULL for params should\nreturn true.\n\nOSSLFUNCencodersettablectxparams() returns a constant OSSLPARAM array describing the\nparameters that OSSLFUNCencodersetctxparams() can handle.\n\nSee OSSLPARAM(3) for further details on the parameters structure used by\nOSSLFUNCencodersetctxparams() and OSSLFUNCencodersettablectxparams().\n"
                },
                {
                    "name": "Import functions",
                    "content": "A provider-native object may be associated with a foreign provider, and may therefore be\nunsuitable for direct use with a given ENCODER implementation.  Provided that the foreign\nprovider's implementation to handle the object has a function to export that object in\nOSSLPARAM(3) array form, the ENCODER implementation should be able to import that array and\ncreate a suitable object to be passed to OSSLFUNCencoderencode()'s objraw.\n\nOSSLFUNCencoderimportobject() should import the subset of params given with selection to\ncreate a provider-native object that can be passed as objraw to OSSLFUNCencoderencode().\n\nOSSLFUNCencoderfreeobject() should free the object that was created with\nOSSLFUNCencoderimportobject().\n"
                },
                {
                    "name": "Encoding functions",
                    "content": "OSSLFUNCencoderencode() should take a provider-native object (in objraw) or an object\nabstraction (in objabstract), and should output the object in encoded form to the\nOSSLCOREBIO.  The selection bits, if relevant, should determine in greater detail what will\nbe output.  The encoding functions also take an OSSLPASSPHRASECALLBACK function pointer\nalong with a pointer to application data cbarg, which should be used when a pass phrase\nprompt is needed.\n"
                },
                {
                    "name": "Encoder operation parameters",
                    "content": "Operation parameters currently recognised by built-in encoders are as follows:\n\n\"cipher\" (OSSLENCODERPARAMCIPHER) <UTF8 string>\nThe name of the encryption cipher to be used when generating encrypted encoding.  This is\nused when encoding private keys, as well as other objects that need protection.\n\nIf this name is invalid for the encoding implementation, the implementation should refuse\nto perform the encoding, i.e.  OSSLFUNCencoderencodedata() and\nOSSLFUNCencoderencodeobject() should return an error.\n\n\"properties\" (OSSLENCODERPARAMPROPERTIES) <UTF8 string>\nThe properties to be queried when trying to fetch the algorithm given with the \"cipher\"\nparameter.  This must be given together with the \"cipher\" parameter to be considered\nvalid.\n\nThe encoding implementation isn't obligated to use this value.  However, it is\nrecommended that implementations that do not handle property strings return an error on\nreceiving this parameter unless its value NULL or the empty string.\n\n\"save-parameters\" (OSSLENCODERPARAMSAVEPARAMETERS) <integer>\nIf set to 0 disables saving of key domain parameters. Default is 1.  It currently has an\neffect only on DSA keys.\n\nParameters currently recognised by the built-in pass phrase callback:\n\n\"info\" (OSSLPASSPHRASEPARAMINFO) <UTF8 string>\nA string of information that will become part of the pass phrase prompt.  This could be\nused to give the user information on what kind of object it's being prompted for.\n"
                }
            ]
        },
        "RETURN VALUES": {
            "content": "OSSLFUNCencodernewctx() returns a pointer to a context, or NULL on failure.\n\nOSSLFUNCencodersetctxparams() returns 1, unless a recognised parameter was invalid or\ncaused an error, for which 0 is returned.\n\nOSSLFUNCencodersettablectxparams() returns a pointer to an array of constant OSSLPARAM\nelements.\n\nOSSLFUNCencoderdoesselection() returns 1 if the encoder implementation supports any of\nthe selection bits, otherwise 0.\n\nOSSLFUNCencoderencode() returns 1 on success, or 0 on failure.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "provider(7)\n",
            "subsections": []
        },
        "HISTORY": {
            "content": "The ENCODER 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-ENCODER(7SSL)",
            "subsections": []
        }
    },
    "summary": "provider-encoder - The OSSLENCODER library <-> provider functions",
    "flags": [],
    "examples": [],
    "see_also": [
        {
            "name": "provider",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/provider/7/json"
        }
    ]
}