EC_GROUP_NEW_CURVE_GFP(3)
π EC_GROUP_NEW_CURVE_GFP(3) β Library Functions Manual, but make it cute π
okay so bestie, this is the Library Functions Manual page for EC_GROUP_NEW_CURVE_GFP(3), and we are getting into elliptic curve group territory. π
πΈ NAME πΈ
EC_GROUP_new_curve_GFpEC_GROUP_set_curveEC_GROUP_get_curveEC_GROUP_set_generatorEC_GROUP_get0_generatorEC_GROUP_get_degreeEC_GROUP_get_orderEC_GROUP_order_bitsEC_GROUP_get_cofactorEC_GROUP_clear_freeEC_GROUP_set_curve_GFpEC_GROUP_get_curve_GFp
β define elliptic curves and retrieve information from them. periodt. β¨
π SYNOPSIS π
library βlibcryptoβ #include <openssl/bn.h>
#include <openssl/ec.h>
EC_GROUP *
EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a,
const BIGNUM *b, BN_CTX *ctx);
int
EC_GROUP_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a,
const BIGNUM *b, BN_CTX *ctx);
int
EC_GROUP_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a,
BIGNUM *b, BN_CTX *ctx);
int
EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator,
const BIGNUM *order, const BIGNUM *cofactor);
const EC_POINT *
EC_GROUP_get0_generator(const EC_GROUP *group);
int
EC_GROUP_get_degree(const EC_GROUP *);
int
EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx);
int
EC_GROUP_order_bits(const EC_GROUP *group);
int
EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor,
BN_CTX *ctx);
Deprecated:
void
EC_GROUP_clear_free(EC_GROUP *group);
int
EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p,
const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
int
EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a,
BIGNUM *b, BN_CTX *ctx);
π¦ DESCRIPTION π¦
π¨ The one thing to remember, bestie: with the exception of the getters, the functions in this manual should not be used. Use EC_GROUP_new_by_curve_name(3) instead. no cap.
The EC library uses EC_GROUP objects to represent elliptic curves in Weierstrass form. These curves are defined over the prime field of order p via the Weierstrass equation
y^2 = x^3 + ax + b
where a and b are such that the discriminant 4a^3 - 27b^2 is non-zero. They consist of affine points, which are pairs of field elements (x, y) satisfying the Weierstrass equation, and an extra point at infinity. iconic behavior honestly. β¨
The points on an elliptic curve form a group. Cryptographic applications usually depend on the choice of a generator whose multiples form a cyclic subgroup of a certain order. By Lagrange's theorem, the number of points on the elliptic curve is the product of order and another integer called the cofactor. Hasse's theorem is the inequality
|order * cofactor - (p + 1)| <= 2 sqrt(p)
which implies an upper bound on order in terms of p and allows the computation of cofactor provided that order is large enough. math girlie behavior. π
EC_GROUP_new_curve_GFp()β instantiates a newEC_GROUPobject over the prime field of sizepwith Weierstrass equation given by the coefficientsaandb. The optionalctxis used to transform the other arguments into internal representation. It is the caller's responsibility to ensure thatpis a prime number greater than three and that the discriminant is non-zero. This can be done withEC_GROUP_check_discriminant(3)or as part ofEC_GROUP_check(3)afterEC_GROUP_set_generator().EC_GROUP_set_curve()β sets the curve parameters ofgrouptop,a,busing the optionalctx, and the comments inEC_GROUP_new_curve_GFp()apply. Existing generator, order, or cofactor ongroupare left unmodified and become most likely invalid. They must therefore be set to legitimate values usingEC_GROUP_set_generator().EC_GROUP_get_curve()β copies the curve parameters ofgroupinto the caller-ownedp,a, andb, possibly making use of thectxfor conversion from internal representations. Except forgroup, all arguments are optional.EC_GROUP_set_generator()β performs sanity checks based on Hasse's theorem and copiesgenerator,orderand the optionalcofactorintogroup, replacing all existing entries. It is the caller's responsibility to ensure thatgeneratoris a point on the curve and thatorderis its order, which can partially be accomplished with a subsequent call toEC_GROUP_check(3). IfcofactorisNULL, it can be computed on curves of cryptographic interest, in which casecofactoris set to the computed value, otherwise it is set to zero.EC_GROUP_get0_generator()β returns an internal pointer to the group's generator, which may beNULLif no generator was set.EC_GROUP_get_degree()β returns the bit length of the primepset ongroup.EC_GROUP_get_order()β copies the value of the group's order into the caller-ownedorder, returning failure if the group's order is zero. Thectxargument is ignored.EC_GROUP_order_bits()β returns the number of bits in the group's order, which is the result of callingBN_num_bits(3)onorder. UnlikeEC_GROUP_get_order(), it does not fail iforderis zero.EC_GROUP_get_cofactor()β copies the value of the group's cofactor into the caller-ownedcofactor, returning failure if the group's cofactor is zero. Thectxargument is ignored.EC_GROUP_clear_free()β deprecated. It usesexplicit_bzero(3)andfreezero(3)to clear and free all data associated withgroup. IfgroupisNULL, no action occurs. Since there is no secret data ingroup, this API is useless. In LibreSSL,EC_GROUP_free(3)andEC_GROUP_clear_free()behave identically.EC_GROUP_set_curve_GFp()andEC_GROUP_get_curve_GFp()β deprecated aliases forEC_GROUP_set_curve()andEC_GROUP_get_curve(), respectively.
π RETURN VALUES π
EC_GROUP_new_curve_GFp()returns a newly allocated group orNULLif memory allocation fails, or if some minimal sanity checks onp,a, andbfail.EC_GROUP_set_curve()andEC_GROUP_set_curve_GFp()return1on success and0on failure. Failure conditions include thatpis smaller than or equal to three, or even, or memory allocation failure.EC_GROUP_get_curve()andEC_GROUP_get_curve_GFp()return1on success and0on memory allocation failure.EC_GROUP_set_generator()returns1on success and0on memory allocation failure, or iforderorcofactorare larger than Hasse's theorem allows.EC_GROUP_get0_generator()returns an internal pointer to the generator orNULLif none was set ongroup.EC_GROUP_get_order()returns1on success or0on memory allocation failure or if the order is zero.EC_GROUP_get_cofactor()returns1on success or0on memory allocation failure or if the cofactor is zero.EC_GROUP_get_degree(), andEC_GROUP_order_bits()return the number of bits in the group'sp, andorder, respectively.
π SEE ALSO π
BN_new(3)BN_num_bits(3)crypto(3)d2i_ECPKParameters(3)EC_GROUP_check(3)EC_GROUP_get_curve_name(3)EC_GROUP_new_by_curve_name(3)EC_KEY_METHOD_new(3)EC_KEY_new(3)EC_POINT_add(3)EC_POINT_get_affine_coordinates(3)EC_POINT_new(3)EC_POINT_point2oct(3)ECDH_compute_key(3)ECDSA_SIG_new(3)
β STANDARDS β
- SEC 1: Elliptic Curve Cryptography, Version 2.0,
https://www.secg.org/sec1-v2.pdf, May 21, 2009. - SEC 2: Recommended Elliptic Curve Domain Parameters, Version 2.0,
https://www.secg.org/sec2-v2.pdf, Jan 27, 2010.
π§ HISTORY π§
EC_GROUP_new_curve_GFp(),EC_GROUP_clear_free(),EC_GROUP_set_curve_GFp(),EC_GROUP_get_curve_GFp(),EC_GROUP_set_generator(),EC_GROUP_get0_generator(),EC_GROUP_get_order(), andEC_GROUP_get_cofactor()first appeared in OpenSSL 0.9.7 and have been available since OpenBSD 3.2.EC_GROUP_get_degree()first appeared in OpenSSL 0.9.8 and has been available since OpenBSD 4.5.EC_GROUP_set_curve(),EC_GROUP_get_curve(), andEC_GROUP_order_bits()first appeared in OpenSSL 1.1.1 and have been available since OpenBSD 7.0
π BUGS π
Too many. The API is unergonomic and the design is very poor even by OpenSSL's standards. Naming is inconsistent, especially in regard to the _GFp suffix and the _get_ infix. Function signatures are inconsistent. In particular, functions that should have a BN_CTX argument don't have one and functions that don't need it have one. π
okay bye bestie π«Ά this Debian edition is dated August 31, 2025, and the page is EC_GROUP_NEW_CURVE_GFP(3) β periodt. π
β¨
π¦ where this page comes from
- alpine 3.24: libressl-doc 4.3.1-r0 Β· custom
- arch rolling: libressl 4.4.0-1 Β· ISC AND custom:OpenSSL
- Copyright (c) 2025 Theo Buehler <tb@openbsd.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms