{
    "mode": "man",
    "parameter": "EVP_PKEY-EC",
    "section": "7",
    "url": "https://www.chedong.com/phpMan.php/man/EVP_PKEY-EC/7/json",
    "generated": "2026-06-14T07:28:04Z",
    "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",
            "subsections": [
                {
                    "name": "Common EC parameters",
                    "content": "The normal way of specifying domain parameters for an EC curve is via the curve name \"group\".\nFor curves with no curve name, explicit parameters can be used that specify \"field-type\",\n\"p\", \"a\", \"b\", \"generator\" and \"order\".  Explicit parameters are supported for backwards\ncompability reasons, but they are not compliant with multiple standards (including RFC5915)\nwhich only allow named curves.\n\nThe following KeyGen/Gettable/Import/Export types are available for the built-in EC\nalgorithm:\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-field\", which correspond\nto 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 F2^m p represents the\nirreducible polynomial - each bit represents a term in the polynomial. Therefore, there\nwill either be three or five bits set dependent on whether the polynomial is a trinomial\nor a 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 p = x^3 +ax + b mod p\nOR For F2^m: y^2 + xy = x^3 + ax^2 + b\n\nseed is an optional value that is for information purposes only.  It represents the\nrandom number seed used to generate the coefficient 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 cryptographic operations.\nThe encoding conforms with Sec. 2.3.3 of the SECG SEC 1 (\"Elliptic Curve Cryptography\")\nstandard. See ECPOINToct2point().  Integers used for point multiplications will be\nbetween 0 and order - 1.  cofactor is an optional value.  order multiplied by the\ncofactor gives the number of points on the curve.\n\n\"decoded-from-explicit\" (OSSLPKEYPARAMECDECODEDFROMEXPLICITPARAMS) <integer>\nGets a flag indicating wether the key or parameters were decoded from explicit curve\nparameters. Set to 1 if so or 0 if a named curve was used.\n\n\"use-cofactor-flag\" (OSSLPKEYPARAMUSECOFACTORECDH) <integer>\nEnable Cofactor DH (ECC CDH) if this value is 1, otherwise it uses normal EC DH if the\nvalue is zero. The cofactor variant multiplies the shared secret by the EC curve's\ncofactor (note for some curves the cofactor is 1).\n\n\"encoding\" (OSSLPKEYPARAMECENCODING) <UTF8 string>\nSet the format used for serializing the EC group parameters.  Valid values are \"explicit\"\nor \"namedcurve\". The default value is \"namedcurve\".\n\n\"point-format\" (OSSLPKEYPARAMECPOINTCONVERSIONFORMAT) <UTF8 string>\nSets or gets the pointconversionform for the key. For a description of\npointconversionforms please see ECPOINTnew(3). Valid values are \"uncompressed\" or\n\"compressed\". The default value is \"uncompressed\".\n\n\"group-check\" (OSSLPKEYPARAMECGROUPCHECKTYPE) <UTF8 string>\nSets or Gets the type of group check done when EVPPKEYparamcheck() is called.  Valid\nvalues are \"default\", \"named\" and \"named-nist\".  The \"named\" type checks that the domain\nparameters match the inbuilt curve parameters, \"named-nist\" is similiar but also checks\nthat the named curve is a nist curve.  The \"default\" type does domain parameter\nvalidation for the OpenSSL default provider, but is equivalent to \"named-nist\" for the\nOpenSSL fips provider.\n\n\"include-public\" (OSSLPKEYPARAMECINCLUDEPUBLIC) <integer>\nSetting this value to 0 indicates that the public key should not be included when\nencoding the private key. The default value of 1 will include the public key.\n\nSee also EVPKEYEXCH-ECDH(7) for the related OSSLEXCHANGEPARAMECECDHCOFACTORMODE\nparameter that can be set on 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 public key is expected\nto be a point conforming to Sec. 2.3.4 of the SECG SEC 1 (\"Elliptic Curve Cryptography\")\nstandard.\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 \"SHA256\" as of OpenSSL\n3.0).\n\nThe following Gettable types are also available for the built-in EC algorithm:\n\n\"basis-type\" (OSSLPKEYPARAMECCHAR2TYPE) <UTF8 string>\nSupports the values \"tpBasis\" for a trinomial or \"ppBasis\" for a pentanomial.  This field\nis 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 degree of the binary field.\n\ntp is the middle bit of a trinomial so its value must be in the range m > tp > 0.\n\nk1, k2 and k3 are used to get the middle bits of a pentanomial such that m > k3 > k2 > k1\n> 0\n"
                }
            ]
        },
        "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 group 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 a \"K-571\" named group\nby 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), EVPSIGNATURE-ECDSA(7),\nEVPKEYEXCH-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 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-06-02                            EVPPKEY-EC(7SSL)",
            "subsections": []
        }
    },
    "summary": "EVPPKEY-EC, EVPKEYMGMT-EC - EVPPKEY EC keytype and algorithm support",
    "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"
        }
    ]
}