EC_GROUP_GET_CURVE_NAME(3)
π EC_GROUP_GET_CURVE_NAME(3) β like, the whole curve-vibes manual, bestie π
okay so this is a page from the Library Functions Manual, and honestly? it's giving "backstage pass to how your elliptic curves get ASN.1-ified." buckle up π
β¨ NAME β¨
EC_GROUP_get_curve_name, EC_GROUP_set_curve_name, EC_GROUP_get_asn1_flag, EC_GROUP_set_asn1_flag, EC_GROUP_get0_seed, EC_GROUP_get_seed_len, EC_GROUP_set_seed, EC_GROUP_get_point_conversion_form, EC_GROUP_set_point_conversion_form, EC_GROUP_get_basis_type β these are the little guys that configure and inspect the deets of the ASN.1 encoding of EC_GROUP and related objects π«Ά
πΈ SYNOPSIS πΈ
the library is libcrypto, and you're gonna need this include, no cap:
#include <openssl/ec.h>
then the whole squad of function signatures, verbatim, because we do NOT paraphrase code:
int
EC_GROUP_get_curve_name(const EC_GROUP *group);
void
EC_GROUP_set_curve_name(EC_GROUP *group, int nid);
int
EC_GROUP_get_asn1_flag(const EC_GROUP *group);
void
EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag);
unsigned char *
EC_GROUP_get0_seed(const EC_GROUP *group);
size_t
EC_GROUP_get_seed_len(const EC_GROUP *group);
size_t
EC_GROUP_set_seed(EC_GROUP *group, const unsigned char *seed,
size_t len);
and this very iconic enum β please memorize the numbers, they're literally on the exam π :
typedef enum {
POINT_CONVERSION_COMPRESSED = 2,
POINT_CONVERSION_UNCOMPRESSED = 4,
POINT_CONVERSION_HYBRID = 6
} point_conversion_form_t;
point_conversion_form_t
EC_GROUP_get_point_conversion_form(const EC_GROUP *group);
void
EC_GROUP_set_point_conversion_form(EC_GROUP *group,
point_conversion_form_t form);
and then there's the deprecated one, living its retired main-character era:
int
EC_GROUP_get_basis_type(const EC_GROUP *group);
yeah, it's flagged Deprecated. we still mention it because we're thorough, not because we're recommending it π
π¦ DESCRIPTION π¦
so every function on this page either tweaks or peeks at the details of the ASN.1 encoding that the i2d_ECPKParameters(3) family of functions spits out. that's the whole vibe. and like, modern applications use named curves with uncompressed point encoding β which, fun fact, is the default for EC_GROUP_new_by_curve_name(3). so if you're doing normal stuff, the defaults already ate π₯
in this library, elliptic curve parameters get encoded in one of two ways:
- as a named curve, using an ASN.1 Object Identifier (OID) to refer to standardized parameters that need to be built into the library, or
- as explicit curve parameters, where the field, the curve equation, the base point's coordinates and other data are encoded explicitly.
the implicitly CA variant? yeah, that one isn't supported. not invited to the party π
EC_GROUP_get_curve_name() gets the Numerical Identifier (NID) representation of the ASN.1 Object Identifier used for the named curve encoding of group. EC_GROUP_set_curve_name() sets it to nid. simple as π
EC_GROUP_get_asn1_flag() retrieves the value of the asn1_flag member of group. if the bit corresponding to OPENSSL_EC_NAMED_CURVE is set, named curve encoding is used for group; otherwise it's explicit encoding, periodt. EC_GROUP_set_asn1_flag() sets the asn1_flag member of group to flag, which should be either OPENSSL_EC_NAMED_CURVE (for named curve encoding) or OPENSSL_EC_EXPLICIT_CURVE (for explicit encoding). pick your fighter β¨
the ASN.1 encoding of explicit curve parameters includes an optional seed value for parameters generated verifiably at random. if a seed value is set on group, EC_GROUP_get0_seed() returns a pointer to the internal byte string whose length is returned by EC_GROUP_get_seed_len() π
EC_GROUP_set_seed() first clears any seed and length already stored in group. if seed is not NULL and len is not zero, it stores a copy of them in group. the seed should be a random byte string of len at least 20 bytes. you can unset the seed by passing NULL as a seed and a len of zero. and here's the thing, bestie β the library does not perform any computation or validation with this seed, it only includes it in its ASN.1 encoded parameters, whether it contains a sensible value or not. so like, it's not checking your work. it's just vibes π
points on an elliptic curve β like the generator or a public key β can be encoded in compressed form, uncompressed form, or in a hybrid form that encompasses both, see EC_POINT_point2oct(3). EC_GROUP_get_point_conversion_form() retrieves the encoding used for points on group, and EC_GROUP_set_point_conversion_form() sets it to form. slay π¦
the deprecated EC_GROUP_get_basis_type() only makes sense for curves over binary fields. it is provided for compatibility only. that's it. that's the whole personality π
π RETURN VALUES π
lowkey the most important section, let's go:
EC_GROUP_get_curve_name()returns the NID to be used for named curve encoding of group, orNID_undefif no NID is set.EC_GROUP_get_asn1_flag()returns the value most recently set byEC_GROUP_set_asn1_flag()on group.EC_GROUP_get0_seed()returns an internal pointer to the seed on group, orNULLif none is set.EC_GROUP_get_seed_len()returns the byte length of the seed set on group, or zero if none is set.EC_GROUP_set_seed()returns0on memory allocation failure. it returns len on success, unless seed isNULLor len is zero β in which case it returns1.EC_GROUP_get_point_conversion_form()returns the point conversion form last set byEC_GROUP_set_point_conversion_form()on group.EC_GROUP_get_basis_type()always returnsNID_undef. always. no notes π
π SEE ALSO π
go read these too, iykyk:
crypto(3), d2i_ECPKParameters(3), EC_GROUP_check(3), EC_GROUP_new_by_curve_name(3), EC_GROUP_new_curve_GFp(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), OBJ_obj2nid(3)
β HISTORY β
these functions first appeared in OpenSSL 0.9.8 and have been available since OpenBSD 4.5. vintage. iconic. still here π
π BUGS π
okay so this part is a little rough ngl β most of the setters cannot report errors, and none of them perform proper input validation and accept most of the values passed in. π which means you can absolutely end up with invalid or nonsensical ASN.1 encoding produced by i2d_ECPKParameters(3) and related functions. so like, garbage in, garbage out, but make it cryptography π
fr fr: validate your own inputs, bestie. the library is not gonna do it for you.
mwah π this page was brought to you by Debian, dated June 13, 2025, and the letters E, C, and the entire concept of curve names. go forth and encode responsibly π§β¨
π¦ 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