EC_POINT_NEW(3)

πŸ“¦ version 4.4.0, in alpine 3.24, arch rolling

πŸ’– 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 allocated EC_POINT or NULL on memory allocation failure. πŸ’€
  • EC_POINT_copy() returns 1 on success or 0 on error. error conditions include memory allocation failure and that dst is incompatible with the group on which src is defined. mismatch = no slay.
  • EC_POINT_dup() returns a newly allocated EC_POINT or NULL on failure. error conditions include memory allocation failure or that group is incompatible with src.

πŸ’œ 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