{
    "content": [
        {
            "type": "text",
            "text": "# EVP_KEYMGMT-EC (info)\n\n## NAME\n\nEVPPKEY-EC, EVPKEYMGMT-EC - EVPPKEY EC keytype and algorithm support\n\n## DESCRIPTION\n\nThe EC keytype is implemented in OpenSSL's default provider.\n\n## Sections\n\n- **NAME**\n- **DESCRIPTION**\n- **EXAMPLES**\n- **SEE ALSO**\n- **COPYRIGHT**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "EVP_KEYMGMT-EC",
        "section": "",
        "mode": "info",
        "summary": "EVPPKEY-EC, EVPKEYMGMT-EC - EVPPKEY EC keytype and algorithm support",
        "synopsis": null,
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [
            "An EVPPKEY context can be obtained by calling:",
            "EVPPKEYCTX *pctx =",
            "EVPPKEYCTXnewfromname(NULL, \"EC\", NULL);",
            "An EVPPKEY ECDSA or ECDH key can be generated with a \"P-256\" named",
            "group by calling:",
            "pkey = EVPECgen(\"P-256\");",
            "or like this:",
            "EVPPKEY *key = NULL;",
            "OSSLPARAM params[2];",
            "EVPPKEYCTX *gctx =",
            "EVPPKEYCTXnewfromname(NULL, \"EC\", NULL);",
            "EVPPKEYkeygeninit(gctx);",
            "params[0] = OSSLPARAMconstructutf8string(OSSLPKEYPARAMGROUPNAME,",
            "\"P-256\", 0);",
            "params[1] = OSSLPARAMconstructend();",
            "EVPPKEYCTXsetparams(gctx, params);",
            "EVPPKEYgenerate(gctx, &key);",
            "EVPPKEYprintprivate(bioout, key, 0, NULL);",
            "...",
            "EVPPKEYfree(key);",
            "EVPPKEYCTXfree(gctx);",
            "An EVPPKEY EC CDH (Cofactor Diffie-Hellman) key can be generated with",
            "a \"K-571\" named group by calling:",
            "int usecdh = 1;",
            "EVPPKEY *key = NULL;",
            "OSSLPARAM params[3];",
            "EVPPKEYCTX *gctx =",
            "EVPPKEYCTXnewfromname(NULL, \"EC\", NULL);",
            "EVPPKEYkeygeninit(gctx);",
            "params[0] = OSSLPARAMconstructutf8string(OSSLPKEYPARAMGROUPNAME,",
            "\"K-571\", 0);",
            "/*",
            "* This curve has a cofactor that is not 1 - so setting CDH mode changes",
            "* the behaviour. For many curves the cofactor is 1 - so setting this has",
            "* no effect.",
            "*/",
            "params[1] = OSSLPARAMconstructint(OSSLPKEYPARAMUSECOFACTORECDH,",
            "&usecdh);",
            "params[2] = OSSLPARAMconstructend();",
            "EVPPKEYCTXsetparams(gctx, params);",
            "EVPPKEYgenerate(gctx, &key);",
            "EVPPKEYprintprivate(bioout, key, 0, NULL);",
            "...",
            "EVPPKEYfree(key);",
            "EVPPKEYCTXfree(gctx);"
        ],
        "see_also": [
            {
                "name": "EVPECgen",
                "section": "3",
                "url": "https://www.chedong.com/phpMan.php/man/EVPECgen/3/json"
            },
            {
                "name": "EVPKEYMGMT",
                "section": "3",
                "url": "https://www.chedong.com/phpMan.php/man/EVPKEYMGMT/3/json"
            },
            {
                "name": "EVPPKEY",
                "section": "3",
                "url": "https://www.chedong.com/phpMan.php/man/EVPPKEY/3/json"
            },
            {
                "name": "provider-keymgmt",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/provider-keymgmt/7/json"
            },
            {
                "name": "EVPSIGNATURE-ECDSA",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/EVPSIGNATURE-ECDSA/7/json"
            },
            {
                "name": "EVPKEYEXCH-ECDH",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/EVPKEYEXCH-ECDH/7/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 132,
                "subsections": []
            },
            {
                "name": "EXAMPLES",
                "lines": 60,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "COPYRIGHT",
                "lines": 8,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "EVPPKEY-EC, EVPKEYMGMT-EC - EVPPKEY EC keytype and algorithm support\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "The EC keytype is implemented in OpenSSL's default provider.\n\nCommon EC parameters\nThe normal way of specifying domain parameters for an EC curve is via\nthe curve name \"group\". For curves with no curve name, explicit\nparameters can be used that specify \"field-type\", \"p\", \"a\", \"b\",\n\"generator\" and \"order\".  Explicit parameters are supported for\nbackwards compability reasons, but they are not compliant with multiple\nstandards (including RFC5915) which only allow named curves.\n\nThe following KeyGen/Gettable/Import/Export types are available for the\nbuilt-in EC algorithm:\n\n\"group\" (OSSLPKEYPARAMGROUPNAME) <UTF8 string>\nThe curve name.\n\n\"field-type\" (OSSLPKEYPARAMECFIELDTYPE) <UTF8 string>\nThe value should be either \"prime-field\" or \"characteristic-two-\nfield\", which correspond to prime field Fp and binary field F2^m.\n\n\"p\" (OSSLPKEYPARAMECP) <unsigned integer>\nFor a curve over Fp p is the prime for the field. For a curve over\nF2^m p represents the irreducible polynomial - each bit represents\na term in the polynomial. Therefore, there will either be three or\nfive bits set dependent on whether the polynomial is a trinomial or\na pentanomial.\n\n\"a\" (OSSLPKEYPARAMECA) <unsigned integer>\n\"b\" (OSSLPKEYPARAMECB) <unsigned integer>\n\"seed\" (OSSLPKEYPARAMECSEED) <octet string>\na and b represents the coefficients of the curve For Fp:   y^2 mod\np = x^3 +ax + b mod p OR For F2^m: y^2 + xy = x^3 + ax^2 + b\n\nseed is an optional value that is for information purposes only.\nIt represents the random number seed used to generate the\ncoefficient b from a random number.\n\n\"generator\" (OSSLPKEYPARAMECGENERATOR) <octet string>\n\"order\" (OSSLPKEYPARAMECORDER) <unsigned integer>\n\"cofactor\" (OSSLPKEYPARAMECCOFACTOR) <unsigned integer>\nThe generator is a well defined point on the curve chosen for\ncryptographic operations. The encoding conforms with Sec. 2.3.3 of\nthe SECG SEC 1 (\"Elliptic Curve Cryptography\") standard. See\nECPOINToct2point().  Integers used for point multiplications will\nbe between 0 and order - 1.  cofactor is an optional value.  order\nmultiplied by the cofactor gives the number of points on the curve.\n\n\"decoded-from-explicit\"\n(OSSLPKEYPARAMECDECODEDFROMEXPLICITPARAMS) <integer>\nGets a flag indicating wether the key or parameters were decoded\nfrom explicit curve parameters. Set to 1 if so or 0 if a named\ncurve was used.\n\n\"use-cofactor-flag\" (OSSLPKEYPARAMUSECOFACTORECDH) <integer>\nEnable Cofactor DH (ECC CDH) if this value is 1, otherwise it uses\nnormal EC DH if the value is zero. The cofactor variant multiplies\nthe shared secret by the EC curve's cofactor (note for some curves\nthe cofactor is 1).\n\n\"encoding\" (OSSLPKEYPARAMECENCODING) <UTF8 string>\nSet the format used for serializing the EC group parameters.  Valid\nvalues are \"explicit\" or \"namedcurve\". The default value is\n\"namedcurve\".\n\n\"point-format\" (OSSLPKEYPARAMECPOINTCONVERSIONFORMAT) <UTF8\nstring>\nSets or gets the pointconversionform for the key. For a\ndescription of pointconversionforms please see ECPOINTnew(3).\nValid values are \"uncompressed\" or \"compressed\". The default value\nis \"uncompressed\".\n\n\"group-check\" (OSSLPKEYPARAMECGROUPCHECKTYPE) <UTF8 string>\nSets or Gets the type of group check done when\nEVPPKEYparamcheck() is called.  Valid values are \"default\",\n\"named\" and \"named-nist\".  The \"named\" type checks that the domain\nparameters match the inbuilt curve parameters, \"named-nist\" is\nsimiliar but also checks that the named curve is a nist curve.  The\n\"default\" type does domain parameter validation for the OpenSSL\ndefault provider, but is equivalent to \"named-nist\" for the OpenSSL\nfips provider.\n\n\"include-public\" (OSSLPKEYPARAMECINCLUDEPUBLIC) <integer>\nSetting this value to 0 indicates that the public key should not be\nincluded when encoding the private key. The default value of 1 will\ninclude the public key.\n\nSee also EVPKEYEXCH-ECDH(7) for the related\nOSSLEXCHANGEPARAMECECDHCOFACTORMODE parameter that can be set\non a per-operation basis.\n\n\"pub\" (OSSLPKEYPARAMPUBKEY) <octet string>\nThe public key value in EC point format.\n\n\"priv\" (OSSLPKEYPARAMPRIVKEY) <unsigned integer>\nThe private key value.\n\n\"encoded-pub-key\" (OSSLPKEYPARAMENCODEDPUBLICKEY) <octet string>\nUsed for getting and setting the encoding of an EC public key. The\npublic key is expected to be a point conforming to Sec. 2.3.4 of\nthe SECG SEC 1 (\"Elliptic Curve Cryptography\") standard.\n\n\"qx\" (OSSLPKEYPARAMECPUBX) <unsigned integer>\nUsed for getting the EC public key X component.\n\n\"qy\" (OSSLPKEYPARAMECPUBY) <unsigned integer>\nUsed for getting the EC public key Y component.\n\n(OSSLPKEYPARAMDEFAULTDIGEST) <UTF8 string>\nGetter that returns the default digest name.  (Currently returns\n\"SHA256\" as of OpenSSL 3.0).\n\nThe following Gettable types are also available for the built-in EC\nalgorithm:\n\n\"basis-type\" (OSSLPKEYPARAMECCHAR2TYPE) <UTF8 string>\nSupports the values \"tpBasis\" for a trinomial or \"ppBasis\" for a\npentanomial.  This field is only used for a binary field F2^m.\n\n\"m\" (OSSLPKEYPARAMECCHAR2M) <integer>\n\"tp\" (OSSLPKEYPARAMECCHAR2TPBASIS) <integer>\n\"k1\" (OSSLPKEYPARAMECCHAR2PPK1) <integer>\n\"k2\" (OSSLPKEYPARAMECCHAR2PPK2) <integer>\n\"k3\" (OSSLPKEYPARAMECCHAR2PPK3) <integer>\nThese fields are only used for a binary field F2^m.  m is the\ndegree of the binary field.\n\ntp is the middle bit of a trinomial so its value must be in the\nrange m > tp > 0.\n\nk1, k2 and k3 are used to get the middle bits of a pentanomial such\nthat m > k3 > k2 > k1 > 0\n",
                "subsections": []
            },
            "EXAMPLES": {
                "content": "An EVPPKEY context can be obtained by calling:\n\nEVPPKEYCTX *pctx =\nEVPPKEYCTXnewfromname(NULL, \"EC\", NULL);\n\nAn EVPPKEY ECDSA or ECDH key can be generated with a \"P-256\" named\ngroup by calling:\n\npkey = EVPECgen(\"P-256\");\n\nor like this:\n\nEVPPKEY *key = NULL;\nOSSLPARAM params[2];\nEVPPKEYCTX *gctx =\nEVPPKEYCTXnewfromname(NULL, \"EC\", NULL);\n\nEVPPKEYkeygeninit(gctx);\n\nparams[0] = OSSLPARAMconstructutf8string(OSSLPKEYPARAMGROUPNAME,\n\"P-256\", 0);\nparams[1] = OSSLPARAMconstructend();\nEVPPKEYCTXsetparams(gctx, params);\n\nEVPPKEYgenerate(gctx, &key);\n\nEVPPKEYprintprivate(bioout, key, 0, NULL);\n...\nEVPPKEYfree(key);\nEVPPKEYCTXfree(gctx);\n\nAn EVPPKEY EC CDH (Cofactor Diffie-Hellman) key can be generated with\na \"K-571\" named group by calling:\n\nint usecdh = 1;\nEVPPKEY *key = NULL;\nOSSLPARAM params[3];\nEVPPKEYCTX *gctx =\nEVPPKEYCTXnewfromname(NULL, \"EC\", NULL);\n\nEVPPKEYkeygeninit(gctx);\n\nparams[0] = OSSLPARAMconstructutf8string(OSSLPKEYPARAMGROUPNAME,\n\"K-571\", 0);\n/*\n* This curve has a cofactor that is not 1 - so setting CDH mode changes\n* the behaviour. For many curves the cofactor is 1 - so setting this has\n* no effect.\n*/\nparams[1] = OSSLPARAMconstructint(OSSLPKEYPARAMUSECOFACTORECDH,\n&usecdh);\nparams[2] = OSSLPARAMconstructend();\nEVPPKEYCTXsetparams(gctx, params);\n\nEVPPKEYgenerate(gctx, &key);\nEVPPKEYprintprivate(bioout, key, 0, NULL);\n...\nEVPPKEYfree(key);\nEVPPKEYCTXfree(gctx);\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "EVPECgen(3), EVPKEYMGMT(3), EVPPKEY(3), provider-keymgmt(7),\nEVPSIGNATURE-ECDSA(7), EVPKEYEXCH-ECDH(7)\n",
                "subsections": []
            },
            "COPYRIGHT": {
                "content": "Copyright 2020-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                 EVPPKEY-EC(7SSL)",
                "subsections": []
            }
        }
    }
}