{
    "content": [
        {
            "type": "text",
            "text": "# EVP_PKEY-EC (man)\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** (2 subsections)\n- **EXAMPLES**\n- **SEE ALSO**\n- **COPYRIGHT**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "EVP_PKEY-EC",
        "section": "",
        "mode": "man",
        "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": 2,
                "subsections": [
                    {
                        "name": "Common EC parameters",
                        "lines": 122
                    },
                    {
                        "name": "EC key validation",
                        "lines": 14
                    }
                ]
            },
            {
                "name": "EXAMPLES",
                "lines": 59,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "COPYRIGHT",
                "lines": 7,
                "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",
                "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\ncompatibility 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  whether 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\nSee also EVPKEYEXCH-ECDH(7) for  the  related  OSSLEXCHANGEPARAMECECDHCOFACTORMODE\nparameter that can be set on a per-operation basis.\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 similar 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\n\"pub\" (OSSLPKEYPARAMPUBKEY) <octet string>\nThe public key value in encoded EC point format conforming to Sec. 2.3.3 and 2.3.4 of the\nSECG  SEC  1  (\"Elliptic  Curve  Cryptography\")  standard.   This  parameter is used when\nimporting  or  exporting  the  public  key  value  with   the   EVPPKEYfromdata()   and\nEVPPKEYtodata() functions.\n\nNote,  in  particular,  that the choice of point compression format used for encoding the\nexported value via EVPPKEYtodata() depends on the underlying  provider  implementation.\nBefore  OpenSSL 3.0.8, the implementation of providers included with OpenSSL always opted\nfor an  encoding  in  compressed  format,  unconditionally.   Since  OpenSSL  3.0.8,  the\nimplementation  has  been changed to honor the OSSLPKEYPARAMECPOINTCONVERSIONFORMAT\nparameter, if set, or to default to uncompressed 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\"default-digest\" (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"
                    },
                    {
                        "name": "EC key validation",
                        "content": "For EC keys, EVPPKEYparamcheck(3) behaves in the following way: For  the  OpenSSL  default\nprovider  it  uses either ECGROUPcheck(3) or ECGROUPchecknamedcurve(3) depending on the\nflag ECFLAGCHECKNAMEDGROUP.  The OpenSSL FIPS provider uses ECGROUPchecknamedcurve(3)\nin order to conform to SP800-56Ar3 Assurances of Domain-Parameter Validity.\n\nFor EC keys, EVPPKEYparamcheckquick(3) is equivalent to EVPPKEYparamcheck(3).\n\nFor  EC  keys,  EVPPKEYpubliccheck(3)  and   EVPPKEYpubliccheckquick(3)   conform   to\nSP800-56Ar3   ECC   Full   Public-Key   Validation  and  ECC  Partial  Public-Key  Validation\nrespectively.\n\nFor EC Keys, EVPPKEYprivatecheck(3) and EVPPKEYpairwisecheck(3) conform to  SP800-56Ar3\nPrivate key validity and Owner Assurance of Pair-wise Consistency respectively.\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-2023 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\n3.0.13                                       2026-07-29                            EVPPKEY-EC(7SSL)",
                "subsections": []
            }
        }
    }
}