{
    "mode": "info",
    "parameter": "PROVIDER-ASYM_CIPHER",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/info/PROVIDER-ASYM_CIPHER/json",
    "generated": "2026-07-05T13:21:45Z",
    "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 *OSSLFUNCasymciphernewctx(void *provctx);\nvoid OSSLFUNCasymcipherfreectx(void *ctx);\nvoid *OSSLFUNCasymcipherdupctx(void *ctx);\n/* Encryption */\nint OSSLFUNCasymcipherencryptinit(void *ctx, void *provkey,\nconst OSSLPARAM params[]);\nint OSSLFUNCasymcipherencrypt(void *ctx, unsigned char *out, sizet *outlen,\nsizet outsize, const unsigned char *in,\nsizet inlen);\n/* Decryption */\nint OSSLFUNCasymcipherdecryptinit(void *ctx, void *provkey,\nconst OSSLPARAM params[]);\nint OSSLFUNCasymcipherdecrypt(void *ctx, unsigned char *out, sizet *outlen,\nsizet outsize, const unsigned char *in,\nsizet inlen);\n/* Asymmetric Cipher parameters */\nint OSSLFUNCasymciphergetctxparams(void *ctx, OSSLPARAM params[]);\nconst OSSLPARAM *OSSLFUNCasymciphergettablectxparams(void *provctx);\nint OSSLFUNCasymciphersetctxparams(void *ctx, const OSSLPARAM params[]);\nconst OSSLPARAM *OSSLFUNCasymciphersettablectxparams(void *provctx);",
    "sections": {
        "NAME": {
            "content": "provider-asymcipher - The asymcipher 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 *OSSLFUNCasymciphernewctx(void *provctx);\nvoid OSSLFUNCasymcipherfreectx(void *ctx);\nvoid *OSSLFUNCasymcipherdupctx(void *ctx);\n\n/* Encryption */\nint OSSLFUNCasymcipherencryptinit(void *ctx, void *provkey,\nconst OSSLPARAM params[]);\nint OSSLFUNCasymcipherencrypt(void *ctx, unsigned char *out, sizet *outlen,\nsizet outsize, const unsigned char *in,\nsizet inlen);\n\n/* Decryption */\nint OSSLFUNCasymcipherdecryptinit(void *ctx, void *provkey,\nconst OSSLPARAM params[]);\nint OSSLFUNCasymcipherdecrypt(void *ctx, unsigned char *out, sizet *outlen,\nsizet outsize, const unsigned char *in,\nsizet inlen);\n\n/* Asymmetric Cipher parameters */\nint OSSLFUNCasymciphergetctxparams(void *ctx, OSSLPARAM params[]);\nconst OSSLPARAM *OSSLFUNCasymciphergettablectxparams(void *provctx);\nint OSSLFUNCasymciphersetctxparams(void *ctx, const OSSLPARAM params[]);\nconst OSSLPARAM *OSSLFUNCasymciphersettablectxparams(void *provctx);\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This documentation is primarily aimed at provider authors. See\nprovider(7) for further information.\n\nThe asymmetric cipher (OSSLOPASYMCIPHER) operation enables providers\nto implement asymmetric cipher algorithms and make them available to\napplications via the API functions EVPPKEYencrypt(3),\nEVPPKEYdecrypt(3) and other related functions).\n\nAll \"functions\" mentioned here are passed as function pointers between\nlibcrypto and the provider in OSSLDISPATCH arrays via OSSLALGORITHM\narrays that are returned by the provider's providerqueryoperation()\nfunction (see \"Provider Functions\" in provider-base(7)).\n\nAll these \"functions\" have a corresponding function type definition\nnamed OSSLFUNC{name}fn, and a helper function to retrieve the\nfunction pointer from an OSSLDISPATCH element named OSSLFUNC{name}.\nFor example, the \"function\" OSSLFUNCasymciphernewctx() has these:\n\ntypedef void *(OSSLFUNCasymciphernewctxfn)(void *provctx);\nstatic osslinline OSSLFUNCasymciphernewctxfn\nOSSLFUNCasymciphernewctx(const OSSLDISPATCH *opf);\n\nOSSLDISPATCH arrays are indexed by numbers that are provided as macros\nin openssl-coredispatch.h(7), as follows:\n\nOSSLFUNCasymciphernewctx               OSSLFUNCASYMCIPHERNEWCTX\nOSSLFUNCasymcipherfreectx              OSSLFUNCASYMCIPHERFREECTX\nOSSLFUNCasymcipherdupctx               OSSLFUNCASYMCIPHERDUPCTX\n\nOSSLFUNCasymcipherencryptinit         OSSLFUNCASYMCIPHERENCRYPTINIT\nOSSLFUNCasymcipherencrypt              OSSLFUNCASYMCIPHERENCRYPT\n\nOSSLFUNCasymcipherdecryptinit         OSSLFUNCASYMCIPHERDECRYPTINIT\nOSSLFUNCasymcipherdecrypt              OSSLFUNCASYMCIPHERDECRYPT\n\nOSSLFUNCasymciphergetctxparams       OSSLFUNCASYMCIPHERGETCTXPARAMS\nOSSLFUNCasymciphergettablectxparams  OSSLFUNCASYMCIPHERGETTABLECTXPARAMS\nOSSLFUNCasymciphersetctxparams       OSSLFUNCASYMCIPHERSETCTXPARAMS\nOSSLFUNCasymciphersettablectxparams  OSSLFUNCASYMCIPHERSETTABLECTXPARAMS\n\nAn asymmetric cipher algorithm implementation may not implement all of\nthese functions.  In order to be a consistent set of functions a\nprovider must implement OSSLFUNCasymciphernewctx and\nOSSLFUNCasymcipherfreectx.  It must also implement both of\nOSSLFUNCasymcipherencryptinit and OSSLFUNCasymcipherencrypt,\nor both of OSSLFUNCasymcipherdecryptinit and\nOSSLFUNCasymcipherdecrypt.  OSSLFUNCasymciphergetctxparams is\noptional but if it is present then so must\nOSSLFUNCasymciphergettablectxparams.  Similarly,\nOSSLFUNCasymciphersetctxparams is optional but if it is present\nthen so must OSSLFUNCasymciphersettablectxparams.\n\nAn asymmetric cipher algorithm must also implement some mechanism for\ngenerating, loading or importing keys via the key management\n(OSSLOPKEYMGMT) operation.  See provider-keymgmt(7) for further\ndetails.\n\nContext Management Functions\nOSSLFUNCasymciphernewctx() should create and return a pointer to a\nprovider side structure for holding context information during an\nasymmetric cipher operation.  A pointer to this context will be passed\nback in a number of the other asymmetric cipher operation function\ncalls.  The parameter provctx is the provider context generated during\nprovider initialisation (see provider(7)).\n\nOSSLFUNCasymcipherfreectx() is passed a pointer to the provider\nside asymmetric cipher context in the ctx parameter.  This function\nshould free any resources associated with that context.\n\nOSSLFUNCasymcipherdupctx() should duplicate the provider side\nasymmetric cipher context in the ctx parameter and return the duplicate\ncopy.\n\nEncryption Functions\nOSSLFUNCasymcipherencryptinit() initialises a context for an\nasymmetric encryption given a provider side asymmetric cipher context\nin the ctx parameter, and a pointer to a provider key object in the\nprovkey parameter.  The params, if not NULL, should be set on the\ncontext in a manner similar to using\nOSSLFUNCasymciphersetctxparams().  The key object should have\nbeen previously generated, loaded or imported into the provider using\nthe key management (OSSLOPKEYMGMT) operation (see\nprovider-keymgmt(7)>.  OSSLFUNCasymcipherencrypt() performs the\nactual encryption itself.  A previously initialised asymmetric cipher\ncontext is passed in the ctx parameter.  The data to be encrypted is\npointed to by the in parameter which is inlen bytes long.  Unless out\nis NULL, the encrypted data should be written to the location pointed\nto by the out parameter and it should not exceed outsize bytes in\nlength.  The length of the encrypted data should be written to *outlen.\nIf out is NULL then the maximum length of the encrypted data should be\nwritten to *outlen.\n\nDecryption Functions\nOSSLFUNCasymcipherdecryptinit() initialises a context for an\nasymmetric decryption given a provider side asymmetric cipher context\nin the ctx parameter, and a pointer to a provider key object in the\nprovkey parameter.  The params, if not NULL, should be set on the\ncontext in a manner similar to using\nOSSLFUNCasymciphersetctxparams().  The key object should have\nbeen previously generated, loaded or imported into the provider using\nthe key management (OSSLOPKEYMGMT) operation (see\nprovider-keymgmt(7)>.\n\nOSSLFUNCasymcipherdecrypt() performs the actual decryption itself.\nA previously initialised asymmetric cipher context is passed in the ctx\nparameter.  The data to be decrypted is pointed to by the in parameter\nwhich is inlen bytes long.  Unless out is NULL, the decrypted data\nshould be written to the location pointed to by the out parameter and\nit should not exceed outsize bytes in length.  The length of the\ndecrypted data should be written to *outlen.  If out is NULL then the\nmaximum length of the decrypted data should be written to *outlen.\n\nAsymmetric Cipher Parameters\nSee OSSLPARAM(3) for further details on the parameters structure used\nby the OSSLFUNCasymciphergetctxparams() and\nOSSLFUNCasymciphersetctxparams() functions.\n\nOSSLFUNCasymciphergetctxparams() gets asymmetric cipher\nparameters associated with the given provider side asymmetric cipher\ncontext ctx and stores them in params.  Passing NULL for params should\nreturn true.\n\nOSSLFUNCasymciphersetctxparams() sets the asymmetric cipher\nparameters associated with the given provider side asymmetric cipher\ncontext ctx to params.  Any parameter settings are additional to any\nthat were previously set.  Passing NULL for params should return true.\n\nParameters currently recognised by built-in asymmetric cipher\nalgorithms are as follows.  Not all parameters are relevant to, or are\nunderstood by all asymmetric cipher algorithms:\n\n\"pad-mode\" (OSSLASYMCIPHERPARAMPADMODE) <integer>\nThe type of padding to be used. The interpretation of this value\nwill depend on the algorithm in use. The default provider\nunderstands these RSA padding modes: 1 (RSAPKCS1PADDING), 3\n(RSANOPADDING), 4 (RSAPKCS1OAEPPADDING), 5 (RSAX931PADDING),\n6 (RSAPKCS1PSSPADDING) and 7 (RSAPKCS1WITHTLSPADDING). See\nEVPPKEYCTXsetrsapadding(3) for further details.\n\n\"digest\" (OSSLASYMCIPHERPARAMOAEPDIGEST) <UTF8 string>\nGets or sets the name of the OAEP digest algorithm used when OAEP\npadding is in use.\n\n\"digest\" (OSSLASYMCIPHERPARAMDIGEST) <UTF8 string>\nGets or sets the name of the digest algorithm used by the algorithm\n(where applicable).\n\n\"digest-props\" (OSSLASYMCIPHERPARAMOAEPDIGESTPROPS) <UTF8 string>\nGets or sets the properties to use when fetching the OAEP digest\nalgorithm.\n\n\"digest-props\" (OSSLASYMCIPHERPARAMDIGESTPROPS) <UTF8 string>\nGets or sets the properties to use when fetching the cipher digest\nalgorithm.\n\n\"mgf1-digest\" (OSSLASYMCIPHERPARAMMGF1DIGEST) <UTF8 string>\nGets or sets the name of the MGF1 digest algorithm used when OAEP\nor PSS padding is in use.\n\n\"mgf1-digest-props\" (OSSLASYMCIPHERPARAMMGF1DIGESTPROPS) <UTF8\nstring>\nGets or sets the properties to use when fetching the MGF1 digest\nalgorithm.\n\n\"oaep-label\" (OSSLASYMCIPHERPARAMOAEPLABEL) <octet string>\nGets or sets the OAEP label used when OAEP padding is in use.\n\n\"tls-client-version\" (OSSLASYMCIPHERPARAMTLSCLIENTVERSION)\n<unsigned integer>\nThe TLS protocol version first requested by the client. See\nRSAPKCS1WITHTLSPADDING on the page\nEVPPKEYCTXsetrsapadding(3).\n\n\"tls-negotiated-version\" (OSSLASYMCIPHERPARAMTLSCLIENTVERSION)\n<unsigned integer>\nThe negotiated TLS protocol version. See RSAPKCS1WITHTLSPADDING\non the page EVPPKEYCTXsetrsapadding(3).\n\n\"implicit-rejection\" (OSSLPKEYPARAMIMPLICITREJECTION) <unsigned\ninteger>\nGets of sets the use of the implicit rejection mechanism for RSA\nPKCS#1 v1.5 decryption. When set (non zero value), the decryption\nAPI will return a deterministically random value if the PKCS#1 v1.5\npadding check fails.  This makes explotation of the Bleichenbacher\nsignificantly harder, even if the code using the RSA decryption API\nis not implemented in side-channel free manner. Set by default.\n\nOSSLFUNCasymciphergettablectxparams() and\nOSSLFUNCasymciphersettablectxparams() get a constant OSSLPARAM\narray that describes the gettable and settable parameters, i.e.\nparameters that can be used with OSSLFUNCasymciphergetctxparams()\nand OSSLFUNCasymciphersetctxparams() respectively.  See\nOSSLPARAM(3) for the use of OSSLPARAM as parameter descriptor.\n",
            "subsections": []
        },
        "RETURN VALUES": {
            "content": "OSSLFUNCasymciphernewctx() and OSSLFUNCasymcipherdupctx()\nshould return the newly created provider side asymmetric cipher\ncontext, or NULL on failure.\n\nAll other functions should return 1 for success or 0 on error.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "provider(7)\n",
            "subsections": []
        },
        "HISTORY": {
            "content": "The provider ASYMCIPHER 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\nthis file except in compliance with the License.  You can obtain a copy\nin the file LICENSE in the source distribution or at\n<https://www.openssl.org/source/license.html>.\n\n3.0.2                             2026-06-02        PROVIDER-ASYMCIPHER(7SSL)",
            "subsections": []
        }
    },
    "summary": "provider-asymcipher - The asymcipher library <-> provider functions",
    "flags": [],
    "examples": [],
    "see_also": [
        {
            "name": "provider",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/provider/7/json"
        }
    ]
}