EC_POINT_NEW(3)
π EC_POINT_NEW π
okay bestie so this one lives in the Library Functions Manual and it's literally all about elliptic curve points β allocating them, freeing them, copying them. the whole glow-up. let's get into it π«Ά
πΈ NAME πΈ
EC_POINT_new, EC_POINT_free, EC_POINT_clear_free, EC_POINT_copy, EC_POINT_dup β allocate, free and copy elliptic curve points π
β¨ SYNOPSIS β¨
library βlibcryptoβ #include <openssl/ec.h>
EC_POINT *
EC_POINT_new(const EC_GROUP *group);
void
EC_POINT_free(EC_POINT *point);
void
EC_POINT_clear_free(EC_POINT *point);
int
EC_POINT_copy(EC_POINT *dst, const EC_POINT *src);
EC_POINT *
EC_POINT_dup(const EC_POINT *point, const EC_GROUP *group);
π¦ DESCRIPTION π¦
so an EC_POINT object holds a point on the elliptic curve that's represented by an EC_GROUP. and like, the details of how it's represented internally? those depend on the group, and they should never be an application's concern β the EC library literally has an API for setting a point's coordinates: EC_POINT_set_affine_coordinates(3). so stay in your lane, bestie, and let the library handle it π
EC_POINT_new() allocates and initializes an EC_POINT object to be used with the group. heads up tho: before you explicitly set its coordinates, the returned EC_POINT is invalid. so it's giving "new phone who dis" until you actually give it a value β¨
EC_POINT_free() frees point and all memory associated with it. if point is a NULL pointer, no action occurs. super chill, no drama.
EC_POINT_clear_free() is intended to destroy sensitive data held in point in addition to freeing all memory associated with it. but real talk β elliptic curve points usually hold public data, so this is rarely needed. and in LibreSSL, EC_POINT_free() and EC_POINT_clear_free() behave identically. twins fr fr π―ββοΈ
EC_POINT_copy() copies the internal representation of src into dst. if src and dst are identical, no action occurs. both src and dst should be the result of EC_POINT_new() with the same group argument β although EC_POINT_copy() cannot check that. sorry babe, it's not a mind reader π
EC_POINT_dup() creates a deep copy of point by combining EC_POINT_new() with EC_GROUP_copy(). deep copy!! not just a vibe, an actual real one π
π RETURN VALUES π
EC_POINT_new()returns a newly allocatedEC_POINTorNULLon memory allocation failure. πEC_POINT_copy()returns1on success or0on error. error conditions include memory allocation failure and thatdstis incompatible with the group on whichsrcis defined. mismatch = no slay.EC_POINT_dup()returns a newly allocatedEC_POINTorNULLon failure. error conditions include memory allocation failure or thatgroupis incompatible withsrc.
π SEE ALSO π
BN_CTX_new(3), BN_is_zero(3), crypto(3), d2i_ECPKParameters(3), EC_GROUP_check(3), EC_GROUP_get_curve_name(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_point2oct(3), ECDH_compute_key(3), ECDSA_SIG_new(3)
like, the whole friend group honestly π
π§ HISTORY π§
EC_POINT_new(), EC_POINT_free(), EC_POINT_clear_free(), and EC_POINT_copy() first appeared in OpenSSL 0.9.7 and have been available since OpenBSD 3.2. β¨
EC_POINT_dup() first appeared in OpenSSL 0.9.8 and has been available since OpenBSD 4.5. a little late to the party but we stan π
π BUGS π
okay so this is the part where we get real π
a fundamental flaw in the OpenSSL API toolkit is that *_new() functions usually create invalid objects that are tricky to turn into valid objects. not me calling out the whole toolkit π
one specific flaw in the EC library internals is that EC_POINT objects do not hold a reference to the group they live on β despite the fact that EC_POINT_new() has a group argument. like, why even have the argument then bestie? π this is difficult to fix because EC_GROUP objects are not reference counted and because of const qualifiers in the API. this is the root cause for various contortions in the EC library and API, and there are security implications β because not only does the library not know whether an EC_POINT object represents a valid point, even if it did know that, it would still not know on what curve. that's the messy part fr fr.
also: the signature of EC_GROUP_dup() is bizarre and the order of point and group is inconsistent with the rest of the EC API. inconsistent!! in this economy!! π
and that's the whole page, bestie π«Ά this one's from Debian, dated June 13, 2025, and you can find it filed under EC_POINT_NEW(3) whenever you need it. mwah π
π¦ 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